Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxComplex Class Reference

Class definition complex. More...

#include <HxComplex.h>

List of all members.

Constructors

 HxComplex ()
 Default constructor. More...

 HxComplex (double re, double im)
 Conversion from native type. More...

 HxComplex (const HxComplex &rhs)
 Copy constructor. More...


Inquiry

int dim () const
 Dimensionality. More...

double x () const
 Real Value. More...

double y () const
 Imaginary Value. More...

double getValue (int dimension) const
 Element in given dimension. More...

void setValue (int dimension, double value)

Conversion

 operator HxScalarInt () const
 Cast to HxScalarInt. More...

 operator HxScalarDouble () const
 Cast to HxScalarDouble. More...

 operator HxVec2Int () const
 Cast to HxVec2Int. More...

 operator HxVec2Double () const
 Cast to HxVec2Double. More...

 operator HxVec3Int () const
 Cast to HxVec3Int. More...

 operator HxVec3Double () const
 Cast to HxVec3Double. More...


Operators

Mathematical definition: Binary operations on pixel values

int operator== (const HxComplex &v) const
 Equal. More...

int operator!= (const HxComplex &v) const
 Not equal. More...

int operator< (const HxComplex &v) const
 Less than. More...

int operator<= (const HxComplex &v) const
 Less equal. More...

int operator> (const HxComplex &v) const
 Greater than. More...

int operator>= (const HxComplex &v) const
 Greater equal. More...

const HxComplex SMALL_VAL = HxComplex(0, 0)
 A small value w.r.t to the comparison operators "<" and ">". More...

const HxComplex LARGE_VAL = HxComplex(1e300, 1e300)
 A large value w.r.t to the comparison operators "<" and ">". More...


Unary operations

Mathematical definition: Unary operations on pixel values

HxComplex operator- () const
 Negation. More...

HxComplex complement () const
 Complement. More...

HxComplex conjugate () const
 Conjugate. More...

HxScalarDouble abs () const
 Absolute value. More...

HxScalarDouble arg () const
 Argument. More...

HxComplex ceil () const
 Ceiling. More...

HxComplex floor () const
 Floor. More...

HxComplex round () const
 Round. More...

HxComplex sum () const
 Sum. More...

HxComplex product () const
 Product. More...

HxScalarDouble min () const
 Minimum. More...

HxScalarDouble max () const
 Maximum. More...

HxScalarDouble norm1 () const
 L1 norm. More...

HxScalarDouble norm2 () const
 L2 norm. More...

HxScalarDouble normInf () const
 L infinity norm. More...

HxComplex sqrt () const
 Square root. More...

HxComplex sin () const
 Sine. More...

HxComplex cos () const
 Cosine. More...

HxComplex tan () const
 Tangent. More...

HxComplex asin () const
 Arc sine. More...

HxComplex acos () const
 Arc cosine. More...

HxComplex atan () const
 Arc tangent. More...

HxComplex atan2 () const
 Arc tangent. More...

HxComplex sinh () const
 Hyperbolic sine. More...

HxComplex cosh () const
 Hyperbolic cosine. More...

HxComplex tanh () const
 Hyperbolic tangent. More...

HxComplex exp () const
 Exponent. More...

HxComplex log () const
 Natural logarithm. More...

HxComplex log10 () const
 Base 10 logarithm. More...


Binary operations

Mathematical definition: Binary operations on pixel values

HxComplex & operator+= (const HxComplex &v)
 Addition and assignment. More...

HxComplex & operator-= (const HxComplex &v)
 Subtraction and assignment. More...

HxComplex & operator *= (const HxComplex &v)
 Multiplication and assignment. More...

HxComplex & operator/= (const HxComplex &v)
 Division and assignment. More...

HxComplex min (const HxComplex &v) const
 Minimum. More...

HxComplex & minAssign (const HxComplex &v)
 Minimum and assignment. More...

HxComplex max (const HxComplex &v) const
 Maximum. More...

HxComplex & maxAssign (const HxComplex &v)
 Maximum and assignment. More...

