Skip to content

Commit 4242e87

Browse files
committed
More formatting
1 parent 3215c69 commit 4242e87

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static double[] solveSystem(double[][] matrix, double[] constants) {
3131
maxIdx = j;
3232
}
3333
}
34-
if (Math.abs(maxVal) < tol){
34+
if (Math.abs(maxVal) < tol) {
3535
// hope the matrix works out
3636
continue;
3737
}
@@ -56,14 +56,13 @@ public static double[] solveSystem(double[][] matrix, double[] constants) {
5656
System.arraycopy(constants, 0, x, 0, constants.length);
5757
for (int i = matrix.length - 1; i >= 0; i--) {
5858
double sum = 0;
59-
for (int j = i + 1; j < matrix.length; j++){
59+
for (int j = i + 1; j < matrix.length; j++) {
6060
sum += matrix[i][j] * x[j];
6161
}
6262
x[i] = constants[i] - sum;
63-
if (Math.abs(matrix[i][i]) > tol){
63+
if (Math.abs(matrix[i][i]) > tol) {
6464
x[i] /= matrix[i][i];
65-
}
66-
else{
65+
} else {
6766
throw new IllegalArgumentException("Matrix was found to be singular");
6867
}
6968
}

0 commit comments

Comments
 (0)