Back to the table of contents

Matrix functions

9.1 Calculation of the transposed matrix

To compute the transpose of the matrix A must run transpose(A) or A^T.

No result yet

9.2 Getting the dimensions of a matrix and a vector

You can get the number of rows, the number of columns, or both dimensions of a matrix. To do this, you need to execute one of the commands rowNumb(A), colNumb(A), or size(A). The same commands can be used for both a vector row and a vector column.

No result yet

9.3 The calculation of adjoint and inverse matrices

The calculation of inverse matrix

To calculate the inverse matrix for the matrix A, to execute inverse(A) or A^(1).

No result yet

No result yet

Calculation of adjoint matrix

To calculate the adjoint matrix for a given matrix A execute adjoint(A) or A^star.

No result yet

No result yet

9.4 Calculation of the matrix determinant and rank

To calculate the rank of a matrix A, you must run rank(A), to calculate its determinant, you must run det(A).

No result yet

No result yet

No result yet

No result yet

9.5 Calculation of the conjugate matrix

To calculate the conjugate matrix, you must run conjugate(A) or A^ast.

No result yet

9.6 Computing SVD-decomposition

To calculate the SVD-decomposition of a matrix, you must execute the command SVD(A). As a result, three matrices [U,D,V] will be calculated. The matrices U,V are unitary, the matrix D is diagonal: A=UDV.

\begin {verbatim} SPACE = R64[]; A = [[2,3,4], [1,3,3], [2,4,3]]; B = \SVD(A); \print(B); \end{verbatim}

9.7 Calculation of the generalized inverse matrix

To compute the generalized inverse Moore-Penrose matrix must run genInverse(A) or A^+.

No result yet

9.8 Computation of the kernel and echelon form

Computation of the echelon form

To compute the echelon form of the matrix A, you should run toEchelonForm(A).

No result yet

No result yet

Computation of the kernel

To calculate the kernel of matrix A, you should run kernel(A).

No result yet

No result yet

9.9 Calculating the characteristic polynomial of matrix

To calculate the characteristic polynomial of the matrix A with entries in R[x1,,xm], you should give the ring R[x1,,xm]R[t] or R[t,x1,,xm] with some new variable t and run charPolynom(A).

No result yet

No result yet

9.10 Calculating LSU-decomposition of the matrix

To calculate the LSU-decomposition of the matrix A, you must run LSU(A).

The result is a vector of three matrices [L,D,U]. Where L is a lower triangular matrix, U — upper triangular matrix, D — permutation matrix, multiplied by the inverse of the diagonal matrix. If the elements of the matrix A are elements of commutative domain R, then elements of matrices L, D1, U are elements of the same domain R.

No result yet

No result yet

No result yet

\section {Choletsky Decomposition}

