File r37/log/sparse.rlg artifact 9fa850638e part of check-in aacf49ddfa


Sun Aug 18 18:25:17 2002 run on Windows
% Test file for Sparse Matrices and the Linear Algebra Package for
% Sparse Matrices.

% Author: Stephen Scowcroft.                    Date: June 1995.

% Firstly, the matrices need to be created.

% This is the standard way to create a sparse matrix.

% Create a sparse matrix.

sparse mat1(5,5);



%Fill the sparse matrix with data

mat1(1,1):=2;


mat1(1,1) := 2

mat1(2,2):=4;


mat1(2,2) := 4

mat1(3,3):=6;


mat1(3,3) := 6

mat1(4,4):=8;


mat1(4,4) := 8

mat1(5,5):=10;


mat1(5,5) := 10


sparse mat4(5,5);



mat4(1,1):=x;


mat4(1,1) := x

mat4(2,2):=x;


mat4(2,2) := x

mat4(3,3):=x;


mat4(3,3) := x

mat4(4,4):=x;


mat4(4,4) := x

mat4(5,5):=x;


mat4(5,5) := x


% A small function to automatically fill a sparse matrix with data.

procedure makematsp(nam,row);
 begin; 
  sparse nam(row,row);
    for i := 1:row do <<nam(i,i):=i>>
 end;


makematsp


clear mat2;


makematsp(mat2,100);



% Matrices created in the standard Matrix way.

zz1:=mat((1,2),(3,4));


       [1  2]
zz1 := [    ]
       [3  4]


zz2:=mat((x,x),(x,x));


       [x  x]
zz2 := [    ]
       [x  x]


zz3:=mat((i+1,i+2,i+3),(4,5,2),(1,i,0));


       [i + 1  i + 2  i + 3]
       [                   ]
zz3 := [  4      5      2  ]
       [                   ]
       [  1      i      0  ]



% I have taken advantage of the Linear Algebra Package (Matt Rebbeck)
% in order to create some Sparse Matrices.

mat3:=diagonal(zz1,zz1,zz1);


        [1  2  0  0  0  0]
        [                ]
        [3  4  0  0  0  0]
        [                ]
        [0  0  1  2  0  0]
mat3 := [                ]
        [0  0  3  4  0  0]
        [                ]
        [0  0  0  0  1  2]
        [                ]
        [0  0  0  0  3  4]


mat5:=band_matrix({1,3,1},100)$


mat6:=diagonal(zz3,zz3);


        [i + 1  i + 2  i + 3    0      0      0  ]
        [                                        ]
        [  4      5      2      0      0      0  ]
        [                                        ]
        [  1      i      0      0      0      0  ]
mat6 := [                                        ]
        [  0      0      0    i + 1  i + 2  i + 3]
        [                                        ]
        [  0      0      0      4      5      2  ]
        [                                        ]
        [  0      0      0      1      i      0  ]


mat7:=band_matrix({a,b,c},4);


        [b  c  0  0]
        [          ]
        [a  b  c  0]
mat7 := [          ]
        [0  a  b  c]
        [          ]
        [0  0  a  b]



% These are then "translated" into the Sparse operator using the 
% function transmat.
% This is a destructive function in the sense that the matrices are no
% longer of type 'matrix but are now 'sparse.

transmat mat3;


transmat mat5;


transmat mat6;


transmat mat7;



poly  := x^7+x^5+4*x^4+5*x^3+12;


         7    5      4      3
poly := x  + x  + 4*x  + 5*x  + 12

poly1 := x^2+x*y^3+x*y*z^3+y*x+2+y*3;


          2      3        3
poly1 := x  + x*y  + x*y*z  + x*y + 3*y + 2


% Firstly some basic matrix operations.
% These are the same as the present matrix package

mat1^-1;



             1
spm(1,1) := ---$
             2

             1
spm(2,2) := ---$
             4

             1
spm(3,3) := ---$
             6

             1
spm(4,4) := ---$
             8

             1
spm(5,5) := ----$
             10

mat4^-1;



             1
spm(1,1) := ---$
             x

             1
spm(2,2) := ---$
             x

             1
spm(3,3) := ---$
             x

             1
spm(4,4) := ---$
             x

             1
spm(5,5) := ---$
             x

mat2 + mat5$


mat2 - mat5$


mat1-mat1;


"Empty Matrix"

mat4 + mat1;



spm(1,1) := x + 2$

spm(2,2) := x + 4$

spm(3,3) := x + 6$

spm(4,4) := x + 8$

spm(5,5) := x + 10$

mat4 * mat1;



spm(1,1) := 2*x$

spm(2,2) := 4*x$

spm(3,3) := 6*x$

spm(4,4) := 8*x$

spm(5,5) := 10*x$


2*mat1 + (3*mat4 + mat1);



spm(1,1) := 3*(x + 2)$

spm(2,2) := 3*(x + 4)$

spm(3,3) := 3*(x + 6)$

spm(4,4) := 3*(x + 8)$

spm(5,5) := 3*(x + 10)$

% It is also possible to combine both 'matrix and 'sparse type matrices
% in these operations.

pp:=band_matrix({1,3,1},100)$


mat5*pp;



spm(1,1) := 10$

spm(1,2) := 6$

spm(1,3) := 1$

spm(2,1) := 6$

spm(2,2) := 11$

spm(2,3) := 6$

spm(2,4) := 1$

spm(3,1) := 1$

spm(3,2) := 6$

spm(3,3) := 11$

spm(3,4) := 6$

spm(3,5) := 1$

spm(4,2) := 1$

spm(4,3) := 6$

spm(4,4) := 11$

spm(4,5) := 6$

spm(4,6) := 1$

spm(5,3) := 1$

spm(5,4) := 6$

spm(5,5) := 11$

spm(5,6) := 6$

spm(5,7) := 1$

spm(6,4) := 1$

spm(6,5) := 6$

spm(6,6) := 11$

spm(6,7) := 6$

spm(6,8) := 1$

spm(7,5) := 1$

spm(7,6) := 6$

spm(7,7) := 11$

spm(7,8) := 6$

spm(7,9) := 1$

spm(8,6) := 1$

spm(8,7) := 6$

spm(8,8) := 11$

spm(8,9) := 6$

spm(8,10) := 1$

spm(9,7) := 1$

spm(9,8) := 6$

spm(9,9) := 11$

spm(9,10) := 6$

spm(9,11) := 1$

spm(10,8) := 1$

spm(10,9) := 6$

spm(10,10) := 11$

spm(10,11) := 6$

spm(10,12) := 1$

spm(11,9) := 1$

spm(11,10) := 6$

spm(11,11) := 11$

spm(11,12) := 6$

spm(11,13) := 1$

