WOLFRAM SYSTEM MODELER

solve

Solve real system of linear equations A*x=b with a b vector (Gaussian elimination with partial pivoting)

Wolfram Language

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

Information

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

Syntax

Matrices.solve(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.leastSquares 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] = {10,22,12};
  Real x[3];
algorithm
  x := Matrices.solve(A,b);  // x = {3,2,1}

See also

Matrices.LU, Matrices.LU_solve, Matrices.leastSquares.

Syntax

x = solve(A, b)

Inputs (2)

A

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

Description: Matrix A of A*x = b

b

Type: Real[size(A, 1)]

Description: Vector b of A*x = b

Outputs (1)

x

Type: Real[size(b, 1)]

Description: Vector x such that A*x = b