Matrix Functions
[Functions]


Functions

matrix AddCols (matrix M, matrix A)
 Produces horizontal concatenation of two appropriate matrices.
matrix AddRows (matrix M, matrix A)
 Produces vertical concatenation of two appropriate matrices.
matrix Col2Sym (tensor T)
 Transforms the vector in one index of a tensor into a symmetric matrix.
matrix Col2Sym (matrix V)
 Transforms a single column matrix into a symmetric matrix.
scalar det (tensor T)
 Evaluates the determinant in two indices of a tensor.
scalar det (matrix M)
 Evaluates the determinant of a matrix.
matrix Diag2Row (matrix M)
 Transforms the diagonal of a matrix to a matrix with a single row, i.e. a row-vector.
matrix DiagToRow (matrix M)
 Transforms the diagonal of a matrix to a matrix with a single row, i.e. a row-vector.
list Eigen (tensor T)
 Evaluates the eigenvalues and eigenvectors of a sub-matrix of a tensor.
list Eigen (matrix M)
 Find eigenvalues and eigenvectors.
list EigenValues (tensor T)
 Evaluates the eigenvalues of a sub-matrix of a tensor.
list EigenValues (matrix M)
 Find eigenvalues of a matrix.
list FindMainNRows (matrix M, counter N)
 Get a list of N matrix rows which mainly span the row space.
matrix GetMVProductMatrix (list L, counter ProductId, counter Left, list Mask)
 Generates a matrix based on a list of multivectors and a product.
matrix GetMVProductMatrix (list L, counter ProductId, list Mask, counter Left)
 Generates a matrix based on a list of multivector and a product.
matrix GetMVProductMatrix (multivector A, counter ProductId, counter Left, list Mask)
 Generates a matrix based on a multivector and a product.
matrix GetMVProductMatrix (multivector A, counter ProductId, list Mask, counter Left)
 Generates a matrix based on a multivector and a product.
matrix GetRows (matrix M, list Idx)
 Construct matrix from rows of another matrix.
matrix IdMatrix (counter rows, counter cols)
 Generates an identity matrix.
matrix Matrix (multivector A)
 Generates a symmetric 3 by 3 matrix from a vector from 2D-conic space.
matrix Matrix (counter rows, counter cols)
 Generates a matrix with zeroed entries of the given dimension.
matrix Matrix (tensor T)
 Transforms a tensor or part of a tensor into a matrix.
matrix Matrix (list L)
 Generates a matrix from a nested list of scalar values.
matrix Matrix2MV (matrix M, list Mask)
 Generates a multivector from a column vector or the column vectors of a matrix.
matrix MV2Matrix (list L, list Mask)
 Generates a column vector based on a multivector.
matrix MV2Matrix (multivector A, list Mask)
 Generates a column vector based on a multivector.
matrix ReadMatrix (string filename, string sepsym)
 Reads a matrix from a text file.
matrix ReshapeMatrix (matrix M, counter Rows, counter Cols)
 Changes the shape of a matrix.
matrix ResizeMatrix (matrix M, counter Rows, counter Cols)
 Changes the size of a matrix.
matrix Row2Diag (matrix M)
 Transforms a row-vector to a diagonal matrix.
list RowSpace (matrix M, scalar prec)
 Reduce matrix to those rows that span the row space and have highest magnitude.
matrix RowToDiag (matrix M)
 Transforms a row-vector to a diagonal matrix.
list Size (matrix M)
 Returns the dimension of a matrix.
list SVD (tensor T)
 Evaluates the singular value decomposition (SVD) of a submatrix of a tensor.
list SVD (matrix M)
 Evaluates a singular value decomposition (SVD) of a matrix.
matrix Sym2Col (tensor T)
 Transforms the upper triangular part including the diagonal of a symmetric matrix into a column vector.
matrix Sym2Col (matrix M)
 Transforms the upper triangular part including the diagonal of a symmetric matrix into a column vector.

Detailed Description

Functions that have to do with the generation of and operation on matrices.

Function Documentation

matrix AddCols matrix  M,
matrix  A
 

