Back to index

nux  3.0.0
Public Member Functions | Private Attributes
nux::ComplexNumber Class Reference

#include <Complex.h>

List of all members.

Public Member Functions

 ~ComplexNumber ()
 ComplexNumber (float re=0.0f, float im=0.0f)
 ComplexNumber (const ComplexNumber &)
ComplexNumberoperator= (const ComplexNumber &)
void operator+= (const ComplexNumber &)
void operator-= (const ComplexNumber &)
void operator*= (const ComplexNumber &)
void operator/= (const ComplexNumber &)
void conjugue ()
float absolute ()
bool IsNull ()
float real () const
float imaginary () const
void real (float r)
void imaginary (float i)

Private Attributes

float real_
float imaginary_

Detailed Description

Definition at line 29 of file Complex.h.


Constructor & Destructor Documentation

Definition at line 41 of file Complex.cpp.

  {
  }
nux::ComplexNumber::ComplexNumber ( float  re = 0.0f,
float  im = 0.0f 
)

Definition at line 29 of file Complex.cpp.

  {
    real_ = re;
    imaginary_ = im;
  }

Definition at line 35 of file Complex.cpp.

  {
    real_ = complex.real_;
    imaginary_ = complex.imaginary_;
  }

Member Function Documentation

Definition at line 191 of file Complex.cpp.

  {
    float x, y, result, temp;

    x = (float) std::fabs (real_);
    y = (float) std::fabs (imaginary_);

    if (x == 0.0)
      result = y;
    else
    {
      if (y == 0.0)
        result = x;
      else
      {
        if (x > y)
        {
          temp = y / x;
          result = x * (float) std::sqrt (1.0 + temp * temp);
        }
        else
        {
          temp = x / y;
          result = y * (float) std::sqrt (1.0 + temp * temp);
        }
      }
    }

    return result;
  }

Definition at line 186 of file Complex.cpp.

Definition at line 237 of file Complex.cpp.

  {
    return imaginary_;
  }

Here is the caller graph for this function:

void nux::ComplexNumber::imaginary ( float  i)

Definition at line 247 of file Complex.cpp.

  {
    imaginary_ = i;
  }

Definition at line 222 of file Complex.cpp.

  {
    if ( (real_ == 0) && (imaginary_ == 0) )
    {
      return true;
    }

    return false;
  }
void nux::ComplexNumber::operator*= ( const ComplexNumber complex)

Definition at line 138 of file Complex.cpp.

  {
    ComplexNumber result;
    float a, b, c, d;

    a = real_;
    b = imaginary_;
    c = complex.real_;
    d = complex.imaginary_;

    real_ = (a * c - b * d);
    imaginary_ = (a * d + b * c);
  }
void nux::ComplexNumber::operator+= ( const ComplexNumber complex)

Definition at line 126 of file Complex.cpp.

  {
    real_ += complex.real_;
    imaginary_ += complex.imaginary_;
  }
void nux::ComplexNumber::operator-= ( const ComplexNumber complex)

Definition at line 132 of file Complex.cpp.

  {
    real_ -= complex.real_;
    imaginary_ -= complex.imaginary_;
  }
void nux::ComplexNumber::operator/= ( const ComplexNumber complex)

Definition at line 152 of file Complex.cpp.

  {
    ComplexNumber result;
    float a, b, c, d;
    float inv_denominator;

    //if(complex.real_ == 0 && complex.imaginary_ == 0)
    //    trow(Exeption);

    a = real_;
    b = imaginary_;
    c = complex.real_;
    d = complex.imaginary_;
    inv_denominator = (float) 1.0 / (c * c + d * d);

    real_ = (a * c + b * d) * inv_denominator;
    imaginary_ = (b * c - a * d) * inv_denominator;
  }
ComplexNumber & nux::ComplexNumber::operator= ( const ComplexNumber complex)

Definition at line 45 of file Complex.cpp.

  {
    real_ = complex.real_;
    imaginary_ = complex.imaginary_;

    return *this;
  }
float nux::ComplexNumber::real ( ) const

Definition at line 232 of file Complex.cpp.

  {
    return real_;
  }

Here is the caller graph for this function:

void nux::ComplexNumber::real ( float  r)

Definition at line 242 of file Complex.cpp.

  {
    real_ = r;
  }

Member Data Documentation

Definition at line 62 of file Complex.h.

float nux::ComplexNumber::real_ [private]

Definition at line 61 of file Complex.h.


The documentation for this class was generated from the following files: