Google

Go to the first, previous, next, last section, table of contents.


newmat

newmat(row,col [,[[a,b,...],[c,d,...],...]])
:: Creates a new matrix with row rows and col columns.
return
matrix
row,col
non-negative integer
a,b,c,d
arbitrary
  • If the third argument, a list, is given, the newly created matrix is initialized so that each element of the list (again a list) initializes each of the rows of the matrix. Elements are used from the first through the last. If the list is short, 0's are filled in the remaining matrix elements. If no third argument is given all the elements are cleared to 0.
  • The size of a matrix is given by function size().
  • Let M be a program variable assigned to a matrix. Then, M[I] denotes a (row) vector which corresponds with the I-th row of the matrix. Note that the vector shares its element with the original matrix. Subsequently, if an element of the vector is modified, then the corresponding matrix element is also modified.
  • When a matrix is passed to a function as its argument (actual parameter), the matrix element can be modified within that function.
[0] A = newmat(3,3,[[1,1,1],[x,y],[x^2]]);
[ 1 1 1 ]
[ x y 0 ]
[ x^2 0 0 ]
[1] det(A);
-y*x^2
[2] size(A);
[3,3]
[3] A[1];
[ x y 0 ]
[4] A[1][3];
getarray : Out of range
return to toplevel
References
section newvect, section size, section det,invmat.


Go to the first, previous, next, last section, table of contents.