HxComplex inf (const HxComplex &v) const
 Infimum. More...

HxComplex & infAssign (const HxComplex &v)
 Infimum and assignment. More...

HxComplex sup (const HxComplex &v) const
 Supremum. More...

HxComplex & supAssign (const HxComplex &v)
 Supremum and assignment. More...

HxComplex pow (const HxComplex &v) const
 Power. More...

HxComplex mod (const HxComplex &v) const
 Modulo. More...

HxComplex and (const HxComplex &v) const
 And. More...

HxComplex or (const HxComplex &v) const
 Or. More...

HxComplex xor (const HxComplex &v) const
 Xor. More...

HxComplex leftShift (const HxComplex &v) const
 Left shift. More...

HxComplex rightShift (const HxComplex &v) const
 Right shift. More...

HxScalarDouble dot (const HxComplex &v) const
 Dot product. More...

HxComplex cross (const HxComplex &v) const
 Cross product. More...

HxComplex operator+ (const HxComplex &v1, const HxComplex &v2)
 Addition. More...

HxComplex operator- (const HxComplex &v1, const HxComplex &v2)
 Subtraction. More...

HxComplex operator * (const HxComplex &v1, const HxComplex &v2)
 Multiplication. More...

HxComplex operator/ (const HxComplex &v1, const HxComplex &v2)
 Division. More...


Output

STD_OSTREAM & put (STD_OSTREAM &os) const
 Print value on stream. More...

HxString toString () const
 Value as a string. More...


Public Methods

void * operator new (size_t, void *=0)
HxComplex & operator= (const HxComplex &rhs)


Detailed Description

Class definition complex.


Constructor & Destructor Documentation

HxComplex::HxComplex   [inline]
 

Default constructor.

00330 { 
00331 }

HxComplex::HxComplex double    re,
double    im
[inline]
 

Conversion from native type.

00335 {
00336     _values[0] = re;
00337     _values[1] = im;
00338 }

HxComplex::HxComplex const HxComplex &    v [inline]
 

Copy constructor.

00342 {
00343     _values[0] = v._values[0];
00344     _values[1] = v._values[1];
00345 }


Member Function Documentation

int HxComplex::dim   const [inline]
 

Dimensionality.

00363 { 
00364     return 2;
00365 }

double HxComplex::x   const [inline]
 

Real Value.

00369 { 
00370     return _values[0];
00371 }

double HxComplex::y   const [inline]
 

Imaginary Value.

00375 { 
00376     return _values[1]; 
00377 }

double HxComplex::getValue int    dim const [inline]
 

Element in given dimension.

00381 { 
00382     return _values[dim - 1]; 
00383 }

HxComplex::operator HxScalarInt   const
 

Cast to HxScalarInt.

00027 {
00028     return (int) _values[0];
00029 }

HxComplex::operator HxScalarDouble   const
 

Cast to HxScalarDouble.

00032 {
00033     return _values[0];
00034 }

HxComplex::operator HxVec2Int   const
 

Cast to HxVec2Int.

00037 {
00038     return HxVec2Int(int(_values[0]), int(_values[1]));
00039 }

HxComplex::operator HxVec2Double   const
 

Cast to HxVec2Double.

00042 {
00043     return HxVec2Int(_values[0], _values[1]);
00044 }

HxComplex::operator HxVec3Int   const
 

Cast to HxVec3Int.

00047 {
00048     return HxVec3Int(int(_values[0]), int(_values[1]), 0);
00049 }

HxComplex::operator HxVec3Double   const
 

Cast to HxVec3Double.

00052 {
00053     return HxVec3Double(_values[0], _values[1], 0);
00054 }

int HxComplex::operator== const HxComplex &    v const [inline]
 

Equal.

00393 {
00394     return (_values[0] == v._values[0]) && (_values[1] == v._values[1]);
00395 }

int HxComplex::operator!= const HxComplex &    v const [inline]
 

Not equal.

