First develop commit. Adding all existing files.
This commit is contained in:
37
test/math/MatrixTest.java
Normal file
37
test/math/MatrixTest.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package math;
|
||||
|
||||
import math.matrix.Matrix;
|
||||
import exception.IllegalDimensionException;
|
||||
|
||||
public class MatrixTest {
|
||||
public static void main(String[] args) throws IllegalDimensionException {
|
||||
Matrix A = new Matrix(new double[][] { { 0, 1, 1 },
|
||||
{ 2, 4, -2 },
|
||||
{ 0, 3, 15 } });
|
||||
|
||||
Matrix b = new Matrix(new double[][] { { 4 },
|
||||
{ 2 },
|
||||
{ 36 } });
|
||||
Matrix x = A.solve(b);
|
||||
Matrix residual = A.times(x).minus(b);
|
||||
double rnorm = residual.normInf();
|
||||
|
||||
System.out.println("A");
|
||||
A.print(9, 6); // printf("%9.6f");
|
||||
|
||||
System.out.println("b");
|
||||
b.print(9, 6);
|
||||
|
||||
System.out.println("x");
|
||||
x.print(9, 6);
|
||||
System.out.println(x);
|
||||
|
||||
System.out.println("residual");
|
||||
residual.print(9, 6);
|
||||
|
||||
System.out.println("rnorm");
|
||||
System.out.println(rnorm);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user