===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 2006-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -337,10 +337,11 @@
Result_Matrix => Real_Matrix,
Operation => "abs");
- function Solve is
- new Matrix_Vector_Solution (Real'Base, Real_Vector, Real_Matrix);
+ function Solve is new
+ Matrix_Vector_Solution (Real'Base, 0.0, Real_Vector, Real_Matrix);
- function Solve is new Matrix_Matrix_Solution (Real'Base, Real_Matrix);
+ function Solve is new
+ Matrix_Matrix_Solution (Real'Base, 0.0, Real_Matrix);
function Unit_Matrix is new
Generic_Array_Operations.Unit_Matrix
===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 2006-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -30,9 +30,7 @@
------------------------------------------------------------------------------
with Ada.Numerics; use Ada.Numerics;
-
package body System.Generic_Array_Operations is
-
function Check_Unit_Last
(Index : Integer;
Order : Positive;
@@ -696,6 +694,11 @@
end loop;
Forward_Eliminate (MA, MX, Det);
+
+ if Det = Zero then
+ raise Constraint_Error with "matrix is singular";
+ end if;
+
Back_Substitute (MA, MX);
for J in 0 .. R'Length - 1 loop
@@ -735,6 +738,11 @@
end loop;
Forward_Eliminate (MA, MB, Det);
+
+ if Det = Zero then
+ raise Constraint_Error with "matrix is singular";
+ end if;
+
Back_Substitute (MA, MB);
return MB;
===================================================================
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
+-- Copyright (C) 2006-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -396,6 +396,7 @@
generic
type Scalar is private;
+ Zero : Scalar;
type Vector is array (Integer range <>) of Scalar;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
with procedure Back_Substitute (M, N : in out Matrix) is <>;
@@ -411,6 +412,7 @@
generic
type Scalar is private;
+ Zero : Scalar;
type Matrix is array (Integer range <>, Integer range <>) of Scalar;
with procedure Back_Substitute (M, N : in out Matrix) is <>;
with procedure Forward_Eliminate
===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 2006-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -30,7 +30,6 @@
------------------------------------------------------------------------------
with System.Generic_Array_Operations; use System.Generic_Array_Operations;
-with Ada.Numerics; use Ada.Numerics;
package body Ada.Numerics.Generic_Complex_Arrays is
@@ -694,11 +693,11 @@
-- Solve --
-----------
- function Solve is
- new Matrix_Vector_Solution (Complex, Complex_Vector, Complex_Matrix);
+ function Solve is new Matrix_Vector_Solution
+ (Complex, (0.0, 0.0), Complex_Vector, Complex_Matrix);
- function Solve is
- new Matrix_Matrix_Solution (Complex, Complex_Matrix);
+ function Solve is new Matrix_Matrix_Solution
+ (Complex, (0.0, 0.0), Complex_Matrix);
-----------------
-- Unit_Matrix --