Skip to content

Commit

Permalink
tensors: Simplify some code in function Matrix_Solve
Browse files Browse the repository at this point in the history
  • Loading branch information
onox committed May 26, 2024
1 parent 3803b98 commit 173b277
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions orka_numerics/src/orka-numerics-tensors-operations.adb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ package body Orka.Numerics.Tensors.Operations is
end Find_Largest_Pivot;

Pivots : array (0 .. Rows) of Natural := [others => 0];
Row_Last_Pivot : Natural := 0;
begin
-- Forward phase: row reduce augmented matrix to echelon form

Expand All @@ -253,6 +254,7 @@ package body Orka.Numerics.Tensors.Operations is
Pivot_Index := 0;
exit;
end if;
Row_Last_Pivot := Index;

Swap_Rows (Ab, Index, Row_Index);

Expand All @@ -265,17 +267,8 @@ package body Orka.Numerics.Tensors.Operations is

-- Backward phase: row reduce augmented matrix to reduced echelon form

for Index in reverse 1 .. Rows loop
declare
Pivot_Index : Index_Type renames Pivots (Index);
begin
if Pivot_Index > 0 then
Back_Substitute (Ab, Index, Pivot_Index);
else
-- Row contains only zeros; no pivot
null;
end if;
end;
for Index in reverse 1 .. Row_Last_Pivot loop
Back_Substitute (Ab, Index, Pivots (Index));
end loop;

if (for some I in 1 .. Rows => Pivots (I) = 0
Expand Down

0 comments on commit 173b277

Please sign in to comment.