spm(12,10) := 1$

spm(12,11) := 6$

spm(12,12) := 11$

spm(12,13) := 6$

spm(12,14) := 1$

spm(13,11) := 1$

spm(13,12) := 6$

spm(13,13) := 11$

spm(13,14) := 6$

spm(13,15) := 1$

spm(14,12) := 1$

spm(14,13) := 6$

spm(14,14) := 11$

spm(14,15) := 6$

spm(14,16) := 1$

spm(15,13) := 1$

spm(15,14) := 6$

spm(15,15) := 11$

spm(15,16) := 6$

spm(15,17) := 1$

spm(16,14) := 1$

spm(16,15) := 6$

spm(16,16) := 11$

spm(16,17) := 6$

spm(16,18) := 1$

spm(17,15) := 1$

spm(17,16) := 6$

spm(17,17) := 11$

spm(17,18) := 6$

spm(17,19) := 1$

spm(18,16) := 1$

spm(18,17) := 6$

spm(18,18) := 11$

spm(18,19) := 6$

spm(18,20) := 1$

spm(19,17) := 1$

spm(19,18) := 6$

spm(19,19) := 11$

spm(19,20) := 6$

spm(19,21) := 1$

spm(20,18) := 1$

spm(20,19) := 6$

spm(20,20) := 11$

spm(20,21) := 6$

spm(20,22) := 1$

spm(21,19) := 1$

spm(21,20) := 6$

spm(21,21) := 11$

spm(21,22) := 6$

spm(21,23) := 1$

spm(22,20) := 1$

spm(22,21) := 6$

spm(22,22) := 11$

spm(22,23) := 6$

spm(22,24) := 1$

spm(23,21) := 1$

spm(23,22) := 6$

spm(23,23) := 11$

spm(23,24) := 6$

spm(23,25) := 1$

spm(24,22) := 1$

spm(24,23) := 6$

spm(24,24) := 11$

spm(24,25) := 6$

spm(24,26) := 1$

spm(25,23) := 1$

spm(25,24) := 6$

spm(25,25) := 11$

spm(25,26) := 6$

spm(25,27) := 1$

spm(26,24) := 1$

spm(26,25) := 6$

spm(26,26) := 11$

spm(26,27) := 6$

spm(26,28) := 1$

spm(27,25) := 1$

spm(27,26) := 6$

spm(27,27) := 11$

spm(27,28) := 6$

spm(27,29) := 1$

spm(28,26) := 1$

spm(28,27) := 6$

spm(28,28) := 11$

spm(28,29) := 6$

spm(28,30) := 1$

spm(29,27) := 1$

spm(29,28) := 6$

spm(29,29) := 11$

spm(29,30) := 6$

spm(29,31) := 1$

spm(30,28) := 1$

spm(30,29) := 6$

spm(30,30) := 11$

spm(30,31) := 6$

spm(30,32) := 1$

spm(31,29) := 1$

spm(31,30) := 6$

spm(31,31) := 11$

spm(31,32) := 6$

spm(31,33) := 1$

spm(32,30) := 1$

spm(32,31) := 6$

spm(32,32) := 11$

spm(32,33) := 6$

spm(32,34) := 1$

spm(33,31) := 1$

spm(33,32) := 6$

spm(33,33) := 11$

spm(33,34) := 6$

spm(33,35) := 1$

spm(34,32) := 1$

spm(34,33) := 6$

spm(34,34) := 11$

spm(34,35) := 6$

spm(34,36) := 1$

spm(35,33) := 1$

spm(35,34) := 6$

spm(35,35) := 11$

spm(35,36) := 6$

spm(35,37) := 1$

spm(36,34) := 1$

spm(36,35) := 6$

spm(36,36) := 11$

spm(36,37) := 6$

spm(36,38) := 1$

spm(37,35) := 1$

spm(37,36) := 6$

spm(37,37) := 11$

spm(37,38) := 6$

spm(37,39) := 1$

spm(38,36) := 1$

spm(38,37) := 6$

spm(38,38) := 11$

spm(38,39) := 6$

spm(38,40) := 1$

spm(39,37) := 1$

spm(39,38) := 6$

spm(39,39) := 11$

spm(39,40) := 6$

spm(39,41) := 1$

spm(40,38) := 1$

spm(40,39) := 6$

spm(40,40) := 11$

spm(40,41) := 6$

spm(40,42) := 1$

spm(41,39) := 1$

spm(41,40) := 6$

spm(41,41) := 11$

spm(41,42) := 6$

spm(41,43) := 1$

spm(42,40) := 1$

spm(42,41) := 6$

spm(42,42) := 11$

spm(42,43) := 6$

spm(42,44) := 1$

spm(43,41) := 1$

spm(43,42) := 6$

spm(43,43) := 11$

spm(43,44) := 6$

spm(43,45) := 1$

spm(44,42) := 1$

spm(44,43) := 6$

spm(44,44) := 11$

spm(44,45) := 6$

spm(44,46) := 1$

spm(45,43) := 1$

spm(45,44) := 6$

spm(45,45) := 11$

spm(45,46) := 6$

spm(45,47) := 1$

spm(46,44) := 1$

spm(46,45) := 6$

spm(46,46) := 11$

spm(46,47) := 6$

spm(46,48) := 1$

spm(47,45) := 1$

spm(47,46) := 6$

spm(47,47) := 11$

spm(47,48) := 6$

spm(47,49) := 1$

spm(48,46) := 1$

spm(48,47) := 6$

spm(48,48) := 11$

spm(48,49) := 6$

spm(48,50) := 1$

spm(49,47) := 1$

spm(49,48) := 6$

spm(49,49) := 11$

spm(49,50) := 6$

spm(49,51) := 1$

spm(50,48) := 1$

spm(50,49) := 6$

spm(50,50) := 11$

spm(50,51) := 6$

spm(50,52) := 1$

spm(51,49) := 1$

spm(51,50) := 6$

spm(51,51) := 11$

spm(51,52) := 6$

spm(51,53) := 1$

spm(52,50) := 1$

spm(52,51) := 6$

spm(52,52) := 11$

spm(52,53) := 6$

spm(52,54) := 1$

spm(53,51) := 1$

spm(53,52) := 6$

spm(53,53) := 11$

spm(53,54) := 6$

spm(53,55) := 1$

spm(54,52) := 1$

spm(54,53) := 6$

spm(54,54) := 11$

spm(54,55) := 6$

spm(54,56) := 1$

spm(55,53) := 1$

spm(55,54) := 6$

spm(55,55) := 11$

spm(55,56) := 6$

spm(55,57) := 1$

spm(56,54) := 1$

spm(56,55) := 6$

spm(56,56) := 11$

spm(56,57) := 6$

