Skip to content

Commit 3acae12

Browse files
committed
Pull Request changes
1 parent c90a5ae commit 3acae12

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/main/java/com/thealgorithms/matrix/SolveSystem.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ public static double[] solveSystem(double[][] matrix, double[] constants) {
4242
double tempConst = constants[k];
4343
constants[k] = constants[maxIdx];
4444
constants[maxIdx] = tempConst;
45-
4645
for (int i = k + 1; i < matrix.length; i++) {
4746
// compute multipliers and save them in the column
48-
4947
matrix[i][k] /= matrix[k][k];
5048
for (int j = k + 1; j < matrix.length; j++) {
5149
matrix[i][j] -= matrix[i][k] * matrix[k][j];
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
package com.thealgorithms.matrix;
22

3+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
4+
5+
import java.util.stream.Stream;
36
import org.junit.jupiter.params.ParameterizedTest;
47
import org.junit.jupiter.params.provider.Arguments;
58
import org.junit.jupiter.params.provider.MethodSource;
69

7-
import java.util.stream.Stream;
8-
9-
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
10-
1110
class SolveSystemTest {
1211

1312
@ParameterizedTest
1413
@MethodSource({"matrixGenerator"})
1514
void solveSystem(double[][] matrix, double[] constants, double[] solution) {
16-
1715
double[] expected = SolveSystem.solveSystem(matrix, constants);
1816
assertArrayEquals(expected, solution, 1.0E-10, "Solution does not match expected");
1917
}
20-
2118
private static Stream<Arguments> matrixGenerator() {
22-
2319
return Stream.of(Arguments.of(new double[][] {{-5, 8, -4}, {0, 6, 3}, {0, 0, -4}}, new double[] {38, -9, 20}, new double[] {-2, 1, -5}), Arguments.of(new double[][] {{-2, -1, -1}, {3, 4, 1}, {3, 6, 5}}, new double[] {-11, 19, 43}, new double[] {2, 2, 5}));
2420
}
2521
}

0 commit comments

Comments
 (0)