K
Klaas Vantournhout
Hi,
I am using CLAPACK to do lots of matrix operations, but this is done on
complex matrices. There I also need to work with normal complex
operators, I use also the standard complex library. Unfortunately this
one conflicts with some stuff in f2c.h needed to run CLAPACK. Examples
are that f2c.h declares a variable complex that fights with everything
from the standard complex header. Most errors I got rid of by dumping
all the Lapack headers in a separate namespace, but now I still did not
resolve one last problem. And I think it might be basic C++.
Assume the following file
** begin code.cpp **
#include <iostream>
#include <complex>
using namespace std;
// putting lapack in a namespace
namespace lapack {
extern "C" {
#include "f2c.h"
#include "clapack.h"
}
}
int main(void) {
cout << abs(complex<double>(0.,1.)) << endl;
/* here comes more code using lapack:
functions) */
return 1;
}
** end code.cpp **
Compiling this gives an error of the sort
error: no match for ‘operator>=’ in ‘std::complex<double>(0.0, 1.0e+0) >= 0’
because fc2.h contains a line
#define abs(x) ((x) >= 0 ? (x) : -(x))
But abs is also defined in the complex header, but preprocessor
directives win over function calls I think.
So I guess you see my question.
How can I circumvent this problem?
Regards
Klaas
I am using CLAPACK to do lots of matrix operations, but this is done on
complex matrices. There I also need to work with normal complex
operators, I use also the standard complex library. Unfortunately this
one conflicts with some stuff in f2c.h needed to run CLAPACK. Examples
are that f2c.h declares a variable complex that fights with everything
from the standard complex header. Most errors I got rid of by dumping
all the Lapack headers in a separate namespace, but now I still did not
resolve one last problem. And I think it might be basic C++.
Assume the following file
** begin code.cpp **
#include <iostream>
#include <complex>
using namespace std;
// putting lapack in a namespace
namespace lapack {
extern "C" {
#include "f2c.h"
#include "clapack.h"
}
}
int main(void) {
cout << abs(complex<double>(0.,1.)) << endl;
/* here comes more code using lapack:
return 1;
}
** end code.cpp **
Compiling this gives an error of the sort
error: no match for ‘operator>=’ in ‘std::complex<double>(0.0, 1.0e+0) >= 0’
because fc2.h contains a line
#define abs(x) ((x) >= 0 ? (x) : -(x))
But abs is also defined in the complex header, but preprocessor
directives win over function calls I think.
So I guess you see my question.
How can I circumvent this problem?
Regards
Klaas