spm(56,58) := 1$

spm(57,55) := 1$

spm(57,56) := 6$

spm(57,57) := 11$

spm(57,58) := 6$

spm(57,59) := 1$

spm(58,56) := 1$

spm(58,57) := 6$

spm(58,58) := 11$

spm(58,59) := 6$

spm(58,60) := 1$

spm(59,57) := 1$

spm(59,58) := 6$

spm(59,59) := 11$

spm(59,60) := 6$

spm(59,61) := 1$

spm(60,58) := 1$

spm(60,59) := 6$

spm(60,60) := 11$

spm(60,61) := 6$

spm(60,62) := 1$

spm(61,59) := 1$

spm(61,60) := 6$

spm(61,61) := 11$

spm(61,62) := 6$

spm(61,63) := 1$

spm(62,60) := 1$

spm(62,61) := 6$

spm(62,62) := 11$

spm(62,63) := 6$

spm(62,64) := 1$

spm(63,61) := 1$

spm(63,62) := 6$

spm(63,63) := 11$

spm(63,64) := 6$

spm(63,65) := 1$

spm(64,62) := 1$

spm(64,63) := 6$

spm(64,64) := 11$

spm(64,65) := 6$

spm(64,66) := 1$

spm(65,63) := 1$

spm(65,64) := 6$

spm(65,65) := 11$

spm(65,66) := 6$

spm(65,67) := 1$

spm(66,64) := 1$

spm(66,65) := 6$

spm(66,66) := 11$

spm(66,67) := 6$

spm(66,68) := 1$

spm(67,65) := 1$

spm(67,66) := 6$

spm(67,67) := 11$

spm(67,68) := 6$

spm(67,69) := 1$

spm(68,66) := 1$

spm(68,67) := 6$

spm(68,68) := 11$

spm(68,69) := 6$

spm(68,70) := 1$

spm(69,67) := 1$

spm(69,68) := 6$

spm(69,69) := 11$

spm(69,70) := 6$

spm(69,71) := 1$

spm(70,68) := 1$

spm(70,69) := 6$

spm(70,70) := 11$

spm(70,71) := 6$

spm(70,72) := 1$

spm(71,69) := 1$

spm(71,70) := 6$

spm(71,71) := 11$

spm(71,72) := 6$

spm(71,73) := 1$

spm(72,70) := 1$

spm(72,71) := 6$

spm(72,72) := 11$

spm(72,73) := 6$

spm(72,74) := 1$

spm(73,71) := 1$

spm(73,72) := 6$

spm(73,73) := 11$

spm(73,74) := 6$

spm(73,75) := 1$

spm(74,72) := 1$

spm(74,73) := 6$

spm(74,74) := 11$

spm(74,75) := 6$

spm(74,76) := 1$

spm(75,73) := 1$

spm(75,74) := 6$

spm(75,75) := 11$

spm(75,76) := 6$

spm(75,77) := 1$

spm(76,74) := 1$

spm(76,75) := 6$

spm(76,76) := 11$

spm(76,77) := 6$

spm(76,78) := 1$

spm(77,75) := 1$

spm(77,76) := 6$

spm(77,77) := 11$

spm(77,78) := 6$

spm(77,79) := 1$

spm(78,76) := 1$

spm(78,77) := 6$

spm(78,78) := 11$

spm(78,79) := 6$

spm(78,80) := 1$

spm(79,77) := 1$

spm(79,78) := 6$

spm(79,79) := 11$

spm(79,80) := 6$

spm(79,81) := 1$

spm(80,78) := 1$

spm(80,79) := 6$

spm(80,80) := 11$

spm(80,81) := 6$

spm(80,82) := 1$

spm(81,79) := 1$

spm(81,80) := 6$

spm(81,81) := 11$

spm(81,82) := 6$

spm(81,83) := 1$

spm(82,80) := 1$

spm(82,81) := 6$

spm(82,82) := 11$

spm(82,83) := 6$

spm(82,84) := 1$

spm(83,81) := 1$

spm(83,82) := 6$

spm(83,83) := 11$

spm(83,84) := 6$

spm(83,85) := 1$

spm(84,82) := 1$

spm(84,83) := 6$

spm(84,84) := 11$

spm(84,85) := 6$

spm(84,86) := 1$

spm(85,83) := 1$

spm(85,84) := 6$

spm(85,85) := 11$

spm(85,86) := 6$

spm(85,87) := 1$

spm(86,84) := 1$

spm(86,85) := 6$

spm(86,86) := 11$

spm(86,87) := 6$

spm(86,88) := 1$

spm(87,85) := 1$

spm(87,86) := 6$

spm(87,87) := 11$

spm(87,88) := 6$

spm(87,89) := 1$

spm(88,86) := 1$

spm(88,87) := 6$

spm(88,88) := 11$

spm(88,89) := 6$

spm(88,90) := 1$

spm(89,87) := 1$

spm(89,88) := 6$

spm(89,89) := 11$

spm(89,90) := 6$

spm(89,91) := 1$

spm(90,88) := 1$

spm(90,89) := 6$

spm(90,90) := 11$

spm(90,91) := 6$

spm(90,92) := 1$

spm(91,89) := 1$

spm(91,90) := 6$

spm(91,91) := 11$

spm(91,92) := 6$

spm(91,93) := 1$

spm(92,90) := 1$

spm(92,91) := 6$

spm(92,92) := 11$

spm(92,93) := 6$

spm(92,94) := 1$

spm(93,91) := 1$

spm(93,92) := 6$

spm(93,93) := 11$

spm(93,94) := 6$

spm(93,95) := 1$

spm(94,92) := 1$

spm(94,93) := 6$

spm(94,94) := 11$

spm(94,95) := 6$

spm(94,96) := 1$

spm(95,93) := 1$

spm(95,94) := 6$

spm(95,95) := 11$

spm(95,96) := 6$

spm(95,97) := 1$

spm(96,94) := 1$

spm(96,95) := 6$

spm(96,96) := 11$

spm(96,97) := 6$

spm(96,98) := 1$

spm(97,95) := 1$

spm(97,96) := 6$

spm(97,97) := 11$

spm(97,98) := 6$

spm(97,99) := 1$

spm(98,96) := 1$

spm(98,97) := 6$

spm(98,98) := 11$

spm(98,99) := 6$

spm(98,100) := 1$

spm(99,97) := 1$

spm(99,98) := 6$

spm(99,99) := 11$

spm(99,100) := 6$

spm(100,98) := 1$

spm(100,99) := 6$

spm(100,100) := 10$


mat5^2$



det(mat1);


3840

det(mat4);


 5
x

trace(mat1);


30

trace(mat4);


5*x


rank(mat1);


5

rank mat5;


