Home Online Manual
Top
Back: matrix expressions
Forward: matrix operations
FastBack: map
FastForward: module
Up: matrix
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.11.3 matrix type cast

Syntax:
matrix ( expression )
matrix ( expression, int_n, int_m )
Type:
matrix
Purpose:
Converts expression to a matrix, where expression must be of type int, intmat, intvec, number, poly, ideal, vector, module, or matrix. If int_n and int_m are supplied, then they specify the dimension of the matrix. Otherwise, the size (resp. dimensions) of the matrix is determined by the size (resp. dimensions) of the expression.
Example:
 
  ring r=32003,(x,y,z),dp;
  matrix(x);
==> _[1,1]=x
  matrix(x, 1, 2);
==> _[1,1]=x
==> _[1,2]=0
  matrix(intmat(intvec(1,2,3,4), 2, 2));
==> _[1,1]=1
==> _[1,2]=2
==> _[2,1]=3
==> _[2,2]=4
  matrix(_, 2, 3);
==> _[1,1]=1
==> _[1,2]=2
==> _[1,3]=0
==> _[2,1]=3
==> _[2,2]=4
==> _[2,3]=0
  matrix(_, 2, 1);
==> _[1,1]=1
==> _[2,1]=3
See Type conversion and casting; intmat type cast; matrix.