A:= Matrix( [ [1, 2, 3] , [3, 6, 7] , [5, 6, 9] , [7, 7, 7] ]); whattype(A); Matrix size:=LinearAlgebra:-Dimension(A); size := 4, 3 row:=size[1]; row := 4 col:=size[2]; col := 3
You can extract any part of the matrix like this:
By Carl Devore http://mathforum.org/kb/message.jspa?messageID=1570678
Maple list and sequence structures are more flexible than Matrices, which are highly structured. A Maple list of lists (called a listlist in Maple) is akin to a matrix in some other languages. Many matrix operations can be performed directly on the listlist form, but to do serious linear algebra, you should convert to a Matrix. Of course, it is trivial to convert a listlist to Matrix: LL:= [[1,2], [3,4]]; M:= Matrix(LL); So here is another solution in line with your original wishes. This is "index free", but the table-based solution I gave earlier should be faster. (It is usually considered bad form to repeatedly append to a list or sequence.) L:= [][]; # Create a NULL sequence do line:= readline(file); if line::string then if line contains valid data then Z:= a list of that data; L:= L, Z fi else break fi od A:= Matrix([L]); # Note []: seq -> list.
To move move a column into a matrix: Here, I want to copy 2nd column to the 3rd column:
A;
B:=A[1..row,2];
A[1..row,3]:=B: A;