Skip to content

Commit 358ae02

Browse files
authored
Update ChebyshevIterationTest.java
1 parent 2bf2580 commit 358ae02

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/test/java/com/thealgorithms/maths/ChebyshevIterationTest.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,100 +5,100 @@
55

66
import org.junit.jupiter.api.Test;
77

8-
public class ChebyshevIterationTest {
8+
public class ChebyshevIterationTest {
99

1010
@Test
1111
public void testSolveSimple2x2Diagonal() {
12-
double[][] a = { { 2, 0 }, { 0, 1 } };
13-
double[] b = { 2, 2 };
14-
double[] x0 = { 0, 0 };
12+
double[][] a = {{2, 0}, {0, 1}};
13+
double[] b = {2, 2};
14+
double[] x0 = {0, 0};
1515
double minEig = 1.0;
1616
double maxEig = 2.0;
1717
int maxIter = 50;
1818
double tol = 1e-9;
19-
double[] expected = { 1.0, 2.0 };
19+
double[] expected = {1.0, 2.0};
2020

2121
double[] result = ChebyshevIteration.solve(a, b, x0, minEig, maxEig, maxIter, tol);
2222
assertArrayEquals(expected, result, 1e-9);
2323
}
2424

2525
@Test
2626
public void testSolve2x2Symmetric() {
27-
double[][] a = { { 4, 1 }, { 1, 3 } };
28-
double[] b = { 1, 2 };
29-
double[] x0 = { 0, 0 };
27+
double[][] a = {{4, 1}, {1, 3}};
28+
double[] b = {1, 2};
29+
double[] x0 = {0, 0};
3030
double minEig = (7.0 - Math.sqrt(5.0)) / 2.0;
3131
double maxEig = (7.0 + Math.sqrt(5.0)) / 2.0;
3232
int maxIter = 100;
3333
double tol = 1e-10;
34-
double[] expected = { 1.0 / 11.0, 7.0 / 11.0 };
34+
double[] expected = {1.0 / 11.0, 7.0 / 11.0};
3535

3636
double[] result = ChebyshevIteration.solve(a, b, x0, minEig, maxEig, maxIter, tol);
3737
assertArrayEquals(expected, result, 1e-9);
3838
}
3939

4040
@Test
4141
public void testAlreadyAtSolution() {
42-
double[][] a = { { 2, 0 }, { 0, 1 } };
43-
double[] b = { 2, 2 };
44-
double[] x0 = { 1, 2 };
42+
double[][] a = {{2, 0}, {0, 1}};
43+
double[] b = {2, 2};
44+
double[] x0 = {1, 2};
4545
double minEig = 1.0;
4646
double maxEig = 2.0;
4747
int maxIter = 10;
4848
double tol = 1e-5;
49-
double[] expected = { 1.0, 2.0 };
49+
double[] expected = {1.0, 2.0};
5050

5151
double[] result = ChebyshevIteration.solve(a, b, x0, minEig, maxEig, maxIter, tol);
5252
assertArrayEquals(expected, result, 0.0);
5353
}
5454

5555
@Test
5656
public void testMismatchedDimensionsAB() {
57-
double[][] a = { { 1, 0 }, { 0, 1 } };
58-
double[] b = { 1 };
59-
double[] x0 = { 0, 0 };
57+
double[][] a = {{1, 0}, {0, 1}};
58+
double[] b = {1};
59+
double[] x0 = {0, 0};
6060
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, 1, 2, 10, 1e-5));
6161
}
6262

6363
@Test
6464
public void testMismatchedDimensionsAX() {
65-
double[][] a = { { 1, 0 }, { 0, 1 } };
66-
double[] b = { 1, 1 };
67-
double[] x0 = { 0 };
65+
double[][] a = {{1, 0}, {0, 1}};
66+
double[] b = {1, 1};
67+
double[] x0 = {0};
6868
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, 1, 2, 10, 1e-5));
6969
}
7070

7171
@Test
7272
public void testNonSquareMatrix() {
73-
double[][] a = { { 1, 0, 0 }, { 0, 1, 0 } };
74-
double[] b = { 1, 1 };
75-
double[] x0 = { 0, 0 };
73+
double[][] a = {{1, 0, 0}, {0, 1, 0}};
74+
double[] b = {1, 1};
75+
double[] x0 = {0, 0};
7676
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, 1, 2, 10, 1e-5));
7777
}
7878

7979
@Test
8080
public void testInvalidEigenvalues() {
81-
double[][] a = { { 1, 0 }, { 0, 1 } };
82-
double[] b = { 1, 1 };
83-
double[] x0 = { 0, 0 };
81+
double[][] a = {{1, 0}, {0, 1}};
82+
double[] b = {1, 1};
83+
double[] x0 = {0, 0};
8484
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, 2, 1, 10, 1e-5));
8585
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, 1, 1, 10, 1e-5));
8686
}
8787

8888
@Test
8989
public void testNonPositiveDefinite() {
90-
double[][] a = { { 1, 0 }, { 0, 1 } };
91-
double[] b = { 1, 1 };
92-
double[] x0 = { 0, 0 };
90+
double[][] a = {{1, 0}, {0, 1}};
91+
double[] b = {1, 1};
92+
double[] x0 = {0, 0};
9393
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, 0, 1, 10, 1e-5));
9494
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, -1, 1, 10, 1e-5));
9595
}
9696

9797
@Test
9898
public void testInvalidIterationCount() {
99-
double[][] a = { { 1, 0 }, { 0, 1 } };
100-
double[] b = { 1, 1 };
101-
double[] x0 = { 0, 0 };
99+
double[][] a = {{1, 0}, {0, 1}};
100+
double[] b = {1, 1};
101+
double[] x0 = {0, 0};
102102
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, 1, 2, 0, 1e-5));
103103
assertThrows(IllegalArgumentException.class, () -> ChebyshevIteration.solve(a, b, x0, 1, 2, -1, 1e-5));
104104
}

0 commit comments

Comments
 (0)