#include <Complex.h>
Public Member Functions | |
| Complex () | |
| Default constructor. | |
| Complex (Real i) | |
| Construct Complex from real part. | |
| Complex (Real r, Real i) | |
| Construct Complex from real and imaginary. | |
| Real | r (Void) |
| Get the real part of Complex number as a Real. | |
| Real | i (Void) |
| Get the imaginary part of the Complex number as a Real. | |
| Void | r (Real r) |
| Set the real part of Complex number. | |
| Void | i (Real i) |
| Set the imaginary part of Complex number. | |
| Complex & | operator= (Const Real &x) |
| Asignment operator for Complex = Real. | |
| Bool | operator== (Const Complex &x) Const |
| Equality operator for Complex == Complex. | |
| Bool | operator!= (Const Complex &x) Const |
| Inquality operator for Complex != Complex. | |
| Bool | operator< (Const Complex &x) Const |
| Less-than operator for Complex < Complex. | |
| Bool | operator<= (Const Complex &x) Const |
| Less-than or equal operator for Complex < Complex. | |
| Bool | operator>= (Const Complex &x) Const |
| Greater-than or equal operator for Complex < Complex. | |
| Bool | operator> (Const Complex &x) Const |
| Greater-than operator for Complex < Complex. | |
| Complex | operator+ (Const Complex &c) |
| Addition operator for Complex + Complex. | |
| Complex | operator- (Const Complex &c) |
| Subtraction operator for Complex - Complex. | |
| Complex | operator- () |
| Negation operator for Complex. | |
| Complex | operator~ () |
| Conjugation operator for Complex. | |
| Complex | operator * (Const Complex &c) |
| Multiplication operator for Complex * Complex. | |
| Complex | operator * (Const Real &r) |
| Multiplication operator for Complex * Real. | |
| Complex | operator/ (Const Complex &c) |
| Division operator for Complex / Complex. | |
| Complex | operator/ (Const Real &r) |
| Division operator for Complex / Real. | |
| Complex & | operator+= (const Complex x) |
| Increment operator for Complex += Complex. | |
| Complex & | operator-= (const Complex x) |
| Decrement operator for Complex -= Complex. | |
| Complex & | operator *= (const Complex x) |
| Multiply scale operator for Complex *= Complex. | |
| Complex & | operator/= (const Complex x) |
| Divide scale operator for Complex /= Complex. | |
| Complex & | operator/= (const Real r) |
| Divide scale operator for Complex /= Real. | |
| Complex | Abs () |
| Complex absolute value. | |
| Complex | Conjugate () |
| Complex conjugate. | |
| Complex | Exp (Complex e) |
| Complex exponentiation. | |
| Void | print (String s=0) |
| Print complex value, prepended by String s if not null. | |
Friends | |
| ostream & | operator<< (ostream &os, const Complex &c) |
| Print to output stream. | |
| istream & | operator>> (istream &is, Complex &c) |
| Read from input stream. | |
Definition at line 28 of file Complex.h.
| Complex::Complex | ( | ) | [inline] |
Default constructor.
Definition at line 55 of file Complex.h.
Referenced by operator *(), operator+(), operator-(), operator/(), and operator~().
| Complex::Complex | ( | Real | i | ) | [inline] |
| Complex Complex::Abs | ( | ) | [inline] |
| Complex Complex::Conjugate | ( | ) | [inline] |
| Void Complex::i | ( | Real | i | ) | [inline] |
| Real Complex::i | ( | Void | ) | [inline] |
Get the imaginary part of the Complex number as a Real.
Definition at line 83 of file Complex.h.
References Return.
Referenced by Exp(), ImagPart(), and operator/().
00083 { 00084 Return m_i; 00085 }
| Complex Complex::operator- | ( | ) | [inline] |
Division operator for Complex / Complex.
Definition at line 167 of file Complex.h.
References Complex(), i(), r(), and Return.
00167 { 00168 Real modulus = c.m_r * c.m_r + c.m_i * c.m_i; 00169 Real r = m_i * c.m_i + m_r * c.m_r; 00170 Real i = m_i * c.m_r - m_r * c.m_i; 00171 00172 Return Complex(r / modulus, i / modulus); 00173 }
| Complex Complex::operator~ | ( | ) | [inline] |
| Void Complex::print | ( | String | s = 0 |
) | [inline] |
Print complex value, prepended by String s if not null.
Complex value is printed as "{r,i}".
| s | String to prefix to complex number. |
Definition at line 233 of file Complex.h.
References If.
00233 { 00234 If (s) 00235 cout << s; 00236 cout << "{ "; 00237 cout.precision(2); 00238 cout << m_r << ", "; 00239 cout << m_i; 00240 cout << " }" << endl; 00241 }
| Void Complex::r | ( | Real | r | ) | [inline] |
| Real Complex::r | ( | Void | ) | [inline] |
Get the real part of Complex number as a Real.
Definition at line 77 of file Complex.h.
References Return.
Referenced by Exp(), operator/(), and RealPart().
00077 { 00078 Return m_r; 00079 }
| ostream& operator<< | ( | ostream & | os, | |
| const Complex & | c | |||
| ) | [friend] |
Print to output stream.
Complex number is printed as '(' <real_part> ',' <imag_part> ')'
Definition at line 32 of file Complex.h.
00032 { 00033 cout << "("; 00034 // cout.precision(2); // Use this to set precision, if desired 00035 cout << c.m_r << ", "; 00036 cout << c.m_i; 00037 cout << ")"; 00038 Return os; 00039 }
| istream& operator>> | ( | istream & | is, | |
| Complex & | c | |||
| ) | [friend] |
Read from input stream.
Complex number is scanned as '{' <real_part> ',' <imag_part> '}' Alternately, parenthesis can be used to bracket complex number.
Definition at line 44 of file Complex.h.
00044 { 00045 char ch; 00046 is >> ch && (ch == '{' || ch == '(') 00047 && is >> c.m_r >> ch && ch == ',' 00048 && is >> c.m_i >> ch && (ch == '}' || ch == '('); 00049 Return is; 00050 }
1.4.7