7.5.3 Complex Number Calculation Class Library

The header file for the complex number calculation class library is as follows:

-

<complex>

Defines the float_complex and double_complex classes.

These classes have no derivation.

(a)

float_complex Class

Type

Definition Name

Description

Type

value_type

float type

Variable

_re

Defines the real part of float precision.

_im

Defines the imaginary part of float precision.

Function

float_complex(float re = 0.0f, float im = 0.0f)

Constructor.

float_complex(const double_complex& rhs)

float real() const

Acquires the real part (_re).

float imag() const

Acquires the imaginary part (_im).

float_complex& operator=(float rhs)

Copies rhs to the real part..
0.0f is assigned to the imaginary part.

float_complex& operator+=(float rhs)

Adds rhs to the real part and stores the sum in *this.

float_complex& operator-=(float rhs)

Subtracts rhs from the real part and stores the difference in *this.

float_complex& operator*=(float rhs)

Multiplies *this by rhs and stores the product in *this.

float_complex& operator/=(float rhs)

Divides *this by rhs and stores the quotient in *this.

float_complex& operator=(
const float_complex& rhs)

Copies rhs.

float_complex& operator+=(
const float_complex& rhs)

Adds rhs to *this and stores the sum in *this.

float_complex& operator-=(
const float_complex& rhs)

Subtracts rhs from *this and stores the difference in *this.

float_complex& operator*=(
const float_complex& rhs)

Multiplies *this by rhs and stores the product in *this.

float_complex& operator/=(
const float_complex& rhs)

Divides *this by rhs and stores the quotient in *this.

 

float_complex::float_complex(float re = 0.0f, float im = 0.0f)

Constructor of class float_complex.

The initial settings are as follows:

_re = re;

_im = im;

 

float_ complex::float_complex(const double_complex& rhs)

Constructor of class float_complex.

The initial settings are as follows:

_re = (float)rhs.real();

_im = (float)rhs.imag();

 

float float_complex::real() const

Acquires the real part.

Return value: this->_re

 

float float_complex::imag() const

Acquires the imaginary part.

Return value: this->_im

 

float_complex& float_complex::operator=(float rhs)

Copies rhs to the real part (_re).

0.0f is assigned to the imaginary part (_im).

Return value: *this

 

float_complex& float_complex::operator+=(float rhs)

Adds rhs to the real part (_re) and stores the result in the real part (_re).

The value of the imaginary part (_im) does not change.

Return value: *this

 

float_complex& float_complex::operator-=(float rhs)

Subtracts rhs from the real part (_re) and stores the result in the real part (_re).

The value of the imaginary part (_im) does not change.

Return value: *this

 

float_complex& float_complex::operator*=(float rhs)

Multiplies *this by rhs and stores the result in *this.

(_re=_re*rhs, _im=_im*rhs)

Return value: *this

 

float_complex& float_complex::operator/=(float rhs)

Divides *this by rhs and stores the result in *this.

(_re=_re/rhs, _im=_im/rhs)

Return value: *this

float_complex& float_complex::operator=(const float_complex& rhs)

Copies rhs to *this.

Return value: *this

 

float_complex& float_complex::operator+=(const float_complex& rhs)

Adds rhs to *this and stores the result in *this

Return value: *this

float_complex& float_complex::operator-=(const float_complex& rhs)

Subtracts rhs from *this and stores the result in *this.

Return value: *this

 

float_complex& float_complex::operator*=(const float_complex& rhs)

Multiplies *this by rhs and stores the result in *this.

Return value: *this

 

float_complex& float_complex::operator/=(const float_complex& rhs)

Divides *this by rhs and stores the result in *this.

Return value: *this

 

(b)

float_complex Non-Member Function

Type

Definition Name

Description

Function

float_complex operator+(
const float_complex& lhs)

Performs unary + operation of lhs.

float_complex operator+(
const float_complex& lhs,
const float_complex& rhs)

Returns the result of adding lhs to rhs.

float_complex operator+(
const float_complex& lhs,
const float& rhs)

float_complex operator+(
const float& lhs,
const float_complex& rhs)

float_complex operator-(
const float_complex& lhs)

Performs unary - operation of lhs.

