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