From 9e81359999f98c99f297375a17cc35403f957d5f Mon Sep 17 00:00:00 2001 From: HOS Date: Mon, 26 Oct 2026 13:58:18 +0100 Subject: [PATCH 1/2] Update determinant with better recommendations, and follow them. Closes #4687 --- .../Electrical/Polyphase/Basic/MutualInductor.mo | 2 +- .../QuasiStatic/Polyphase/Basic/MutualInductor.mo | 2 +- Modelica/Math/package.mo | 13 ++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Modelica/Electrical/Polyphase/Basic/MutualInductor.mo b/Modelica/Electrical/Polyphase/Basic/MutualInductor.mo index b4a4ecb65d..c2b1c6a239 100644 --- a/Modelica/Electrical/Polyphase/Basic/MutualInductor.mo +++ b/Modelica/Electrical/Polyphase/Basic/MutualInductor.mo @@ -4,7 +4,7 @@ model MutualInductor "Linear mutual inductor" parameter Real epsilon=1e-9 "Relative accuracy tolerance of matrix symmetry"; parameter SI.Inductance L[m, m] "Mutual inductance matrix"; initial equation - if abs(Modelica.Math.Matrices.det(L)) < epsilon then + if Modelica.Math.Matrices.rcond(L) < epsilon then Modelica.Utilities.Streams.print("Warning: mutual inductance matrix singular!"); end if; equation diff --git a/Modelica/Electrical/QuasiStatic/Polyphase/Basic/MutualInductor.mo b/Modelica/Electrical/QuasiStatic/Polyphase/Basic/MutualInductor.mo index 60f5aa27b8..47cd240a51 100644 --- a/Modelica/Electrical/QuasiStatic/Polyphase/Basic/MutualInductor.mo +++ b/Modelica/Electrical/QuasiStatic/Polyphase/Basic/MutualInductor.mo @@ -5,7 +5,7 @@ model MutualInductor "Linear mutual inductor" parameter Real epsilon=1e-9 "Relative accuracy tolerance of matrix symmetry"; parameter SI.Inductance L[m, m] "Mutual inductance matrix"; initial equation - if abs(Modelica.Math.Matrices.det(L)) < epsilon then + if Modelica.Math.Matrices.rcond(L) < epsilon then Modelica.Utilities.Streams.print("Warning: mutual inductance matrix singular!"); end if; equation diff --git a/Modelica/Math/package.mo b/Modelica/Math/package.mo index 6a875a6082..8943ff27a6 100644 --- a/Modelica/Math/package.mo +++ b/Modelica/Math/package.mo @@ -2579,18 +2579,17 @@ result = Matrices.det(A); This function returns the determinant \"result\" of matrix A computed by a LU decomposition with row pivoting. For details about determinants, see http://en.wikipedia.org/wiki/Determinant. -Usually, this function should never be used, because +Usually, this function should not be used, because there are nearly always better numerical algorithms -as by computing the determinant. Examples: +than computing the determinant. Examples:

See also

From 4d24b7e0f0f55cf19c65e0ee12cdb26f3d1c4c37 Mon Sep 17 00:00:00 2001 From: HOS Date: Mon, 26 Oct 2026 14:03:49 +0100 Subject: [PATCH 2/2] FixSyntax --- Modelica/Math/package.mo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modelica/Math/package.mo b/Modelica/Math/package.mo index 8943ff27a6..8794110767 100644 --- a/Modelica/Math/package.mo +++ b/Modelica/Math/package.mo @@ -2588,7 +2588,7 @@ than computing the determinant. Examples:
  • Use Matrices.solve to solve the linear equation A*x = b.
  • -
  • Use (A)>=epsilon +
  • Use Matrices.rcond(A)>=epsilon to check that the system is well-conditioned and not singular.