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
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[:,size(A, 1)] | A | Matrix A of X*op(A) = B | |
| Real[:,size(A, 1)] | B | Matrix B of X*op(A) = B | |
| Boolean | transA | false | True if op(A)=A', false if op(A)=A |
| Boolean | isTriangular | false | True if the A is already lower triangular |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[size(B, 1),size(B, 2)] | X | B | Matrix X such that X*op(A) = B |
| Integer | info |