00399 {
00400     return (_values[0] != v._values[0]) || (_values[1] != v._values[1]);
00401 }

int HxComplex::operator< const HxComplex &    v const [inline]
 

Less than.

00405 {
00406     return (fabs(_values[0]) + fabs(_values[1])) <
00407            (fabs(v._values[0]) + fabs(v._values[1]));
00408 }

int HxComplex::operator<= const HxComplex &    v const [inline]
 

Less equal.

00412 {
00413     return (fabs(_values[0]) + fabs(_values[1])) <=
00414            (fabs(v._values[0]) + fabs(v._values[1]));
00415 }

int HxComplex::operator> const HxComplex &    v const [inline]
 

Greater than.

00419 {
00420     return (fabs(_values[0]) + fabs(_values[1])) >
00421            (fabs(v._values[0]) + fabs(v._values[1]));
00422 }

int HxComplex::operator>= const HxComplex &    v const [inline]
 

Greater equal.

00426 {
00427     return (fabs(_values[0]) + fabs(_values[1])) >=
00428            (fabs(v._values[0]) + fabs(v._values[1]));
00429 }

HxComplex HxComplex::operator-   const [inline]
 

Negation.

00433 {
00434     return HxComplex(-_values[0], -_values[1]);
00435 }

HxComplex HxComplex::complement   const [inline]
 

Complement.

00439 {
00440     return HxComplex(-_values[0], -_values[1]);
00441 }

HxComplex HxComplex::conjugate   const [inline]
 

Conjugate.

00445 {
00446     return HxComplex(_values[0], -_values[1]);
00447 }

HxScalarDouble HxComplex::abs   const [inline]
 

Absolute value.

00451 {
00452     return HxScalarDouble(::sqrt(_values[0]*_values[0]+_values[1]*_values[1]));
00453 }

HxScalarDouble HxComplex::arg   const [inline]
 

Argument.

00457 {
00458     return HxScalarDouble(::atan2(_values[1], _values[0]));
00459 }

HxComplex HxComplex::ceil   const [inline]
 

Ceiling.

00463 {
00464     return HxComplex(::ceil(_values[0]), ::ceil(_values[1]));
00465 }

HxComplex HxComplex::floor   const [inline]
 

Floor.

00469 {
00470     return HxComplex(::floor(_values[0]), ::floor(_values[1]));
00471 }

HxComplex HxComplex::round   const [inline]
 

Round.

00475 {
00476     return HxComplex((int) (_values[0] + ((_values[0] >= 0) ? 0.5 : -0.5)),
00477                         (int) (_values[1] + ((_values[1] >= 0) ? 0.5 : -0.5)));
00478 }

HxComplex HxComplex::sum   const [inline]
 

Sum.

00798 {
00799     return *this;
00800 }

HxComplex HxComplex::product   const [inline]
 

Product.

00804 {
00805     return *this;
00806 }

HxScalarDouble HxComplex::min   const [inline]
 

Minimum.

00810 {
00811     return (_values[0] < _values[1]) ? _values[0] : _values[1];
00812 }

HxScalarDouble HxComplex::max   const [inline]
 

Maximum.

00816 {
00817     return (_values[0] > _values[1]) ? _values[0] : _values[1];
00818 }

HxScalarDouble HxComplex::norm1   const
 

L1 norm.

00058 {
00059     return fabs(_values[0]) + fabs(_values[1]);
00060 }

HxScalarDouble HxComplex::norm2   const
 

L2 norm.

00064 {
00065     return ::sqrt(_values[0]*_values[0] + _values[1]*_values[1]);
00066 }

HxScalarDouble HxComplex::normInf   const
 

L infinity norm.

00070 {
00071     return (fabs(_values[0]) > fabs(_values[1])) ? fabs(_values[0]) :
00072                                                    fabs(_values[1]);
00073 }

HxComplex HxComplex::sqrt   const [inline]
 

Square root.