100


tp(mat3);



spm(1,1) := 1$

spm(1,2) := 3$

spm(2,1) := 2$

spm(2,2) := 4$

spm(3,3) := 1$

spm(3,4) := 3$

spm(4,3) := 2$

spm(4,4) := 4$

spm(5,5) := 1$

spm(5,6) := 3$

spm(6,5) := 2$

spm(6,6) := 4$


spmateigen(mat3,eta);


     2
{{eta  - 5*eta - 2,3,

               2*arbcomplex(1)*(eta + 1)
  spm(1,1) := ---------------------------$
                       5*eta + 1

  spm(2,1) := arbcomplex(1)$

               2*arbcomplex(2)*(eta + 1)
  spm(3,1) := ---------------------------$
                       5*eta + 1

  spm(4,1) := arbcomplex(2)$

               2*arbcomplex(3)*(eta + 1)
  spm(5,1) := ---------------------------$
                       5*eta + 1

  spm(6,1) := arbcomplex(3)$
  }}


% Next, tests for the Linear Algebra Package for Sparse Matrices.

%Basic matrix manipulations.

spadd_columns(mat1,1,2,5*y);



spm(1,1) := 2$

spm(1,2) := 10*y$

spm(2,2) := 4$

spm(3,3) := 6$

spm(4,4) := 8$

spm(5,5) := 10$

spadd_rows(mat1,1,2,x);



spm(1,1) := 2$

spm(2,1) := 2*x$

spm(2,2) := 4$

spm(3,3) := 6$

spm(4,4) := 8$

spm(5,5) := 10$


spadd_to_columns(mat1,3,1000);



spm(1,1) := 2$

spm(1,3) := 1000$

spm(2,2) := 4$

spm(2,3) := 1000$

spm(3,3) := 1006$

spm(4,3) := 1000$

spm(4,4) := 8$

spm(5,3) := 1000$

spm(5,5) := 10$

spadd_to_columns(mat5,{1,2,3},y)$


spadd_to_rows(mat1,2,1000);



spm(1,1) := 2$

spm(2,1) := 1000$

spm(2,2) := 1004$

spm(2,3) := 1000$

spm(2,4) := 1000$

spm(2,5) := 1000$

spm(3,3) := 6$

spm(4,4) := 8$

spm(5,5) := 10$

spadd_to_rows(mat5,{1,2,3},x)$



spaugment_columns(mat3,2);



spm(1,1) := 2$

spm(2,1) := 4$
  
spaugment_columns(mat1,{1,2,5});



spm(1,1) := 2$

spm(2,2) := 4$

spm(5,3) := 10$

spstack_rows(mat1,3);



spm(1,3) := 6$
  
spstack_rows(mat1,{1,3,5});



spm(1,1) := 2$

spm(2,3) := 6$

spm(3,5) := 10$
  

spchar_poly(mat1,x);


 5       4        3         2
x  - 30*x  + 340*x  - 1800*x  + 4384*x - 3840


spcol_dim(mat2);


100

sprow_dim(mat1);


5


spcopy_into(mat7,mat1,2,2);



spm(1,1) := 2$

spm(2,2) := b$

spm(2,3) := c$

spm(3,2) := a$

spm(3,3) := b$

spm(3,4) := c$

spm(4,3) := a$

spm(4,4) := b$

spm(4,5) := c$

spm(5,4) := a$

spm(5,5) := b$

spcopy_into(mat7,mat1,5,5);

***** Error in spcopy_into: the matrix

spm(1,1) := b$

spm(1,2) := c$

spm(2,1) := a$

spm(2,2) := b$

spm(2,3) := c$

spm(3,2) := a$

spm(3,3) := b$

spm(3,4) := c$

spm(4,3) := a$

spm(4,4) := b$
      does not fit into

spm(1,1) := 2$

spm(2,2) := 4$

spm(3,3) := 6$

spm(4,4) := 8$

spm(5,5) := 10$
      at position 5,5.

spcopy_into(zz1,mat1,1,1);



spm(1,1) := 1$

spm(1,2) := 2$

spm(2,1) := 3$

spm(2,2) := 4$

spm(3,3) := 6$

spm(4,4) := 8$

spm(5,5) := 10$


spdiagonal(3);



spm(1,1) := 3$

% spdiagonal can take both a list of arguments or just the arguments.
spdiagonal({mat2,mat5})$


spdiagonal(mat2,mat5)$


% spdiagonal can also take a mixture of 'sparse and 'matrix types.
spdiagonal(zz1,mat4,zz1);



spm(1,1) := 1$

spm(1,2) := 2$

spm(2,1) := 3$

spm(2,2) := 4$

spm(3,3) := x$

spm(4,4) := x$

spm(5,5) := x$

spm(6,6) := x$

spm(7,7) := x$

spm(8,8) := 1$

spm(8,9) := 2$

spm(9,8) := 3$

spm(9,9) := 4$


spextend(mat1,3,2,x);



spm(1,1) := 2$

spm(2,2) := 4$

spm(3,3) := 6$

spm(4,4) := 8$

spm(5,5) := 10$

spm(6,6) := x$

spm(6,7) := x$

spm(7,6) := x$

spm(7,7) := x$

spm(8,6) := x$

spm(8,7) := x$


spfind_companion(mat5,x);


 98   2
x  *(x  - 3*x - 1)


spget_columns(mat1,1);


{

 spm(1,1) := 2$
 }

spget_columns(mat1,{1,2});


{

 spm(1,1) := 2$
 ,

 spm(2,1) := 4$
 }

spget_rows(mat1,3);


{

 spm(1,3) := 6$
 }

spget_rows(mat1,{1,3});


{

 spm(1,1) := 2$
 ,

 spm(1,3) := 6$
 }


sphermitian_tp(mat6);



spm(1,1) :=  - i + 1$

spm(1,2) := 4$

spm(1,3) := 1$

spm(2,1) :=  - i + 2$

spm(2,2) := 5$

spm(2,3) :=  - i$

spm(3,1) :=  - i + 3$

spm(3,2) := 2$

spm(4,4) :=  - i + 1$

spm(4,5) := 4$

spm(4,6) := 1$

spm(5,4) :=  - i + 2$

spm(5,5) := 5$

spm(5,6) :=  - i$

spm(6,4) :=  - i + 3$

spm(6,5) := 2$


% matrix_augment and matrix_stack can take both a list of arguments 
% or just the arguments.

spmatrix_augment({mat1,mat1});



spm(1,1) := 2$

spm(1,6) := 2$

spm(2,2) := 4$

spm(2,7) := 4$

spm(3,3) := 6$

spm(3,8) := 6$

spm(4,4) := 8$

spm(4,9) := 8$

spm(5,5) := 10$

