0

I am trying to compute eigenvectors and eigenvalues for the below matrix. I am able to get results but all eigenvectors are positive

Example:

12.48 -1.88 -6.7

-1.88 26.7 4.32

-6.7 4.32 21.2

[1] Real Eigenvalue = 8.8362 =S3

[1] Real Eigenvector:

0.8753

-0.0247

0.4830

[2] Real Eigenvalue = 20.9867 =S2

[2] Real Eigenvector:

0.3873

0.6337

-0.6696

[3] Real Eigenvalue = 30.5570 =S1

[3] Real Eigenvector:

0.2895

-0.7731

-0.5643

Below is my methods and and output when I was testing.

 /**
 * Computes the Principal eigenvalues of a given matrix
 *
 * @param matrix matrix in which eigenvalues are computed
 * @return Principal eigenvalues list in an ascending order
 */
public List<Double> getPrincipalEigenValues(DoubleMatrix matrix) {

    List<Double> EigenValuesList = new ArrayList<Double>();// initialize a list to store eigenvalues
    ComplexDoubleMatrix eigenvalues = Eigen.eigenvalues(matrix);// compute eigenvalues
    for (ComplexDouble eigenvalue : eigenvalues.toArray()) {
        Double value = Double.parseDouble(String.format("%.2f ", eigenvalue.abs()));
        EigenValuesList.add(value);
    }
    //it returns Principal Eigen Values in the  order of [S3, S2, S1]
    return EigenValuesList;
}

/**
 * Computes the Principal eigenvectors of a given matrix
 *
 * @param matrix matrix in which eigenvectors are computed
 * @return Principal eigenvectors list in the same order as the eigenvalues
 */
public List<Double> getPrincipalEigenVectors(DoubleMatrix matrix) {

    List<Double> EigenVectorList = new ArrayList<Double>();// initialize a list to store veigenvectors
    ComplexDoubleMatrix eigenvectors = Eigen.eigenvectors(matrix)[0];// compute veigenvectors
    for (ComplexDouble eigenvector : eigenvectors.toArray()) {
        Double value = Double.parseDouble(String.format("%.4f ", eigenvector.abs()));
        EigenVectorList.add(value);
    }
    //it returns Principal Eigen Vectors in the  order of [n3x, n3y, n3z,n2x, n2y, n2z,n1x, n1y, n1z]
    return EigenVectorList;
}

My results after testing methods.

Principal EigenValues[8.84, 20.99, 30.56] Principal EigenVectors[0.8753, 0.0247, 0.483, 0.3873, 0.6337, 0.6696, 0.2895, 0.7731, 0.5643]

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216

0 Answers0