X = Matrices.solve2r(A,B); X = Matrices.solve2r(A, B, transA=false, isTriangular=false);
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.
The solution is computed with the LAPACK function "dgesv", i.e., by Gaussian elemination with partial pivoting.
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] */
Modelica.Math.Matrices.LU, Modelica.Math.Matrices.LU_solve2
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;