spm(5,10) := 10$

spmatrix_augment(mat5,mat2,mat5)$


spmatrix_stack(mat2,mat2)$



spminor(mat1,2,3);



spm(1,1) := 2$

spm(3,3) := 8$

spm(4,4) := 10$


spmult_columns(mat1,3,y);



spm(1,1) := 2$

spm(2,2) := 4$

spm(3,3) := 6*y$

spm(4,4) := 8$

spm(5,5) := 10$

spmult_columns(mat2,{2,3,4},100)$


spmult_rows(mat2,2,x);



spm(1,1) := 1$

spm(2,2) := 2*x$

spm(3,3) := 3$

spm(4,4) := 4$

spm(5,5) := 5$

spm(6,6) := 6$

spm(7,7) := 7$

spm(8,8) := 8$

spm(9,9) := 9$

spm(10,10) := 10$

spm(11,11) := 11$

spm(12,12) := 12$

spm(13,13) := 13$

spm(14,14) := 14$

spm(15,15) := 15$

spm(16,16) := 16$

spm(17,17) := 17$

spm(18,18) := 18$

spm(19,19) := 19$

spm(20,20) := 20$

spm(21,21) := 21$

spm(22,22) := 22$

spm(23,23) := 23$

spm(24,24) := 24$

spm(25,25) := 25$

spm(26,26) := 26$

spm(27,27) := 27$

spm(28,28) := 28$

spm(29,29) := 29$

spm(30,30) := 30$

spm(31,31) := 31$

spm(32,32) := 32$

spm(33,33) := 33$

spm(34,34) := 34$

spm(35,35) := 35$

spm(36,36) := 36$

spm(37,37) := 37$

spm(38,38) := 38$

spm(39,39) := 39$

spm(40,40) := 40$

spm(41,41) := 41$

spm(42,42) := 42$

spm(43,43) := 43$

spm(44,44) := 44$

spm(45,45) := 45$

spm(46,46) := 46$

spm(47,47) := 47$

spm(48,48) := 48$

spm(49,49) := 49$

spm(50,50) := 50$

spm(51,51) := 51$

spm(52,52) := 52$

spm(53,53) := 53$

spm(54,54) := 54$

spm(55,55) := 55$

spm(56,56) := 56$

spm(57,57) := 57$

spm(58,58) := 58$

spm(59,59) := 59$

spm(60,60) := 60$

spm(61,61) := 61$

spm(62,62) := 62$

spm(63,63) := 63$

spm(64,64) := 64$

spm(65,65) := 65$

spm(66,66) := 66$

spm(67,67) := 67$

spm(68,68) := 68$

spm(69,69) := 69$

spm(70,70) := 70$

spm(71,71) := 71$

spm(72,72) := 72$

spm(73,73) := 73$

spm(74,74) := 74$

spm(75,75) := 75$

spm(76,76) := 76$

spm(77,77) := 77$

spm(78,78) := 78$

spm(79,79) := 79$

spm(80,80) := 80$

spm(81,81) := 81$

spm(82,82) := 82$

spm(83,83) := 83$

spm(84,84) := 84$

spm(85,85) := 85$

spm(86,86) := 86$

spm(87,87) := 87$

spm(88,88) := 88$

spm(89,89) := 89$

spm(90,90) := 90$

spm(91,91) := 91$

spm(92,92) := 92$

spm(93,93) := 93$

spm(94,94) := 94$

spm(95,95) := 95$

spm(96,96) := 96$

spm(97,97) := 97$

spm(98,98) := 98$

spm(99,99) := 99$

spm(100,100) := 100$

spmult_rows(mat1,{1,3,5},10);



spm(1,1) := 20$

spm(2,2) := 4$

spm(3,3) := 60$

spm(4,4) := 8$

spm(5,5) := 100$


sppivot(mat3,3,3);



spm(1,1) := 1$

spm(1,2) := 2$

spm(2,1) := 3$

spm(2,2) := 4$

spm(3,3) := 1$

spm(3,4) := 2$

spm(4,4) := -2$

spm(5,5) := 1$

spm(5,6) := 2$

spm(6,5) := 3$

spm(6,6) := 4$

sprows_pivot(mat3,1,1,{2,4});



spm(1,1) := 1$

spm(1,2) := 2$

spm(2,2) := -2$

spm(3,3) := 1$

spm(3,4) := 2$

spm(4,3) := 3$

spm(4,4) := 4$

spm(5,5) := 1$

spm(5,6) := 2$

spm(6,5) := 3$

spm(6,6) := 4$


spremove_columns(mat1,3);



spm(1,1) := 2$

spm(2,2) := 4$

spm(4,3) := 8$

spm(5,4) := 10$

spremove_columns(mat3,{2,3,4});



spm(1,1) := 1$

spm(2,1) := 3$

spm(5,2) := 1$

spm(5,3) := 2$

spm(6,2) := 3$

spm(6,3) := 4$

spremove_rows(mat1,2);



spm(1,1) := 2$

spm(2,3) := 6$

spm(3,4) := 8$

spm(4,5) := 10$

spremove_rows(mat2,{1,3})$


spremove_rows(mat1,{1,2,3,4,5});

***** Warning in spremove_rows:
      all the rows have been removed. Returning nil.


spswap_cols(mat1,2,4);



spm(1,1) := 2$

spm(2,4) := 4$

spm(3,3) := 6$

spm(4,2) := 8$

spm(5,5) := 10$

spswap_rows(mat5,1,2)$


spswap_entries(mat1,{1,1},{5,5});



spm(1,1) := 10$

spm(2,2) := 4$

spm(3,3) := 6$

spm(4,4) := 8$

spm(5,5) := 2$




% Constructors - functions that create matrices.

spband_matrix(x,500)$


spband_matrix({x,y,z},6000)$



spblock_matrix(1,2,{mat1,mat1});



spm(1,1) := 2$

spm(1,6) := 2$

spm(2,2) := 4$

spm(2,7) := 4$

spm(3,3) := 6$

spm(3,8) := 6$

spm(4,4) := 8$

spm(4,9) := 8$

spm(5,5) := 10$

spm(5,10) := 10$

spblock_matrix(2,3,{mat3,mat6,mat3,mat6,mat3,mat6});



spm(1,1) := 1$

spm(1,2) := 2$

spm(1,7) := i + 1$

spm(1,8) := i + 2$

spm(1,9) := i + 3$

spm(1,13) := 1$

spm(1,14) := 2$

spm(2,1) := 3$

spm(2,2) := 4$

spm(2,7) := 4$

spm(2,8) := 5$

spm(2,9) := 2$

spm(2,13) := 3$

spm(2,14) := 4$

spm(3,3) := 1$

spm(3,4) := 2$

spm(3,7) := 1$

spm(3,8) := i$

spm(3,15) := 1$

spm(3,16) := 2$

spm(4,3) := 3$

spm(4,4) := 4$

spm(4,10) := i + 1$

spm(4,11) := i + 2$

spm(4,12) := i + 3$

spm(4,15) := 3$

spm(4,16) := 4$

spm(5,5) := 1$

spm(5,6) := 2$

spm(5,10) := 4$

spm(5,11) := 5$

spm(5,12) := 2$

spm(5,17) := 1$

spm(5,18) := 2$

spm(6,5) := 3$

spm(6,6) := 4$

spm(6,10) := 1$

spm(6,11) := i$

spm(6,17) := 3$

spm(6,18) := 4$

spm(7,1) := i + 1$

spm(7,2) := i + 2$

spm(7,3) := i + 3$

spm(7,7) := 1$

spm(7,8) := 2$

spm(7,13) := i + 1$

spm(7,14) := i + 2$

spm(7,15) := i + 3$

spm(8,1) := 4$

spm(8,2) := 5$

spm(8,3) := 2$

spm(8,7) := 3$

spm(8,8) := 4$

spm(8,13) := 4$

spm(8,14) := 5$

spm(8,15) := 2$

spm(9,1) := 1$

spm(9,2) := i$

spm(9,9) := 1$

spm(9,10) := 2$

spm(9,13) := 1$

spm(9,14) := i$

spm(10,4) := i + 1$

spm(10,5) := i + 2$

spm(10,6) := i + 3$

spm(10,9) := 3$

spm(10,10) := 4$

spm(10,16) := i + 1$

spm(10,17) := i + 2$

spm(10,18) := i + 3$

spm(11,4) := 4$

spm(11,5) := 5$

spm(11,6) := 2$

spm(11,11) := 1$

spm(11,12) := 2$

spm(11,16) := 4$

spm(11,17) := 5$

spm(11,18) := 2$

spm(12,4) := 1$

spm(12,5) := i$

spm(12,11) := 3$

spm(12,12) := 4$

spm(12,16) := 1$

spm(12,17) := i$


spchar_matrix(mat3,x);



spm(1,1) := x - 1$

spm(1,2) := -2$

spm(2,1) := -3$

spm(2,2) := x - 4$

spm(3,3) := x - 1$

spm(3,4) := -2$

spm(4,3) := -3$

spm(4,4) := x - 4$

spm(5,5) := x - 1$

spm(5,6) := -2$

spm(6,5) := -3$

spm(6,6) := x - 4$


cfmat := spcoeff_matrix({y+4*+-5*w=10,y-z=20,y+4+3*z,w+x+50});


{

 spm(1,1) := 1$

 spm(1,2) := -20$

 spm(2,1) := 1$

 spm(2,3) := -1$

 spm(3,1) := 1$

 spm(3,3) := 3$

 spm(4,2) := 1$

 spm(4,4) := 1$
 ,

 spm(1,1) := y$

 spm(2,1) := w$

 spm(3,1) := z$

 spm(4,1) := x$
 ,

 spm(1,1) := 10$

 spm(2,1) := 20$

 spm(3,1) := -4$

 spm(4,1) := -50$
cfmat :=  }

first cfmat * second cfmat;



spm(1,1) :=  - 20*w + y$

spm(2,1) := y - z$

spm(3,1) := y + 3*z$

spm(4,1) := w + x$

third cfmat;



spm(1,1) := 10$

spm(2,1) := 20$

spm(3,1) := -4$

spm(4,1) := -50$


spcompanion(poly,x);



spm(1,7) := -12$

spm(2,1) := 1$

spm(3,2) := 1$

spm(4,3) := 1$

spm(4,7) := -5$

spm(5,4) := 1$

spm(5,7) := -4$

spm(6,5) := 1$

spm(6,7) := -1$

spm(7,6) := 1$


sphessian(poly1,{w,x,y,z});



spm(2,2) := 2$

               2    3
spm(2,3) := 3*y  + z  + 1$

                 2
spm(2,4) := 3*y*z $

               2    3
spm(3,2) := 3*y  + z  + 1$

spm(3,3) := 6*x*y$

                 2
spm(3,4) := 3*x*z $

                 2
spm(4,2) := 3*y*z $

                 2
spm(4,3) := 3*x*z $

spm(4,4) := 6*x*y*z$


spjacobian({x^4,x*y^2,x*y*z^3},{w,x,y,z});



               3
spm(1,2) := 4*x $

             2
spm(2,2) := y $

spm(2,3) := 2*x*y$

               3
spm(3,2) := y*z $

               3
spm(3,3) := x*z $

                   2
spm(3,4) := 3*x*y*z $


spjordan_block(x,500)$



spmake_identity(1000)$



on rounded;

 % makes output easier to read.
ch := spcholesky(mat1);


{

 spm(1,1) := 1.41421356237$

 spm(2,2) := 2.0$

 spm(3,3) := 2.44948974278$

 spm(4,4) := 2.82842712475$

 spm(5,5) := 3.16227766017$
 ,

 spm(1,1) := 1.41421356237$

 spm(2,2) := 2.0$

 spm(3,3) := 2.44948974278$

 spm(4,4) := 2.82842712475$

 spm(5,5) := 3.16227766017$
ch :=  }

tp first ch - second ch;


"Empty Matrix"

tmp := first ch * second ch;



spm(1,1) := 2.0$

spm(2,2) := 4.0$

spm(3,3) := 6.0$

spm(4,4) := 8.0$

spm(5,5) := 10.0$
tmp := 

tmp - mat1;


"Empty Matrix"

off rounded;



% The gram schmidt functions takes a list of vectors.
% These vectors are matrices of type 'sparse with column dimension 1.

%Create the "vectors".
sparse a(4,1);


sparse b(4,1);


sparse c(4,1);


sparse d(4,1);



%Fill the "vectors" with data.
a(1,1):=1;


a(1,1) := 1

b(1,1):=1;


b(1,1) := 1

b(2,1):=1;


b(2,1) := 1

c(1,1):=1;


c(1,1) := 1

c(2,1):=1;


c(2,1) := 1

c(3,1):=1;


c(3,1) := 1

d(1,1):=1;


d(1,1) := 1

d(2,1):=1;


d(2,1) := 1

d(3,1):=1;


d(3,1) := 1

d(4,1):=1;


d(4,1) := 1


spgram_schmidt({{a},{b},{c},{d}});


{

 spm(1,1) := 1$
 ,

 spm(2,1) := 1$
 ,

 spm(3,1) := 1$
 ,

 spm(4,1) := 1$
 }


on rounded;

 % again, makes large quotients a bit more readable.
