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 // ----------------------------------------------------------------------------
17 #define complex _Complex
20 #define _Complex_I ( const float _Complex ) { 0, 1 }
22 // TODO: imaginary is only defined if implementation supports _Imaginary.
23 #define imaginary _Imaginary
26 #define _Imaginary_I ( ( const float _Imaginary ) 1 )
30 #define I _Imaginary_I
35 // ----------------------------------------------------------------------------
40 // These functions return the absolute value (magnitude) of their parameter.
41 double abs( double _Complex x );
42 float abs( float _Complex x );
43 long double abs( long double _Complex x );
44 double fabs( double _Complex x );
45 float fabs( float _Complex x );
46 long double fabs( long double _Complex x );
48 // These functions return the sine of their parameter.
49 double _Complex sin( double _Complex x );
50 float _Complex sin( float _Complex x );
51 long double _Complex sin( long double _Complex x );
53 // These functions return the hyperbolic sine of their parameter.
54 double _Complex sinh( double _Complex x );
55 float _Complex sinh( float _Complex x );
56 long double _Complex sinh( long double _Complex x );
58 // These functions return the arcsine of their parameter.
59 double _Complex asin( double _Complex x );
60 float _Complex asin( float _Complex x );
61 long double _Complex asin( long double _Complex x );
63 // These functions return the hyperbolic arcsine of their parameter.
64 double _Complex asinh( double _Complex x );
65 float _Complex asinh( float _Complex x );
66 long double _Complex asinh( long double _Complex x );
68 // These functions return the cosine of their parameter.
69 double _Complex cos( double _Complex x );
70 float _Complex cos( float _Complex x );
71 long double _Complex cos( long double _Complex x );
73 // These functions return the hyperbolic cosine of their parameter.
74 double _Complex cosh( double _Complex x );
75 float _Complex cosh( float _Complex x );
76 long double _Complex cosh( long double _Complex x );
78 // These functions return the arccosine of their parameter.
79 double _Complex acos( double _Complex x );
80 float _Complex acos( float _Complex x );
81 long double _Complex acos( long double _Complex x );
83 // These functions return the hyperbolic arccosine of their parameter.
84 double _Complex acosh( double _Complex x );
85 float _Complex acosh( float _Complex x );
86 long double _Complex acosh( long double _Complex x );
88 // These functions return the tangent of their parameter.
89 double _Complex tan( double _Complex x );
90 float _Complex tan( float _Complex x );
91 long double _Complex tan( long double _Complex x );
93 // These functions return the hyperbolic tangent of their parameter.
94 double _Complex tanh( double _Complex x );
95 float _Complex tanh( float _Complex x );
96 long double _Complex tanh( long double _Complex x );
98 // These functions return the arctangent of their parameter.
99 double _Complex atan( double _Complex x );
100 float _Complex atan( float _Complex x );
101 long double _Complex atan( long double _Complex x );
103 // These functions return the hyperbolic arctangent of their parameter.
104 double _Complex atanh( double _Complex x );
105 float _Complex atanh( float _Complex x );
106 long double _Complex atanh( long double _Complex x );
108 // These functions return the imaginary part of their parameter.
109 double imag( double _Complex x );
110 float imag( float _Complex x );
111 long double imag( long double _Complex x );
112 float cimag( float _Complex x );
113 long double cimag( long double _Complex x );
115 // These functions return the real part of their parameter.
116 double real( double _Complex x );
117 float real( float _Complex x );
118 long double real( long double _Complex x );
119 float creal( float _Complex x );
120 long double creal( long double _Complex x );
122 // These functions return x^y.
123 double _Complex pow( double _Complex x, double _Complex y );
124 float _Complex pow( float _Complex x, float _Complex y );
125 long double _Complex pow( long double _Complex x, long double _Complex y );
127 // These functions return the square root of their parameter.
128 double _Complex sqrt( double _Complex x );
129 float _Complex sqrt( float _Complex x );
130 long double _Complex sqrt( long double _Complex x );
132 // These functions return the exponential of their parameter.
133 double _Complex exp( double _Complex x );
134 float _Complex exp( float _Complex x );
135 long double _Complex exp( long double _Complex x );
137 // These functions return the logarithm of their parameter.
138 double _Complex log( double _Complex x );
139 float _Complex log( float _Complex x );
140 long double _Complex log( long double _Complex x );
142 // These functions return the phase angle of their parameter.
143 double arg( double _Complex x );
144 float arg( float _Complex x );
145 long double arg( long double _Complex x );
146 float carg( float _Complex x );
147 long double carg( long double _Complex x );
149 // These functions return the conjugate of their parameter.
150 float _Complex conj( float _Complex x );
151 long double _Complex conj( long double _Complex x );
153 // These functions return the projection of their parameter.
154 float _Complex cproj( float _Complex x );
155 long double _Complex cproj( long double _Complex x );
157 #endif // __cplusplus
159 // ----------------------------------------------------------------------------
160 // FUNCTIONS - Standard C
162 // These functions return the absolute value (magnitude) of their parameter.
163 double cabs( double _Complex x );
164 float cabsf( float _Complex x );
165 long double cabsl( long double _Complex x );
167 // These functions return the sine of their parameter.
168 double _Complex csin( double _Complex x );
169 float _Complex csinf( float _Complex x );
170 long double _Complex csinl( long double _Complex x );
172 // These functions return the hyperbolic sine of their parameter.
173 double _Complex csinh( double _Complex x );
174 float _Complex csinhf( float _Complex x );
175 long double _Complex csinhl( long double _Complex x );
177 // These functions return the arcsine of their parameter.
178 double _Complex casin( double _Complex x );
179 float _Complex casinf( float _Complex x );
180 long double _Complex casinl( long double _Complex x );
182 // These functions return the hyperbolic arcsine of their parameter.
183 double _Complex casinh( double _Complex x );
184 float _Complex casinhf( float _Complex x );
185 long double _Complex casinhl( long double _Complex x );
187 // These functions return the cosine of their parameter.
188 double _Complex ccos( double _Complex x );
189 float _Complex ccosf( float _Complex x );
190 long double _Complex ccosl( long double _Complex x );
192 // These functions return the hyperbolic cosine of their parameter.
193 double _Complex ccosh( double _Complex x );
194 float _Complex ccoshf( float _Complex x );
195 long double _Complex ccoshl( long double _Complex x );
197 // These functions return the arccosine of their parameter.
198 double _Complex cacos( double _Complex x );
199 float _Complex cacosf( float _Complex x );
200 long double _Complex cacosl( long double _Complex x );
202 // These functions return the hyperbolic arccosine of their parameter.
203 double _Complex cacosh( double _Complex x );
204 float _Complex cacoshf( float _Complex x );
205 long double _Complex cacoshl( long double _Complex x );
207 // These functions return the tangent of their parameter.
208 double _Complex ctan( double _Complex x );
209 float _Complex ctanf( float _Complex x );
210 long double _Complex ctanl( long double _Complex x );
212 // These functions return the hyperbolic tangent of their parameter.
213 double _Complex ctanh( double _Complex x );
214 float _Complex ctanhf( float _Complex x );
215 long double _Complex ctanhl( long double _Complex x );
217 // These functions return the arctangent of their parameter.
218 double _Complex catan( double _Complex x );
219 float _Complex catanf( float _Complex x );
220 long double _Complex catanl( long double _Complex x );
222 // These functions return the hyperbolic arctangent of their parameter.
223 double _Complex catanh( double _Complex x );
224 float _Complex catanhf( float _Complex x );
225 long double _Complex catanhl( long double _Complex x );
227 // These functions return the imaginary part of their parameter.
228 double cimag( double _Complex x );
229 float cimagf( float _Complex x );
230 long double cimagl( long double _Complex x );
232 // These functions return the real part of their parameter.
233 double creal( double _Complex x );
234 float crealf( float _Complex x );
235 long double creall( long double _Complex x );
237 // These functions return x^y.
238 double _Complex cpow( double _Complex x, double _Complex y );
239 float _Complex cpowf( float _Complex x, float _Complex y );
240 long double _Complex cpowl( long double _Complex x, long double _Complex y );
242 // These functions return the square root of their parameter.
243 double _Complex csqrt( double _Complex x );
244 float _Complex csqrtf( float _Complex x );
245 long double _Complex csqrtl( long double _Complex x );
247 // These functions return the exponential of their parameter.
248 double _Complex cexp( double _Complex x );
249 float _Complex cexpf( float _Complex x );
250 long double _Complex cexpl( long double _Complex x );
252 // These functions return the logarithm of their parameter.
253 double _Complex clog( double _Complex x );
254 float _Complex clogf( float _Complex x );
255 long double _Complex clogl( long double _Complex x );
257 // These functions return the phase angle of their value.
258 double carg( double _Complex x );
259 float cargf( float _Complex x );
260 long double cargl( long double _Complex x );
262 // These functions return the conjugate of their parameter.
263 double _Complex conj( double _Complex x );
264 float _Complex conjf( float _Complex x );
265 long double _Complex conjl( long double _Complex x );
267 // These functions return the projection of their parameter.
268 double _Complex cproj( double _Complex x );
269 float _Complex cprojf( float _Complex x );
270 long double _Complex cprojl( long double _Complex x );
272 #endif // __COMPLEX_H