Produces horizontal concatenation of two appropriate matrices.

Parameters:
M A matrix.
A A matrix to add.
Returns:
An enlarged matrix.
Since:
v2.0
This function appends matrix A from the right to matrix M, if both matrices have the same number of rows.

matrix AddRows matrix  M,
matrix  A
 

Produces vertical concatenation of two appropriate matrices.

Parameters:
M A matrix.
A A matrix to add.
Returns:
An enlarged matrix.
Since:
v2.0
This function appends matrix A from beneath to matrix M, if both matrices have the same number of columns.

matrix Col2Sym tensor  T  ) 
 

Transforms the vector in one index of a tensor into a symmetric matrix.

Parameters:
T The vector.
Returns:
The corresponding symmetric matrix.
    ?T = Tensor([[1,2,3], [4,5,6]]);
    ?M = Col2Sym(T(1,-1));

Output:

T (2x3)=
123
456

M (2x2)=
11.41
1.413

Note that the components in the column vector that are mapped to off-diagonal elements of the symmetric matrix, are divided by the square root of 2.

matrix Col2Sym matrix  V  ) 
 

Transforms a single column matrix into a symmetric matrix.

Parameters:
V The single column matrix.
Returns:
The corresponding symmetric matrix.
    ?V = Matrix([1,2,3]);
    ?M = Col2Sym(V);

Output:

V (3x1)=
1
2
3

M (2x2)=
11.41
1.413

Note that the components in the column vector that are mapped to off-diagonal elements of the symmetric matrix, are divided by the square root of 2.

scalar det tensor  T  ) 
 

Evaluates the determinant in two indices of a tensor.

Parameters:
T The tensor.
Returns:
The determinant of T.
Since:
v2.2
For example,
    ?T = Tensor( [ [[1,2], [3,4]], [[5,6],[7,8]] ] );
    ?dV = det(T(1,-1,-2));

produces the output

T (2x2x2)=
12
34

56
78

dV = -2

scalar det matrix  M  ) 
 

Evaluates the determinant of a matrix.

Parameters:
M The matrix.
Returns:
The determinant of M.
Since:
v1.0
For example,
?M = Matrix( ((1,2), (3,4)) );
?DetM = det(M);

produces the output

M = (| 1 2|, | 3 4|)
DetM = -2

matrix Diag2Row matrix  M  ) 
 

Transforms the diagonal of a matrix to a matrix with a single row, i.e. a row-vector.

Parameters:
M The matrix.
Returns:
A row-vector containing the diagonal of M.
Since:
v1.5
For example,

?M = IdMatrix( 3, 3 );
?R = DiagToRow(M);

produces the output

M = (| 1 0 0|, | 0 1 0|, | 0 0 1|)
R = (| 1 1 1|)

matrix DiagToRow matrix  M  ) 
 

Transforms the diagonal of a matrix to a matrix with a single row, i.e. a row-vector.

Parameters:
M The matrix.
Returns:
A row-vector containing the diagonal of M.
Since:
v1.4
Deprecated:
Use the new name Diag2Row() instead.
For example,

?M = IdMatrix( 3, 3 );
?R = DiagToRow(M);

produces the output

M = (| 1 0 0|, | 0 1 0|, | 0 0 1|)
R = (| 1 1 1|)

list Eigen tensor  T  ) 
 

Evaluates the eigenvalues and eigenvectors of a sub-matrix of a tensor.

Parameters:
T The tensor.
Returns:
A list of four matrices giving the eigenvalues and the normalized eigenvectors.
Since:
v2.2
See the function Eigen() for matrices for a detailed description. For example, if T is given by T = Tensor(3, [2,3,3]) you can evaluate the eigenvalues and eigenvectors a submatrix by Eigen(T(1,-1,-2)).

list Eigen matrix  M  ) 
 

Find eigenvalues and eigenvectors.

