1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
7 // Provides the types float _Complex, double _Complex and long double _Complex
8 // plus math functions on those types.
9 // ----------------------------------------------------------------------------
12 #define __COMPLEX_H __COMPLEX_H
14 // ----------------------------------------------------------------------------
18 #define complex _Complex
21 #define _Complex_I (float _Complex){0, 1}
22 #define imaginary _Imaginary // optional
25 #define _Imaginary_I ((float _Imaginary)1)
29 #define I _Imaginary_I
34 // ----------------------------------------------------------------------------
39 // These functions return the absolute value (magnitude) of their parameter.
40 double abs( double _Complex x );
41 float abs( float _Complex x );
42 long double abs( long double _Complex x );
43 double fabs( double _Complex x );
44 float fabs( float _Complex x );
45 long double fabs( long double _Complex x );
47 // These functions return the sine of their parameter.
48 double _Complex sin( double _Complex x );
49 float _Complex sin( float _Complex x );
50 long double _Complex sin( long double _Complex x );
52 // These functions return the hyperbolic sine of their parameter.
53 double _Complex sinh( double _Complex x );
54 float _Complex sinh( float _Complex x );
55 long double _Complex sinh( long double _Complex x );
57 // These functions return the arcsine of their parameter.
58 double _Complex asin( double _Complex x );
59 float _Complex asin( float _Complex x );
60 long double _Complex asin( long double _Complex x );
62 // These functions return the hyperbolic arcsine of their parameter.
63 double _Complex asinh( double _Complex x );
64 float _Complex asinh( float _Complex x );
65 long double _Complex asinh( long double _Complex x );
67 // These functions return the cosine of their parameter.
68 double _Complex cos( double _Complex x );
69 float _Complex cos( float _Complex x );
70 long double _Complex cos( long double _Complex x );
72 // These functions return the hyperbolic cosine of their parameter.
73 double _Complex cosh( double _Complex x );
74 float _Complex cosh( float _Complex x );
75 long double _Complex cosh( long double _Complex x );
77 // These functions return the arccosine of their parameter.
78 double _Complex acos( double _Complex x );
79 float _Complex acos( float _Complex x );
80 long double _Complex acos( long double _Complex x );
82 // These functions return the hyperbolic arccosine of their parameter.
83 double _Complex acosh( double _Complex x );
84 float _Complex acosh( float _Complex x );
85 long double _Complex acosh( long double _Complex x );
87 // These functions return the tangent of their parameter.
88 double _Complex tan( double _Complex x );
89 float _Complex tan( float _Complex x );
90 long double _Complex tan( long double _Complex x );
92 // These functions return the hyperbolic tangent of their parameter.
93 double _Complex tanh( double _Complex x );
94 float _Complex tanh( float _Complex x );
95 long double _Complex tanh( long double _Complex x );
97 // These functions return the arctangent of their parameter.
98 double _Complex atan( double _Complex x );
99 float _Complex atan( float _Complex x );
100 long double _Complex atan( long double _Complex x );
102 // These functions return the hyperbolic arctangent of their parameter.
103 double _Complex atanh( double _Complex x );
104 float _Complex atanh( float _Complex x );
105 long double _Complex atanh( long double _Complex x );
107 // These functions return the imaginary part of their parameter.
108 double imag( double _Complex x );
109 float imag( float _Complex x );
110 long double imag( long double _Complex x );
111 float cimag( float _Complex x );
112 long double cimag( long double _Complex x );
114 // These functions return the real part of their parameter.
115 double real( double _Complex x );
116 float real( float _Complex x );
117 long double real( long double _Complex x );
118 float creal( float _Complex x );
119 long double creal( long double _Complex x );
121 // These functions return x^y.
122 double _Complex pow( double _Complex x, double _Complex y );
123 float _Complex pow( float _Complex x, float _Complex y );
124 long double _Complex pow( long double _Complex x, long double _Complex y );
126 // These functions return the square root of their parameter.
127 double _Complex sqrt( double _Complex x );
128 float _Complex sqrt( float _Complex x );
129 long double _Complex sqrt( long double _Complex x );
131 // These functions return the exponential of their parameter.
132 double _Complex exp( double _Complex x );
133 float _Complex exp( float _Complex x );
134 long double _Complex exp( long double _Complex x );
136 // These functions return the logarithm of their parameter.
137 double _Complex log( double _Complex x );
138 float _Complex log( float _Complex x );
139 long double _Complex log( long double _Complex x );
141 // These functions return the phase angle of their parameter.
142 double arg( double _Complex x );
143 float arg( float _Complex x );
144 long double arg( long double _Complex x );
145 float carg( float _Complex x );
146 long double carg( long double _Complex x );
148 // These functions return the conjugate of their parameter.
149 float _Complex conj( float _Complex x );
150 long double _Complex conj( long double _Complex x );
152 // These functions return the projection of their parameter.
153 float _Complex cproj( float _Complex x );
154 long double _Complex cproj( long double _Complex x );
156 #endif // __cplusplus
158 // ----------------------------------------------------------------------------
159 // FUNCTIONS - Standard C
161 // These functions return the absolute value (magnitude) of their parameter.
162 double cabs( double _Complex x );
163 float cabsf( float _Complex x );
164 long double cabsl( long double _Complex x );
166 // These functions return the sine of their parameter.
167 double _Complex csin( double _Complex x );
168 float _Complex csinf( float _Complex x );
169 long double _Complex csinl( long double _Complex x );
171 // These functions return the hyperbolic sine of their parameter.
172 double _Complex csinh( double _Complex x );
173 float _Complex csinhf( float _Complex x );
174 long double _Complex csinhl( long double _Complex x );
176 // These functions return the arcsine of their parameter.
177 double _Complex casin( double _Complex x );
178 float _Complex casinf( float _Complex x );
179 long double _Complex casinl( long double _Complex x );
181 // These functions return the hyperbolic arcsine of their parameter.
182 double _Complex casinh( double _Complex x );
183 float _Complex casinhf( float _Complex x );
184 long double _Complex casinhl( long double _Complex x );
186 // These functions return the cosine of their parameter.
187 double _Complex ccos( double _Complex x );
188 float _Complex ccosf( float _Complex x );
189 long double _Complex ccosl( long double _Complex x );
191 // These functions return the hyperbolic cosine of their parameter.
192 double _Complex ccosh( double _Complex x );
193 float _Complex ccoshf( float _Complex x );
194 long double _Complex ccoshl( long double _Complex x );
196 // These functions return the arccosine of their parameter.
197 double _Complex cacos( double _Complex x );
198 float _Complex cacosf( float _Complex x );
199 long double _Complex cacosl( long double _Complex x );
201 // These functions return the hyperbolic arccosine of their parameter.
202 double _Complex cacosh( double _Complex x );
203 float _Complex cacoshf( float _Complex x );
204 long double _Complex cacoshl( long double _Complex x );
206 // These functions return the tangent of their parameter.
207 double _Complex ctan( double _Complex x );
208 float _Complex ctanf( float _Complex x );
209 long double _Complex ctanl( long double _Complex x );
211 // These functions return the hyperbolic tangent of their parameter.
212 double _Complex ctanh( double _Complex x );
213 float _Complex ctanhf( float _Complex x );
214 long double _Complex ctanhl( long double _Complex x );
216 // These functions return the arctangent of their parameter.
217 double _Complex catan( double _Complex x );
218 float _Complex catanf( float _Complex x );
219 long double _Complex catanl( long double _Complex x );
221 // These functions return the hyperbolic arctangent of their parameter.
222 double _Complex catanh( double _Complex x );
223 float _Complex catanhf( float _Complex x );
224 long double _Complex catanhl( long double _Complex x );
226 // These functions return the imaginary part of their parameter.
227 double cimag( double _Complex x );
228 float cimagf( float _Complex x );
229 long double cimagl( long double _Complex x );
231 // These functions return the real part of their parameter.
232 double creal( double _Complex x );
233 float crealf( float _Complex x );
234 long double creall( long double _Complex x );
236 // These functions return x^y.
237 double _Complex cpow( double _Complex x, double _Complex y );
238 float _Complex cpowf( float _Complex x, float _Complex y );
239 long double _Complex cpowl( long double _Complex x, long double _Complex y );
241 // These functions return the square root of their parameter.
242 double _Complex csqrt( double _Complex x );
243 float _Complex csqrtf( float _Complex x );
244 long double _Complex csqrtl( long double _Complex x );
246 // These functions return the exponential of their parameter.
247 double _Complex cexp( double _Complex x );
248 float _Complex cexpf( float _Complex x );
249 long double _Complex cexpl( long double _Complex x );
251 // These functions return the logarithm of their parameter.
252 double _Complex clog( double _Complex x );
253 float _Complex clogf( float _Complex x );
254 long double _Complex clogl( long double _Complex x );
256 // These functions return the phase angle of their value.
257 double carg( double _Complex x );
258 float cargf( float _Complex x );
259 long double cargl( long double _Complex x );
261 // These functions return the conjugate of their parameter.
262 double _Complex conj( double _Complex x );
263 float _Complex conjf( float _Complex x );
264 long double _Complex conjl( long double _Complex x );
266 // These functions return the projection of their parameter.
267 double _Complex cproj( double _Complex x );
268 float _Complex cprojf( float _Complex x );
269 long double _Complex cprojl( long double _Complex x );
271 #endif // __COMPLEX_H