1
votes

I am trying to make a conversion from a non positive definite matrix into a positive definite one in order to be able to make a cholesky decomposition. Working with EJML, which I think is a good library, I have come into a trouble when trying to obtain the eigenvectors of a matrix.

EJML returns a null value for each eigenvector where exists an imaginary value. It does not offer any functionality (not an obvious one, at least) to extract the real value, unlike other java libraries like JBlas.

According to EJML javadoc (here):

MatrixType getEigenVector(int index)

Used to retrieve real valued eigenvectors. If an eigenvector is associated with a complex eigenvalue then null is returned instead.

Parameters:

index - Index of the eigenvalue eigenvector pair.

Returns:

If the associated eigenvalue is real then an eigenvector is returned, null otherwise.

In order to reproduce my issue, consider the following algorithm:

DenseMatrix64F origMatrix = RandomMatrices.createRandom(size, size, -2, 2, rand);

Original Matrix (non positive definite):

0.543  -1.405   1.580  
1.227   1.686  -0.064  
1.080  -1.689   0.645 

EigenDecomposition<DenseMatrix64F> eig = DecompositionFactory.eig(size, true);
eig.decompose(origMatrix);

int eigValNum = eig.getNumberOfEigenvalues();  

for(int i = 0; i < eigValNum; i++){
    DenseMatrix64F eigMat = eig.getEigenVector(i);
    if(eigMat != null){
        //Store all vectors inside a matrix
    }
}

Eigenvector Matrix:

0.000   0.000   0.573  
0.000   0.000  -0.299  
0.000   0.000  -0.763  

For what I understand, the first two columns on eigenvectors matrix are null due to an existent imaginary value which makes EJML return a NULL value. I need a method or technique that will allow me to margin the imaginary values and extract the real ones without loosing all the vector in the process.

1

1 Answers

1
votes

EJML doesn't support complex eigenvectors. To compute complex eigenvectors support for complex matrices and a complex eigenvalue decomposition must be provided, which EJML doesn't provide. You could make a feature request on its website.