Parameters:
M A matrix.
Returns:
A list of four matrices giving the eigenvalues and the normalized eigenvectors.
Since:
v2.0
This function evaluates the eigenvalue decomposition of matrices $M\,=\,VDV^{-1}$ . The return is a list L consisting of four elements, two matrices of size $1\times n$ and two matrices of size $n\times n$ . The former matrices represent the eigenvalues, whereas the latter represent the eigenvectors, resp. the matrix $V$ . The particular first list elements, i.e. L(1) and L(3) give the real parts. Elements with even list index give the corresponding imaginary parts. The eigenvalues are sorted in descending order according to their magnitude. The order of the eigenvectors, i.e. the columns of matrix $V$ is taken over from the one of the eigenvalues. The following example shall clarify the use of function Eigen.

    _FrameBoxSize = 0;
    M = Matrix([ [0,3,1,4], [3,0,1,5], [1,1,0,9],[ 4,5,9,0] ]);
    L = Eigen( M );
    ? "Size of list L = " + Size( L );
    
    StartOverlay();
    SetLatexAlign(0,1);
    SetLatexMagStep(4);
    :White; 
    P1 = DrawLatex( 5,       5,0, "$M\, =\, " + Latex( M ) + "$", "1");
    P2 = DrawLatex( 5, P1(2)+5,0, "$L(1)\, =\, D_{\mbox{real}}\, =\, " + Latex( Row2Diag(L(1)) ) + "$", "2");
    P3 = DrawLatex(P2(4)+5, P1(2)+5,0, "$L(3)\, =\, V_{\mbox{real}}\, =\, " + Latex( L(3) ) + "$", "4");
    P2 = DrawLatex( 5, P3(2)+5,0, "$L(2)\, =\, D_{\mbox{imag}}\, =\, " + Latex( Row2Diag(L(2)) ) + "$", "3");
    P2 = DrawLatex(P2(4)+5, P3(2)+5,0, "$L(4)\, =\, V_{\mbox{imag}}\, =\, " + Latex( L(4) ) + "$", "5");
    EndOverlay();
       Matrix is symmetric --> pure real   
    ? V = L(3);
    ? D = Row2Diag( L(1) );
    
    ? M = V * D * !V;
    ? M = V * D * ~V; // Since V is nomalized (!).
This will result in

Eigen_img1.jpg

list EigenValues tensor  T  ) 
 

Evaluates the eigenvalues of a sub-matrix of a tensor.

Parameters:
T The tensor.
Returns:
A list of two matrices giving the eigenvalues.
Since:
v2.2
See the function EigenValues() for matrices for a detailed description. For example, if T is given by T = Tensor(3, [2,3,3]) you can evaluate the eigenvalues of a submatrix by EigenValues(T(1,-1,-2)).

list EigenValues matrix  M  ) 
 

Find eigenvalues of a matrix.

Parameters:
M A matrix.
Returns:
A list of two matrices giving the eigenvalues.
Since:
v2.0
This function evaluates the eigenvalues of a matrix. It's output is a list of two matrices which are just the first two matrices in the return of function Eigen, i.e. with L1 = Eigenvalues(M) and L2 = (Eigen(M))([ [1], [2] ]) we have that L1 is equal to L2.

list FindMainNRows matrix  M,
counter  N
 

Get a list of N matrix rows which mainly span the row space.

Parameters:
M A matrix.
N The number of rows to be selected.
Returns:
A list of N indices.
Since:
v2.0
This function is akin to RowSpace. But instead of setting a threshold for choosing rows the parameter N determines the number of rows. By using the function GetRows a new matrix can be constructed.

matrix GetMVProductMatrix list  L,
counter  ProductId,
counter  Left,
list  Mask
 

Generates a matrix based on a list of multivectors and a product.

Since:
v1.5
This is the same function as before, only the order of the optional parameters Mask and Left is changed. Details of how this function works can be found in the section Solving Multivector Equations.

matrix GetMVProductMatrix list  L,
counter  ProductId,
list  Mask,
counter  Left
 

Generates a matrix based on a list of multivector and a product.

Parameters:
L A list of multivector.
ProductId An id-number identifying the type of product. This parameter can take on the values of the following predefined variables.
  • MVOP_INNER
    The inner product
  • MVOP_OUTER
    The outer product
  • MVOP_GEO
    The geometric product
