【 以下文字转载自 Computation 讨论区 】
发信人: bankbuster (恭喜发财), 信区: Computation
标 题: C++里用Blas/Lapack的问题
发信站: BBS 未名空间站 (Tue Aug 9 14:57:49 2011, 美东)
我用atlas,程序里简单调用zgeev函数。编译没有错,没有警告。运行也不出错,但结
果完全不对。似乎函数根本没有被调用。
另外哪里能找到在C或者C++下调用Blas/Lapack函数的具体格式?我这里函数参数还是
在网上搜的。完全没有相关的手册。难道Blas/Lapack只是给fortran用的?
程序如下
#include
#include
#include
#include
#include
using namespace std;
typedef complex dcomplex;
extern "C" void zgeev_( char* jobvl, char* jobvr, int* n, dcomplex* a,
int* lda, dcomplex* w, dcomplex* vl, int* ldvl, dcomplex*
vr, int* ldvr, dcomplex* work, int* lwork, double* rwork, int* info );
int main()
{
/* Locals */
int N=4;
int LDVL=N,LDVR=N,LDA=N;
int n = N, lda = N, ldvl = LDVL, ldvr = LDVR, info, lwork;
cout<dcomplex wkopt;
dcomplex* work;
/* Local arrays */
/* rwork dimension should be at least 2*n */
double rwork[2*N];
dcomplex w[N], vl[LDVL*N], vr[LDVR*N];
dcomplex a[16] = {
(-3.84, 2.25), (-0.66, 0.83), (-3.99, -4.73), ( 7.74, 4.18),
(-8.94, -4.75), (-4.40, -3.82), (-5.88, -6.60), ( 3.66, -7.53),
( 8.95, -6.53), (-3.50, -4.26), (-3.36, -0.40), ( 2.58, 3.60),
(-9.87, 4.82), (-3.15, 7.36), (-0.75, 5.23), ( 4.59, 5.41)};
lwork = -1;
char jobvl='V',jobvr='N';
zgeev_(&jobvl, &jobvr, &n, a, &lda, w, vl, &ldvl, vr, &ldvr, &wkopt,
&lwork, rwork, &info );
cout<}
输出结果是
w=(0,0)(0,0)(0,0)(0,0)
问题出在哪里呢?谢谢!