Wednesday 25 July 2012

complex Library

<complex>


A complex supports complex arithmetic. It has real and imaginary parts of type T. Mixed type expressions promote real to complex (e.g. double to complex<double> and lower precision to higher precision (e.g. complex<int> to complex<double>). complex<T> x; // (0,0), T is a numeric type
complex<T> x=r; // (r,0), convert real r to complex
complex<T> x(r, i); // (r,i)
x=polar<T>(rho, theta); // Polar notation: radius, angle in radians
x.real() // r
x.imag() // i
abs(x) // rho = sqrt(r*r+i*i)
arg(x) // tan(theta) = i/r
norm(x) // abs(x)*abs(x)
conj(x) // (r,-i)
x+y // Also - * / == != = += -= *= /= and unary + -
sin(x) // Also sinh, sqrt, tan, tanh, cos, cosh, exp, log, log10, pow(x,y)
cout << x // Prints in format "(r,i)"
cin >> x // Expects "r", "(r)", or "(r,i)"

No comments:

Post a Comment