00001
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TBCI_CPLX_H
00014 #define TBCI_CPLX_H
00015
00016 #include "basics.h"
00017 #ifndef TBCI_CPLX_DONT_INCLUDE_CONSTANTS
00018 # include "constants.h"
00019 #endif
00020
00021 #ifdef PRAGMA_I
00022 # pragma interface "cplx.h"
00023 #endif
00024
00025
00026 #if defined(__GNUC__) && defined (USE_BUILTIN_CPLX)
00027 # include "builtin_cplx.h"
00028 #endif
00029
00030 #ifndef CPLX
00031 # define CPLX(t) cplx<t>
00032 # define CPLXR(t,a,r) cplx<t> a (r)
00033 # define CPLXRI(t,a,r,i) cplx<t> a (r,i)
00034 # define CPLXC(t,a,c) cplx<t> a (c)
00035 # define CPLXVRI(t,r,i) (cplx<t>(r,i))
00036 #endif
00037
00038 #if !defined(NO_GD) && !defined(AUTO_DECL)
00039 # include "cplx_gd.h"
00040 #endif
00041
00042
00043
00044 NAMESPACE_TBCI
00045
00046
00047
00048 template <typename T> class cplx;
00049
00054 template <typename T>
00055 class cplx
00056 {
00057 protected:
00058 #ifdef CPLX_NEED_PUBLIC
00059 public:
00060 #endif
00061 T re ALIGN(MIN_ALIGN), im;
00062
00063 public:
00064
00065 typedef T value_type;
00066 typedef T aligned_value_type TALIGN(MIN_ALIGN);
00067 typedef T cplx_base;
00068 typedef cplx<T> cplx_t;
00069
00070
00071 cplx () {}
00072 cplx (const T r, const T i = (T)0) : re(r), im(i) {}
00073 cplx (const cplx<T>& c) : re(c.re), im(c.im) {}
00074
00075 #ifndef HAVE_PROMOTION_BUG
00076
00077 # ifndef HAVE_GCC295_TMPLFRNDCLS_BUG
00078 template <typename U> friend class cplx;
00079 template <typename U> explicit cplx (const cplx<U>& c) : re(c.re), im(c.im) {}
00080 # else
00081 template <typename U> explicit cplx (const cplx<U>& c) : re(c.real()), im(c.imag()) {}
00082 # endif
00083 #endif
00084
00085 ~cplx () {}
00086
00087
00088
00089 cplx<T>& operator = (const T r) { re = r; im = (T)0; return *this; }
00090 cplx<T>& operator = (const cplx<T>& c)
00091 { re = c.re; im = c.im; return *this; }
00092
00093
00094 cplx<T>& operator += (const T);
00095 cplx<T>& operator += (const cplx<T>&);
00096 cplx<T>& operator -= (const T);
00097 cplx<T>& operator -= (const cplx<T>&);
00098 cplx<T>& operator *= (const T);
00099 cplx<T>& operator *= (const cplx<T>&);
00100 cplx<T>& operator /= (const T);
00101 cplx<T>& operator /= (const cplx<T>&);
00102
00103
00104 cplx<T>& set (const T r, const T i) { re = r; im = i; return *this; }
00105
00106 T real () const { return re; }
00107 T imag () const { return im; }
00108
00109 T& real () { return re; }
00110 T& imag () { return im; }
00111
00112
00113
00114
00115
00116
00117
00118 cplx<T> operator + (const cplx<T>&) const;
00119 cplx<T> operator - (const cplx<T>&) const;
00120
00121 cplx<T> operator * (const cplx<T>&) const;
00122
00123 friend cplx<T> dot FGD (const cplx<T>&, const cplx<T>&);
00124 cplx<T> operator / (const cplx<T>&) const;
00125
00126
00127 cplx<T> plus (const T v) const
00128 { return cplx<T> (v+re, im); }
00129
00130 cplx<T> minus (const T v) const
00131 { return cplx<T> (v-re, -im); }
00132
00133 cplx<T> mult (const T v) const
00134 { return cplx<T> (v*re, v*im); }
00135
00136
00137 cplx<T> div (const T a) const
00138 {
00139 register const T den ALIGN(MIN_ALIGN) = (T)1 / (re*re + im*im);
00140 return cplx<T> ( (a * re) * den, (- a * im) * den );
00141 }
00142
00143 cplx<T> operator + (const T) const;
00144 cplx<T> operator - (const T) const;
00145 cplx<T> operator * (const T) const;
00146 cplx<T> operator / (const T) const;
00147 cplx<T> operator - () const;
00148 cplx<T> operator ~ () const;
00149
00150
00151
00152 T theta () const;
00153
00154
00155
00156
00157
00158 cplx<T> conj () const { return cplx<T> (re, -im); }
00159
00160
00161
00162 cplx<T>& do_conj () { im = -im; return *this; }
00163
00164 double fabssqr () const { return (double)(re*re + im*im); }
00165 double fabs () const;
00166 double norm () const { return fabssqr(); }
00167 T abs () const;
00168
00169 cplx<T> exp () const;
00170 cplx<T> sqrt () const;
00171
00172 cplx<T> power (const double) const;
00173 cplx<T> power (const cplx<T>&) const;
00174 cplx<T> ln () const;
00175
00176 cplx<T> sin () const;
00177 cplx<T> cos () const;
00178 cplx<T> sinh () const;
00179 cplx<T> cosh () const;
00180
00181 cplx<T> asin () const;
00182 cplx<T> acos () const;
00183 cplx<T> atan () const;
00184 cplx<T> asinh () const;
00185 cplx<T> acosh () const;
00186 cplx<T> atanh () const;
00187
00188
00189 bool operator == (const cplx<T>& c) const { return (re == c.re && im == c.im); }
00190 bool operator != (const cplx<T>& c) const { return (re != c.re || im != c.im); }
00191
00192 bool operator > (const cplx<T>& c) const { return fabssqr() > c.fabssqr(); }
00193 bool operator >= (const cplx<T>& c) const { return fabssqr() >= c.fabssqr(); }
00194 bool operator < (const cplx<T>& c) const { return fabssqr() < c.fabssqr(); }
00195 bool operator <= (const cplx<T>& c) const { return fabssqr() <= c.fabssqr(); }
00196
00197
00198
00199
00200
00201 friend STD__ ostream& operator << FGD (STD__ ostream&, const cplx< T >&);
00202
00203 friend STD__ istream& operator >> FGD (STD__ istream&, cplx< T >&);
00204
00205 } ;
00206
00207
00208 NAMESPACE_END
00209
00210 NAMESPACE_CSTD
00211 template <typename T>
00212 inline TBCI__ cplx<T> sqrt (const TBCI__ cplx<T>& z);
00213 NAMESPACE_CSTD_END
00214
00215 NAMESPACE_TBCI
00216
00217 template <typename T>
00218 inline cplx<T>& cplx<T>::operator += (const T a)
00219 {
00220 re += a; return *this;
00221 }
00222
00223
00224 template <typename T>
00225 inline cplx<T>& cplx<T>::operator += (const cplx<T>& a)
00226 {
00227 re += a.re; im += a.im; return *this;
00228 }
00229
00230 template <typename T>
00231 inline cplx<T>& cplx<T>::operator -= (const T a)
00232 {
00233 re -= a; return *this;
00234 }
00235
00236
00237 template <typename T>
00238 inline cplx<T>& cplx<T>::operator -= (const cplx<T>& a)
00239 {
00240 re -= a.re; im -= a.im; return *this;
00241 }
00242
00243
00244 template <typename T>
00245 inline cplx<T>& cplx<T>::operator *= (const T a)
00246 {
00247 re *= a; im *= a; return *this;
00248 }
00249
00250
00251 template <typename T>
00252 inline cplx<T>& cplx<T>::operator *= (const cplx<T>& a)
00253 {
00254 register const T tmp ALIGN(MIN_ALIGN) = re;
00255 re = tmp*a.re - im*a.im;
00256 im = tmp*a.im + im*a.re;
00257 return *this;
00258 }
00259
00260
00261 template <typename T>
00262 inline cplx<T>& cplx<T>::operator /= (const T a)
00263 {
00264 re /= a; im /= a; return *this;
00265 }
00266
00267 template <typename T>
00268 inline cplx<T>& cplx<T>::operator /= (const cplx<T>& a)
00269 {
00270 register const T tmp ALIGN(MIN_ALIGN) = re;
00271 register const T den ALIGN(MIN_ALIGN) = (a.re*a.re + a.im*a.im);
00272
00273 re = (tmp*a.re + im*a.im) / den;
00274 im = (im*a.re - tmp*a.im) / den;
00275 return *this;
00276 }
00277
00278
00279 template <typename T>
00280 inline cplx<T> cplx<T>::operator + (const cplx<T>& a) const
00281 {
00282 return cplx<T> (re + a.re, im + a.im);
00283 }
00284
00285
00286 template <typename T>
00287 inline cplx<T> cplx<T>::operator - (const cplx<T>& a) const
00288 {
00289 return cplx<T> (re - a.re, im - a.im);
00290 }
00291
00292
00293 template <typename T>
00294 inline cplx<T> cplx<T>::operator * (const cplx<T>& a) const
00295 {
00296 return cplx<T>( re*a.re - im*a.im, im*a.re + re*a.im );
00297 }
00298
00299 template <typename T>
00300 inline cplx<T> dot (const cplx<T>& a, const cplx<T>& b)
00301 {
00302 return cplx<T> (a.re*b.re + a.im*b.im, a.re*b.im - a.im*b.re);
00303
00304 }
00305
00306 template <typename T>
00307 inline cplx<T> cplx<T>::operator / (const cplx<T>& a) const
00308 {
00309 register const T den ALIGN(MIN_ALIGN) = (T)1 / (a.re*a.re + a.im*a.im);
00310
00311 return cplx<T>( ( re*a.re + im*a.im ) * den, ( im*a.re - re*a.im ) * den );
00312 }
00313
00314
00315 INST(template <typename T> class cplx friend cplx<T> operator + (const T, const cplx<T>&);)
00316 template <typename T>
00317 inline cplx<T> operator + (const T a, const cplx<T>& b)
00318 { return b.plus (a); }
00319
00320
00321 INST(template <typename T> class cplx friend cplx<T> operator - (const T, const cplx<T>&);)
00322 template <typename T>
00323 inline cplx<T> operator - (const T a, const cplx<T>& b)
00324 { return b.minus (a); }
00325
00326
00327 #if 0
00328 template <typename T, typename U>
00329 cplx<T> operator * (const U f, const cplx<T>& c)
00330 { return cplx<T> (f*c.real(), f*c.imag()); }
00331 #endif
00332
00333
00334 INST(template <typename T> class cplx friend cplx<T> operator * (const T, const cplx<T>&);)
00335 template <typename T>
00336 inline cplx<T> operator * (const T a, const cplx<T>& b)
00337 { return b.mult (a); }
00338
00339
00340 INST(template <typename T> class cplx friend cplx<T> operator / (const T, const cplx<T>&);)
00341 template <typename T>
00342 inline cplx<T> operator / (const T a, const cplx<T>& b)
00343 { return b.div (a); }
00344
00345
00346 template <typename T>
00347 inline cplx<T> cplx<T>::operator + (const T b) const
00348 {
00349 return cplx<T> (re + b, im);
00350 }
00351
00352
00353 template <typename T>
00354 inline cplx<T> cplx<T>::operator - (const T b) const
00355 {
00356 return cplx<T> (re - b, im);
00357 }
00358
00359
00360 template <typename T>
00361 inline cplx<T> cplx<T>::operator * (const T b) const
00362 {
00363 return cplx<T> (re * b, im * b);
00364 }
00365
00366
00367 template <typename T>
00368 inline cplx<T> cplx<T>::operator / (const T b) const
00369 {
00370 return cplx<T> (re / b, im / b);
00371 }
00372
00373
00374 template <typename T>
00375 inline cplx<T> cplx<T>::operator - () const
00376 {
00377 return cplx<T> (-re, -im);
00378 }
00379
00380
00381 template <typename T>
00382 inline cplx<T> cplx<T>::operator ~ () const
00383 {
00384 return cplx<T> (re, -im);
00385 }
00386
00387
00388 INST(template <typename T> class cplx friend double fabssqr (const cplx<T>&);)
00389 template <typename T>
00390 inline double fabssqr(const cplx<T>& c)
00391 { return c.fabssqr(); }
00392
00393
00394 template <typename T>
00395 inline double cplx<T>::fabs () const
00396 {
00397
00398
00399 if (UNLIKELY(im != 0)) {
00400 if (UNLIKELY(GLBL__ MATH__ fabs(im) > GLBL__ MATH__ fabs(re)))
00401 return (GLBL__ MATH__ fabs(im) * GLBL__ MATH__ sqrt(1.0+(double)re*re/(im*im)) );
00402 else
00403 return (GLBL__ MATH__ fabs(re) * GLBL__ MATH__ sqrt(1.0+(double)im*im/(re*re)) );
00404
00405 } else
00406 return (GLBL__ MATH__ fabs(re));
00407 }
00408
00409
00410 template <typename T>
00411 inline T cplx<T>::abs () const
00412 {
00413
00414
00415 if (UNLIKELY(im != 0)) {
00416 if (UNLIKELY(GLBL__ CSTD__ abs(im) > GLBL__ CSTD__ abs(re)))
00417 return (GLBL__ CSTD__ abs(im) * GLBL__ MATH__ sqrt(1+re*re/(im*im)) );
00418 else
00419 return (GLBL__ CSTD__ abs(re) * GLBL__ MATH__ sqrt(1+im*im/(re*re)) );
00420
00421 } else
00422 return (GLBL__ CSTD__ abs(re));
00423 }
00424
00425
00426 template <typename T>
00427 T cplx<T>::theta () const
00428 {
00429
00430 if (UNLIKELY(re == 0)) {
00431 if (LIKELY(im > 0))
00432 return 0.5*pi;
00433 else if (LIKELY(im < 0))
00434 return -0.5*pi;
00435 else
00436 return 0;
00437 }
00438
00439
00440
00441 if (UNLIKELY(im == 0.0))
00442 return atan2 (0.0, re);
00443 else
00444 return atan2 (im, re);
00445 }
00446
00447 INST(template <typename T> class TBCI__ cplx friend cplx<T> sqr (const cplx<T>&);)
00448 template <typename T>
00449 inline cplx<T> sqr (const cplx<T>& c)
00450 {
00451
00452 register const T re(c.real()), im(c.imag());
00453
00454
00455 return cplx<T> (re*re - im*im, 2*re*im);
00456 }
00457
00458 INST(template <typename T> class TBCI__ cplx friend cplx<T> expi (const T);)
00459 template <typename T>
00460 cplx<T> expi (const T phi)
00461 {
00462 const register T tmp ALIGN(MIN_ALIGN) = MATH__ fmod (phi, 2*pi);
00463 return cplx<T> (MATH__ cos(tmp), MATH__ sin(tmp));
00464 }
00465
00466 template <typename T>
00467 cplx<T> cplx<T>::sqrt () const
00468 {
00469 return GLBL__ MATH__ sqrt (fabs()) * TBCI__ expi ((double)(0.5) * theta());
00470 }
00471
00472 template <typename T>
00473 inline cplx<T> cplx<T>::exp () const
00474 {
00475 return GLBL__ MATH__ exp ((double)(this->real())) * TBCI__ expi(this->imag());
00476 }
00477
00478 template <typename T>
00479 inline cplx<T> cplx<T>::power (const double n) const
00480 {
00481 return GLBL__ MATH__ pow (this->fabs(), n) * TBCI__ expi (n*this->theta());
00482 }
00483
00484 template <typename T>
00485 cplx<T> cplx<T>::power (const cplx<T>& z) const
00486 {
00487 const double lnt = GLBL__ MATH__ log (fabs());
00488 const T phi = theta();
00489 return GLBL__ MATH__ exp (lnt*z.re - phi*z.im) * expi (phi*z.re + lnt*z.im);
00490 }
00491
00492 template <typename T>
00493 inline cplx<T> cplx<T>::ln () const
00494 {
00495 return cplx<T>(GLBL__ MATH__ log (fabs()), theta());
00496 }
00497
00498 template <typename T>
00499 cplx<T> cplx<T>::sin () const
00500 {
00501 const cplx<T> zi = cplx<T> (-im, re);
00502 return cplx<T>(0.0,-0.5) * (zi.exp() - (-zi).exp());
00503 }
00504
00505 template <typename T>
00506 cplx<T> cplx<T>::cos () const
00507 {
00508 const cplx<T> zi = cplx<T> (-im, re);
00509 return 0.5 * (zi.exp() + (-zi).exp());
00510 }
00511
00512 template <typename T>
00513 cplx<T> cplx<T>::sinh () const
00514 {
00515 return 0.5 * (exp() - (-(*this)).exp());
00516 }
00517
00518 template <typename T>
00519 cplx<T> cplx<T>::cosh () const
00520 {
00521 return 0.5 * (exp() + (-(*this)).exp());
00522 }
00523
00524 template <typename T>
00525 cplx<T> cplx<T>::asin () const
00526 {
00527 const cplx<T> arg = cplx<T>(-im, re) + GLBL__ MATH__ sqrt (1.0 - sqr(*this));
00528 return cplx<T>(0.0,-1.0) * arg.ln();
00529 }
00530
00531 template <typename T>
00532 cplx<T> cplx<T>::acos () const
00533 {
00534 const cplx<T> arg = *this + GLBL__ MATH__ sqrt (sqr(*this) - 1.0);
00535 return cplx<T>(0.0,-1.0) * arg.ln();
00536 }
00537
00538 template <typename T>
00539 cplx<T> cplx<T>::asinh () const
00540 {
00541 const cplx<T> arg = *this + GLBL__ MATH__ sqrt (sqr(*this) + 1.0);
00542 return arg.ln();
00543 }
00544
00545 template <typename T>
00546 cplx<T> cplx<T>::acosh () const
00547 {
00548 const cplx<T> arg = *this + GLBL__ MATH__ sqrt (sqr(*this) - 1.0);
00549 return arg.ln();
00550 }
00551
00552 template <typename T>
00553 cplx<T> cplx<T>::atan () const
00554 {
00555 const cplx<T> arg = (1.0 + cplx<T>(-im,re)) / ( 1.0 - cplx<T>(-im,re));
00556 return cplx<T>(0.0,-0.5) * arg.ln();
00557 }
00558
00559 template <typename T>
00560 cplx<T> cplx<T>::atanh () const
00561 {
00562 const cplx<T> arg = (1.0 + *this) / (1.0 - *this);
00563 return 0.5 * arg.ln();
00564 }
00565
00566
00567 #ifdef TBCI_CPLX_OLD_IOFMT
00568 template <typename T> STD__ ostream& operator << (STD__ ostream& os, const cplx<T>& c)
00569 {
00570 os << "( " << c.re;
00571 if (c.im < 0)
00572 os << " - i " << -c.im;
00573 else
00574 os << " + i " << c.im;
00575 os << " )";
00576 return os;
00577 }
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590 template <typename T>
00591 STD__ istream& operator >> (STD__ istream& in, cplx<T>& c)
00592 {
00593 T r, i;
00594 char s = '+', b = 'i', bra = '(';
00595
00596 if (! (in >> bra))
00597 return in;
00598 if (bra != '(') in.putback(bra);
00599 if (! (in >> r))
00600 return in;
00601 in >> s;
00602 if ((s != '+') && (s != '-')) in.putback(s);
00603 in >> b;
00604 if ((b != 'i')) in.putback(b);
00605 if (! (in >> i))
00606 return in;
00607 c.re = r;
00608 if (s == '-') c.im =- i;
00609 else c.im = i;
00610 if (bra == '(')
00611 {
00612 if (! (in >> bra))
00613 return in;
00614 if (bra != ')') in.putback(bra);
00615 }
00616 return in;
00617 }
00618
00619 #else
00620
00621 template <typename T> STD__ ostream& operator << (STD__ ostream& os, const cplx<T>& c)
00622 {
00623 return os << "(" << c.re << "," << c.im << ")";
00624 }
00625
00626 template <typename T>
00627 STD__ istream& operator >> (STD__ istream& in, cplx<T>& c)
00628 {
00629 T r ALIGN(MIN_ALIGN), i = (T)0;
00630 char bra;
00631
00632 if (! (in >> bra))
00633 return in;
00634 if (bra != '(') {
00635 in.putback(bra);
00636 if (in >> r) {
00637 c.re = r; c.im = (T)0;
00638 }
00639 return in;
00640 }
00641 if (!(in >> r))
00642 return in;
00643 in >> bra;
00644 c.re = r; c.im = (T)0;
00645 if (bra != ',')
00646 return in;
00647 if (! (in >> i))
00648 return in;
00649 c.im = i;
00650 in >> bra;
00651 if (bra != ')')
00652 ;
00653 return in;
00654 }
00655
00656 #endif
00657
00658 NAMESPACE_END
00659 NAMESPACE_CPLX
00660
00661 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> conj (const TBCI__ cplx<T>&);)
00662 template <typename T>
00663 inline TBCI__ cplx<T> conj (const TBCI__ cplx<T>& c)
00664 { return c.conj(); }
00665
00666
00667
00668 INST(template <typename T> class TBCI__ cplx friend T real (const TBCI__ cplx<T>&);)
00669 INST(template <typename T> class TBCI__ cplx friend T imag (const TBCI__ cplx<T>&);)
00670 template <typename T>
00671 inline T real (const TBCI__ cplx<T>& z)
00672 { return z.real(); }
00673 template <typename T>
00674 inline T imag (const TBCI__ cplx<T>& z)
00675 { return z.imag(); }
00676
00677
00678 INST(template <typename T> class TBCI__ cplx friend T& real (TBCI__ cplx<T>&);)
00679 INST(template <typename T> class TBCI__ cplx friend T& imag (TBCI__ cplx<T>&);)
00680 template <typename T>
00681 inline T& real (TBCI__ cplx<T>& z)
00682 { return z.real(); }
00683 template <typename T>
00684 inline T& imag (TBCI__ cplx<T>& z)
00685 { return z.imag(); }
00686
00687
00688 INST(template <typename T> class TBCI__ cplx friend T arg (const TBCI__ cplx<T>&);)
00689 template <typename T>
00690 inline T arg (const TBCI__ cplx<T>& c)
00691 { return c.theta(); }
00692
00693 INST(template <typename T> class TBCI__ cplx friend double norm (const TBCI__ cplx<T>&);)
00694 template <typename T>
00695 inline double norm (const TBCI__ cplx<T>& c)
00696 { return c.norm(); }
00697
00698
00699
00700 NAMESPACE_CPLX_END
00701 NAMESPACE_TBCI
00702
00703 #ifndef NO_NS
00704 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> polar (const T&, const T&);)
00705 template <typename T>
00706 inline TBCI__ cplx<T> polar (const T& r, const T& p)
00707 { return r * TBCI__ expi (p); }
00708 #else
00709 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> _polar (const T&, const T&);)
00710 template <typename T>
00711 inline TBCI__ cplx<T> _polar (const T& r, const T& p)
00712 { return r * TBCI__ expi (p); }
00713 #endif
00714
00715 #if defined(__i386__) && defined(__GNUC__) && defined(USE_ASM) && defined(CPLX_ASM) && !defined(NO_DOUBLE_SPEC)
00716 template <>
00717 inline cplx<double> cplx<double>::operator * (const cplx<double>& a) const
00718 {
00719 register double r, i;
00720 asm (" fldl %3; fmull %5; fldl %2; fmull %4; fsubp %%st,%%st(1); \n\
00721 fldl %2; fmull %5; fldl %3; fmull %4; faddp %%st,%%st(1); \n"
00722 : "=u" (r), "=t" (i)
00723 : "g" (re), "g" (im), "m" (a.re), "m" (a.im)
00724 : "st(6)", "st(7)" );
00725 return cplx<double> (r, i);
00726 }
00727 #endif
00728
00729 #ifdef NEED_IMAG_UNIT
00730 const cplx<double> Imag_unit (0.0, 1.0);
00731 #endif
00732
00733 NAMESPACE_END
00734
00735
00736 NAMESPACE_CSTD
00737
00738
00739 INST(template <typename T> class TBCI__ cplx friend T abs (const TBCI__ cplx<T>&);)
00740 template <typename T>
00741 inline T abs (const TBCI__ cplx<T>& c)
00742 { return c.abs(); }
00743
00744 INST(template <typename T> class TBCI__ cplx friend double fabs (const TBCI__ cplx<T>&);)
00745 template <typename T>
00746 inline double fabs (const TBCI__ cplx<T>& c)
00747 { return c.fabs(); }
00748
00749 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> sqrt (const TBCI__ cplx<T>&);)
00750 template <typename T>
00751 inline TBCI__ cplx<T> sqrt (const TBCI__ cplx<T>& z)
00752 { return z.sqrt(); }
00753
00754 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> exp (const TBCI__ cplx<T>&);)
00755 template <typename T>
00756 inline TBCI__ cplx<T> exp (const TBCI__ cplx<T>& z)
00757 { return z.exp (); }
00758
00759 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> pow (const TBCI__ cplx<T>&, const double);)
00760 template <typename T>
00761 inline TBCI__ cplx<T> pow (const TBCI__ cplx<T>& z, const double n)
00762 { return z.power (n); }
00763
00764 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> pow (const TBCI__ cplx<T>&, const TBCI__ cplx<T>&);)
00765 template <typename T>
00766 inline TBCI__ cplx<T> pow (const TBCI__ cplx<T>& z, const TBCI__ cplx<T>& x)
00767 { return z.power (x); }
00768
00769 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> log (const TBCI__ cplx<T>&);)
00770 template <typename T>
00771 inline TBCI__ cplx<T> log (const TBCI__ cplx<T>& z)
00772 { return z.ln(); }
00773
00774 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> sin (const TBCI__ cplx<T>&);)
00775 template <typename T>
00776 inline TBCI__ cplx<T> sin (const TBCI__ cplx<T>& z)
00777 { return z.sin(); }
00778
00779 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> sinh (const TBCI__ cplx<T>&);)
00780 template <typename T>
00781 inline TBCI__ cplx<T> sinh (const TBCI__ cplx<T>& z)
00782 { return z.sinh(); }
00783
00784 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> cos (const TBCI__ cplx<T>&);)
00785 template <typename T>
00786 inline TBCI__ cplx<T> cos (const TBCI__ cplx<T>& z)
00787 { return z.cos(); }
00788
00789 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> cosh (const TBCI__ cplx<T>&);)
00790 template <typename T>
00791 inline TBCI__ cplx<T> cosh (const TBCI__ cplx<T>& z)
00792 { return z.cosh(); }
00793
00794 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> tan (const TBCI__ cplx<T>&);)
00795 template <typename T>
00796 inline TBCI__ cplx<T> tan (const TBCI__ cplx<T>& z)
00797 { return z.sin()/z.cos(); }
00798
00799 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> tanh (const TBCI__ cplx<T>&);)
00800 template <typename T>
00801 inline TBCI__ cplx<T> tanh (const TBCI__ cplx<T>& z)
00802 { return z.sinh()/z.cosh(); }
00803
00804 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> asin (const TBCI__ cplx<T>&);)
00805 template <typename T>
00806 inline TBCI__ cplx<T> asin (const TBCI__ cplx<T>& z)
00807 { return z.asin(); }
00808
00809 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> asinh (const TBCI__ cplx<T>&);)
00810 template <typename T>
00811 inline TBCI__ cplx<T> asinh (const TBCI__ cplx<T>& z)
00812 { return z.asinh(); }
00813
00814 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> acos (const TBCI__ cplx<T>&);)
00815 template <typename T>
00816 inline TBCI__ cplx<T> acos (const TBCI__ cplx<T>& z)
00817 { return z.acos(); }
00818
00819 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> acosh (const TBCI__ cplx<T>&);)
00820 template <typename T>
00821 inline TBCI__ cplx<T> acosh (const TBCI__ cplx<T>& z)
00822 { return z.acosh(); }
00823
00824 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> atan (const TBCI__ cplx<T>&);)
00825 template <typename T>
00826 inline TBCI__ cplx<T> atan (const TBCI__ cplx<T>& z)
00827 { return z.atan(); }
00828
00829 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> atanh (const TBCI__ cplx<T>&);)
00830 template <typename T>
00831 inline TBCI__ cplx<T> atanh (const TBCI__ cplx<T>& z)
00832 { return z.atanh(); }
00833
00834 INST(template <typename T> class TBCI__ cplx friend TBCI__ cplx<T> log10 (const TBCI__ cplx<T>&);)
00835 template <typename T>
00836 inline TBCI__ cplx<T> log10 (const TBCI__ cplx<T>& z)
00837 { const static double InvLn10 = (1.0 / log(10.0));
00838 return z.ln()*InvLn10;
00839 }
00840
00841 NAMESPACE_CSTD_END
00842
00843
00844 # include "cplx_memalloc.h"
00845
00846 NAMESPACE_TBCI
00847
00848
00849 SPEC_TBCI_TRAITS_LOOP_COPY(TBCI__ cplx<float>);
00850 SPEC_TBCI_TRAITS_LOOP_COPY(TBCI__ cplx<double>);
00851 SPEC_TBCI_TRAITS_ALWAYS_COPY(TBCI__ cplx<float>*);
00852 SPEC_TBCI_TRAITS_ALWAYS_COPY(TBCI__ cplx<double>*);
00853
00854 NAMESPACE_END
00855
00856 #endif
00857