diff --git a/src/Gemstone.Numeric/Matrix/Matrix.cs b/src/Gemstone.Numeric/Matrix/Matrix.cs index 255a2ec18..0bd4f0768 100644 --- a/src/Gemstone.Numeric/Matrix/Matrix.cs +++ b/src/Gemstone.Numeric/Matrix/Matrix.cs @@ -662,7 +662,7 @@ private Matrix CombinedLUPDecomposition(out int[] Permutation) if (NRows != NColumns) throw new Exception("Attempt to decompose a non-square m"); - Matrix result = new(this); + Matrix result = (Matrix)this.Clone(); Permutation = Enumerable.Range(0, NRows).ToArray(); @@ -683,12 +683,8 @@ private Matrix 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)