Can anyone tell me how use LAPACK in C++ code in Ubuntu 12.04?
I saw in Synaptic that I have the llapack an lbas packages installed (although I dont know if those are for fortran...), but I don't now what I need to include in the C++ code (apart from the zgesv parameters) and how to compile/run it in the command line.
The code (with dgesv!) from this website works: http://www.physics.utah.edu/~detar/phys ... apack.html
(I compiled using "g++ -c myprog.cc" and then "g++ myprog.o -o myprog -L/usr/local/lib64 -llapack -lblas -lgfortran -lm" as shown in the same site)
But if I do the same for zgesv I get some errors...
I made the modification from the dgesv as:
- Code: Select all
extern "C" {
void zgesv_(int *Nmatrix, int *nrhs, complex<double> *Matrix, int *lda,
int *ipvt, complex<double> *Vector, int *ldb, int *info);
}
and after that
- Code: Select all
int nrhs = 1;
int lda = Nmatrix;
int ldb = Nmatrix;
int ipvt[Nmatrix];
int info;
zgesv_(&Nmatrix, &nrhs, &Matrix, &lda, ipvt, &Vector, &ldb, &info);
And I get these errors when compiling using g++:
...path...$ g++ -c maincode.cxx functions.cxx
maincode.cxx: In function ‘int main()’:
maincode.cxx:97:67: error: cannot convert ‘std::complex<double> (*)[(((long unsigned int)(((long int)Nmatrix) + -0x00000000000000001)) + 1)][(((long unsigned int)(((long int)Nmatrix) + -0x00000000000000001)) + 1)]’ to ‘std::complex<double>*’ for argument ‘3’ to ‘void zgesv_(int*, int*, std::complex<double>*, int*, int*, std::complex<double>*, int*, int*)’
What am I doing wrong?
Best regards