Complex.h

Classes

Global Functions -- Single and double precision complex numbers (full description)
Global Functions -- Complex NaN (full description)
Global Functions -- Complex comparisons (full description)
Global Functions -- DComplex NaN (full description)
Global Functions -- DComplex comparisons (full description)
Global Functions -- Additional complex mathematical functions (full description)
Global Functions -- The near functions (full description)
Global Functions -- Max and min, floor and ceil functions (full description)
Global Functions -- fmod (full description)
Global Functions -- Inverse trigonometry (full description)
Global Functions -- Error function (full description)

Single and double precision complex numbers (source)

Interface

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Synopsis

The class Complex is a straight typedef as the standard library complex<float>.

In a similar way DComplex is typedef-ed as complex<double>.

IComplex is defined as a specific class. It is only used by the FITS classes.

lDComplex has not been defined: long double is not part of the standard aips++ data suite (yet)

A set of global functions are added for historic reasons (they were present in the original aips++/gcc complex implementation).

See the standard library documentation for the expected behaviour of the Complex and DComplex classes.

Tip In the following all references to Complex can be replaced with DComplex. with simultaneous replacement of Float with Double.

Complex numbers may be constructed and used in the following ways:

Complex x;
Declares an uninitialized Complex.

Complex x = 2; Complex y(2.0);
Set x and y to the Complex value (2.0, 0.0);

Complex x(2, 3);
Sets x to the Complex value (2, 3);

Complex u(x); Complex v = x;
Set u and v to the same value as x.

Float real(Complex& x);
returns the real part of x.

Float imag(Complex& x);
returns the imaginary part of x.

Float abs(Complex& x);
returns the magnitude of x.

Float norm(Complex& x);
returns the square of the magnitude of x.

Float arg(Complex& x);
returns the argument (amplitude) of x.

Complex polar(Float r, Float t = 0.0);
returns a Complex with abs of r and arg of t.

Complex conj(Complex& x);
returns the complex conjugate of x

Complex cos(Complex& x);
returns the complex cosine of x.

Complex sin(Complex& x);
returns the complex sine of x.

Complex cosh(Complex& x);
returns the complex hyperbolic cosine of x.

Complex sinh(Complex& x);
returns the complex hyperbolic sine of x.

Complex exp(Complex& x);
returns the exponential of x.

Complex log(Complex& x);
returns the natural log of x.

Complex pow(Complex& x, long p);
returns x raised to the p power.

Complex pow(Complex& x, Complex& p);
returns x raised to the p power.

Complex sqrt(Complex& x);
returns the square root of x.

Complex min(Complex x,Complex y);
Returns the minumum of x,y (using operator<=, i.e. the norm).

Complex max(Complex x,Complex y);
Returns the maximum of x,y (using operator>=, i.e. the norm).

Bool near(Complex val1, Complex val2, Double tol = 1.0e-5);
returns whether val1 is relatively near val2 (see Math.h). (Note the Double tolerance)

Bool nearAbs(Complex val1, Complex val2, Double tol = 1.0e-5);
returns whether val1 is absolutely near val2 (see Math.h). (Note the Double tolerance)

ostream << x;
prints x in the form (re, im).

istream >> x;
reads x in the form (re, im), or just (re) or re in which case the imaginary part is set to zero.

Member Description


Complex NaN (source)

Interface

Bool isNaN (const Complex& val)
void setNaN(Complex& val)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

Bool isNaN (const Complex& val)

void setNaN(Complex& val)


Complex comparisons (source)

Interface

inline Bool operator>= (const Complex& left, const Complex& right)
inline Bool operator> (const Complex& left, const Complex& right)
inline Bool operator<= (const Complex& left, const Complex& right)
inline Bool operator< (const Complex& left, const Complex& right)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

inline Bool operator>= (const Complex& left, const Complex& right)

inline Bool operator> (const Complex& left, const Complex& right)

inline Bool operator<= (const Complex& left, const Complex& right)

inline Bool operator< (const Complex& left, const Complex& right)


DComplex NaN (source)

Interface

Bool isNaN (const DComplex& val)
void setNaN(DComplex& val)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

Bool isNaN (const DComplex& val)

void setNaN(DComplex& val)


DComplex comparisons (source)

Interface

inline Bool operator>= (const DComplex& left, const DComplex& right)
inline Bool operator> (const DComplex& left, const DComplex& right)
inline Bool operator<= (const DComplex& left, const DComplex& right)
inline Bool operator< (const DComplex& left, const DComplex& right)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

inline Bool operator>= (const DComplex& left, const DComplex& right)

inline Bool operator> (const DComplex& left, const DComplex& right)

inline Bool operator<= (const DComplex& left, const DComplex& right)

inline Bool operator< (const DComplex& left, const DComplex& right)


Additional complex mathematical functions (source)

Interface

