Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/Gemstone.Numeric/Matrix/Matrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ private Matrix<T> CombinedLUPDecomposition(out int[] Permutation)
if (NRows != NColumns)
throw new Exception("Attempt to decompose a non-square m");

Matrix<T> result = new(this);
Matrix<T> result = (Matrix<T>)this.Clone();

Permutation = Enumerable.Range(0, NRows).ToArray();

Expand All @@ -683,12 +683,8 @@ private Matrix<T> CombinedLUPDecomposition(out int[] Permutation)

if (pRow != j) // if largest value not on pivot, swap rows
{
T[] row = result[pRow];
result[j] = result[j].Select((v, i) => (i <= j ? v : row[i])).ToArray();

int tmp = Permutation[pRow]; // and swap perm info
Permutation[pRow] = Permutation[j];
Permutation[j] = tmp;
(result[pRow], result[j]) = (result[j], result[pRow]);
(Permutation[pRow], Permutation[j]) = (Permutation[j], Permutation[pRow]);
}

// if (result[j][j] == 0.0)
Expand Down
Loading