1 import cern.colt.matrix.tfloat.FloatMatrix2D;
2 import cern.colt.matrix.tfloat.algo.SparseFloatAlgebra;
3 import cern.colt.matrix.tfloat.impl.SparseFloatMatrix2D;
4
5
6
7
8
9
10
11
12
13
14 public class SparseMatrixProblem
15 {
16
17
18
19
20
21 public static void main(final String[] args)
22 {
23 float[][] values = { {1, 2, 3}, {3, 5, 7}, {5, 10, 0}};
24 Float determinant = null;
25
26 FloatMatrix2D floatMatrix2D = new SparseFloatMatrix2D(values.length, values[0].length);
27 for (int row = 0; row < values.length; row++)
28 {
29 for (int column = 0; column < values[row].length; column++)
30 {
31 floatMatrix2D.set(row, column, values[row][column]);
32 }
33 }
34 System.out.println("matrix: " + floatMatrix2D.toString());
35 System.out.println("calling SparseFloatAlgebra().det(this.matrixSI)");
36 try
37 {
38 determinant = new SparseFloatAlgebra().det(floatMatrix2D);
39 }
40 catch (IllegalArgumentException exception)
41 {
42 exception.printStackTrace();
43 }
44 System.out.println("determinant is " + determinant + " (should be 15.0)");
45 }
46 }