.Modelica_LinearSystems2.Math.Matrices.solve2r

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

Matrices.LU, Matrices.LU_solve2

Interface

function solve2r
  extends Modelica.Icons.Function;
  import Modelica;
  import Modelica_LinearSystems2;
  import Modelica_LinearSystems2.Math.Matrices.LAPACK;
  input Real A[:, size(A, 1)] "Matrix A of X*op(A) = B";
  input Real B[:, size(A, 1)] "Matrix B of X*op(A) = B";
  input Boolean transA = false "True if op(A)=A', false if op(A)=A";
  input Boolean isTriangular = false "True if the A is already lower triangular";
  output Real X[size(B, 1), size(B, 2)] = B "Matrix X such that X*op(A) = B";
  output Integer info;
end solve2r;

Generated at 2024-04-28T18:16:21Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos