up previous next
MakeMatByRows, MakeMatByCols    --    convert a list into a matrix


Syntax
MakeMatByRows(R: INT, C: INT, L: LIST): MAT
MakeMatByCols(R: INT, C: INT, L: LIST): MAT

Description
These functions create an RxC matrix from the list L. The first argument R is the number of rows, and the second C is the number of columns. It is an error if the length of L is not RxC.

The ring of the matrix is determined from the ring containing the elements of L. If L contains only integers/rationals then the matrix is over QQ.

Example
/**/  MakeMatByRows(2, 10, 1..20);
matrix(QQ,
 [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
  [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]])

/**/  MakeMatByCols(2, 10, 1..20);
matrix(QQ,
 [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19],
  [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]])

See Also