CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

function

Tests.Assertions.spdResidual

Maximum residual of a successful SPD solve

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
inputAReal[:, size(A, 1)]
inputBReal[size(A, 1), :]
outputresidualReal

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

function spdResidual "Maximum residual of a successful SPD solve"
  input Real A[:, size(A, 1)];
  input Real B[size(A, 1), :];
  output Real residual;
protected
  Real X[size(B, 1), size(B, 2)];
  Boolean ok;
algorithm
  (X, ok) := LinearAlgebra.solveSPD(A, B);
  assert(ok, "solveSPD rejected a positive-definite test matrix");
  residual := Tests.Assertions.maxAbsMatrix(A * X - B);
end spdResidual;