Mask An embedding mask. This parameter is optional.
Left Flag indicating whether product is to be executed from left (1) or right (0). This parameter is optional.
Returns:
A matrix representing a multivector product.
Since:
v1.4
Details of how this function works can be found in the section Solving Multivector Equations.

matrix GetMVProductMatrix multivector  A,
counter  ProductId,
counter  Left,
list  Mask
 

Generates a matrix based on a multivector and a product.

Since:
v1.5
This is the same function as before, only the order of the optional parameters Mask and Left is changed. Details of how this function works can be found in the section Solving Multivector Equations.

matrix GetMVProductMatrix multivector  A,
counter  ProductId,
list  Mask,
counter  Left
 

Generates a matrix based on a multivector and a product.

Parameters:
A A multivector.
ProductId An id-number identifying the type of product. This parameter can take on the values of the following predefined variables.
  • MVOP_INNER
    The inner product
  • MVOP_OUTER
    The outer product
  • MVOP_GEO
    The geometric product
Mask An embedding mask. This parameter is optional.
Left Flag indicating whether product is to be executed from left (1) or right (0). This parameter is optional.
Returns:
A matrix representing a multivector product.
Since:
v1.4
Details of how this function works can be found in the section Solving Multivector Equations.

matrix GetRows matrix  M,
list  Idx
 

Construct matrix from rows of another matrix.

Parameters:
M A matrix.
Idx A list containing indices.
Returns:
A matrix assembled by selected rows of the original matrix.
Since:
v2.0
Selecting the first and 4th row of matrix M by

    Idx = [ 1, 4 ];
    ? M = Matrix( [ [16, 2, 3, 13], [5, 11, 10, 8], [9, 7, 6, 12], [4, 14, 5, 1] ] );
    ? R = GetRows( M, Idx );
gives the result

    M = (| 16 2 3 13|, | 5 11 10 8|, | 9 7 6 12|, | 4 14 5 1|)
    R = (| 16 2 3 13|, | 4 14 5 1|)

matrix IdMatrix counter  rows,
counter  cols
 

Generates an identity matrix.

Parameters:
rows The number of rows.
cols The number of columns
Returns:
An identity matrix of the given dimensions.
Since:
v1.4
Note that only an identity matrix is returned if the given dimensions are those of a square matrix. Otherwise, this function is identical to Matrix(). For example,

?M = IdMatrix( 3, 3 );
?M = IdMatrix( 3, 4 );

produces the output

M = (| 1 0 0|, | 0 1 0|, | 0 0 1|)
M = (| 0 0 0 0|, | 0 0 0 0|, | 0 0 0 0|)

matrix Matrix multivector  A  ) 
 

Generates a symmetric 3 by 3 matrix from a vector from 2D-conic space.

Parameters:
A The vector from 2D-conic space.
Returns:
A symmetric 3 by 3 matrix.
Since:
v2.0
For example,

A = VecC2(1,2);
?M = Matrix( A );

produces the output

M = (| 1 2 1|, | 2 4 2|, | 1 2 1|)

matrix Matrix counter  rows,
counter  cols
 

Generates a matrix with zeroed entries of the given dimension.

Parameters:
rows The number of rows.
cold The number of columns
Returns:
A matrix of the given dimension with zeroed entries.
Since:
v1.0
For example,

?M = Matrix( 3, 4 );

produces the output

M = (| 0 0 0 0|, | 0 0 0 0|, | 0 0 0 0|)

where the elements enclodes in |.| give the row elements.

matrix Matrix tensor  T  ) 
 

Transforms a tensor or part of a tensor into a matrix.

Parameters:
T The tensor that is to be transformed.
Returns:
The matrix representation of the tensor.
Since:
v2.2
The variable T either has to be a 2-valence tensor or a tensor with two specified counting indices. For example,

    T1 = Tensor(2, [2,3]);
    T2 = Tensor(3, [2,3,4]);
    
    ?M1 = Matrix(T1);
    ?M2 = Matrix(T2(1,-1,-2));

