#include <HxComplex.h>
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 | |
| 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 | |
| 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 | |
| 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) |
|
|
Default constructor.
00330 {
00331 }
|
|
||||||||||||
|
Conversion from native type.
00335 {
00336 _values[0] = re;
00337 _values[1] = im;
00338 }
|
|
|
Copy constructor.
|
|
|
Dimensionality.
00363 {
00364 return 2;
00365 }
|
|
|
Real Value.
00369 {
00370 return _values[0];
00371 }
|
|
|
Imaginary Value.
00375 {
00376 return _values[1];
00377 }
|
|
|
Element in given dimension.
00381 {
00382 return _values[dim - 1];
00383 }
|
|
|
Cast to HxScalarInt.
00027 {
00028 return (int) _values[0];
00029 }
|
|
|
Cast to HxScalarDouble.
00032 {
00033 return _values[0];
00034 }
|
|
|
Cast to HxVec2Int.
00037 {
00038 return HxVec2Int(int(_values[0]), int(_values[1]));
00039 }
|
|
|
Cast to HxVec2Double.
00042 {
00043 return HxVec2Int(_values[0], _values[1]);
00044 }
|
|
|
Cast to HxVec3Int.
00047 {
00048 return HxVec3Int(int(_values[0]), int(_values[1]), 0);
00049 }
|
|
|
Cast to HxVec3Double.
00052 {
00053 return HxVec3Double(_values[0], _values[1], 0);
00054 }
|
|
|
Equal.
|
|
|
Not equal.
|
|
|
Less than.
|
|
|
Less equal.
|
|
|
Greater than.
|
|
|
Greater equal.
|
|
|
Negation.
00433 {
00434 return HxComplex(-_values[0], -_values[1]);
00435 }
|
|
|
Complement.
00439 {
00440 return HxComplex(-_values[0], -_values[1]);
00441 }
|
|
|
Conjugate.
00445 {
00446 return HxComplex(_values[0], -_values[1]);
00447 }
|
|
|
Absolute value.
00451 {
00452 return HxScalarDouble(::sqrt(_values[0]*_values[0]+_values[1]*_values[1]));
00453 }
|
|
|
Argument.
00457 {
00458 return HxScalarDouble(::atan2(_values[1], _values[0]));
00459 }
|
|
|
Ceiling.
|
|
|
Floor.
|
|
|
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 }
|
|
|
Sum.
00798 {
00799 return *this;
00800 }
|
|
|
Product.
00804 {
00805 return *this;
00806 }
|
|
|
Minimum.
00810 {
00811 return (_values[0] < _values[1]) ? _values[0] : _values[1];
00812 }
|
|
|
Maximum.
00816 {
00817 return (_values[0] > _values[1]) ? _values[0] : _values[1];
00818 }
|
|
|
L1 norm.
00058 {
00059 return fabs(_values[0]) + fabs(_values[1]);
00060 }
|
|
|
L2 norm.
00064 {
00065 return ::sqrt(_values[0]*_values[0] + _values[1]*_values[1]);
00066 }
|
|
|
L infinity norm.
00070 {
00071 return (fabs(_values[0]) > fabs(_values[1])) ? fabs(_values[0]) :
00072 fabs(_values[1]);
00073 }
|
|
|
Square root.
|
|
|
Sine.
|
|
|
Cosine.
|
|
|
Tangent.
|
|
|
Arc sine.
|
|
|
Arc cosine.
|
|
|
Arc tangent.
|
|
|
Arc tangent.
|
|
|
Hyperbolic sine.
|
|
|
Hyperbolic cosine.
|
|
|
Hyperbolic tangent.
|
|
|
Exponent.
|
|
|
Natural logarithm.
|
|
|
Base 10 logarithm.
|
|
|
Addition and assignment.
|
|
|
Subtraction and assignment.
|
|
|
Multiplication and assignment.
|
|
|
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 }
|
|
|
Minimum.
00679 {
00680 return (operator<(v)) ? (*this) : v;
00681 }
|
|
|
Minimum and assignment.
00685 {
00686 if (operator<(v))
00687 return *this;
00688 operator=(v);
00689 return *this;
00690 }
|
|
|
Maximum.
00694 {
00695 return (operator>(v)) ? (*this) : v;
00696 }
|
|
|
Maximum and assignment.
00700 {
00701 if (operator>(v))
00702 return *this;
00703 operator=(v);
00704 return *this;
00705 }
|
|
|
Infimum.
|
|
|
Infimum and assignment.
|
|
|
Supremum.
|
|
|
Supremum and assignment.
|
|
|
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 }
|
|
|
Modulo.
00756 {
00757 return (*this);
00758 }
|
|
|
And.
00762 {
00763 return (*this);
00764 }
|
|
|
Or.
00768 {
00769 return (*this);
00770 }
|
|
|
Xor.
00774 {
00775 return (*this);
00776 }
|
|
|
Left shift.
00780 {
00781 return (*this);
00782 }
|
|
|
Right shift.
00786 {
00787 return (*this);
00788 }
|
|
|
Dot product.
|
|
|
Cross product.
00792 {
00793 return HxComplex(0, 0);
00794 }
|
|
|
Print value on stream. For global operator<<
00096 {
00097 return os << _values[0] << (_values[1]>=0 ? "+":"") << _values[1] << "i";
00098 }
|
|
|
Value as a string.
00101 {
00102 return makeString(_values[0]) + (_values[1]>=0 ? "+" : "")
00103 + makeString(_values[1]) + "i";
00104 }
|
|
||||||||||||
|
Addition.
|
|
||||||||||||
|
Subtraction.
|
|
||||||||||||
|
Multiplication.
|
|
||||||||||||
|
Division.
|
|
|
A small value w.r.t to the comparison operators "<" and ">". Not actually the minimum to avoid overflow. |
|
|
A large value w.r.t to the comparison operators "<" and ">". Not actually the maximum to avoid overflow. |
1.2.12 written by Dimitri van Heesch,
© 1997-2001