float_complex operator-(
const float_complex& lhs,
const float_complex& rhs)

Returns the result of subtracting rhs from lhs.

float_complex operator-(
const float_complex& lhs,
const float& rhs)

float_complex operator-(
const float& lhs,
const float_complex& rhs)

float_complex operator*(
const float_complex& lhs,
const float_complex& rhs)

Returns the result of multiplying lhs by rhs.

float_complex operator*(
const float_complex& lhs,
const float& rhs)

float_complex operator*(
const float& lhs,
const float_complex& rhs)

Function

float_complex operator/(
const float_complex& lhs,
const float_complex& rhs)

Returns the result of dividing lhs by rhs.

float_complex operator/(
const float_complex& lhs,
const float& rhs)

float_complex operator/(
const float& lhs,
const float_complex& rhs)

Divides lhs by rhs and stores the quotient in lhs.

bool operator==(
const float_complex& lhs,
const float_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

bool operator==(
const float_complex& lhs,
const float& rhs)

bool operator== (
const float& lhs,
const float_complex& rhs)

bool operator!=(
const float_complex& lhs,
const float_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

bool operator!=(
const float_complex& lhs,
const float& rhs)

bool operator!=(
const float& lhs,
const float_complex& rhs)

istream& operator>>(
istream& is,
float_complex& x)

Inputs x in a format of u, (u), or (u,v) (u: real part, v: imaginary part).

ostream& operator<<(
ostream& os,
const float_complex& x)

Outputs x in a format of u, (u), or (u,v) (u: real part, v: imaginary part).

float real(const float_complex& x)

Acquires the real part.

float imag(const float_complex& x)

Acquires the imaginary part.

float abs(const float_complex& x)

Calculates the absolute value.

float arg(const float_complex& x)

Calculates the phase angle.

float norm(const float_complex& x)

Calculates the absolute value of the square.

float_complex conj(const float_complex& x)

Calculates the conjugate complex number.

float_complex polar(
const float& rho,
const float& theta)

Calculates the float_complex value for a complex number with size rho and phase angle theta.

float_complex cos(const float_complex& x)

Calculates the complex cosine.

float_complex cosh(const float_complex& x)

Calculates the complex hyperbolic cosine.

Function

float_complex exp(const float_complex& x)

Calculates the exponent function.

float_complex log(const float_complex& x)

Calculates the natural logarithm.

float_complex log10(const float_complex& x)

Calculates the common logarithm.

float_complex pow(
const float_complex& x,
int y)

Calculates x to the yth power.

float_complex pow(
const float_complex& x,
const float& y)

float_complex pow(
const float_complex& x,
const float_complex& y)

float_complex pow(
const float& x,
const float_complex& y)

float_complex sin(const float_complex& x)

Calculates the complex sine.

float_complex sinh(const float_complex& x)

Calculates the complex hyperbolic sine.

float_complex sqrt(const float_complex& x)

Calculates the square root within the right half space.

float_complex tan(const float_complex& x)

Calculates the complex tangent.

float_complex tanh(const float_complex& x)

Calculates the complex hyperbolic tangent.

 

float_complex operator+(const float_complex& lhs)

Performs unary + operation of lhs.

Return value: lhs

 

float_complex operator+(const float_complex& lhs, const float_complex& rhs)

Returns the result of adding lhs to rhs.

Return value: float_complex(lhs)+=rhs

 

float_complex operator+(const float_complex& lhs, const float& rhs)

Returns the result of adding lhs to rhs.

Return value: float_complex(lhs)+=rhs

 

float_complex operator+(const float& lhs, const float_complex& rhs)

Returns the result of adding lhs to rhs.

Return value: float_complex(lhs)+=rhs

 

float_complex operator-(const float_complex& lhs)

Performs unary - operation of lhs.

Return value: float_complex(-lhs.real(), -lhs.imag())

 

float_complex operator-(const float_complex& lhs, const float_complex& rhs)

Returns the result of subtracting rhs from lhs.

Return value: float_complex(lhs)-=rhs

 

float_complex operator-(const float_complex& lhs, const float& rhs)

Returns the result of subtracting rhs from lhs.

Return value: float_complex(lhs)-=rhs

 

float_complex operator-(const float& lhs, const float_complex& rhs)

Returns the result of subtracting rhs from lhs.

Return value: float_complex(lhs)-=rhs

 

float_complex operator*(const float_complex& lhs, const float_complex& rhs)

Returns the result of multiplying lhs by rhs.

Return value: float_complex(lhs)*=rhs

 

float_complex operator*(const float_complex& lhs, const float& rhs)

Returns the result of multiplying lhs by rhs.

Return value: float_complex(lhs)*=rhs

 

float_complex operator*(const float& lhs, const float_complex& rhs)

Returns the result of multiplying lhs by rhs.

Return value: float_complex(lhs)*=rhs

 

float_complex operator/(const float_complex& lhs, const float_complex& rhs)

Returns the result of dividing lhs by rhs.

Return value: float_complex(lhs)/=rhs

 

float_complex operator/(const float_complex& lhs, const float& rhs)

Returns the result of dividing lhs by rhs.

Return value: float_complex(lhs)/=rhs

 

float_complex operator/(const float& lhs, const float_complex& rhs)

Returns the result of dividing lhs by rhs.

Return value: float_complex(lhs)/=rhs

 

bool operator==(const float_complex& lhs, const float_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a float type parameter, the imaginary part is assumed to be 0.0f.

Return value: lhs.real()==rhs.real() && lhs.imag()==rhs.imag()

 

bool operator==(const float_complex& lhs, const float& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a float type parameter, the imaginary part is assumed to be 0.0f.

Return value: lhs.real()==rhs.real() && lhs.imag()==rhs.imag()

 

bool operator==(const float& lhs, const float_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a float type parameter, the imaginary part is assumed to be 0.0f.

Return value: lhs.real()==rhs.real() && lhs.imag()==rhs.imag()

 

bool operator!=(const float_complex& lhs, const float_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a float type parameter, the imaginary part is assumed to be 0.0f.

Return value: lhs.real()!=rhs.real() || lhs.imag()!=rhs.imag()

 

bool operator!=(const float_complex& lhs, const float& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a float type parameter, the imaginary part is assumed to be 0.0f.

Return value: lhs.real()!=rhs.real() || lhs.imag()!=rhs.imag()

 

bool operator!=(const float& lhs, const float_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a float type parameter, the imaginary part is assumed to be 0.0f.

Return value: lhs.real()!=rhs.real() || lhs.imag()!=rhs.imag()

 

istream& operator>>(istream& is, float_complex& x)

Inputs x in a format of u, (u), or (u,v) (u: real part, v: imaginary part).

The input value is converted to float_complex.

If x is input in a format other than the u, (u), or (u,v) format, is.setstate(ios_base::failbit) is called.

Return value: is

 

ostream& operator<<(ostream& os, const float_complex& x)

Outputs x to os.

The output format is u, (u), or (u,v) (u: real part, v: imaginary part).

Return value: os

 

float real(const float_complex& x)

Acquires the real part.

Return value: x.real()

 

float imag(const float_complex& x)

Acquires the imaginary part.

Return value: x.imag()

 

float abs(const float_complex& x)

Calculates the absolute value.

Return value: (|x.real()|2 + |x.imag()|2)1/2

 

float arg(const float_complex& x)

Calculates the phase angle.

Return value: atan2f(x.imag(), x.real())

 

float norm(const float_complex& x)

Calculates the absolute value of the square.

Return value: |x.real()|2 + |x.imag()|2

 

float_complex conj(const float_complex& x)

Calculates the conjugate complex number.

Return value: float_complex(x.real(), (-1)*x.imag())

 

float_complex polar(const float& rho, const float& theta)

Calculates the float_complex value for a complex number with size rho and phase angle (argument) theta.

Return value: float_complex(rho*cosf(theta), rho*sinf(theta))

 

float_complex cos(const float_complex& x)

Calculates the complex cosine.

Return value: float_complex(cosf(x.real())*coshf(x.imag()),

(-1)*sinf(x.real())*sinhf(x.imag()))

 

float_complex cosh(const float_complex& x)

Calculates the complex hyperbolic cosine.

Return value: cos(float_complex((-1)*x.imag(), x.real()))

 

float_complex& float_complex::operator-=(const float_complex& rhs)

Calculates the exponent function.

Return value: expf(x.real())*cosf(x.imag()),expf(x.real())*sinf(x.imag())

 

float_complex log(const float_complex& x)

Calculates the natural logarithm (base e).

Return value: float_complex(logf(abs(x)), arg(x))

 

float_complex log10(const float_complex& x)

Calculates the common logarithm (base 10).

Return value: float_complex(log10f(abs(x)), arg(x)/logf(10))

 

float_complex pow(const float_complex& x, int y)

Calculates x to the yth power.

If pow(0,0), a domain error will occur.

Return value: If float_complex pow(const float_complex& x, const float_complex& y): exp(y*logf(x))

Otherwise: exp(y*log(x))

 

float_complex pow(const float_complex& x, const float& y)

Calculates x to the yth power.

If pow(0,0), a domain error will occur.

Return value: If float_complex pow(const float_complex& x, const float_complex& y): exp(y*logf(x))

Otherwise: exp(y*log(x))

 

float_complex pow(const float_complex& x, const float_complex& y)

Calculates x to the yth power.

If pow(0,0), a domain error will occur.

Return value: If float_complex pow(const float_complex& x, const float_complex& y): exp(y*logf(x))

Otherwise: exp(y*log(x))

 

float_complex pow(const float& x, const float_complex& y)

Calculates x to the yth power.

If pow(0,0), a domain error will occur.

Return value: If float_complex pow(const float_complex& x, const float_complex& y): exp(y*logf(x))

Otherwise: exp(y*log(x))

 

float_complex sin(const float_complex& x)

Calculates the complex sine.

Return value: float_complex(sinf(x.real())*coshf(x.imag()), cosf(x.real())*sinhf(x.imag()))

 

float_complex sinh(const float_complex& x)

Calculates the complex hyperbolic sine.

Return value: float_complex(0,-1)*sin(float_complex((-1)*x.imag(),x.real()))

 

float_complex sqrt(const float_complex& x)

Calculates the square root within the right half space.

Return value: float_complex(sqrtf(abs(x))*cosf(arg(x)/2), sqrtf(abs(x))*sinf(arg(x)/2))

 

float_complex tan(const float_complex& x)

Calculates the complex tangent.

Return value: sin(x)/cos(x)

 

float_complex tanh(const float_complex& x)

Calculates the complex hyperbolic tangent.

Return value: sinh(x)/cosh(x)

 

(c)

double_complex Class

Type

Definition Name

Description

Type

value_type

double type.

Variable

_re

Defines the real part of double precision.

_im

Defines the imaginary part of double precision.

Function

double_complex(
double re = 0.0,
double im = 0.0)

Constructor.

double_complex(const float_complex&)

double real() const

Acquires the real part.

double imag() const

Acquires the imaginary part.

double_complex& operator=(double rhs)

Copies rhs to the real part.
0.0 is assigned to the imaginary part.

double_complex& operator+=(double rhs)

Adds rhs to the real part of *this and stores the sum in *this.

double_complex& operator-=(double rhs)

Subtracts rhs from the real part of *this and stores the difference in *this.

double_complex& operator*=(double rhs)

Multiplies *this by rhs and stores the product in *this.

double_complex& operator/=(double rhs)

Divides *this by rhs and stores the quotient in *this.

double_complex& operator=(
const double_complex& rhs)

Copies rhs.

double_complex& operator+=(
const double_complex& rhs)

Adds rhs to *this and stores the sum in *this.

double_complex& operator-=(
const double_complex& rhs)

Subtracts rhs from *this and stores the difference in *this.

double_complex& operator*=(
const double_complex& rhs)

Multiplies *this by rhs and stores the product in *this.

double_complex& operator/=(
const double_complex& rhs)

Divides *this by rhs and stores the quotient in *this.

 

double_complex::double_complex(double re = 0.0, double im = 0.0)

Constructor of class double_complex.

The initial settings are as follows:

_re = re;

_im = im;

 

double_complex::double_complex(const float_complex&)

Constructor of class double_complex.

The initial settings are as follows:

_re = (double)rhs.real();

_im = (double)rhs.imag();

 

double double_complex::real() const

Acquires the real part.

Return value: this->_re

 

double double_complex::imag() const

Acquires the imaginary part.

Return value: this->_im

 

double_complex& double_complex::operator=(double rhs)

Copies rhs to the real part (_re).

0.0 is assigned to the imaginary part (_im).

Return value: *this

 

double_complex& double_complex::operator+=(double rhs)

Adds rhs to the real part (_re) and stores the result in the real part (_re).

The value of the imaginary part (_im) does not change.

Return value: *this

 

double_complex& double_complex::operator-= (double rhs)

Subtracts rhs from the real part (_re) and stores the result in the real part (_re).

The value of the imaginary part (_im) does not change.

Return value: *this

 

double_complex& double_complex::operator*=(double rhs)

Multiplies *this by rhs and stores the result in *this.

(_re=_re*rhs, _im=_im*rhs)

Return value: *this

 

double_complex& double_complex::operator/=(double rhs)

Divides *this by rhs and stores the result in *this.

(_re=_re/rhs, _im=_im/rhs)

Return value: *this

 

double_complex& double_complex::operator=(const double_complex& rhs)

Copies rhs to *this.

Return value: *this

 

double_complex& double_complex::operator+=(const double_complex& rhs)

Adds rhs to *this and stores the result in *this.

Return value: *this

 

double_complex& double_complex::operator-=(const double_complex& rhs)

Subtracts rhs from *this and stores the result in *this.

Return value: *this

 

double_complex& double_complex::operator*=(const double_complex& rhs)

Multiplies *this by rhs and stores the result in *this.

Return value: *this

 

double_complex& double_complex::operator/=(const double_complex& rhs)

Divides *this by rhs and stores the result in *this.

Return value: *this

 

(d)

double_complex Non-Member Function

Type

Definition Name

Description

Function

double_complex operator+(
const double_complex& lhs)

Performs unary + operation of lhs.

double_complex operator+(
const double_complex& lhs,
const double_complex& rhs)

Returns the result of adding rhs to lhs.

double_complex operator+(
const double_complex& lhs,
const double& rhs)

double_complex operator+(
const double& lhs,
const double_complex& rhs)

double_complex operator-(
const double_complex& lhs)

Performs unary - operation of lhs.

double_complex operator-(
const double_complex& lhs,
const double_complex& rhs)

Returns the result of subtracting rhs from lhs.

double_complex operator-(
const double_complex& lhs,
const double& rhs)

double_complex operator-(
const double& lhs,
const double_complex& rhs)

double_complex operator*(
const double_complex& lhs,
const double_complex& rhs)

Returns the result of multiplying lhs by rhs.

double_complex operator*(
const double_complex& lhs,
const double& rhs)

double_complex operator*(
const double& lhs,
const double_complex& rhs)

double_complex operator/(
const double_complex& lhs,
const double_complex& rhs)

Returns the result of dividing lhs by rhs.

double_complex operator/(
const double_complex& lhs,
const double& rhs)

double_complex operator/(
const double& lhs,
const double_complex& rhs)

Function

bool operator==(
const double_complex& lhs,
const double_complex& rhs)

Compares the real part of lhs and rhs, and the imaginary parts of lhs and rhs.

bool operator==(
const double_complex& lhs,
const double& rhs)

bool operator==(
const double& lhs,
const double_complex& rhs)

bool operator!=(
const double_complex& lhs,
const double_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

bool operator!=(
const double_complex& lhs,
const double& rhs)

bool operator!=(
const double& lhs,
const double_complex& rhs)

istream& operator>>(
istream& is,
double_complex& x)

Inputs x in a format of u, (u), or (u,v) (u: real part, v: imaginary part).

ostream& operator<<(
ostream& os,
const double_complex& x)

Outputs x in a format of u, (u), or (u,v) (u: real part, v: imaginary part).

double real(const double_complex& x)

Acquires the real part.

double imag(const double_complex& x)

Acquires the imaginary part.

double abs(const double_complex& x)

Calculates the absolute value.

double arg(const double_complex& x)

Calculates the phase angle.

double norm(const double_complex& x)

Calculates the absolute value of the square.

double_complex conj(
const double_complex& x)

Calculates the conjugate complex number.

double_complex polar(
const double& rho,
const double& theta)

Calculates the double_complex value for a complex number with size rho and phase angle theta.

double_complex cos(
const double_complex& x)

Calculates the complex cosine.

double_complex cosh(
const double_complex& x)

Calculates the complex hyperbolic cosine.

double_complex exp(
const double_complex& x)

Calculates the exponent function.

double_complex log(
const double_complex& x)

Calculates the natural logarithm.

double_complex log10(
const double_complex& x)

Calculates the common logarithm.

Function

double_complex pow(
const double_complex& x,
int y)

Calculates x to the yth power.

double_complex pow(
const double_complex& x,
const double& y)

double_complex pow(
const double_complex& x,
const double_complex& y)

double_complex pow(
const double& x,
const double_complex& y)

double_complex sin(
const double_complex& x)

Calculates the complex sine.

double_complex sinh(
const double_complex& x)

Calculates the complex hyperbolic sine.

double_complex sqrt(
const double_complex& x)

Calculates the square root within the right half space.

double_complex tan(
const double_complex& x)

Calculates the complex tangent.

double_complex tanh(
const double_complex& x)

Calculates the complex hyperbolic tangent.

 

double_complex operator+(const double_complex& lhs)

Performs unary + operation of lhs.

Return value: lhs

 

double_complex operator+(const double_complex& lhs, const double_complex& rhs)

Returns the result of adding lhs to rhs.

Return value: double_complex(lhs)+=rhs

 

double_complex operator+(const double_complex& lhs, const double& rhs)

Returns the result of adding lhs to rhs.

Return value: double_complex(lhs)+=rhs

 

double_complex operator+(const double& lhs, const double_complex& rhs)

Returns the result of adding lhs to rhs.

Return value: double_complex(lhs)+=rhs

 

double_complex operator-(const double_complex& lhs)

Performs unary - operation of lhs.

Return value: double_complex(-lhs.real(), -lhs.imag())

 

double_complex operator-(const double_complex& lhs, const double_complex& rhs)

Returns the result of subtracting rhs from lhs.

Return value: double_complex(lhs)-=rhs

 

double_complex operator-(const double_complex& lhs, const double& rhs)

Returns the result of subtracting rhs from lhs.

Return value: double_complex(lhs)-=rhs

 

double_complex operator-(const double& lhs, const double_complex& rhs)

Returns the result of subtracting rhs from lhs.

Return value: double_complex(lhs)-=rhs

 

double_complex operator*(const double_complex& lhs, const double_complex& rhs)

Returns the result of multiplying lhs by rhs.

Return value: double_complex(lhs)*=rhs

 

double_complex operator*(const double_complex& lhs, const double& rhs)

Returns the result of multiplying lhs by rhs.

Return value: double_complex(lhs)*=rhs

 

double_complex operator*(const double& lhs, const double_complex& rhs)

Returns the result of multiplying lhs by rhs.

Return value: double_complex(lhs)*=rhs

 

double_complex operator/(const double_complex& lhs, const double_complex& rhs)

Returns the result of dividing lhs by rhs.

Return value: double_complex(lhs)/=rhs

 

double_complex operator/(const double_complex& lhs, const double& rhs)

Returns the result of dividing lhs by rhs.

Return value: double_complex(lhs)/=rhs

 

double_complex operator/(const double& lhs, const double_complex& rhs)

Returns the result of dividing lhs by rhs.

Return value: double_complex(lhs)/=rhs

 

bool operator==(const double_complex& lhs, const double_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a double type parameter, the imaginary part is assumed to be 0.0.

Return value: lhs.real()==rhs.real() && lhs.imag()==rhs.imag()

 

bool operator==(const double_complex& lhs, const double& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a double type parameter, the imaginary part is assumed to be 0.0.

Return value: lhs.real()==rhs.real() && lhs.imag()==rhs.imag()

 

bool operator==(const double& lhs, const double_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a double type parameter, the imaginary part is assumed to be 0.0.

Return value: lhs.real()==rhs.real() && lhs.imag()==rhs.imag()

 

bool operator!=(const double_complex& lhs, const double_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a double type parameter, the imaginary part is assumed to be 0.0.

Return value: lhs.real()!=rhs.real() || lhs.imag()!=rhs.imag()

 

bool operator!=(const double_complex& lhs, const double& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a double type parameter, the imaginary part is assumed to be 0.0.

Return value: lhs.real()!=rhs.real() || lhs.imag()!=rhs.imag()

 

bool operator!=(const double& lhs, const double_complex& rhs)

Compares the real parts of lhs and rhs, and the imaginary parts of lhs and rhs.

For a double type parameter, the imaginary part is assumed to be 0.0.

Return value: lhs.real()!=rhs.real() || lhs.imag()!=rhs.imag()

 

istream& operator>>(istream& is, double_complex& x)

Inputs complex number x in a format of u, (u), or (u,v) (u: real part, v: imaginary part).

The input value is converted to double_complex.

If x is input in a format other than the u, (u), or (u,v) format, is.setstate(ios_base::failbit) is called.

Return value: is

 

ostream& operator<<(ostream& os, const double_complex& x)

Outputs x to os.

The output format is u, (u), or (u,v) (u: real part, v: imaginary part).

Return value: os

 

double real(const double_complex& x)

Acquires the real part.

Return value: x.real()

 

double imag(const double_complex& x)

Acquires the imaginary part.

Return value: x.imag()

 

double abs(const double_complex& x)

Calculates the absolute value.

Return value: (|x.real()|2 + |x.imag()|2)1/2

 

double arg(const double_complex& x)

Calculates the phase angle.

Return value: atan2(x.imag(), x.real())

 

double norm(const double_complex& x)

Calculates the absolute value of the square.

Return value: |x.real()|2 + |x.imag()|2

 

double_complex conj(const double_complex& x)

Calculates the conjugate complex number.

Return value: double_complex(x.real(), (-1)*x.imag())

 

double_complex polar(const double& rho, const double& theta)

Calculates the double_complex value for a complex number with size rho and phase angle (argument) theta.

Return value: double_complex(rho*cos(theta), rho*sin(theta))

 

double_complex cos(const double_complex& x)

Calculates the complex cosine.

Return value: double_complex(cos(x.real())*cosh(x.imag()),

(-1)*sin(x.real())*sinh(x.imag()))

 

double_complex cosh(const double_complex& x)

Calculates the complex hyperbolic cosine.

Return value: cos(double_complex((-1)*x.imag(), x.real()))

 

double_complex exp(const double_complex& x)

Calculates the exponent function.

Return value: exp(x.real())*cos(x.imag()),exp(x.real())*sin(x.imag())

 

double_complex log(const double_complex& x)

Calculates the natural logarithm (base e).

Return value: double_complex(log(abs(x)), arg(x))

 

double_complex log10(const double_complex& x)

Calculates the common logarithm (base 10).

Return value: double_complex(log10(abs(x)), arg(x)/log(10))

 

double_complex pow(const double_complex& x, int y)

Calculates x to the yth power.

If pow(0,0), a domain error will occur.

Return value: exp(y*log(x))

 

double_complex pow(const double_complex& x, const double& y)

Calculates x to the yth power.

If pow(0,0), a domain error will occur.

Return value: exp(y*log(x))

 

double_complex pow(const double_complex& x, const double_complex& y)

Calculates x to the yth power.

If pow(0,0), a domain error will occur.

Return value: exp(y*log(x))

 

double_complex pow(const double& x, const double_complex& y)

Calculates x to the yth power.

If pow(0,0), a domain error will occur.

Return value: exp(y*log(x))

 

double_complex sin(const double_complex& x)

Calculates the complex sine

Return value: double_complex(sin(x.real())*cosh(x.imag()), cos(x.real())*sinh(x.imag()))

 

double_complex sinh(const double_complex& x)

Calculates the complex hyperbolic sine

Return value: double_complex(0,-1)*sin(double_complex((-1)*x.imag(),x.real()))

 

double_complex sqrt(const double_complex& x)

Calculates the square root within the right half space

Return value: double_complex(sqrt(abs(x))*cos(arg(x)/2), sqrt(abs(x))*sin(arg(x)/2))

 

double_complex tan(const double_complex& x)

Calculates the complex tangent.

Return value: sin(x)/cos(x)

 

double_complex tanh(const double_complex& x)

Calculates the complex hyperbolic tangent.

Return value: sinh(x)/cosh(x)