00482 {
00483     double a = _values[0];
00484     double b = _values[1];
00485     double sq = a*a+b*b;
00486     double arg = ::atan(b/a)*0.5;
00487     double mul = ::pow(sq, 0.25)*::exp(a*0.5);
00488 
00489     return HxComplex(mul*::cos(arg), mul*::sin(arg));
00490 }

HxComplex HxComplex::sin   const [inline]
 

Sine.

00494 {
00495     return HxComplex(::sin(_values[0])*::cosh(_values[1]),
00496         ::cos(_values[0])*::sinh(_values[1]));
00497 }

HxComplex HxComplex::cos   const [inline]
 

Cosine.

00501 {
00502     return HxComplex(::cos(_values[0])*::cosh(_values[1]),
00503         -::sin(_values[0])*::sinh(_values[1]));
00504 }

HxComplex HxComplex::tan   const [inline]
 

Tangent.

00508 {
00509     double den = ::cos(2*_values[0])+::cosh(2*_values[1]);
00510 
00511     return HxComplex(::sin(2*_values[0])/den, ::sinh(2*_values[1])/den);
00512 }

HxComplex HxComplex::asin   const [inline]
 

Arc sine.

00516 {
00517     double a = _values[0];
00518     double b = _values[1];
00519 
00520     HxComplex c = HxComplex(1-a*a+b*b, 2*a*b).sqrt() + HxComplex(-b,a);
00521 
00522     return HxComplex(c.arg().x(), -::log(c.abs().x()));
00523 }

HxComplex HxComplex::acos   const [inline]
 

Arc cosine.

00527 {
00528     double a = _values[0];
00529     double b = _values[1];
00530 
00531     HxComplex c = HxComplex(1-a*a+b*b, 2*a*b).sqrt() + HxComplex(-b,a);
00532 
00533     return HxComplex(M_PI/2.0 - c.arg().x(), ::log(c.abs().x()));
00534 }

HxComplex HxComplex::atan   const [inline]
 

Arc tangent.

00538 {
00539     double a = _values[0];
00540     double b = _values[1];
00541 
00542     HxComplex cp = HxComplex(1-b,a);
00543     HxComplex cm = HxComplex(1+b,-a);
00544 
00545     return HxComplex(0.5*(cp.arg().x()-cm.arg().x()),
00546         0.5*(::log(cm.abs().x())-::log(cp.abs().x())));
00547 }

HxComplex HxComplex::atan2   const
 

Arc tangent.

00077 {   
00078     double a = _values[0];
00079     double b = _values[1];
00080 
00081     HxComplex cp = HxComplex(1-b,a);
00082     HxComplex cm = HxComplex(1+b,-a);
00083 
00084     return HxComplex(0.5*(cp.arg().x()-cm.arg().x()),
00085         0.5*(::log(cm.abs().x())-::log(cp.abs().x())));
00086 }

HxComplex HxComplex::sinh   const [inline]
 

Hyperbolic sine.

00551 {
00552     return HxComplex(::sinh(_values[0])*::cos(_values[1]),
00553         ::cosh(_values[0])*::sin(_values[1]));
00554 }

HxComplex HxComplex::cosh   const [inline]
 

Hyperbolic cosine.

00558 {
00559     return HxComplex(::cosh(_values[0])*::cos(_values[1]),
00560         ::sinh(_values[0])*::sin(_values[1]));
00561 }

HxComplex HxComplex::tanh   const [inline]
 

Hyperbolic tangent.

00565 {
00566     double den = ::cosh(2*_values[0])+::cos(2*_values[1]);
00567 
00568     return HxComplex(::sinh(2*_values[0])/den, ::sin(2*_values[1])/den);
00569 }

HxComplex HxComplex::exp   const [inline]
 

Exponent.

00573 {
00574     double ea = ::exp(_values[0]);
00575     return HxComplex(::cos(_values[1])*ea, ::sin(_values[1])*ea);
00576 }

HxComplex HxComplex::log   const [inline]
 

Natural logarithm.

