I'm unable to eigendecompose some sparse 24x24 symmetric matrices. The following example demonstrates the problem using la4j 0.4.0 (the most current version).
import org.la4j.matrix.Matrices;
import org.la4j.matrix.Matrix;
public class Program {
public static void main(String[] args) {
Matrix matrix = Matrices.BASIC2D_FACTORY.createSquareMatrix(24);
matrix.set(0, 16, 6.488917882340233);
matrix.set(1, 14, 1.0500849109563222);
matrix.set(1, 18, 8.057338506021317);
matrix.set(2, 18, 5.600914629504165);
matrix.set(4, 22, 9.912502191842943);
matrix.set(5, 13, 10.983197714528727);
matrix.set(8, 13, 6.5109096798879476);
matrix.set(9, 16, 1.321253910633423);
matrix.set(10, 14, 7.175174747019432);
matrix.set(10, 17, 3.0219813644087403);
matrix.set(11, 18, 3.5278266874188975);
matrix.set(12, 13, 7.425806151241948);
matrix.set(12, 15, 3.7347574055072483);
matrix.set(13, 5, 10.983197714528727);
matrix.set(13, 8, 6.5109096798879476);
matrix.set(13, 12, 7.425806151241948);
matrix.set(14, 1, 1.0500849109563222);
matrix.set(14, 10, 7.175174747019432);
matrix.set(15, 12, 3.7347574055072483);
matrix.set(15, 22, 3.1315457717146056);
matrix.set(16, 0, 6.488917882340233);
matrix.set(16, 9, 1.321253910633423);
matrix.set(17, 10, 3.0219813644087403);
matrix.set(17, 18, 8.059047125400168);
matrix.set(18, 1, 8.057338506021317);
matrix.set(18, 2, 5.600914629504165);
matrix.set(18, 11, 3.5278266874188975);
matrix.set(18, 17, 8.059047125400168);
matrix.set(22, 4, 9.912502191842943);
matrix.set(22, 15, 3.1315457717146056);
System.out.println(matrix);
// The following line does not complete successfully.
Matrix[] vd = matrix.decompose(Matrices.EIGEN_DECOMPOSITOR);
System.out.println(vd[0]);
System.out.println(vd[1]);
}
}
This matrix can be decomposed by Matlab fine. To see this, save the following as eigtestmat.tsv and execute the following Matlab code.
24 24 0
1 17 6.48891788234023
2 15 1.05008491095632
2 19 8.05733850602132
3 19 5.60091462950416
5 23 9.91250219184294
6 14 10.9831977145287
9 14 6.51090967988795
10 17 1.32125391063342
11 15 7.17517474701943
11 18 3.02198136440874
12 19 3.5278266874189
13 14 7.42580615124195
13 16 3.73475740550725
14 6 10.9831977145287
14 9 6.51090967988795
14 13 7.42580615124195
15 2 1.05008491095632
15 11 7.17517474701943
16 13 3.73475740550725
16 23 3.13154577171461
17 1 6.48891788234023
17 10 1.32125391063342
18 11 3.02198136440874
18 19 8.05904712540017
19 2 8.05733850602132
19 3 5.60091462950416
19 12 3.5278266874189
19 18 8.05904712540017
23 5 9.91250219184294
23 16 3.13154577171461
load eigtestmat.tsv
X=spconvert(eigtestmat)
[V,D]=eigs(X)
It's not just this matrix; I've tried another, of similar structure, which exhibits the same problem.