 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
14 #undef Complex // Complex is defined in X.h
22 template <
typename Type>
29 Complex(
const Type r,
const Type i) : re(r),im(i) {}
82 Type d = (double)c.re*c.re + (
double)c.im*c.im;
84 *
this = (*
this * cc)/d;
92 double d = (double)c.re*c.re + (
double)c.im*c.im;
94 return (*
this * cc)/d;
103 double power() {
return (
double)re*re + (double)im*im; }
104 double amp() {
return sqrt((
double)re*re + (
double)im*im); }
105 double phi() {
return atan2((
double)im, (
double)re); }
107 void set(
const double a,
const double p) { re = a*cos(p); im = a*sin(p); }
108 void real(
const Type d) { re = d; }
109 void imag(
const Type d) { im = d; }
110 void amp(
const double d) { Type r = d/
amp(); re *= r; im *= r; }
111 void phi(
const double d) { Type a = amp(); re = a*cos(d); im = a*sin(d); }
121 template <
typename Type>
123 output.setf(ios::fixed, ios::floatfield);
125 output <<
"{" << c.
real() <<
"," << c.
imag() <<
"}";
129 template <
typename Type>
135 template <
typename Type>
138 return (c1 + c2.
conj()) * 0.5;
141 template <
typename Type>
Complex operator*(const Complex &c)
Complex operator/=(const double d)
Complex operator+=(const Complex &c)
Complex operator*=(const double d)
Complex operator+(const Complex &c)
Complex operator/=(const Complex &c)
Complex operator*=(const Complex &c)
void set(const double a, const double p)
void shift_phi(const double d)
Complex operator/(const double d)
Complex operator-(const Complex &c)
ostream & operator<<(ostream &output, Complex< Type > &c)
Complex operator*(const double d)
Complex< Type > complex_unpack_combined_first(Complex< Type > c1, Complex< Type > c2)
Type & operator[](const int i)
Complex operator/(const Complex &c)
Complex unpack_first(Complex c)
bool isfinite(complex< T > &value)
Complex operator=(const Complex &c)
Complex unpack_second(Complex c)
Complex< Type > complex_unpack_combined_second(Complex< Type > c1, Complex< Type > c2)
Complex operator=(const double &d)
Complex(const Type r, const Type i)
Complex operator-=(const Complex &c)
Complex< Type > operator*(const double d, Complex< Type > &c)
Complex(const Complex &c)