Why am I getting these errors? (I have a clang/g++
compiler.)
error: use of undeclared identifier 'ccos'
error: use of undeclared identifier 'csqrt'; did you mean 'sqrt'?
error: use of undeclared identifier 'cpow'; did you mean 'pow'?
and so forth. I have declared my function as:
#include <complex>
double ghmc1AccNormalised( double ph, double r, double t, double th){
complex<double> numerator;
complex<double> denominator;
double E = exp(1);
numerator=-(cpow(E,t*((-2*r + r*ccos(th) + r* // ... etc
// what follows is 24MB of a horrible polynomial from Mathematica
...
denominator = cpow(2,0.3333333333333333) //... etc
return creal(numerator/denominator);
}
I am trying to ensure that I am handling the imaginary variables correctly. I have spent a long time looking at various posts but I have the following issues:
- The values are coming out as
inf
andnan
when they shouldn't - I suspected that this was due to complex numbers not being handled properly
- This highly rated post notes that
ccos
,csqrt
etc. should be used for complex arguments - I have tried various namespaces in addition to the above:
using complex;
using std::complex;
- I tried also prepending
std::complex
andcomplex::
to each function
Disclaimer This is my first c/c++
function so please ignore trivial issues unless directly related to the question