Skip to content

Commit

Permalink
fix: Correct arraycopy source and destination in dropRow method (#…
Browse files Browse the repository at this point in the history
…130)

This change addresses an issue in the `Matrix` class where the `System.arraycopy` method was used incorrectly in the `dropRow` method. Specifically, the source and destination parameters in `System.arraycopy` were swapped, which led to improper handling of row removal from the matrix.

Signed-off-by: Ryuu Mitsuki <[email protected]>
  • Loading branch information
mitsuki31 committed Sep 13, 2024
2 parents c979b89 + f539c17 commit 654cb32
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/mitsuki/jmatrix/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ public static Matrix dropRow(Matrix m, int row) {
double[][] newEntries = new double[rows - 1][cols];
for (int i = 0, destRow = 0; i < rows; i++) {
if (i == row) continue; // Skip the desired row index
System.arraycopy(newEntries[destRow++], 0, entries[i], 0, cols);
System.arraycopy(entries[i], 0, newEntries[destRow++], 0, cols);
}

return new Matrix(newEntries);
Expand Down

0 comments on commit 654cb32

Please sign in to comment.