How to use complex number in C/C++ Using g++ Using Cray C Sample: /* FILENAME: main.c Shows how to call a FORTRAN routine from C and how to use complex number in C on cray. */ #include void main() { int n=2, lda=2; double complex p1[2][2]; double complex x1[2]; p1[0][0] = CMPLX (0,1); p1[0][1] = CMPLX (0,0); p1[1][0] = CMPLX (0,0); p1[1][1] = CMPLX (0,-1); EVLCG(&n,p1,&lda,x1); printf("%e %e %e %e \n",x1[0], x1[1]); } Using Cray C++ Sample: #include #include void main() { complex x,z; x = complex(0,1); cout << "X: " << x << endl; z = x*x; cout << "Z=X*X= " << z << endl; cout << "Size of Z: " << sizeof(z) << endl; cout << "Real Z: " << real(z) << " Size of Real Z: " << sizeof(real(z)) << endl; cout << "Imag Z: " << imag(z) << " Size of Imag Z: " << sizeof(imag(z)) << endl; }