complex.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef complex_H
00038 #define complex_H
00039
00040 #include "scalar.H"
00041 #include "bool.H"
00042 #include "word.H"
00043 #include "contiguous.H"
00044
00045
00046
00047 namespace Foam
00048 {
00049
00050
00051
00052 class complex;
00053
00054 inline scalar magSqr(const complex&);
00055 inline complex sqr(const complex&);
00056 inline scalar mag(const complex&);
00057 inline const complex& max(const complex&, const complex&);
00058 inline const complex& min(const complex&, const complex&);
00059 inline complex limit(const complex&, const complex&);
00060 inline const complex& sum(const complex&);
00061 inline complex operator+(const complex&, const complex&);
00062 inline complex operator-(const complex&);
00063 inline complex operator-(const complex&, const complex&);
00064 inline complex operator*(const complex&, const complex&);
00065 inline complex operator/(const complex&, const complex&);
00066 inline complex operator*(const scalar, const complex&);
00067 inline complex operator*(const complex&, const scalar);
00068 inline complex operator/(const complex&, const scalar);
00069 inline complex operator/(const scalar, const complex&);
00070 Istream& operator>>(Istream&, complex&);
00071 Ostream& operator<<(Ostream&, const complex&);
00072
00073
00074
00075
00076
00077
00078 class complex
00079 {
00080
00081
00082
00083 scalar re, im;
00084
00085 public:
00086
00087
00088 typedef complex cmptType;
00089
00090
00091
00092
00093 static const char* const typeName;
00094
00095 static const complex zero;
00096 static const complex one;
00097
00098
00099
00100
00101
00102 inline complex();
00103
00104
00105 inline complex(const scalar Re, const scalar Im);
00106
00107
00108 complex(Istream&);
00109
00110
00111
00112
00113
00114
00115 inline scalar Re() const;
00116 inline scalar Im() const;
00117
00118
00119
00120 inline scalar& Re();
00121 inline scalar& Im();
00122
00123
00124
00125 inline complex conjugate() const;
00126
00127
00128
00129
00130 inline const complex& operator=(const complex&);
00131 inline void operator+=(const complex&);
00132 inline void operator-=(const complex&);
00133 inline void operator*=(const complex&);
00134 inline void operator/=(const complex&);
00135
00136 inline const complex& operator=(const scalar);
00137 inline void operator+=(const scalar);
00138 inline void operator-=(const scalar);
00139 inline void operator*=(const scalar);
00140 inline void operator/=(const scalar);
00141
00142 inline complex operator!() const;
00143
00144 inline bool operator==(const complex&) const;
00145 inline bool operator!=(const complex&) const;
00146
00147
00148
00149
00150 friend scalar magSqr(const complex& c);
00151 friend complex sqr(const complex& c);
00152 friend scalar mag(const complex& c);
00153 friend const complex& max(const complex&, const complex&);
00154 friend const complex& min(const complex&, const complex&);
00155
00156 friend complex limit(const complex&, const complex&);
00157
00158 friend const complex& sum(const complex&);
00159
00160
00161
00162
00163 friend complex operator+(const complex&, const complex&);
00164 friend complex operator-(const complex&);
00165 friend complex operator-(const complex&, const complex&);
00166 friend complex operator*(const complex&, const complex&);
00167 friend complex operator/(const complex&, const complex&);
00168
00169 friend complex operator*(const scalar, const complex&);
00170 friend complex operator*(const complex&, const scalar);
00171 friend complex operator/(const complex&, const scalar);
00172 friend complex operator/(const scalar, const complex&);
00173
00174
00175
00176
00177 friend Istream& operator>>(Istream&, complex&);
00178 friend Ostream& operator<<(Ostream&, const complex&);
00179
00180 };
00181
00182
00183
00184
00185
00186 word name(const complex&);
00187
00188
00189
00190 template<>
00191 inline bool contiguous<complex>() {return true;}
00192
00193
00194
00195
00196 }
00197
00198
00199
00200 #include "complexI.H"
00201
00202
00203
00204 #endif
00205
00206
Copyright © 2000-2009 OpenCFD Ltd