Output:

M1 (2x3)=
000
000

M2 (3x4)=
0000
0000
0000

matrix Matrix list  L  ) 
 

Generates a matrix from a nested list of scalar values.

Parameters:
L A nested list of matrix components.
Returns:
A matrix created from the nested list of elements given by L.
Since:
v1.0
A matrix can be created in two different ways: either a nested list is given which can represent a matrix, or the dimensions of a new matrix are given. The elements of the outer list give the rows of the new matrix. Therefore, all elements of the outer list have to be lists of equal dimension. Furthermore, each row entry must be castable to a scalar. See section Working with Matrices for more details. For example,

?M = Matrix( ((1, 2), (3, 4)) );

produces the output

M = (| 1 2|, | 3 4|)

where the elements enclodes in |.| give the row elements.

matrix Matrix2MV matrix  M,
list  Mask
 

Generates a multivector from a column vector or the column vectors of a matrix.

Parameters:
M A matrix.
Mask An embedding mask. This parameter is optional.
Returns:
A multivector.
Since:
v1.4
This function transforms a matrix into one or a set of multivectors. Details of how this function works can be found in the section Solving Multivector Equations.

For example,

    DefVarsE3();
    
    ?A = 1*e1 + 2*e2^e3 + 3*I;
    ?MA = MV2Matrix(A);
    ?B = Matrix2MV(MA);
    
    Mask = (0, 1, 0, 0, 2, 0, 0, 3);
    ?MA2 = MV2Matrix(A, Mask);
    ?B2 = Matrix2MV(MA2, Mask);

produces the output

    A = 1^e1 + 2^e23 + 3^I
    MA = (| 0|, | 1|, | 0|, | 0|, | 2|, | 0|, | 0|, | 3|)
    B = 1^e1 + 2^e23 + 3^I
    MA2 = (| 1|, | 2|, | 3|)
    B2 = 1^e1 + 2^e23 + 3^I

matrix MV2Matrix list  L,
list  Mask
 

Generates a column vector based on a multivector.

Parameters:
L A list of multivectors.
(\b optional) Mask An embedding mask.
Returns:
A matrix whose columns represent the multivectors.
Since:
v2.1
This function transforms a list of multivector into a matrix. Details of how this function works can be found in the section Solving Multivector Equations.

For example,

    DefVarsE3();
    
    ?A = 1*e1 + 2*e2^e3 + 3*I;
    ?B = 3*e1 + 1*e2^e3 + 2*I;
    ?MAB = MV2Matrix([A,B]);
    
    Mask = [0, 1, 0, 0, 2, 0, 0, 3];
    ?MAB2 = MV2Matrix([A,B], Mask);

produces the output

A = 1 e1 + 2 e23 + 3 I
B = 3 e1 + 1 e23 + 2 I
MAB <font size="12">(8x2)</font> = <font size="12">
00
13
00
00
21
00
00
32
.
</font>
MAB2 <font size="12">(3x2)</font> = <font size="12">
13
21
32
.
</font>

matrix MV2Matrix multivector  A,
list  Mask
 

Generates a column vector based on a multivector.

Parameters:
A A multivector.
Mask An embedding mask. This parameter is optional.
Returns:
A column vector representing a multivector.
Since:
v1.4
This function transforms a multivector into a column vector. Details of how this function works can be found in the section Solving Multivector Equations.

For example,

    DefVarsE3();
    
    ?A = 1*e1 + 2*e2^e3 + 3*I;
    ?MA = MV2Matrix(A);
    
    Mask = [0, 1, 0, 0, 2, 0, 0, 3];
    ?MA2 = MV2Matrix(A, Mask);

produces the output

    A = 1^e1 + 2^e23 + 3^I
    MA = (| 0|, | 1|, | 0|, | 0|, | 2|, | 0|, | 0|, | 3|)
    MA2 = (| 1|, | 2|, | 3|)

matrix ReadMatrix string  filename,
string  sepsym
 

Reads a matrix from a text file.

