try to compile with -std=c90 4/n
[liba.git] / include / a / complex.h
blobf7fe9deeb7e464602f9abba1de00514b7b504732
1 /*!
2 @file complex.h
3 @brief complex number
4 */
6 #ifndef LIBA_COMPLEX_H
7 #define LIBA_COMPLEX_H
9 #include "a.h"
11 /*!
12 @ingroup liba
13 @addtogroup a_complex complex number
17 /* clang-format off */
18 /*! format constants for the fprintf family of functions */
19 #define A_COMPLEX_PRI(RF, RC, IF, IC) "(" A_FLOAT_PRI(RF, RC) "," A_FLOAT_PRI(IF, IC) ")"
20 /*! constructs a complex number from real and imaginary parts */
21 #define A_COMPLEX_C(real, imag) {a_float_c(real), a_float_c(imag)}
22 /* clang-format on */
24 /*! static cast to \ref a_complex */
25 #define a_complex_c(x) a_cast_s(a_complex, x)
26 #define a_complex_(_, x) a_cast_s(a_complex _, x)
28 /*!
29 @brief instance structure for complex number
31 typedef struct a_complex
33 a_float real; /*! real part of complex number */
34 a_float imag; /*! imaginary part of complex number */
35 } a_complex;
37 #if defined(__cplusplus)
38 extern "C" {
39 #endif /* __cplusplus */
40 #if defined(LIBA_COMPLEX_C)
41 #undef A_INTERN
42 #define A_INTERN A_INLINE
43 #endif /* LIBA_COMPLEX_C */
45 /*!
46 @brief constructs a complex number from real and imaginary parts
47 @param ctx = \f$ (\rm{Re},\rm{Im}) \f$
48 @param real real part of complex number
49 @param imag imaginary part of complex number
51 static A_INLINE void a_complex_rect(a_complex *ctx, a_float real, a_float imag)
53 ctx->real = real;
54 ctx->imag = imag;
57 /*!
58 @brief constructs a complex number from polar form
59 @param ctx = \f$ (\rho\cos\theta,\rho\sin\theta{i}) \f$
60 @param rho a distance from a reference point
61 @param theta an angle from a reference direction
63 A_EXTERN void a_complex_polar(a_complex *ctx, a_float rho, a_float theta);
65 /*!
66 @brief parse a string into a complex number
67 @param ctx points to an instance structure for complex number
68 @param str complex number string to be parsed
69 @return number of parsed characters
71 A_EXTERN unsigned int a_complex_parse(a_complex *ctx, char const *str);
73 /*!
74 @brief complex number x is equal to complex number y
75 @param x complex number on the left
76 @param y complex number on the right
77 @return result of comparison
79 A_EXTERN a_bool a_complex_eq(a_complex x, a_complex y);
81 /*!
82 @brief complex number x is not equal to complex number y
83 @param x complex number on the left
84 @param y complex number on the right
85 @return result of comparison
87 A_EXTERN a_bool a_complex_ne(a_complex x, a_complex y);
89 /* Properties of complex numbers */
91 /*!
92 @brief computes the natural logarithm of magnitude of a complex number
93 @param z a complex number
94 @return = \f$ \log\left|x\right| \f$
96 A_EXTERN a_float a_complex_logabs(a_complex z);
98 /*!
99 @brief computes the squared magnitude of a complex number
100 @param z a complex number
101 @return = \f$ a^2+b^2 \f$
103 A_EXTERN a_float a_complex_abs2(a_complex z);
106 @brief computes the magnitude of a complex number
107 @param z a complex number
108 @return = \f$ \sqrt{a^2+b^2} \f$
110 A_EXTERN a_float a_complex_abs(a_complex z);
113 @brief computes the phase angle of a complex number
114 @param z a complex number
115 @return = \f$ \arctan\frac{b}{a} \f$
117 A_EXTERN a_float a_complex_arg(a_complex z);
119 /* Complex arithmetic operators */
122 @brief computes the projection on Riemann sphere
123 @param ctx = \f$ z \f$ or \f$ (\inf,\rm{copysign}(0,b)i) \f$
124 @param z a complex number
126 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
127 A_EXTERN void a_complex_proj(a_complex *ctx, a_complex z);
128 #endif /* A_HAVE_INLINE */
129 A_EXTERN void a_complex_proj_(a_complex *ctx);
130 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
131 A_INTERN void a_complex_proj(a_complex *ctx, a_complex z)
133 a_complex_proj_(&z);
134 *ctx = z;
136 #endif /* A_HAVE_INLINE */
139 @brief computes the complex conjugate
140 @param ctx = \f$ (a,-b{i}) \f$
141 @param z a complex number
143 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
144 A_EXTERN void a_complex_conj(a_complex *ctx, a_complex z);
145 #endif /* A_HAVE_INLINE */
146 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
147 A_INTERN void a_complex_conj(a_complex *ctx, a_complex z)
149 ctx->real = +z.real;
150 ctx->imag = -z.imag;
152 #endif /* A_HAVE_INLINE */
153 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
154 A_EXTERN void a_complex_conj_(a_complex *ctx);
155 #endif /* A_HAVE_INLINE */
156 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
157 A_INTERN void a_complex_conj_(a_complex *ctx)
159 ctx->imag = -ctx->imag;
161 #endif /* A_HAVE_INLINE */
164 @brief computes the complex negative
165 @param ctx = \f$ (-a,-b{i}) \f$
166 @param z a complex number
168 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
169 A_EXTERN void a_complex_neg(a_complex *ctx, a_complex z);
170 #endif /* A_HAVE_INLINE */
171 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
172 A_INTERN void a_complex_neg(a_complex *ctx, a_complex z)
174 ctx->real = -z.real;
175 ctx->imag = -z.imag;
177 #endif /* A_HAVE_INLINE */
178 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
179 A_EXTERN void a_complex_neg_(a_complex *ctx);
180 #endif /* A_HAVE_INLINE */
181 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
182 A_INTERN void a_complex_neg_(a_complex *ctx)
184 ctx->real = -ctx->real;
185 ctx->imag = -ctx->imag;
187 #endif /* A_HAVE_INLINE */
190 @brief addition of complex numbers \f[ (a+b i)+(c+d i)=(a+c)+(b+d)i \f]
191 @param ctx = \f$ x + y \f$
192 @param x complex number on the left
193 @param y complex number on the right
195 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
196 A_EXTERN void a_complex_add(a_complex *ctx, a_complex x, a_complex y);
197 #endif /* A_HAVE_INLINE */
198 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
199 A_INTERN void a_complex_add(a_complex *ctx, a_complex x, a_complex y)
201 ctx->real = x.real + y.real;
202 ctx->imag = x.imag + y.imag;
204 #endif /* A_HAVE_INLINE */
205 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
206 A_EXTERN void a_complex_add_(a_complex *ctx, a_complex z);
207 #endif /* A_HAVE_INLINE */
208 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
209 A_INTERN void a_complex_add_(a_complex *ctx, a_complex z)
211 ctx->real += z.real;
212 ctx->imag += z.imag;
214 #endif /* A_HAVE_INLINE */
215 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
216 A_EXTERN void a_complex_add_real(a_complex *ctx, a_complex x, a_float y);
217 #endif /* A_HAVE_INLINE */
218 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
219 A_INTERN void a_complex_add_real(a_complex *ctx, a_complex x, a_float y)
221 ctx->real = x.real + y;
222 ctx->imag = x.imag;
224 #endif /* A_HAVE_INLINE */
225 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
226 A_EXTERN void a_complex_add_real_(a_complex *ctx, a_float x);
227 #endif /* A_HAVE_INLINE */
228 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
229 A_INTERN void a_complex_add_real_(a_complex *ctx, a_float x)
231 ctx->real += x;
233 #endif /* A_HAVE_INLINE */
234 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
235 A_EXTERN void a_complex_add_imag(a_complex *ctx, a_complex x, a_float y);
236 #endif /* A_HAVE_INLINE */
237 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
238 A_INTERN void a_complex_add_imag(a_complex *ctx, a_complex x, a_float y)
240 ctx->real = x.real;
241 ctx->imag = x.imag + y;
243 #endif /* A_HAVE_INLINE */
244 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
245 A_EXTERN void a_complex_add_imag_(a_complex *ctx, a_float x);
246 #endif /* A_HAVE_INLINE */
247 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
248 A_INTERN void a_complex_add_imag_(a_complex *ctx, a_float x)
250 ctx->imag += x;
252 #endif /* A_HAVE_INLINE */
255 @brief subtraction of complex numbers \f[ (a+b i)-(c+d i)=(a-c)+(b-d)i \f]
256 @param ctx = \f$ x - y \f$
257 @param x complex number on the left
258 @param y complex number on the right
260 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
261 A_EXTERN void a_complex_sub(a_complex *ctx, a_complex x, a_complex y);
262 #endif /* A_HAVE_INLINE */
263 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
264 A_INTERN void a_complex_sub(a_complex *ctx, a_complex x, a_complex y)
266 ctx->real = x.real - y.real;
267 ctx->imag = x.imag - y.imag;
269 #endif /* A_HAVE_INLINE */
270 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
271 A_EXTERN void a_complex_sub_(a_complex *ctx, a_complex z);
272 #endif /* A_HAVE_INLINE */
273 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
274 A_INTERN void a_complex_sub_(a_complex *ctx, a_complex z)
276 ctx->real -= z.real;
277 ctx->imag -= z.imag;
279 #endif /* A_HAVE_INLINE */
280 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
281 A_EXTERN void a_complex_sub_real(a_complex *ctx, a_complex x, a_float y);
282 #endif /* A_HAVE_INLINE */
283 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
284 A_INTERN void a_complex_sub_real(a_complex *ctx, a_complex x, a_float y)
286 ctx->real = x.real - y;
287 ctx->imag = x.imag;
289 #endif /* A_HAVE_INLINE */
290 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
291 A_EXTERN void a_complex_sub_real_(a_complex *ctx, a_float x);
292 #endif /* A_HAVE_INLINE */
293 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
294 A_INTERN void a_complex_sub_real_(a_complex *ctx, a_float x)
296 ctx->real -= x;
298 #endif /* A_HAVE_INLINE */
299 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
300 A_EXTERN void a_complex_sub_imag(a_complex *ctx, a_complex x, a_float y);
301 #endif /* A_HAVE_INLINE */
302 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
303 A_INTERN void a_complex_sub_imag(a_complex *ctx, a_complex x, a_float y)
305 ctx->real = x.real;
306 ctx->imag = x.imag - y;
308 #endif /* A_HAVE_INLINE */
309 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
310 A_EXTERN void a_complex_sub_imag_(a_complex *ctx, a_float x);
311 #endif /* A_HAVE_INLINE */
312 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
313 A_INTERN void a_complex_sub_imag_(a_complex *ctx, a_float x)
315 ctx->imag -= x;
317 #endif /* A_HAVE_INLINE */
320 @brief multiplication of complex numbers \f[ (a+b i)(c+d i)=a c+b c i+a d i+b d i^{2}=(a c-b d)+(b c+a d) i \f]
321 @param ctx = \f$ x \times y \f$
322 @param x complex number on the left
323 @param y complex number on the right
325 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
326 A_EXTERN void a_complex_mul(a_complex *ctx, a_complex x, a_complex y);
327 #endif /* A_HAVE_INLINE */
328 A_EXTERN void a_complex_mul_(a_complex *ctx, a_complex z);
329 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
330 A_INTERN void a_complex_mul(a_complex *ctx, a_complex x, a_complex y)
332 a_complex_mul_(&x, y);
333 *ctx = x;
335 #endif /* A_HAVE_INLINE */
336 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
337 A_EXTERN void a_complex_mul_real(a_complex *ctx, a_complex x, a_float y);
338 #endif /* A_HAVE_INLINE */
339 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
340 A_INTERN void a_complex_mul_real(a_complex *ctx, a_complex x, a_float y)
342 ctx->real = x.real * y;
343 ctx->imag = x.imag * y;
345 #endif /* A_HAVE_INLINE */
346 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
347 A_EXTERN void a_complex_mul_real_(a_complex *ctx, a_float x);
348 #endif /* A_HAVE_INLINE */
349 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
350 A_INTERN void a_complex_mul_real_(a_complex *ctx, a_float x)
352 ctx->real *= x;
353 ctx->imag *= x;
355 #endif /* A_HAVE_INLINE */
356 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
357 A_EXTERN void a_complex_mul_imag(a_complex *ctx, a_complex x, a_float y);
358 #endif /* A_HAVE_INLINE */
359 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
360 A_INTERN void a_complex_mul_imag(a_complex *ctx, a_complex x, a_float y)
362 ctx->real = -x.imag * y;
363 ctx->imag = x.real * y;
365 #endif /* A_HAVE_INLINE */
366 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
367 A_EXTERN void a_complex_mul_imag_(a_complex *ctx, a_float x);
368 #endif /* A_HAVE_INLINE */
369 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
370 A_INTERN void a_complex_mul_imag_(a_complex *ctx, a_float x)
372 a_float const real = ctx->real;
373 ctx->real = -ctx->imag * x;
374 ctx->imag = real * x;
376 #endif /* A_HAVE_INLINE */
379 @brief division of complex numbers \f[ \frac{(a+b i)}{(c+d i)}=\frac{(a+b i)(c-d i)}{(c+d i)(c-d i)}=\frac{a c+b c i-a d i-b d i^{2}}{c^{2}-(d i)^{2}}=\frac{(a c+b d)+(b c-a d) i}{c^{2}+d^{2}}=\left(\frac{a c+b d}{c^{2}+d^{2}}\right)+\left(\frac{b c-a d}{c^{2}+d^{2}}\right) i \f]
380 @param ctx = \f$ x \div y \f$
381 @param x complex number on the left
382 @param y complex number on the right
384 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
385 A_EXTERN void a_complex_div(a_complex *ctx, a_complex x, a_complex y);
386 #endif /* A_HAVE_INLINE */
387 A_EXTERN void a_complex_div_(a_complex *ctx, a_complex z);
388 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
389 A_INTERN void a_complex_div(a_complex *ctx, a_complex x, a_complex y)
391 a_complex_div_(&x, y);
392 *ctx = x;
394 #endif /* A_HAVE_INLINE */
395 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
396 A_EXTERN void a_complex_div_real(a_complex *ctx, a_complex x, a_float y);
397 #endif /* A_HAVE_INLINE */
398 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
399 A_INTERN void a_complex_div_real(a_complex *ctx, a_complex x, a_float y)
401 ctx->real = x.real / y;
402 ctx->imag = x.imag / y;
404 #endif /* A_HAVE_INLINE */
405 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
406 A_EXTERN void a_complex_div_real_(a_complex *ctx, a_float x);
407 #endif /* A_HAVE_INLINE */
408 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
409 A_INTERN void a_complex_div_real_(a_complex *ctx, a_float x)
411 ctx->real /= x;
412 ctx->imag /= x;
414 #endif /* A_HAVE_INLINE */
415 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
416 A_EXTERN void a_complex_div_imag(a_complex *ctx, a_complex x, a_float y);
417 #endif /* A_HAVE_INLINE */
418 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
419 A_INTERN void a_complex_div_imag(a_complex *ctx, a_complex x, a_float y)
421 ctx->real = -x.imag / y;
422 ctx->imag = x.real / y;
424 #endif /* A_HAVE_INLINE */
425 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
426 A_EXTERN void a_complex_div_imag_(a_complex *ctx, a_float x);
427 #endif /* A_HAVE_INLINE */
428 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
429 A_INTERN void a_complex_div_imag_(a_complex *ctx, a_float x)
431 a_float const real = ctx->real;
432 ctx->real = -ctx->imag / x;
433 ctx->imag = real / x;
435 #endif /* A_HAVE_INLINE */
438 @brief inverse of a complex number \f[ \frac{a-bi}{a^2+b^2}=\left(\frac{a}{a^2+b^2}\right)-\left(\frac{b}{a^2+b^2}\right)i \f]
439 @param ctx inverse or reciprocal \f$ \frac{1}{z} \f$
440 @param z a complex number
442 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
443 A_EXTERN void a_complex_inv(a_complex *ctx, a_complex z);
444 #endif /* A_HAVE_INLINE */
445 A_EXTERN void a_complex_inv_(a_complex *ctx);
446 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
447 A_INTERN void a_complex_inv(a_complex *ctx, a_complex z)
449 a_complex_inv_(&z);
450 *ctx = z;
452 #endif /* A_HAVE_INLINE */
454 /* Elementary Complex Functions */
457 @brief computes the complex square root
458 @param ctx = \f$ \sqrt{z} \f$
459 @param z a complex number
461 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
462 A_EXTERN void a_complex_sqrt(a_complex *ctx, a_complex z);
463 #endif /* A_HAVE_INLINE */
464 A_EXTERN void a_complex_sqrt_(a_complex *ctx);
465 A_EXTERN void a_complex_sqrt_real(a_complex *ctx, a_float x);
466 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
467 A_INTERN void a_complex_sqrt(a_complex *ctx, a_complex z)
469 a_complex_sqrt_(&z);
470 *ctx = z;
472 #endif /* A_HAVE_INLINE */
475 @brief complex number z raised to complex power a
476 @param ctx = \f$ z^a \f$
477 @param z a complex number
478 @param a a complex number
480 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
481 A_EXTERN void a_complex_pow(a_complex *ctx, a_complex z, a_complex a);
482 #endif /* A_HAVE_INLINE */
483 A_EXTERN void a_complex_pow_(a_complex *ctx, a_complex a);
484 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
485 A_INTERN void a_complex_pow(a_complex *ctx, a_complex z, a_complex a)
487 a_complex_pow_(&z, a);
488 *ctx = z;
490 #endif /* A_HAVE_INLINE */
493 @brief complex number z raised to real power a
494 @param ctx = \f$ z^a \f$
495 @param z a complex number
496 @param a a real number
498 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
499 A_EXTERN void a_complex_pow_real(a_complex *ctx, a_complex z, a_float a);
500 #endif /* A_HAVE_INLINE */
501 A_EXTERN void a_complex_pow_real_(a_complex *ctx, a_float a);
502 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
503 A_INTERN void a_complex_pow_real(a_complex *ctx, a_complex z, a_float a)
505 a_complex_pow_real_(&z, a);
506 *ctx = z;
508 #endif /* A_HAVE_INLINE */
511 @brief computes the complex base-e exponential
512 @param ctx = \f$ e^z \f$
513 @param z a complex number
515 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
516 A_EXTERN void a_complex_exp(a_complex *ctx, a_complex z);
517 #endif /* A_HAVE_INLINE */
518 A_EXTERN void a_complex_exp_(a_complex *ctx);
519 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
520 A_INTERN void a_complex_exp(a_complex *ctx, a_complex z)
522 a_complex_exp_(&z);
523 *ctx = z;
525 #endif /* A_HAVE_INLINE */
528 @brief computes the complex natural logarithm
529 @param ctx = \f$ \ln{z} \f$
530 @param z a complex number
532 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
533 A_EXTERN void a_complex_log(a_complex *ctx, a_complex z);
534 #endif /* A_HAVE_INLINE */
535 A_EXTERN void a_complex_log_(a_complex *ctx);
536 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
537 A_INTERN void a_complex_log(a_complex *ctx, a_complex z)
539 a_complex_log_(&z);
540 *ctx = z;
542 #endif /* A_HAVE_INLINE */
545 @brief computes the complex base-2 logarithm
546 @param ctx = \f$ \log_{2}{z} \f$
547 @param z a complex number
549 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
550 A_EXTERN void a_complex_log2(a_complex *ctx, a_complex z);
551 #endif /* A_HAVE_INLINE */
552 A_EXTERN void a_complex_log2_(a_complex *ctx);
553 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
554 A_INTERN void a_complex_log2(a_complex *ctx, a_complex z)
556 a_complex_log2_(&z);
557 *ctx = z;
559 #endif /* A_HAVE_INLINE */
562 @brief computes the complex base-10 logarithm
563 @param ctx = \f$ \lg{z} \f$
564 @param z a complex number
566 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
567 A_EXTERN void a_complex_log10(a_complex *ctx, a_complex z);
568 #endif /* A_HAVE_INLINE */
569 A_EXTERN void a_complex_log10_(a_complex *ctx);
570 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
571 A_INTERN void a_complex_log10(a_complex *ctx, a_complex z)
573 a_complex_log10_(&z);
574 *ctx = z;
576 #endif /* A_HAVE_INLINE */
579 @brief computes the complex base-b logarithm
580 @param ctx = \f$ \log_{b}{z} \f$
581 @param z a complex number
582 @param b a complex number
584 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
585 A_EXTERN void a_complex_logb(a_complex *ctx, a_complex z, a_complex b);
586 #endif /* A_HAVE_INLINE */
587 A_EXTERN void a_complex_logb_(a_complex *ctx, a_complex b);
588 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
589 A_INTERN void a_complex_logb(a_complex *ctx, a_complex z, a_complex b)
591 a_complex_logb_(&z, b);
592 *ctx = z;
594 #endif /* A_HAVE_INLINE */
596 /* Complex Trigonometric Functions */
599 @brief computes the complex sine \f[ \sin(z)=\frac{\exp(z{i})-\exp(-z{i})}{2{i}} \f]
600 @param ctx = \f$ \sin(z) \f$
601 @param z a complex number
603 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
604 A_EXTERN void a_complex_sin(a_complex *ctx, a_complex z);
605 #endif /* A_HAVE_INLINE */
606 A_EXTERN void a_complex_sin_(a_complex *ctx);
607 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
608 A_INTERN void a_complex_sin(a_complex *ctx, a_complex z)
610 a_complex_sin_(&z);
611 *ctx = z;
613 #endif /* A_HAVE_INLINE */
616 @brief computes the complex cosine \f[ \cos(z)=\frac{\exp(z{i})+\exp(-z{i})}{2} \f]
617 @param ctx = \f$ \cos(z) \f$
618 @param z a complex number
620 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
621 A_EXTERN void a_complex_cos(a_complex *ctx, a_complex z);
622 #endif /* A_HAVE_INLINE */
623 A_EXTERN void a_complex_cos_(a_complex *ctx);
624 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
625 A_INTERN void a_complex_cos(a_complex *ctx, a_complex z)
627 a_complex_cos_(&z);
628 *ctx = z;
630 #endif /* A_HAVE_INLINE */
633 @brief computes the complex tangent \f[ \tan(z)=\frac{\sin(z)}{\cos(z)} \f]
634 @param ctx = \f$ \tan(z) \f$
635 @param z a complex number
637 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
638 A_EXTERN void a_complex_tan(a_complex *ctx, a_complex z);
639 #endif /* A_HAVE_INLINE */
640 A_EXTERN void a_complex_tan_(a_complex *ctx);
641 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
642 A_INTERN void a_complex_tan(a_complex *ctx, a_complex z)
644 a_complex_tan_(&z);
645 *ctx = z;
647 #endif /* A_HAVE_INLINE */
650 @brief computes the complex secant \f[ \sec(z)=\frac{1}{\cos(z)} \f]
651 @param ctx = \f$ \sec(z) \f$
652 @param z a complex number
654 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
655 A_EXTERN void a_complex_sec(a_complex *ctx, a_complex z);
656 #endif /* A_HAVE_INLINE */
657 A_EXTERN void a_complex_sec_(a_complex *ctx);
658 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
659 A_INTERN void a_complex_sec(a_complex *ctx, a_complex z)
661 a_complex_sec_(&z);
662 *ctx = z;
664 #endif /* A_HAVE_INLINE */
667 @brief computes the complex cosecant \f[ \csc(z)=\frac{1}{\sin(z)} \f]
668 @param ctx = \f$ \csc(z) \f$
669 @param z a complex number
671 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
672 A_EXTERN void a_complex_csc(a_complex *ctx, a_complex z);
673 #endif /* A_HAVE_INLINE */
674 A_EXTERN void a_complex_csc_(a_complex *ctx);
675 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
676 A_INTERN void a_complex_csc(a_complex *ctx, a_complex z)
678 a_complex_csc_(&z);
679 *ctx = z;
681 #endif /* A_HAVE_INLINE */
684 @brief computes the complex cotangent \f[ \cot(z)=\frac{1}{\tan(z)} \f]
685 @param ctx = \f$ \cot(z) \f$
686 @param z a complex number
688 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
689 A_EXTERN void a_complex_cot(a_complex *ctx, a_complex z);
690 #endif /* A_HAVE_INLINE */
691 A_EXTERN void a_complex_cot_(a_complex *ctx);
692 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
693 A_INTERN void a_complex_cot(a_complex *ctx, a_complex z)
695 a_complex_cot_(&z);
696 *ctx = z;
698 #endif /* A_HAVE_INLINE */
700 /* Inverse Complex Trigonometric Functions */
703 @brief computes the complex arc sine
704 @param ctx = \f$ \arcsin(z) \f$
705 @param z a complex number
707 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
708 A_EXTERN void a_complex_asin(a_complex *ctx, a_complex z);
709 #endif /* A_HAVE_INLINE */
710 A_EXTERN void a_complex_asin_(a_complex *ctx);
711 A_EXTERN void a_complex_asin_real(a_complex *ctx, a_float x);
712 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
713 A_INTERN void a_complex_asin(a_complex *ctx, a_complex z)
715 a_complex_asin_(&z);
716 *ctx = z;
718 #endif /* A_HAVE_INLINE */
721 @brief computes the complex arc cosine
722 @param ctx = \f$ \arccos(z) \f$
723 @param z a complex number
725 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
726 A_EXTERN void a_complex_acos(a_complex *ctx, a_complex z);
727 #endif /* A_HAVE_INLINE */
728 A_EXTERN void a_complex_acos_(a_complex *ctx);
729 A_EXTERN void a_complex_acos_real(a_complex *ctx, a_float x);
730 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
731 A_INTERN void a_complex_acos(a_complex *ctx, a_complex z)
733 a_complex_acos_(&z);
734 *ctx = z;
736 #endif /* A_HAVE_INLINE */
739 @brief computes the complex arc tangent
740 @param ctx = \f$ \arctan(z) \f$
741 @param z a complex number
743 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
744 A_EXTERN void a_complex_atan(a_complex *ctx, a_complex z);
745 #endif /* A_HAVE_INLINE */
746 A_EXTERN void a_complex_atan_(a_complex *ctx);
747 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
748 A_INTERN void a_complex_atan(a_complex *ctx, a_complex z)
750 a_complex_atan_(&z);
751 *ctx = z;
753 #endif /* A_HAVE_INLINE */
756 @brief computes the complex arc secant \f[ \mathrm{arcsec}(z)=\mathrm{arccos}(\frac{1}{z}) \f]
757 @param ctx = \f$ \mathrm{arcsec}(z) \f$
758 @param z a complex number
760 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
761 A_EXTERN void a_complex_asec(a_complex *ctx, a_complex z);
762 #endif /* A_HAVE_INLINE */
763 A_EXTERN void a_complex_asec_(a_complex *ctx);
764 A_EXTERN void a_complex_asec_real(a_complex *ctx, a_float x);
765 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
766 A_INTERN void a_complex_asec(a_complex *ctx, a_complex z)
768 a_complex_asec_(&z);
769 *ctx = z;
771 #endif /* A_HAVE_INLINE */
774 @brief computes the complex arc cosecant \f[ \mathrm{arccsc}(z)=\mathrm{arcsin}(\frac{1}{z}) \f]
775 @param ctx = \f$ \mathrm{arccsc}(z) \f$
776 @param z a complex number
778 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
779 A_EXTERN void a_complex_acsc(a_complex *ctx, a_complex z);
780 #endif /* A_HAVE_INLINE */
781 A_EXTERN void a_complex_acsc_(a_complex *ctx);
782 A_EXTERN void a_complex_acsc_real(a_complex *ctx, a_float x);
783 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
784 A_INTERN void a_complex_acsc(a_complex *ctx, a_complex z)
786 a_complex_acsc_(&z);
787 *ctx = z;
789 #endif /* A_HAVE_INLINE */
792 @brief computes the complex arc cotangent \f[ \mathrm{arccot}(z)=\mathrm{arctan}(\frac{1}{z}) \f]
793 @param ctx = \f$ \mathrm{arccot}(z) \f$
794 @param z a complex number
796 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
797 A_EXTERN void a_complex_acot(a_complex *ctx, a_complex z);
798 #endif /* A_HAVE_INLINE */
799 A_EXTERN void a_complex_acot_(a_complex *ctx);
800 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
801 A_INTERN void a_complex_acot(a_complex *ctx, a_complex z)
803 a_complex_acot_(&z);
804 *ctx = z;
806 #endif /* A_HAVE_INLINE */
808 /* Complex Hyperbolic Functions */
811 @brief computes the complex hyperbolic sine \f[ \sinh(z)=\frac{\exp(z)-\exp(-z)}{2} \f]
812 @param ctx = \f$ \sinh(z) \f$
813 @param z a complex number
815 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
816 A_EXTERN void a_complex_sinh(a_complex *ctx, a_complex z);
817 #endif /* A_HAVE_INLINE */
818 A_EXTERN void a_complex_sinh_(a_complex *ctx);
819 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
820 A_INTERN void a_complex_sinh(a_complex *ctx, a_complex z)
822 a_complex_sinh_(&z);
823 *ctx = z;
825 #endif /* A_HAVE_INLINE */
828 @brief computes the complex hyperbolic cosine \f[ \cosh(z)=\frac{\exp(z)+\exp(-z)}{2} \f]
829 @param ctx = \f$ \cosh(z) \f$
830 @param z a complex number
832 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
833 A_EXTERN void a_complex_cosh(a_complex *ctx, a_complex z);
834 #endif /* A_HAVE_INLINE */
835 A_EXTERN void a_complex_cosh_(a_complex *ctx);
836 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
837 A_INTERN void a_complex_cosh(a_complex *ctx, a_complex z)
839 a_complex_cosh_(&z);
840 *ctx = z;
842 #endif /* A_HAVE_INLINE */
845 @brief computes the complex hyperbolic tangent \f[ \tanh(z)=\frac{\sinh(z)}{\cosh(z)} \f]
846 @param ctx = \f$ \tanh(z) \f$
847 @param z a complex number
849 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
850 A_EXTERN void a_complex_tanh(a_complex *ctx, a_complex z);
851 #endif /* A_HAVE_INLINE */
852 A_EXTERN void a_complex_tanh_(a_complex *ctx);
853 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
854 A_INTERN void a_complex_tanh(a_complex *ctx, a_complex z)
856 a_complex_tanh_(&z);
857 *ctx = z;
859 #endif /* A_HAVE_INLINE */
862 @brief computes the complex hyperbolic secant \f[ \mathrm{sech}(z)=\frac{1}{\cosh(z)} \f]
863 @param ctx = \f$ \mathrm{sech}(z) \f$
864 @param z a complex number
866 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
867 A_EXTERN void a_complex_sech(a_complex *ctx, a_complex z);
868 #endif /* A_HAVE_INLINE */
869 A_EXTERN void a_complex_sech_(a_complex *ctx);
870 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
871 A_INTERN void a_complex_sech(a_complex *ctx, a_complex z)
873 a_complex_sech_(&z);
874 *ctx = z;
876 #endif /* A_HAVE_INLINE */
879 @brief computes the complex hyperbolic cosecant \f[ \mathrm{csch}(z)=\frac{1}{\sinh(z)} \f]
880 @param ctx = \f$ \mathrm{csch}(z) \f$
881 @param z a complex number
883 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
884 A_EXTERN void a_complex_csch(a_complex *ctx, a_complex z);
885 #endif /* A_HAVE_INLINE */
886 A_EXTERN void a_complex_csch_(a_complex *ctx);
887 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
888 A_INTERN void a_complex_csch(a_complex *ctx, a_complex z)
890 a_complex_csch_(&z);
891 *ctx = z;
893 #endif /* A_HAVE_INLINE */
896 @brief computes the complex hyperbolic cotangent \f[ \mathrm{coth}(z)=\frac{1}{\tanh(z)} \f]
897 @param ctx = \f$ \mathrm{coth}(z) \f$
898 @param z a complex number
900 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
901 A_EXTERN void a_complex_coth(a_complex *ctx, a_complex z);
902 #endif /* A_HAVE_INLINE */
903 A_EXTERN void a_complex_coth_(a_complex *ctx);
904 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
905 A_INTERN void a_complex_coth(a_complex *ctx, a_complex z)
907 a_complex_coth_(&z);
908 *ctx = z;
910 #endif /* A_HAVE_INLINE */
912 /* Inverse Complex Hyperbolic Functions */
915 @brief computes the complex arc hyperbolic sine
916 @param ctx = \f$ \mathrm{arcsinh}(z) \f$
917 @param z a complex number
919 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
920 A_EXTERN void a_complex_asinh(a_complex *ctx, a_complex z);
921 #endif /* A_HAVE_INLINE */
922 A_EXTERN void a_complex_asinh_(a_complex *ctx);
923 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
924 A_INTERN void a_complex_asinh(a_complex *ctx, a_complex z)
926 a_complex_asinh_(&z);
927 *ctx = z;
929 #endif /* A_HAVE_INLINE */
932 @brief computes the complex arc hyperbolic cosine \f[ \mathrm{arccosh}(z)=\log(z-\sqrt{z^2-1}) \f]
933 @param ctx = \f$ \mathrm{arccosh}(z) \f$
934 @param z a complex number
936 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
937 A_EXTERN void a_complex_acosh(a_complex *ctx, a_complex z);
938 #endif /* A_HAVE_INLINE */
939 A_EXTERN void a_complex_acosh_(a_complex *ctx);
940 A_EXTERN void a_complex_acosh_real(a_complex *ctx, a_float x);
941 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
942 A_INTERN void a_complex_acosh(a_complex *ctx, a_complex z)
944 a_complex_acosh_(&z);
945 *ctx = z;
947 #endif /* A_HAVE_INLINE */
950 @brief computes the complex arc hyperbolic tangent
951 @param ctx = \f$ \mathrm{arctanh}(z) \f$
952 @param z a complex number
954 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
955 A_EXTERN void a_complex_atanh(a_complex *ctx, a_complex z);
956 #endif /* A_HAVE_INLINE */
957 A_EXTERN void a_complex_atanh_(a_complex *ctx);
958 A_EXTERN void a_complex_atanh_real(a_complex *ctx, a_float x);
959 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
960 A_INTERN void a_complex_atanh(a_complex *ctx, a_complex z)
962 a_complex_atanh_(&z);
963 *ctx = z;
965 #endif /* A_HAVE_INLINE */
968 @brief computes the complex arc hyperbolic secant \f[ \mathrm{arcsech}(z)=\mathrm{arccosh}(\frac{1}{z}) \f]
969 @param ctx = \f$ \mathrm{arcsech}(z) \f$
970 @param z a complex number
972 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
973 A_EXTERN void a_complex_asech(a_complex *ctx, a_complex z);
974 #endif /* A_HAVE_INLINE */
975 A_EXTERN void a_complex_asech_(a_complex *ctx);
976 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
977 A_INTERN void a_complex_asech(a_complex *ctx, a_complex z)
979 a_complex_asech_(&z);
980 *ctx = z;
982 #endif /* A_HAVE_INLINE */
985 @brief computes the complex arc hyperbolic cosecant \f[ \mathrm{arccsch}(z)=\mathrm{arcsinh}(\frac{1}{z}) \f]
986 @param ctx = \f$ \mathrm{arccsch}(z) \f$
987 @param z a complex number
989 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
990 A_EXTERN void a_complex_acsch(a_complex *ctx, a_complex z);
991 #endif /* A_HAVE_INLINE */
992 A_EXTERN void a_complex_acsch_(a_complex *ctx);
993 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
994 A_INTERN void a_complex_acsch(a_complex *ctx, a_complex z)
996 a_complex_acsch_(&z);
997 *ctx = z;
999 #endif /* A_HAVE_INLINE */
1002 @brief computes the complex arc hyperbolic cotangent \f[ \mathrm{arccoth}(z)=\mathrm{arctanh}(\frac{1}{z}) \f]
1003 @param ctx = \f$ \mathrm{arccoth}(z) \f$
1004 @param z a complex number
1006 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
1007 A_EXTERN void a_complex_acoth(a_complex *ctx, a_complex z);
1008 #endif /* A_HAVE_INLINE */
1009 A_EXTERN void a_complex_acoth_(a_complex *ctx);
1010 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
1011 A_INTERN void a_complex_acoth(a_complex *ctx, a_complex z)
1013 a_complex_acoth_(&z);
1014 *ctx = z;
1016 #endif /* A_HAVE_INLINE */
1018 #if defined(LIBA_COMPLEX_C)
1019 #undef A_INTERN
1020 #define A_INTERN static A_INLINE
1021 #endif /* LIBA_COMPLEX_C */
1022 #if defined(__cplusplus)
1023 } /* extern "C" */
1024 #endif /* __cplusplus */
1026 /*! @} a_complex */
1028 #endif /* a/complex.h */