0

我是 LAPACKE 的第一次用户习惯了这些约定,所以我的问题可能很容易解决。我正在尝试实现函数 LAPACKE_zhetrd 和 LAPACKE_zstegr 来查找复杂 Hermitian 矩阵的特征值。我对 zhetrd 的调用似乎工作正常,但是 zstegr 给出了一个段错误并且没有完成。

根据 zstegr 的文档,如果您搜索所有特征值而不是一些特征值和/或特征向量,则不会引用几个参数。

在下面的代码中,我为未引用且不是数组的参数插入了 0。对于未引用的数组,我只是传递了一个适当类型的虚拟指针。我想我不明白应该如何传递函数的某些参数。我希望有人指出我的错误。

#include <math.h>
#include <cblas.h>
#include <lapacke.h>
#include <stdio.h>
#include <stdlib.h>
#include <complex.h>

void main() {
    int info1, info2, n;
    int* numEig;
    double complex* z;
    int* isuppz;
    
    n = 4;

    double complex a[16] = {1.0, 0.0, 0.0, 0.0,
                        2.3-I*1.2, 3.45, 0.0, 0.0,
                        4.9+I*4.3, 4.0, 9.06, 0.0,
                        5.98-I*8.76, 3.09+I*6.89, 9.7, 15.4};

    double* d = (double*) calloc(n, sizeof(double) );
    double* e = (double*) calloc(n, sizeof(double));
    double* w = (double*) calloc(n, sizeof(double));
    double complex* tau = (double complex*) calloc(n-1, sizeof(double complex));

    info1 = LAPACKE_zhetrd( LAPACK_ROW_MAJOR, 'L', n, a, n, d, e, tau );
    printf("Tridiagonalize info = %d\n", info1);

    info2 = LAPACKE_zstegr( LAPACK_ROW_MAJOR, 'N', 'A', n, d, e, 0, 0, 0, 0, 0, numEig, w, z, 1, isuppz );
    printf("Eigensolve info = %d\n", info2);
}
4

0 回答 0