1818 *
1919 * @author Mitrajit Ghorui(KeyKyrios)
2020 */
21- public final class Chebyshev {
21+ public final class ChebyshevIteration {
2222
23- private Chebyshev () {
23+ private ChebyshevIteration () {
2424 }
2525
2626 /**
@@ -84,7 +84,7 @@ public static double[] solve(
8484 double [] xUpdate = scalarMultiply (alpha , p );
8585 x = vectorAdd (x , xUpdate ); // x = x + alpha * p
8686
87- // Recompute residual for accuracy, though it can be updated iteratively
87+ // Recompute residual for accuracy
8888 r = vectorSubtract (b , matrixVectorMultiply (a , x ));
8989 alphaPrev = alpha ;
9090 }
@@ -132,9 +132,6 @@ private static void validateInputs(
132132 }
133133
134134 // --- Vector/Matrix Helper Methods ---
135- /**
136- * Computes the product of a matrix A and a vector v (Av).
137- */
138135 private static double [] matrixVectorMultiply (double [][] a , double [] v ) {
139136 int n = a .length ;
140137 double [] result = new double [n ];
@@ -148,50 +145,10 @@ private static double[] matrixVectorMultiply(double[][] a, double[] v) {
148145 return result ;
149146 }
150147
151- /**
152- * Computes the subtraction of two vectors (v1 - v2).
153- */
154148 private static double [] vectorSubtract (double [] v1 , double [] v2 ) {
155149 int n = v1 .length ;
156150 double [] result = new double [n ];
157151 for (int i = 0 ; i < n ; i ++) {
158152 result [i ] = v1 [i ] - v2 [i ];
159153 }
160154 return result ;
161- }
162-
163- /**
164- * Computes the addition of two vectors (v1 + v2).
165- */
166- private static double [] vectorAdd (double [] v1 , double [] v2 ) {
167- int n = v1 .length ;
168- double [] result = new double [n ];
169- for (int i = 0 ; i < n ; i ++) {
170- result [i ] = v1 [i ] + v2 [i ];
171- }
172- return result ;
173- }
174-
175- /**
176- * Computes the product of a scalar and a vector (s * v).
177- */
178- private static double [] scalarMultiply (double scalar , double [] v ) {
179- int n = v .length ;
180- double [] result = new double [n ];
181- for (int i = 0 ; i < n ; i ++) {
182- result [i ] = scalar * v [i ];
183- }
184- return result ;
185- }
186-
187- /**
188- * Computes the L2 norm (Euclidean norm) of a vector.
189- */
190- private static double vectorNorm (double [] v ) {
191- double sumOfSquares = 0 ;
192- for (double val : v ) {
193- sumOfSquares += val * val ;
194- }
195- return Math .sqrt (sumOfSquares );
196- }
197- }
0 commit comments