]> pd.if.org Git - pdclib/blob - includes/complex.h
6e7ac5ed5ec7867db01f6d156a5a9a52b7e3250b
[pdclib] / includes / complex.h
1 // ----------------------------------------------------------------------------
2 // $Id$
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
7 // Complex arithmetic
8 // ----------------------------------------------------------------------------
9
10 #ifndef __COMPLEX_H
11 #define __COMPLEX_H __COMPLEX_H
12
13 #include "personality.h"
14
15 // ----------------------------------------------------------------------------
16 // DEFINES
17
18 #ifndef __cplusplus
19 #define complex     _Complex
20 #endif
21
22 #define _Complex_I  ( const float _Complex ) { 0, 1 }
23
24 #ifdef __PERSONALITY_SUPPORTS_IMAGINARY
25 #define imaginary   _Imaginary
26 #endif // __PERSONALITY_SUPPORTS_IMAGINARY
27
28 #ifdef imaginary
29 #define _Imaginary_I ( ( const float _Imaginary ) 1 )
30 #endif
31
32 #ifdef imaginary
33 #define I _Imaginary_I
34 #else
35 #define I _Complex_I
36 #endif
37
38 // ----------------------------------------------------------------------------
39 // FUNCTIONS - C++
40
41 #ifdef __cplusplus
42
43 // These functions return the absolute value (magnitude) of their parameter.
44 double               abs( double      _Complex  x );
45 float                abs( float       _Complex  x );
46 long double          abs( long double _Complex  x );
47 double               fabs( double      _Complex x );
48 float                fabs( float       _Complex x );
49 long double          fabs( long double _Complex x );
50
51 // These functions return the sine of their parameter.
52 double _Complex      sin( double _Complex      x );
53 float _Complex       sin( float _Complex       x );
54 long double _Complex sin( long double _Complex x );
55
56 // These functions return the hyperbolic sine of their parameter.
57 double _Complex      sinh( double _Complex      x );
58 float _Complex       sinh( float _Complex       x );
59 long double _Complex sinh( long double _Complex x );
60
61 // These functions return the arcsine of their parameter.
62 double _Complex      asin( double _Complex      x );
63 float _Complex       asin( float _Complex       x );
64 long double _Complex asin( long double _Complex x );
65
66 // These functions return the hyperbolic arcsine of their parameter.
67 double _Complex      asinh( double _Complex      x );
68 float _Complex       asinh( float _Complex       x );
69 long double _Complex asinh( long double _Complex x );
70
71 // These functions return the cosine of their parameter.
72 double _Complex      cos( double _Complex      x );
73 float _Complex       cos( float _Complex       x );
74 long double _Complex cos( long double _Complex x );
75
76 // These functions return the hyperbolic cosine of their parameter.
77 double _Complex      cosh( double _Complex      x );
78 float _Complex       cosh( float _Complex       x );
79 long double _Complex cosh( long double _Complex x );
80
81 // These functions return the arccosine of their parameter.
82 double _Complex      acos( double      _Complex x );
83 float _Complex       acos( float       _Complex x );
84 long double _Complex acos( long double _Complex x );
85
86 // These functions return the hyperbolic arccosine of their parameter.
87 double _Complex      acosh( double      _Complex x );
88 float _Complex       acosh( float       _Complex x );
89 long double _Complex acosh( long double _Complex x );
90
91 // These functions return the tangent of their parameter.
92 double _Complex      tan( double _Complex      x );
93 float _Complex       tan( float _Complex       x );
94 long double _Complex tan( long double _Complex x );
95
96 // These functions return the hyperbolic tangent of their parameter.
97 double _Complex      tanh( double _Complex      x );
98 float _Complex       tanh( float _Complex       x );
99 long double _Complex tanh( long double _Complex x );
100
101 // These functions return the arctangent of their parameter.
102 double _Complex      atan( double _Complex      x );
103 float _Complex       atan( float _Complex       x );
104 long double _Complex atan( long double _Complex x );
105
106 // These functions return the hyperbolic arctangent of their parameter.
107 double _Complex      atanh( double _Complex      x );
108 float _Complex       atanh( float _Complex       x );
109 long double _Complex atanh( long double _Complex x );
110
111 // These functions return the imaginary part of their parameter.
112 double               imag( double _Complex       x );
113 float                imag( float _Complex        x );
114 long double          imag( long double _Complex  x );
115 float                cimag( float _Complex       x );
116 long double          cimag( long double _Complex x );
117
118 // These functions return the real part of their parameter.
119 double               real( double _Complex       x );
120 float                real( float _Complex        x );
121 long double          real( long double _Complex  x );
122 float                creal( float _Complex       x );
123 long double          creal( long double _Complex x );
124
125 // These functions return x^y.
126 double _Complex      pow( double _Complex      x, double _Complex      y );
127 float _Complex       pow( float _Complex       x, float _Complex       y );
128 long double _Complex pow( long double _Complex x, long double _Complex y );
129
130 // These functions return the square root of their parameter.
131 double _Complex      sqrt( double _Complex      x );
132 float _Complex       sqrt( float _Complex       x );
133 long double _Complex sqrt( long double _Complex x );
134
135 // These functions return the exponential of their parameter.
136 double _Complex      exp( double _Complex      x );
137 float _Complex       exp( float _Complex       x );
138 long double _Complex exp( long double _Complex x );
139
140 // These functions return the logarithm of their parameter.
141 double _Complex      log( double _Complex      x );
142 float _Complex       log( float _Complex       x );
143 long double _Complex log( long double _Complex x );
144
145 // These functions return the phase angle of their parameter.
146 double               arg( double _Complex       x );
147 float                arg( float _Complex        x );
148 long double          arg( long double _Complex  x );
149 float                carg( float _Complex       x );
150 long double          carg( long double _Complex x );
151
152 // These functions return the conjugate of their parameter.
153 float _Complex       conj( float _Complex       x );
154 long double _Complex conj( long double _Complex x );
155
156 // These functions return the projection of their parameter.
157 float _Complex       cproj( float _Complex       x );
158 long double _Complex cproj( long double _Complex x );
159
160 #endif // __cplusplus
161
162 // ----------------------------------------------------------------------------
163 // FUNCTIONS - Standard C
164
165 // These functions return the absolute value (magnitude) of their parameter.
166 double               cabs( double _Complex       x );
167 float                cabsf( float _Complex       x );
168 long double          cabsl( long double _Complex x );
169
170 // These functions return the sine of their parameter.
171 double _Complex      csin( double _Complex       x );
172 float _Complex       csinf( float _Complex       x );
173 long double _Complex csinl( long double _Complex x );
174
175 // These functions return the hyperbolic sine of their parameter.
176 double _Complex      csinh( double _Complex       x );
177 float _Complex       csinhf( float _Complex       x );
178 long double _Complex csinhl( long double _Complex x );
179
180 // These functions return the arcsine of their parameter.
181 double _Complex      casin( double _Complex       x );
182 float _Complex       casinf( float _Complex       x );
183 long double _Complex casinl( long double _Complex x );
184
185 // These functions return the hyperbolic arcsine of their parameter.
186 double _Complex      casinh( double _Complex       x );
187 float _Complex       casinhf( float _Complex       x );
188 long double _Complex casinhl( long double _Complex x );
189
190 // These functions return the cosine of their parameter.
191 double _Complex      ccos( double _Complex       x );
192 float _Complex       ccosf( float _Complex       x );
193 long double _Complex ccosl( long double _Complex x );
194
195 // These functions return the hyperbolic cosine of their parameter.
196 double _Complex      ccosh( double _Complex       x );
197 float _Complex       ccoshf( float _Complex       x );
198 long double _Complex ccoshl( long double _Complex x );
199
200 // These functions return the arccosine of their parameter.
201 double _Complex      cacos( double _Complex       x );
202 float _Complex       cacosf( float _Complex       x );
203 long double _Complex cacosl( long double _Complex x );
204
205 // These functions return the hyperbolic arccosine of their parameter.
206 double _Complex      cacosh( double _Complex       x );
207 float _Complex       cacoshf( float _Complex       x );
208 long double _Complex cacoshl( long double _Complex x );
209
210 // These functions return the tangent of their parameter.
211 double _Complex      ctan( double _Complex       x );
212 float _Complex       ctanf( float _Complex       x );
213 long double _Complex ctanl( long double _Complex x );
214
215 // These functions return the hyperbolic tangent of their parameter.
216 double _Complex      ctanh( double _Complex       x );
217 float _Complex       ctanhf( float _Complex       x );
218 long double _Complex ctanhl( long double _Complex x );
219
220 // These functions return the arctangent of their parameter.
221 double _Complex      catan( double _Complex       x );
222 float _Complex       catanf( float _Complex       x );
223 long double _Complex catanl( long double _Complex x );
224
225 // These functions return the hyperbolic arctangent of their parameter.
226 double _Complex      catanh( double _Complex       x );
227 float _Complex       catanhf( float _Complex       x );
228 long double _Complex catanhl( long double _Complex x );
229
230 // These functions return the imaginary part of their parameter.
231 double               cimag( double _Complex       x );
232 float                cimagf( float _Complex       x );
233 long double          cimagl( long double _Complex x );
234
235 // These functions return the real part of their parameter.
236 double               creal( double _Complex       x );
237 float                crealf( float _Complex       x );
238 long double          creall( long double _Complex x );
239
240 // These functions return x^y.
241 double _Complex      cpow( double _Complex       x, double _Complex      y );
242 float _Complex       cpowf( float _Complex       x, float _Complex       y );
243 long double _Complex cpowl( long double _Complex x, long double _Complex y );
244
245 // These functions return the square root of their parameter.
246 double _Complex      csqrt( double _Complex       x );
247 float _Complex       csqrtf( float _Complex       x );
248 long double _Complex csqrtl( long double _Complex x );
249
250 // These functions return the exponential of their parameter.
251 double _Complex      cexp( double _Complex       x );
252 float _Complex       cexpf( float _Complex       x );
253 long double _Complex cexpl( long double _Complex x );
254
255 // These functions return the logarithm of their parameter.
256 double _Complex      clog( double _Complex       x );
257 float _Complex       clogf( float _Complex       x );
258 long double _Complex clogl( long double _Complex x );
259
260 // These functions return the phase angle of their value.
261 double               carg( double _Complex       x );
262 float                cargf( float _Complex       x );
263 long double          cargl( long double _Complex x );
264
265 // These functions return the conjugate of their parameter.
266 double _Complex      conj( double _Complex       x );
267 float _Complex       conjf( float _Complex       x );
268 long double _Complex conjl( long double _Complex x );
269
270 // These functions return the projection of their parameter.
271 double _Complex      cproj( double _Complex       x );
272 float _Complex       cprojf( float _Complex       x );
273 long double _Complex cprojl( long double _Complex x );
274
275 #endif // __COMPLEX_H