% The algorithm used for splu_decom sometimes swaps the rows of the 
% input matrix so that (given matrix A, splu_decom(A) = {L,U,vec}), 
% we find L*U does not equal A but a row equivalent of it. The call 
% spconvert(A,vec) will return this row equivalent 
% (ie: L*U = convert(A,vec)).
lu := splu_decom(mat5)$


tmp := first lu * second lu$


tmp1 := spconvert(mat5,third lu);



spm(1,1) := 3$

spm(1,2) := 1$

spm(2,1) := 1$

spm(2,2) := 3$

spm(2,3) := 1$

spm(3,2) := 1$

spm(3,3) := 3$

spm(3,4) := 1$

spm(4,3) := 1$

spm(4,4) := 3$

spm(4,5) := 1$

spm(5,4) := 1$

spm(5,5) := 3$

spm(5,6) := 1$

spm(6,5) := 1$

spm(6,6) := 3$

spm(6,7) := 1$

spm(7,6) := 1$

spm(7,7) := 3$

spm(7,8) := 1$

spm(8,7) := 1$

spm(8,8) := 3$

spm(8,9) := 1$

spm(9,8) := 1$

spm(9,9) := 3$

spm(9,10) := 1$

spm(10,9) := 1$

spm(10,10) := 3$

spm(10,11) := 1$

spm(11,10) := 1$

spm(11,11) := 3$

spm(11,12) := 1$

spm(12,11) := 1$

spm(12,12) := 3$

spm(12,13) := 1$

spm(13,12) := 1$

spm(13,13) := 3$

spm(13,14) := 1$

spm(14,13) := 1$

spm(14,14) := 3$

spm(14,15) := 1$

spm(15,14) := 1$

spm(15,15) := 3$

spm(15,16) := 1$

spm(16,15) := 1$

spm(16,16) := 3$

spm(16,17) := 1$

spm(17,16) := 1$

spm(17,17) := 3$

spm(17,18) := 1$

spm(18,17) := 1$

spm(18,18) := 3$

spm(18,19) := 1$

spm(19,18) := 1$

spm(19,19) := 3$

spm(19,20) := 1$

spm(20,19) := 1$

spm(20,20) := 3$

spm(20,21) := 1$

spm(21,20) := 1$

spm(21,21) := 3$

spm(21,22) := 1$

spm(22,21) := 1$

spm(22,22) := 3$

spm(22,23) := 1$

spm(23,22) := 1$

spm(23,23) := 3$

spm(23,24) := 1$

spm(24,23) := 1$

spm(24,24) := 3$

spm(24,25) := 1$

spm(25,24) := 1$

spm(25,25) := 3$

spm(25,26) := 1$

spm(26,25) := 1$

spm(26,26) := 3$

spm(26,27) := 1$

spm(27,26) := 1$

spm(27,27) := 3$

spm(27,28) := 1$

spm(28,27) := 1$

spm(28,28) := 3$

spm(28,29) := 1$

spm(29,28) := 1$

spm(29,29) := 3$

spm(29,30) := 1$

spm(30,29) := 1$

spm(30,30) := 3$

spm(30,31) := 1$

spm(31,30) := 1$

spm(31,31) := 3$

spm(31,32) := 1$

spm(32,31) := 1$

spm(32,32) := 3$

spm(32,33) := 1$

spm(33,32) := 1$

spm(33,33) := 3$

spm(33,34) := 1$

spm(34,33) := 1$

spm(34,34) := 3$

spm(34,35) := 1$

spm(35,34) := 1$

spm(35,35) := 3$

spm(35,36) := 1$

spm(36,35) := 1$

spm(36,36) := 3$

spm(36,37) := 1$

spm(37,36) := 1$

spm(37,37) := 3$

spm(37,38) := 1$

spm(38,37) := 1$

spm(38,38) := 3$

spm(38,39) := 1$

spm(39,38) := 1$

spm(39,39) := 3$

spm(39,40) := 1$

spm(40,39) := 1$

spm(40,40) := 3$

spm(40,41) := 1$

spm(41,40) := 1$

spm(41,41) := 3$

spm(41,42) := 1$

spm(42,41) := 1$

spm(42,42) := 3$

spm(42,43) := 1$

spm(43,42) := 1$

spm(43,43) := 3$

spm(43,44) := 1$

spm(44,43) := 1$

spm(44,44) := 3$

spm(44,45) := 1$

spm(45,44) := 1$

spm(45,45) := 3$

spm(45,46) := 1$

spm(46,45) := 1$

spm(46,46) := 3$

spm(46,47) := 1$

spm(47,46) := 1$

spm(47,47) := 3$

spm(47,48) := 1$

spm(48,47) := 1$

spm(48,48) := 3$

spm(48,49) := 1$

spm(49,48) := 1$

spm(49,49) := 3$

spm(49,50) := 1$

spm(50,49) := 1$

spm(50,50) := 3$

spm(50,51) := 1$

spm(51,50) := 1$

spm(51,51) := 3$

spm(51,52) := 1$

spm(52,51) := 1$

spm(52,52) := 3$

spm(52,53) := 1$

spm(53,52) := 1$

spm(53,53) := 3$

spm(53,54) := 1$

spm(54,53) := 1$

spm(54,54) := 3$

spm(54,55) := 1$

spm(55,54) := 1$

spm(55,55) := 3$

spm(55,56) := 1$

spm(56,55) := 1$

spm(56,56) := 3$

spm(56,57) := 1$

spm(57,56) := 1$

spm(57,57) := 3$

spm(57,58) := 1$

spm(58,57) := 1$

spm(58,58) := 3$

spm(58,59) := 1$

spm(59,58) := 1$

spm(59,59) := 3$

spm(59,60) := 1$

spm(60,59) := 1$

spm(60,60) := 3$

spm(60,61) := 1$

spm(61,60) := 1$

spm(61,61) := 3$

spm(61,62) := 1$

spm(62,61) := 1$

spm(62,62) := 3$

spm(62,63) := 1$

spm(63,62) := 1$

spm(63,63) := 3$

spm(63,64) := 1$

spm(64,63) := 1$

spm(64,64) := 3$

spm(64,65) := 1$

spm(65,64) := 1$

spm(65,65) := 3$

spm(65,66) := 1$

spm(66,65) := 1$

spm(66,66) := 3$

spm(66,67) := 1$

spm(67,66) := 1$

spm(67,67) := 3$

spm(67,68) := 1$

spm(68,67) := 1$

spm(68,68) := 3$

spm(68,69) := 1$

spm(69,68) := 1$

spm(69,69) := 3$

spm(69,70) := 1$

spm(70,69) := 1$

spm(70,70) := 3$

spm(70,71) := 1$