00580 {
00581     double re = _values[0];
00582     double im = _values[1];
00583     double mag = ::sqrt(re*re+im*im);
00584 
00585     return HxComplex(::log(mag), ::atan(re/im));
00586 }

HxComplex HxComplex::log10   const [inline]
 

Base 10 logarithm.

00592 {
00593     double re = _values[0];
00594     double im = _values[1];
00595     double mag = ::sqrt(re*re+im*im);
00596 
00597     return HxComplex(::log(mag)*theLog10, ::atan(re/im)*theLog10);
00598 }

HxComplex & HxComplex::operator+= const HxComplex &    v [inline]
 

Addition and assignment.

00602 {
00603     _values[0] += v._values[0];
00604     _values[1] += v._values[1];
00605     return *this;
00606 }

HxComplex & HxComplex::operator-= const HxComplex &    v [inline]
 

Subtraction and assignment.

00610 {
00611     _values[0] -= v._values[0];
00612     _values[1] -= v._values[1];
00613     return *this;
00614 }

HxComplex & HxComplex::operator *= const HxComplex &    v [inline]
 

Multiplication and assignment.

00618 {
00619     double re = _values[0]*v._values[0] - _values[1]*v._values[1];
00620     double im = _values[0]*v._values[1] + _values[1]*v._values[0];
00621     _values[0] = re;
00622     _values[1] = im;
00623     return *this;
00624 }

HxComplex & HxComplex::operator/= const HxComplex &    v [inline]
 

Division and assignment.

00628 {
00629     double re = v._values[0];
00630     double im = v._values[1];
00631     double sq = re*re+im*im;
00632 
00633     double mulre = _values[0]*re + _values[1]*im;
00634     double mulim = _values[1]*re - _values[0]*im;
00635     _values[0] = mulre / sq;
00636     _values[1] = mulim / sq;
00637 
00638     return *this;
00639 }

HxComplex HxComplex::min const HxComplex &    v const [inline]
 

Minimum.

00679 {
00680     return (operator<(v)) ? (*this) : v;
00681 }

HxComplex & HxComplex::minAssign const HxComplex &    v [inline]
 

Minimum and assignment.

00685 {
00686     if (operator<(v))
00687         return *this;
00688     operator=(v);
00689     return *this;
00690 }

HxComplex HxComplex::max const HxComplex &    v const [inline]
 

Maximum.

00694 {
00695     return (operator>(v)) ? (*this) : v;
00696 }

HxComplex & HxComplex::maxAssign const HxComplex &    v [inline]
 

Maximum and assignment.

00700 {
00701     if (operator>(v))
00702         return *this;
00703     operator=(v);
00704     return *this;
00705 }

HxComplex HxComplex::inf const HxComplex &    v const [inline]
 

Infimum.

00709 {
00710     return HxComplex((_values[0] < v._values[0]) ? _values[0] : v._values[0],
00711                        (_values[1] < v._values[1]) ? _values[1] : v._values[1]);
00712 }

HxComplex & HxComplex::infAssign const HxComplex &    v [inline]
 

Infimum and assignment.

00716 {
00717     _values[0] = (_values[0] < v._values[0]) ? _values[0] : v._values[0];
00718     _values[1] = (_values[1] < v._values[1]) ? _values[1] : v._values[1];
00719     return *this;
00720 }

HxComplex HxComplex::sup const HxComplex &    v const [inline]
 

Supremum.

00724 {
00725     return HxComplex((_values[0] > v._values[0]) ? _values[0] : v._values[0],
00726                        (_values[1] > v._values[1]) ? _values[1] : v._values[1]);
00727 }

HxComplex & HxComplex::supAssign const HxComplex &    v [inline]
 

Supremum and assignment.

00731 {
00732     _values[0] = (_values[0] > v._values[0]) ? _values[0] : v._values[0];
00733     _values[1] = (_values[1] > v._values[1]) ? _values[1] : v._values[1];
00734     return *this;
00735 }

HxComplex HxComplex::pow const HxComplex &    v const [inline]
 

Power.