Parameters:
filename The filename.
sepsym (optional) The separator symbol between elements in text file. The default is a space.
Returns:
The read in matrix.
Since:
v2.1
Assuming the separator symbol to be a space, the text file format that can be read in with this function has to look like this.

    [Rows] [Col]
    [Value Row 1, Col 1] [Value Row1, Col 2] ...
    [Value Row 2, Col 1] [Value Row2, Col 2] ...
    ...

For example, if a text file with the name 'Mat.txt' looks like this

    2 3
    1 2 3
    3 2 1

the script

    ?M = ReadMatrix("Mat.txt");

results in the output

M <font size="12">(2x3)</font> = <font size="12">
123
321
.
</font>

matrix ReshapeMatrix matrix  M,
counter  Rows,
counter  Cols
 

Changes the shape of a matrix.

Parameters:
M The initial matrix.
Rows The new number of rows.
Cols The new number of columns.
Returns:
A matrix of the new shape.
Since:
v1.5
The matrix returned has the same number of elements as the initial matrix. However, the number of rows and columns have changed. This function allows you, for example, to transform a NxM matrix into a (N*M)-vector.

For example,

?M = Matrix( 2, 2 );
M[1,1] = 1;
M[1,2] = 2;
M[2,1] = 3;
M[2,2] = 4;
?M;

?V = ReshapeMatrix( M, 4, 1 );

produces the output

M = (| 0 0|, | 0 0|)
M = (| 1 2|, | 3 4|)
V = (| 1|, | 2|, | 3|, | 4|)

matrix ResizeMatrix matrix  M,
counter  Rows,
counter  Cols
 

Changes the size of a matrix.

Parameters:
M The initial matrix.
Rows The new number of rows.
Cols The new number of columns.
Returns:
A matrix of the new dimensions, which kept the data of the initial matrix as far as possible.
Since:
v1.5
For example,

?M = Matrix( 2, 2 );
M[1,1] = 1;
M[1,2] = 2;
M[2,1] = 3;
M[2,2] = 4;
?M;

?P = ResizeMatrix( M, 3, 3 );

produces the output

M = (| 0 0|, | 0 0|)
M = (| 1 2|, | 3 4|)
P = (| 1 2 0|, | 3 4 0|, | 0 0 0|)

matrix Row2Diag matrix  M  ) 
 

Transforms a row-vector to a diagonal matrix.

Parameters:
M The row vector.
Returns:
A matrix containing the components of the row vector on its diagonal.
Since:
v1.5
For example,

?M = Matrix( 1, 3 );
M[1,1] = 1;
M[1,2] = 2;
M[1,3] = 3;
?M;

?D = RowToDiag(M);

produces the output

M = (| 0 0 0|)
M = (| 1 2 3|)
D = (| 1 0 0|, | 0 2 0|, | 0 0 3|)

list RowSpace matrix  M,
scalar  prec
 

Reduce matrix to those rows that span the row space and have highest magnitude.

Parameters:
M The matrix.
prec (optional) A real number giving the precision for the row selection. Default is $1E-12$ .
Returns:
A list consisting of the reduced matrix and a list of indices corresponding to the rows which have been selected.
Since:
v2.0
The list of indices is sorted according to the $L_2$ -norm of the rows, which was at the same time the criterion for selecting the rows.

In the subsequent example a matrix M is created which is linear dependent since $n+1$ vectors in a $n$ -dimensional vectorspace are always linear dependent.

    dFac = 1.0; // change this value to 0.2 !
    ? M = Matrix( [ [ 1,0,0,0 ], [ 0,1,0,0 ], [ 0,0,1,0 ], [ 1,2,3,0 ] * dFac, [ 0,0,0,1e-5] ] );
    L = RowSpace( M );
    ? Rows = L(2);  
    ? R = L(1);
The application of RowSpace then results in a matrix R which is not linear dependent any more.

    M = (| 1 0 0 0|, | 0 1 0 0|, | 0 0 1 0|, | 1 2 3 0|, | 0 0 0 1.0e-05|)
    Rows = [4, 1, 2, 5]
    R = (| 1 2 3 0|, | 1 0 0 0|, | 0 1 0 0|, | 0 0 0 1.0e-05|)

