## Modelica_LinearSystems2.WorkInProgress.Math.Matrices

### Package Content

Name | Description
--- | ---
C_nullspace | Orthonormal nullspace of a complex matrix
C_QR | QR decomposition of a rectangular complex matrix without column pivoting (A = Q*R)
C_QR2 | QR decomposition of a rectangular complex matrix without column pivoting (A = Q*R)
C_rank | Rank of a complex matrix (computed with singular values)
C_singularValues | Compute singular values and left and right singular vectors of a complex matrix
C_solve2 | computes the solution to a complex system of linear equations A*X=B, using LU decomposition with partial pivoting and row interchanges
C_RQ | RQ decomposition of a rectangular complex matrix without column pivoting (A = R*Q)

## Modelica_LinearSystems2.WorkInProgress.Math.Matrices.C_nullspace

Orthonormal nullspace of a complex matrix

### Information

#### Syntax

>     Z = Matrices.nullspace(A);

>     (Z, nullity) = Matrices.nullspace(A);

#### Description

This function calculates a orthonormal basis Z=[z_1, z_2, ...] of the nullspace of a matrix A, i.e. A*z_i=0.

The nullspace is obtained by svd method. That is, matrix A is dcomposed into the matrices S, U, V:

>             H
>      A = USV

with the orthonormal matrices U and V and the matrix S with

>      S = [S1, 0]
>      S1 = [diag(s); 0]

with the singular values s={s1, s2, ..., sr} of A and r=rank(A). Note, that S has the same size as A. Since, U and V are orthonormal, we may write

>       H
>      U*A*V = [S1, 0].

Matrix S1 obviously has full column rank and therefore, the left n-r rows (n is the number of columns of A or S) of matrix V span a nullspace of A.

The nullity of matrix A is the dimension of the nullspace of A. In view of the above, it becomes clear that nullity holds

>      nullity = n - r

with

>      n = number of columns of matrix A
>      r = rank(A)

#### Example

>       A = [1, 2,  3, 1;
>            3, 4,  5, 2;
>           -1, 2, -3, 3];
>       (Z, nullity) = nullspace(A);

>       results in:

>       Z=[0.1715;
>         -0.686;
>          0.1715;
>          0.686]

>       nullity = 1

#### See also

Matrices.singularValues

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Name | Description
--- | ---
A[:, :] | input matrix

### Outputs

Name | Description
--- | ---
Z[size(A, 2), :] | orthonormal nullspace of matrix A
nullity | nullity, i.e. the dimension of the nullspace

## Modelica_LinearSystems2.WorkInProgress.Math.Matrices.C_QR

QR decomposition of a rectangular complex matrix without column pivoting (A = Q*R)

### Inputs

Name | Description
--- | ---
A[:, :] | Rectangular matrix with size(A,1) >= size(A,2)

### Outputs

Name | Description
--- | ---
Q[size(A, 1), size(A, 2)] | Rectangular matrix with orthonormal columns such that Q*R=A[:,p]
R[min(size(A, 1), size(A, 2)), size(A, 2)] | Square upper triangular matrix

## Modelica_LinearSystems2.WorkInProgress.Math.Matrices.C_QR2

QR decomposition of a rectangular complex matrix without column pivoting (A = Q*R)

### Inputs

Name | Description
--- | ---
A[:, :] | Rectangular matrix with size(A,1) >= size(A,2)

### Outputs

Name | Description
--- | ---
Q[size(A, 1), size(A, 1)] | Rectangular matrix with orthonormal columns such that Q*R=A[:,p]
R[size(A, 1), size(A, 2)] | Square upper triangular matrix

## Modelica_LinearSystems2.WorkInProgress.Math.Matrices.C_rank

Rank of a complex matrix (computed with singular values)

### Information

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Name | Description
--- | ---
A[:, :] | Matrix
eps | If eps > 0, the singular values are checked against eps; otherwise eps=max(size(A))*norm(A)*Modelica.Constants.eps is used

### Outputs

Name | Description
--- | ---
result | Rank of matrix A

## Modelica_LinearSystems2.WorkInProgress.Math.Matrices.C_singularValues

Compute singular values and left and right singular vectors of a complex matrix

### Inputs

Name | Description
--- | ---
A[:, :] | Square or rectangular matrix

### Outputs

Name | Description
--- | ---
sigma[min(size(A, 1), size(A, 2))] | singular values
U[size(A, 1), size(A, 1)] | Left orthogonal matrix
VT[size(A, 2), size(A, 2)] | Transposed right orthogonal matrix

## Modelica_LinearSystems2.WorkInProgress.Math.Matrices.C_solve2

computes the solution to a complex system of linear equations A*X=B, using LU decomposition with partial pivoting and row interchanges

### Inputs

Name | Description
--- | ---
A[:, size(A, 1)] |
B[size(A, 1), :] |

### Outputs

Name | Description
--- | ---
X[size(A, 1), size(B, 2)] |

## Modelica_LinearSystems2.WorkInProgress.Math.Matrices.C_RQ

RQ decomposition of a rectangular complex matrix without column pivoting (A = R*Q)

### Inputs

Name | Description
--- | ---
A[:, :] | Rectangular matrix with size(A,1) >= size(A,2)

### Outputs

Name | Description
--- | ---
R[size(A, 1), size(A, 1)] | Rectangular matrix with orthonormal columns such that Q*R=A[:,p]
Q[size(A, 1), size(A, 2)] | Square upper triangular matrix