WOLFRAM SYSTEM MODELER

solve2

Solve real system of linear equations A*X=B with a B matrix (Gaussian elimination with partial pivoting)

Wolfram Language

In[1]:=
SystemModel["Modelica.Math.Matrices.solve2"]
Out[1]:=

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Syntax

Matrices.solve2(A,b);

Description

This function call returns the solution X of the linear system of equations

A*X = B

If a unique solution X does not exist (since A is singular), an assertion is triggered. If this is not desired, use instead Matrices.leastSquares2 and inquire the singularity of the solution with the return argument rank (a unique solution is computed if rank = size(A,1)).

Note, the solution is computed with the LAPACK function "dgesv", i.e., by Gaussian elimination with partial pivoting.

Example

  Real A[3,3] = [1,2,3;
                 3,4,5;
                 2,1,4];
  Real B[3,2] = [10, 20;
                 22, 44;
                 12, 24];
  Real X[3,2];
algorithm
  X := Matrices.solve2(A, B);  /* X = [3, 6;
                                       2, 4;
                                       1, 2] */

See also

Matrices.LU, Matrices.LU_solve2, Matrices.leastSquares2.

Syntax

X = solve2(A, B)

Inputs (2)

A

Type: Real[:,size(A, 1)]

Description: Matrix A of A*X = B

B

Type: Real[size(A, 1),:]

Description: Matrix B of A*X = B

Outputs (1)

X

Type: Real[size(B, 1),size(B, 2)]

Description: Matrix X such that A*X = B