matrix RowToDiag matrix  M  ) 
 

Transforms a row-vector to a diagonal matrix.

Parameters:
M The row vector.
Returns:
A matrix containing the components of the row vector on its diagonal.
Since:
v1.4
Deprecated:
Use the new name Row2Diag() instead.
For example,

?M = Matrix( 1, 3 );
M[1,1] = 1;
M[1,2] = 2;
M[1,3] = 3;
?M;

?D = RowToDiag(M);

produces the output

M = (| 0 0 0|)
M = (| 1 2 3|)
D = (| 1 0 0|, | 0 2 0|, | 0 0 3|)

list Size matrix  M  ) 
 

Returns the dimension of a matrix.

Parameters:
M A matrix.
Returns:
A list containing the number of rows and columns.
Since:
v2.0
To give a short introduction look at
    ?M = Matrix( [ [1,2,3,4,5], [9,8,7,6,5] ] );
    ?Rows = Size(M)(1);
    ?Cols = Size(M)(2);

The result will be

    Rows = 2
    Cols = 5
Size applied to a scalar val is equivalent to $( \mathtt{val}\; != 0)$ .

list SVD tensor  T  ) 
 

Evaluates the singular value decomposition (SVD) of a submatrix of a tensor.

Parameters:
T A 2-valence tensor, or a tensor with two counting indices.
Returns:
A list of three matrices $(U,D,V)$ , where $M = UDV^T$ and $UU^T = VV^T = I$ .
Since:
v2.2
This function performs a singular value decomposition of a matrix. The diagonal values are given in ascending order and the $U$ and $V$ matrices are ordered accordingly.

list SVD matrix  M  ) 
 

Evaluates a singular value decomposition (SVD) of a matrix.

Parameters:
M The matrix.
Returns:
A list of three matrices $(U,D,V)$ , where $M = UDV^T$ and $UU^T = VV^T = I$ .
Since:
v1.0
This function performs a singular value decomposition of a matrix. The diagonal values are given in ascending order and the $U$ and $V$ matrices are ordered accordingly. For example,

// Define a matrix
?M = Matrix( ((1,2), (3,4)) );

// Evaluate its singular value decomposition
L = SVD(M);

// Extract the three matrices from the list L
?U = L[1];
?D = L[2];
?V = L[3];

// Check that M can be reconstructed
?U*D*~V;

// Check the inverse of M
?M * (V*!D*~U);

produces the output

M = (| 1 2|, | 3 4|)
U = (| 0.914514 0.404554|, | -0.404554 0.914514|)
D = (| 0.365966 0|, | 0 5.464986|)
V = (| -0.817416 0.576048|, | 0.576048 0.817416|)
Constant = (| 1 2|, | 3 4|)
Constant = (| 1 0|, | 0 1|)

matrix Sym2Col tensor  T  ) 
 

Transforms the upper triangular part including the diagonal of a symmetric matrix into a column vector.

Parameters:
T A symmetric tensor.
Returns:
A single column matrix.
The parameter T can be either a 2-valence tensor or, if T is a tensor with a higher valence, two different counting indices have to be given. Here is an example.

    ?T = Tensor(3, [2,3,3]);
    ?V = Sym2Col(T(1,-1,-2));

Output:

T (2x3x3)=
000
000
000

000
000
000

V (6x1)=
0
0
0
0
0
0

matrix Sym2Col matrix  M  ) 
 

Transforms the upper triangular part including the diagonal of a symmetric matrix into a column vector.

Parameters:
M A symmetric matrix.
Returns:
A single column matrix.
Here is an example.

    ?M = Matrix([[1,2,3],[2,4,5],[3,5,6]]);
    ?V = Sym2Col(M);

Output:

M (3x3)=
123
245
356

V (6x1)=
1
2.83
4.24
4
7.07
6

Note that the off-diagonal elements are multiplied with the square root of 2, such that the scalar product of the matrix M with some other symmetric matrix is equal to the scalar product of the vector V with another vector generated in this way.