Install msysDVLPR-1.0.0-alpha-1
[msysgit.git] / include / g++-3 / std / dcomplex.h
blob5812d9fa7dfd0f3daa01dee6669df143fab55262
1 // The -*- C++ -*- double_complex class.
2 // Copyright (C) 1994 Free Software Foundation
4 // This file is part of the GNU ANSI C++ Library. This library is free
5 // software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the
7 // Free Software Foundation; either version 2, or (at your option)
8 // any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this library; see the file COPYING. If not, write to the Free
17 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 // As a special exception, if you link this library with files
20 // compiled with a GNU compiler to produce an executable, this does not cause
21 // the resulting executable to be covered by the GNU General Public License.
22 // This exception does not however invalidate any other reasons why
23 // the executable file might be covered by the GNU General Public License.
25 // Written by Jason Merrill based upon the specification in the 27 May 1994
26 // C++ working paper, ANSI document X3J16/94-0098.
28 #ifndef __DCOMPLEX__
29 #define __DCOMPLEX__
31 #ifdef __GNUG__
32 #pragma interface "dcomplex"
33 #endif
35 extern "C++" {
36 class complex<double>
38 public:
39 complex (double r = 0, double i = 0): re (r), im (i) { }
40 complex (const complex<float>& r): re (r.real ()), im (r.imag ()) { }
41 explicit complex (const complex<long double>& r);
43 complex& operator+= (const complex& r) { return __doapl (this, r); }
44 complex& operator-= (const complex& r) { return __doami (this, r); }
45 complex& operator*= (const complex& r) { return __doaml (this, r); }
46 complex& operator/= (const complex& r) { return __doadv (this, r); }
48 double real () const { return re; }
49 double imag () const { return im; }
50 private:
51 double re, im;
53 friend complex& __doapl<> (complex *, const complex&);
54 friend complex& __doami<> (complex *, const complex&);
55 friend complex& __doaml<> (complex *, const complex&);
56 friend complex& __doadv<> (complex *, const complex&);
58 #ifndef __STRICT_ANSI__
59 friend inline complex operator + (const complex& x, double y)
60 { return operator+<> (x, y); }
61 friend inline complex operator + (double x, const complex& y)
62 { return operator+<> (x, y); }
63 friend inline complex operator - (const complex& x, double y)
64 { return operator-<> (x, y); }
65 friend inline complex operator - (double x, const complex& y)
66 { return operator-<> (x, y); }
67 friend inline complex operator * (const complex& x, double y)
68 { return operator*<> (x, y); }
69 friend inline complex operator * (double x, const complex& y)
70 { return operator*<> (x, y); }
71 friend inline complex operator / (const complex& x, double y)
72 { return operator/<> (x, y); }
73 friend inline complex operator / (double x, const complex& y)
74 { return operator/<> (x, y); }
75 friend inline bool operator == (const complex& x, double y)
76 { return operator==<> (x, y); }
77 friend inline bool operator == (double x, const complex& y)
78 { return operator==<> (x, y); }
79 friend inline bool operator != (const complex& x, double y)
80 { return operator!=<> (x, y); }
81 friend inline bool operator != (double x, const complex& y)
82 { return operator!=<> (x, y); }
83 #endif /* __STRICT_ANSI__ */
86 inline complex<float>::complex (const complex<double>& r)
87 : re (r.real ()), im (r.imag ())
88 { }
89 } // extern "C++"
91 #endif