00739 {
00740     if (v._values[1] == 0) {
00741         double a = _values[0];
00742         double b = _values[1];
00743         double c = v._values[0];
00744         double sq = a*a+b*b;
00745         double arg = ::atan(b/a)*c;
00746         double mul = ::pow(sq, c/2)*::exp(a*c);
00747 
00748         return HxComplex(mul*::cos(arg), mul*::sin(arg));
00749     }
00750 
00751     return (v * (*this).log()).exp();
00752 }

HxComplex HxComplex::mod const HxComplex &    v const [inline]
 

Modulo.

00756 {
00757     return (*this);
00758 }

HxComplex HxComplex::and const HxComplex &    v const [inline]
 

And.

00762 {
00763     return (*this);
00764 }

HxComplex HxComplex::or const HxComplex &    v const [inline]
 

Or.

00768 {
00769     return (*this);
00770 }

HxComplex HxComplex::xor const HxComplex &    v const [inline]
 

Xor.

00774 {
00775     return (*this);
00776 }

HxComplex HxComplex::leftShift const HxComplex &    v const [inline]
 

Left shift.

00780 {
00781     return (*this);
00782 }

HxComplex HxComplex::rightShift const HxComplex &    v const [inline]
 

Right shift.

00786 {
00787     return (*this);
00788 }

HxScalarDouble HxComplex::dot const HxComplex &    v const
 

Dot product.

00090 {
00091     return (_values[0] * v._values[0]) + (_values[1] * v._values[1]);
00092 }

HxComplex HxComplex::cross const HxComplex &    v const [inline]
 

Cross product.

00792 {
00793     return HxComplex(0, 0);
00794 }

STD_OSTREAM & HxComplex::put STD_OSTREAM &    os const
 

Print value on stream.

For global operator<<

00096 {
00097     return os << _values[0] << (_values[1]>=0 ? "+":"") << _values[1] << "i";
00098 }

HxString HxComplex::toString   const
 

Value as a string.

00101                           {
00102     return makeString(_values[0]) + (_values[1]>=0 ? "+" : "")
00103             + makeString(_values[1]) + "i";
00104 }


Friends And Related Function Documentation

HxComplex operator+ const HxComplex &    v1,
const HxComplex &    v2
[friend]
 

Addition.

00643 {
00644     return HxComplex(v1._values[0] + v2._values[0],
00645                         v1._values[1] + v2._values[1]);
00646 }

HxComplex operator- const HxComplex &    v1,
const HxComplex &    v2
[friend]
 

Subtraction.

00650 {
00651     return HxComplex(v1._values[0] - v2._values[0],
00652                         v1._values[1] - v2._values[1]);
00653 }

HxComplex operator * const HxComplex &    v1,
const HxComplex &    v2
[friend]
 

Multiplication.

00657 {
00658     double re = v1._values[0]*v2._values[0] - v1._values[1]*v2._values[1];
00659     double im = v1._values[0]*v2._values[1] + v1._values[1]*v2._values[0];
00660 
00661     return HxComplex(re, im);
00662 }

HxComplex operator/ const HxComplex &    v1,
const HxComplex &    v2
[friend]
 

Division.

00666 {
00667     double re = v2._values[0];
00668     double im = v2._values[1];
00669     double sq = re*re+im*im;
00670 
00671     double mulre = v1._values[0]*re + v1._values[1]*im;
00672     double mulim = v1._values[1]*re - v1._values[0]*im;
00673 
00674     return HxComplex(mulre / sq, mulim / sq);
00675 }


Member Data Documentation

const HxComplex HxComplex::SMALL_VAL = HxComplex(0, 0) [static]
 

A small value w.r.t to the comparison operators "<" and ">".

Not actually the minimum to avoid overflow.

const HxComplex HxComplex::LARGE_VAL = HxComplex(1e300, 1e300) [static]
 

A large value w.r.t to the comparison operators "<" and ">".

Not actually the maximum to avoid overflow.


The documentation for this class was generated from the following files:
Generated on Mon Jan 27 15:48:58 2003 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001