.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

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

Interface

function solve2r
  extends Modelica.Icons.Function;
  import Modelica.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-11-23T19:25:52Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos