0

我正在尝试计算以下矩阵的特征向量和特征值。我能够得到结果,但所有特征向量都是正的

例子:

12.48 -1.88 -6.7

-1.88 26.7 4.32

-6.7 4.32 21.2

[1] 实特征值 = 8.8362 =S3

[1] 实特征向量:

0.8753

-0.0247

0.4830

[2] 实特征值 = 20.9867 =S2

[2] 实特征向量:

0.3873

0.6337

-0.6696

[3] 实特征值 = 30.5570 =S1

[3] 实特征向量:

0.2895

-0.7731

-0.5643

以下是我测试时的方法和输出。

 /**
 * 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;
}

我的测试方法后的结果。

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]

4

0 回答 0