在CLAPACK中使用dhsein计算特征向量

时间:2013-12-16 20:35:42

标签: c numerical-methods lapack eigenvector

这是我的程序:

int getEigenvector(FLOAT* matrix, FLOAT* eigenvalues, int selectedValueIndex, FLOAT* eigenvector, long size){
    char side = 'R'; // We want to calculate the right eigenvector.
    char source = 'Q'; // The eigenvalues come from HSEQR routine.
    char initVectors = 'N'; // No eigenvectors are provided.
    long* selectedValue = malloc((size) * sizeof(long));
    for(int i = 0; i < size; i++){
        selectedValue[i] = 1;
    } 
    long workspaceSize = size * (size+2);
    FLOAT* workSpace = allocateVector(workspaceSize);
    long* fail = malloc(size * sizeof(long));
    long info = 0;
    long output = 0;
    long one = 1;
    HSEIN(&side, &source, &initVectors, selectedValue, &size, matrix, &size, eigenvalues, eigenvalues + size, 
     NULL, &one, eigenvector, &size, &size, &output, workSpace, NULL, fail, &info);
    printf("Info: %ld Output: %ld\n" , info, output);
    return info;
}

应该计算给定Heissenberg矩阵的特征向量(我先用HSEQR计算)。

无论我将“Q”还是“N”作为源,给定矩阵 {{1, 0, 0}, {0, 2, 0}, {0, 0, 3}}让我回复:

  

信息:0输出:2    0001.0000 -000.0000 0000.0000    0000.0000 -000.0000 0000.0000    0000.0000 0001.0000 0000.0000

(数字来自特征向量数组)

对于具有3个不同特征值的3x3矩阵,仅计算2个向量怎么可能呢?

0 个答案:

没有答案