inline Double fabs(const DComplex &val)
inline Float fabs(const Complex &val)
Complex log10(const Complex &val)
DComplex log10(const DComplex &val)
inline Complex pow(const Complex& val, Double p)
inline Complex operator*(const Complex& val, Double f)
inline Complex operator/(const Complex& val, Double f)
inline Complex operator*(const Complex& val, Int f)
inline Complex operator/(const Complex& val, Int f)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

inline Double fabs(const DComplex &val)

inline Float fabs(const Complex &val)

Complex log10(const Complex &val)
DComplex log10(const DComplex &val)

The log10 should be in stl

inline Complex pow(const Complex& val, Double p)

ArrayMath::pow needs this pow function (on SGI).

inline Complex operator*(const Complex& val, Double f)
inline Complex operator/(const Complex& val, Double f)

QMath needs these operators * and / (on SGI).

inline Complex operator*(const Complex& val, Int f)
inline Complex operator/(const Complex& val, Int f)

These operators are useful, otherwise both Float and Double are applicable for Ints.


The near functions (source)

Interface

Bool near(const Complex &val1, const Complex &val2, Double tol=1.0e-5)
Bool near(const DComplex &val1, const DComplex &val2, Double tol=1.0e-13)
Bool nearAbs(const Complex &val1, const Complex &val2, Double tol=1.0e-5)
Bool nearAbs(const DComplex &val1, const DComplex &val2, Double tol=1.0e-13)
inline Bool allNear(const Complex &val1, const Complex &val2, Double tol=1.0e-5)
inline Bool allNear(const DComplex &val1, const DComplex &val2, Double tol=1.0e-13)
inline Bool allNearAbs(const Complex &val1, const Complex &val2, Double tol=1.0e-5)
inline Bool allNearAbs(const DComplex &val1, const DComplex &val2, Double tol=1.0e-13)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

Bool near(const Complex &val1, const Complex &val2, Double tol=1.0e-5)

Bool near(const DComplex &val1, const DComplex &val2, Double tol=1.0e-13)

Bool nearAbs(const Complex &val1, const Complex &val2, Double tol=1.0e-5)

Bool nearAbs(const DComplex &val1, const DComplex &val2, Double tol=1.0e-13)

inline Bool allNear(const Complex &val1, const Complex &val2, Double tol=1.0e-5)

inline Bool allNear(const DComplex &val1, const DComplex &val2, Double tol=1.0e-13)

inline Bool allNearAbs(const Complex &val1, const Complex &val2, Double tol=1.0e-5)

inline Bool allNearAbs(const DComplex &val1, const DComplex &val2, Double tol=1.0e-13)


Max and min, floor and ceil functions (source)

Interface

inline Complex max(const Complex &x, const Complex &y)
inline DComplex max(const DComplex &x, const DComplex &y)
inline Complex min(const Complex &x, const Complex &y)
inline DComplex min(const DComplex &x, const DComplex &y)
inline Complex floor(const Complex &x)
inline DComplex floor(const DComplex &x)
inline Complex ceil(const Complex &x)
inline DComplex ceil(const DComplex &x)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

inline Complex max(const Complex &x, const Complex &y)

inline DComplex max(const DComplex &x, const DComplex &y)

inline Complex min(const Complex &x, const Complex &y)

inline DComplex min(const DComplex &x, const DComplex &y)

inline Complex floor(const Complex &x)

inline DComplex floor(const DComplex &x)

inline Complex ceil(const Complex &x)

inline DComplex ceil(const DComplex &x)


fmod (source)

Interface

DComplex fmod(const DComplex &in, const DComplex &f)
Complex fmod(const Complex &in, const Complex &f)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

DComplex fmod(const DComplex &in, const DComplex &f)

Complex fmod(const Complex &in, const Complex &f)


Inverse trigonometry (source)

Interface

DComplex atan(const DComplex &in)
Complex atan(const Complex &in)
DComplex asin(const DComplex &in)
Complex asin(const Complex &in)
DComplex acos(const DComplex &in)
Complex acos(const Complex &in)
DComplex atan2(const DComplex &in, const DComplex &t2)
Complex atan2(const Complex &in, const Complex &t2)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

DComplex atan(const DComplex &in)

atan not valid for z == -1

Complex atan(const Complex &in)

DComplex asin(const DComplex &in)

Complex asin(const Complex &in)

DComplex acos(const DComplex &in)

Complex acos(const Complex &in)

DComplex atan2(const DComplex &in, const DComplex &t2)

Complex atan2(const Complex &in, const Complex &t2)


Error function (source)

Interface

DComplex erf(const DComplex &in)
Complex erf(const Complex &in)
DComplex erfc(const DComplex &in)
Complex erfc(const Complex &in)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Member Description

DComplex erf(const DComplex &in)

Preliminary to get Functionals working. erf(z) will return erf(real(z)) only for now.

Complex erf(const Complex &in)

DComplex erfc(const DComplex &in)

Complex erfc(const Complex &in)