R
Reshmi
Hi,
I have this C code which does complex number arithmetic. When I try to
write a similar file for C++, it says that "creal’ was not declared in
this scope". Can anyone give a better idea to write it using
"complex.h", other than using own data structures?
#include <stdio.h>
#include <complex.h>
int main(){
// double pi = 4*atan2(1);
double complex A = 32 + 24*I;
double complex B = 64 + 48*I;
double complex sum = A + B;
printf("\na is %f + %fi\n",creal(A), cimag(A));
printf("b is %f + %fi\n",creal(B), cimag(B));
printf("sum is %f + %fi\n",creal(sum), cimag(sum));
printf("sum: abs = %f , angle = %f\n", cabs(sum), carg(sum));
return(0);
}
Thanks,
Reshmi
I have this C code which does complex number arithmetic. When I try to
write a similar file for C++, it says that "creal’ was not declared in
this scope". Can anyone give a better idea to write it using
"complex.h", other than using own data structures?
#include <stdio.h>
#include <complex.h>
int main(){
// double pi = 4*atan2(1);
double complex A = 32 + 24*I;
double complex B = 64 + 48*I;
double complex sum = A + B;
printf("\na is %f + %fi\n",creal(A), cimag(A));
printf("b is %f + %fi\n",creal(B), cimag(B));
printf("sum is %f + %fi\n",creal(sum), cimag(sum));
printf("sum: abs = %f , angle = %f\n", cabs(sum), carg(sum));
return(0);
}
Thanks,
Reshmi