spm(71,70) := 1$

spm(71,71) := 3$

spm(71,72) := 1$

spm(72,71) := 1$

spm(72,72) := 3$

spm(72,73) := 1$

spm(73,72) := 1$

spm(73,73) := 3$

spm(73,74) := 1$

spm(74,73) := 1$

spm(74,74) := 3$

spm(74,75) := 1$

spm(75,74) := 1$

spm(75,75) := 3$

spm(75,76) := 1$

spm(76,75) := 1$

spm(76,76) := 3$

spm(76,77) := 1$

spm(77,76) := 1$

spm(77,77) := 3$

spm(77,78) := 1$

spm(78,77) := 1$

spm(78,78) := 3$

spm(78,79) := 1$

spm(79,78) := 1$

spm(79,79) := 3$

spm(79,80) := 1$

spm(80,79) := 1$

spm(80,80) := 3$

spm(80,81) := 1$

spm(81,80) := 1$

spm(81,81) := 3$

spm(81,82) := 1$

spm(82,81) := 1$

spm(82,82) := 3$

spm(82,83) := 1$

spm(83,82) := 1$

spm(83,83) := 3$

spm(83,84) := 1$

spm(84,83) := 1$

spm(84,84) := 3$

spm(84,85) := 1$

spm(85,84) := 1$

spm(85,85) := 3$

spm(85,86) := 1$

spm(86,85) := 1$

spm(86,86) := 3$

spm(86,87) := 1$

spm(87,86) := 1$

spm(87,87) := 3$

spm(87,88) := 1$

spm(88,87) := 1$

spm(88,88) := 3$

spm(88,89) := 1$

spm(89,88) := 1$

spm(89,89) := 3$

spm(89,90) := 1$

spm(90,89) := 1$

spm(90,90) := 3$

spm(90,91) := 1$

spm(91,90) := 1$

spm(91,91) := 3$

spm(91,92) := 1$

spm(92,91) := 1$

spm(92,92) := 3$

spm(92,93) := 1$

spm(93,92) := 1$

spm(93,93) := 3$

spm(93,94) := 1$

spm(94,93) := 1$

spm(94,94) := 3$

spm(94,95) := 1$

spm(95,94) := 1$

spm(95,95) := 3$

spm(95,96) := 1$

spm(96,95) := 1$

spm(96,96) := 3$

spm(96,97) := 1$

spm(97,96) := 1$

spm(97,97) := 3$

spm(97,98) := 1$

spm(98,97) := 1$

spm(98,98) := 3$

spm(98,99) := 1$

spm(99,98) := 1$

spm(99,99) := 3$

spm(99,100) := 1$

spm(100,99) := 1$

spm(100,100) := 3$
tmp1 := 

tmp - tmp1;


"Empty Matrix"

% and the complex case..
on complex;


*** Domain mode rounded changed to complex-rounded 

lu1 := splu_decom(mat6);


{

 spm(1,1) := 1$

 spm(2,1) := 4$

 spm(2,2) := 5 - 4*i$

 spm(3,1) := 1 + i$

 spm(3,2) := 3$

 spm(3,3) := 2.26829268293 + 0.414634146341*i$

 spm(4,4) := 1$

 spm(5,4) := 4$

 spm(5,5) := 5 - 4*i$

 spm(6,4) := 1 + i$

 spm(6,5) := 3$

 spm(6,6) := 2.26829268293 + 0.414634146341*i$
 ,

 spm(1,1) := 1$

 spm(1,2) := i$

 spm(2,2) := 1$

 spm(2,3) := 0.243902439024 + 0.19512195122*i$

 spm(3,3) := 1$

 spm(4,4) := 1$

 spm(4,5) := i$

 spm(5,5) := 1$

 spm(5,6) := 0.243902439024 + 0.19512195122*i$

 spm(6,6) := 1$
lu1 :=  ,[3,2,3,6,5,6]}

mat6;



spm(1,1) := i + 1$

spm(1,2) := i + 2$

spm(1,3) := i + 3$

spm(2,1) := 4$

spm(2,2) := 5$

spm(2,3) := 2$

spm(3,1) := 1$

spm(3,2) := i$

spm(4,4) := i + 1$

spm(4,5) := i + 2$

spm(4,6) := i + 3$

spm(5,4) := 4$

spm(5,5) := 5$

spm(5,6) := 2$

spm(6,4) := 1$

spm(6,5) := i$

tmp := first lu1 * second lu1;



spm(1,1) := 1$

spm(1,2) := i$

spm(2,1) := 4$

spm(2,2) := 5$

spm(2,3) := 2.0$

spm(3,1) := 1 + i$

spm(3,2) := 2 + i$

spm(3,3) := 3.0 + i$

spm(4,4) := 1$

spm(4,5) := i$

spm(5,4) := 4$

spm(5,5) := 5$

spm(5,6) := 2.0$

spm(6,4) := 1 + i$

spm(6,5) := 2 + i$

spm(6,6) := 3.0 + i$
tmp := 

tmp1 := spconvert(mat6,third lu1);



spm(1,1) := 1$

spm(1,2) := i$

spm(2,1) := 4$

spm(2,2) := 5$

spm(2,3) := 2$

spm(3,1) := i + 1$

spm(3,2) := i + 2$

spm(3,3) := i + 3$

spm(4,4) := 1$

spm(4,5) := i$

spm(5,4) := 4$

spm(5,5) := 5$

spm(5,6) := 2$

spm(6,4) := i + 1$

spm(6,5) := i + 2$

spm(6,6) := i + 3$
tmp1 := 

tmp - tmp1;


"Empty Matrix"

off complex;


*** Domain mode complex-rounded changed to rounded 


mat3inv := sppseudo_inverse(mat3);



spm(1,1) :=  - 2.0$

spm(1,2) := 1$

spm(2,1) := 1.5$

spm(2,2) :=  - 0.5$

spm(3,3) :=  - 2.0$

spm(3,4) := 1$

spm(4,3) := 1.5$

spm(4,4) :=  - 0.5$

spm(5,5) :=  - 2.0$

spm(5,6) := 1$

spm(6,5) := 1.5$

spm(6,6) :=  - 0.5$
mat3inv := 

mat3 * mat3inv;



spm(1,1) := 1$

spm(2,2) := 1$

spm(3,3) := 1$

spm(4,4) := 1$

spm(5,5) := 1$

spm(6,6) := 1$



% Predicates.

matrixp(mat1);


t

matrixp(poly);



squarep(mat2);


t

squarep(mat3);


t


symmetricp(mat1);


t

symmetricp(mat3);



sparsematp(mat1);


t

sparsematp(poly);



off rounded;



end;


Time for test: 13295 ms, plus GC time: 40 ms


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]