]>
gcc.gnu.org Git - gcc.git/blob - libstdc++/std/ldcomplex.h
1 // The -*- C++ -*- long_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)
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.
32 #pragma interface "ldcomplex"
36 class complex<long double>
39 complex (long double r
= 0, long double i
= 0): re (r
), im (i
) { }
40 complex (const complex<float>& r
): re (r
.real ()), im (r
.imag ()) { }
41 complex (const complex<double>& r
): re (r
.real ()), im (r
.imag ()) { }
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 long double real () const { return re
; }
49 long double imag () const { return 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 // These functions are specified as friends for purposes of name injection;
59 // they do not actually reference private members.
60 friend long double real (const complex& x
) { return x
.real (); }
61 friend long double imag (const complex& x
) { return x
.imag (); }
62 friend complex operator + (const complex&, const complex&) __attribute__ ((const));
63 friend complex operator + (const complex&, long double) __attribute__ ((const));
64 friend complex operator + (long double, const complex&) __attribute__ ((const));
65 friend complex operator - (const complex&, const complex&) __attribute__ ((const));
66 friend complex operator - (const complex&, long double) __attribute__ ((const));
67 friend complex operator - (long double, const complex&) __attribute__ ((const));
68 friend complex operator * (const complex&, const complex&) __attribute__ ((const));
69 friend complex operator * (const complex&, long double) __attribute__ ((const));
70 friend complex operator * (long double, const complex&) __attribute__ ((const));
71 friend complex operator / (const complex&, const complex&) __attribute__ ((const));
72 friend complex operator / (const complex&, long double) __attribute__ ((const));
73 friend complex operator / (long double, const complex&) __attribute__ ((const));
74 friend bool operator == (const complex&, const complex&) __attribute__ ((const));
75 friend bool operator == (const complex&, long double) __attribute__ ((const));
76 friend bool operator == (long double, const complex&) __attribute__ ((const));
77 friend bool operator != (const complex&, const complex&) __attribute__ ((const));
78 friend bool operator != (const complex&, long double) __attribute__ ((const));
79 friend bool operator != (long double, const complex&) __attribute__ ((const));
80 friend complex polar (long double, long double) __attribute__ ((const));
81 friend complex pow (const complex&, const complex&) __attribute__ ((const));
82 friend complex pow (const complex&, long double) __attribute__ ((const));
83 friend complex pow (const complex&, int) __attribute__ ((const));
84 friend complex pow (long double, const complex&) __attribute__ ((const));
85 friend istream
& operator>> (istream
&, complex&);
86 friend ostream
& operator<< (ostream
&, const complex&);
89 inline complex<float>::complex (const complex<long double>& r
)
90 : re (r
.real ()), im (r
.imag ())
93 inline complex<double>::complex (const complex<long double>& r
)
94 : re (r
.real ()), im (r
.imag ())
This page took 0.042764 seconds and 5 git commands to generate.