Mat
Calling sequence
A=[a11, a12, ..., a1n;
a21, a22, ..., a2n;
...
am1, am2, ...; amn]
|
Parameters
- a11 ...: real or complex numbers.
Description
The Mat data type is the basic matrix numerical object. More generally, matrices are two
dimensional arrays which contains scalar objects (real or complex numbers, boolean numbers,
strings, polynomials). The Mat data type is built from real or complex numbers.
Column vectors are considered as m x 1 matrices and row vectors as 1 x n matrices.
Internally numerical matrices Mat type are stored by default as arrays of double.
Operations on matrices
Matrix methods
- A.add[B] add matrix B to matrix A.
- A.blas_axpy[alpha, x [i1,i2 [,j1,j2]]] constant times a vector plus a vector i.e
A = A + alpha*X
- A.blas_ger[alpha, x, y [,i1,i2,j1,j2]] rank one update A = A + alpha*x*y’
on a submatrix of A.
- A.scale_rows[x] multiplies each row i of A with a scalar: A(i,:) = x(i) A(i,:).
- A.scale_cols[x] multiplies each column j of A with a scalar: A(:,j) = x(j) A(:,j).
Methods from the matint interface
- A.redim[m,n] reshape matrix to size mxn. m or n can be set to -1
- A.concatr[B] A = [A,B]
- A.concatd[B] A = [A;B]
- A.perm_elem[p,q[,dim]] permute p and q: elements (default or dim=0), rows (dim=1)
or columns (dim=2).
Extraction, insertion, deletion
- If I and is J are respectively row and column indices A(I,J) is the submatrix of A with
entries in I and j.
- A(I,:) is the submatrix of A with row indices in I.
- A(:,J) is the submatrix of A with comumn indices in I.
- A(:,:) is A
- A(:) is the column matrix obtained by stacking the columns of A.
- If I and is J are row and column indices A(I,J)=B inserts matrix B into matrix A in
rows I and columns J.
- A(I,:)=[] removes the rows of A with indices in J.
- A(:,J)=[] removes the columns of A with indices in J.
Empty matrices
Empty matrices are matrices with zero rows or zero columns. Operations with
empty matrices are compatible with linear algebra operations. The m x n zero matrix can be
factorized as the empty m x 0 matrix * the 0 x n matrix.
For loop control
With a matrix A:
is a loop with size(A,2) iterations, the loop variable col being equal to the ith column of A at the
i-th iteration.
Some functions
- length(A) returns the number of entries in A.
- size(A) returns in a 1 x 2 vector the dimensions (rows, columns) of A. size(A,1)
(resp. size(A,2)) retuns the number of rows (resp. columns) of A.
See also
Authors jpc, bp