.Modelica_LinearSystems2.Math.Matrices.solve2

Information

Syntax

Matrices.solve2(A,b);

Description

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

A*X = B

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[3,2] = [10, 20;
                 22, 44;
                 12, 24];
  Real X[3,2];
algorithm
  (LU, pivots) := Matrices.LU(A);
  X := Matrices.solve2(A, B1);  /* X = [3, 6;
                                        2, 4;
                                        1, 2] */

See also

Matrices.LU, Matrices.LU_solve2

Interface

function solve2
  extends Modelica.Icons.Function;
  input Real A[:, size(A, 1)] "Matrix A of A*X = B";
  input Real B[size(A, 1), :] "Matrix B of A*X = B";
  output Real X[size(B, 1), size(B, 2)] "Matrix X such that A*X = B";
end solve2;

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