1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
8 // ----------------------------------------------------------------------------
11 #define __COMPLEX_H __COMPLEX_H
13 #include "personality.h"
15 // ----------------------------------------------------------------------------
19 #define complex _Complex
22 #define _Complex_I ( const float _Complex ) { 0, 1 }
24 #ifdef __PERSONALITY_SUPPORTS_IMAGINARY
25 #define imaginary _Imaginary
26 #endif // __PERSONALITY_SUPPORTS_IMAGINARY
29 #define _Imaginary_I ( ( const float _Imaginary ) 1 )
33 #define I _Imaginary_I
38 // ----------------------------------------------------------------------------
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
160 #endif // __cplusplus
162 // ----------------------------------------------------------------------------
163 // FUNCTIONS - Standard C
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
275 #endif // __COMPLEX_H