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