This decomposition is done with a command where the argument is the original matrix: cholesky} {(A) or cholesky(A, 0). In this case, the matrix must be symmetric and positive definite, only in this case the expansion will be correctly calculated.

The result is two lower triangular matrices: [L,S], with A=lLT and SL=I.

For large dense matrices, starting from a size of 100x100, you can use a fast algorithm that uses multiplication of blocks by the Winograd-Strassen algorithm: cholesky(A, 1).

No result yet

9.11 LSUWMdet decomposition

To calculate the LSU-decomposition of the matrix A together with decomposition of the pseudo inverse matrix A×=(1/det2)WSM, you must run LSUWMdet(A).

The result is a vector of five matrices and determinant of the largest non-degenerate corner block [L,D,U,W,M,det]. Here L and U ~ are the lower and upper triangular matrices, S ~ — truncated weighted permutation matrix, DM and WD ~ — lower and upper triangular matrices. Moreover, A=LSU and A×=(1/det2)WSM. If the elements of the matrix A are taken from the commutative domain, then all matrices, except for S, also belong to this domain.

No result yet

9.12 Calculating Bruhat decomposition of the matrix

To calculate the Bruhat decomposition of the matrix A, you must run BruhatDecomposition(A).

The result is a vector of three matrices [V,D,U]. Where V and U — upper triangular matrices, D — permutation matrix, multiplied by the inverse of the diagonal matrix. If the elements of the matrix A are elements of commutative domain R, then elements of matrices V, D1, U are elements of the same domain R.

No result yet

No result yet

\

Other functions:

\

LSUWMdet — Result is a vector of 6 matrices [L,S,U,W,M,[[det]]]. A = LSU, pseudoInverse(A) = (1/det2)WSM, det is a nonzero maximum in size angular minor.

pseudoInverse} { — Pseudo inverse of a matrix. It, unlike the Moore-Penrose matrix, satisfies only two of the four identities. However, it is faster to compute;

SVD} { — SVD decomposition of a matrix over real numbers. The result is a vector of three matrices [U,D,VT]. Here U,VT — are orthogonal matrices, D is a diagonal matrix.

QR} { — QR decomposition of a matrix over real numbers. The result is a vector of two matrices [Q,R]. Here Q — is an orthogonal matrix, R — is an upper triangular matrix.

sylvesterp1, p2, kind=0 or 1 — the Sylvester matrix is constructed from the coefficients of the polynomials p1,p2. The ring Z [x, y, z, u] will be considered as a ring Z[u][x, y, z] (ring in one variable u with coefficients from Z[x, y, z].) If kind = 0, then the size of the matrix is (n1 + n2), if kind = 1, then the size of the matrix is 2*max(n1, n2).

9.13 Linear programming

Let there be given the objective function nj=1cjxj and conditions nj=1aijxjbi, here i=1,2,,m,

xj0, here j=1,2,,n.

We define m×n-matrix A=(aij), m-dimensional vector b=(bi), n-dimensional vector c=(cj) and n-dimensional vector x=(xj).

Then the objective function can be written as cTx, and and conditions can be written as Axb,

x0.

For solving linear programming problems, you can use one of the following two commands SimplexMax or SimplexMin. The result is a vector.

Depending on the type of problem you have the following options.

1. To solve the problem cTxmax

under conditions Axb,
x0,
we use the SimplexMax(A, b, c).

If the objective function needs to be minimized, , i.e. cTxmin,

then we use the SimplexMin(A, b, c).

Example.

We need to maximize the 3x1+x2+2x3

under the conditions x1+x2+3x330,2x1+2x2+5x324,4x1+x2+2x336,x1,x2,x30.

No result yet

2. To solve the problem cTxmax

under the conditions A1xb1,
A2x=b2,
x0,
we use the SimplexMax(A_1,A_2, b_1, b_2, c).

If the objective function needs to be minimized, i.e. cTxmin,

then we use the SimplexMin(A_1,A_2, b_1, b_2, c).

Example.

We need to maximize the 7x1+x34x4

under the conditions x1x2+2x3x46,2x1+x2x3=1,x1,x2,x3,x40.

No result yet

3. To solve the problem cTxmax

under the conditions A1xb1,
A2x=b2,
A3xb3,
we use the SimplexMax(A_1,A_2, A_3,b_1, b_2, b_3,c).

If the objective function needs to be minimized, i.e. cTxmin,

then we use the SimplexMin(A_1,A_2, A_3,b_1, b_2, b_3, c).

Example.

7x1+x34x4

We need to maximize the x1+x2
under the conditions 4x1x28,2x1+x210,5x1+2x22,x1,x20.

No result yet

4. To solve the problem cTxmax

in mixed conditions desired by the matrix A and vector b, you can use the command SimplexMax(A,signs,b,c), where an array of integers signs determines the signs of comparison:

-1 means "less than or equal to",

0 means "equal to",

1 means "greater than or equal to".

The array signs must contain the same number of elements as the vector b. If the objective function needs to be minimized, i.e. cTxmin,

then we use the SimplexMin(A,signs,b,c).

Example.

We need to minimize the 2x14x22x3

under the conditions

2x1+x2+x34,x1+x2+3x36,x13x2+x32,x1,x2,x30.

In:

No result yet

Back to the table of contents