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