在CLAPACK中使用dhsein计算特征向量
以下是我的程序:在CLAPACK中使用dhsein计算特征向量,c,numerical-methods,lapack,eigenvector,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 routi
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;
}
int-getEigenvector(FLOAT*矩阵,FLOAT*特征值,int-selectedValueIndex,FLOAT*特征向量,长尺寸){
char-side='R';//我们要计算右特征向量。
char source='Q';//特征值来自HSEQR例程。
char initVectors='N';//未提供特征向量。
long*selectedValue=malloc((大小)*sizeof(长));
对于(int i=0;i
它应该计算给定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个向量呢