#include <rw/dcomplex.h> DComplex a;
Class DComplex is used with compilers that do not have a native complex class. Otherwise, the name is typedefed to the name of the native complex class. If you're using a Standard C++ Library build, DComplex is typedef'd to complex<double>, the Standard C++ Library complex number class complex<T> with T as a double.
Please note that the Related Global Functions for DComplex are defined at the end of this entry, rather than in the Global Function Reference part of the Math.h++ User's Guide.
DComplex()
Unadorned constructor. The real and imaginary parts are initialized to 0.
DComplex(double r);
Constructs a complex number with real part equal to r and imaginary part equal to 0.
DComplex(double r, double i);
Constructs a complex number with real part equal to r and imaginary part equal to i.
void operator+=(DComplex); void operator-=(DComplex); void operator*=(DComplex); void operator/=(DComplex);
Performs the indicated operation, but the operations are defined for complex numbers. For example,
a += b,
where a and b are complex numbers, implies:
Re(a) replaced by: Re(a) + Re(b);
Im(a) replaced by: Im(a) + Im(b).
DComplex operator-(DComplex); DComplex operator+(DComplex, DComplex); DComplex operator-(DComplex, DComplex); DComplex operator*(DComplex, DComplex); DComplex operator/(DComplex, DComplex); DComplex operator+(double, DComplex); DComplex operator+(DComplex, double); DComplex operator-(double, DComplex); DComplex operator-(DComplex, double); DComplex operator*(DComplex, double); DComplex operator*(double, DComplex);
Performs the indicated operation, but the operations are defined for complex numbers. Note that some of these operators involve type double.
int operator==(DComplex a, DComplex b); int operator!=(DComplex a, DComplex b);
Tests for equality or inequality. For operator== to return 1, both Re(a) == Re(b) and Im(a) == Im(b) must be true. If either expression is false, then operator!= returns 1.
ostream& operator<<(ostream& s, DComplex a);
Writes a complex number a to ostream s in the form:
( Re(a), Im(a) )
istream& operator>>(istream& s, DComplex& a);
Reads a complex number from istream s in any of the following forms:
u
( u )
or:
( u, v )
where u is the real part and v is the imaginary part of the number.
double real(const DComplex& a); double imag(const DComplex& a);
Returns the real or imaginary part of a complex number as a double precision number.
double abs(DComplex); double norm(DComplex);
Returns the absolute value or the norm of a complex number as a double precision number: [norm(a) = abs(a)2].
double arg(DComplex);
Returns the argument in radians of a complex number as a double precision number.
DComplex conj(DComplex a);
Returns the complex conjugate of a complex number.
DComplex polar(double r, double t);
For arguments r and t, where complex number a = reit, returns a complex number in Cartesian form.
DComplex cos(DComplex); DComplex cosh(DComplex); DComplex exp(DComplex); DComplex log(DComplex); DComplex pow(double, DComplex); DComplex pow(DComplex, int); DComplex pow(DComplex, double); DComplex pow(DComplex, DComplex); DComplex sin(DComplex); DComplex sinh(DComplex); DComplex sqrt(DComplex);
Analogous to the standard C functions, except that they are defined as complex functions, taking arguments of type DComplex and returning type DComplex. For multivalued functions such as log or sqrt, the principal value is returned. Note that several instances of pow are defined, with different argument types.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.