functionsolve2r

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

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

Information

Syntax

X = Matrices.solve2r(A,B);
X = Matrices.solve2r(A, B, transA=false, isTriangular=false);

Description

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

X*op(A) = B

with

op(A) = transpose((A)) if transA==true
op(A) = (A) if transA==false

If matrix (A) is already lower triangular, the factorization is avoided if input "isTriangular" is set true. If a unique solution X does not exist (since A is singular), an exception is raised.

Note

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

Example

  Real A[3,3] = [1,2,3;
                 3,4,5;
                 2,1,4];

  Real B[2,3]  = [10, 22, 12;
                  20, 44, 24];
  Real X[2,3];
algorithm
  X := Matrices.solve2r(A, B);  /* X = [-34.0, 17.2, 2.4;
                                        -68.0, 34.4, 4.8] */

See also

Modelica.Math.Matrices.LU, Modelica.Math.Matrices.LU_solve2

Inputs

TypeNameDefaultDescription
Real[:,size(A, 1)]AMatrix A of X*op(A) = B
Real[:,size(A, 1)]BMatrix B of X*op(A) = B
BooleantransAfalseTrue if op(A)=A', false if op(A)=A
BooleanisTriangularfalseTrue if the A is already lower triangular

Outputs

TypeNameDefaultDescription
Real[size(B, 1),size(B, 2)]XBMatrix X such that X*op(A) = B
Integerinfo