rename MAIN_,MAIN to MAIN,main in test
[liba.git] / include / a / complex.h
blob9bd90fd01f98626a1ba6eafb284b8bd43697db76
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 A
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 constant from real and imaginary parts */
21 #if !defined __cplusplus
22 #define A_COMPLEX_C(R, I) (a_complex){A_FLOAT_C(R), A_FLOAT_C(I)}
23 #else /* !__cplusplus */
24 #define A_COMPLEX_C(R, I) {A_FLOAT_C(R), A_FLOAT_C(I)}
25 #endif /* __cplusplus */
26 /*! constructs a complex number from real and imaginary parts */
27 #if !defined __cplusplus
28 #define a_complex_c(r, i) (a_complex){a_float_c(r), a_float_c(i)}
29 #else /* !__cplusplus */
30 #define a_complex_c(r, i) {a_float_c(r), a_float_c(i)}
31 #endif /* __cplusplus */
32 // clang-format on
34 /*!
35 @brief instance structure for complex number
37 typedef struct a_complex
39 a_float real; //!< real part of complex number
40 a_float imag; //!< imaginary part of complex number
41 } a_complex;
43 #if defined(__cplusplus)
44 extern "C" {
45 #endif /* __cplusplus */
46 #if defined(LIBA_COMPLEX_C)
47 #undef A_INTERN
48 #define A_INTERN A_INLINE
49 #endif /* LIBA_COMPLEX_C */
51 /*!
52 @brief constructs a complex number from real and imaginary parts
53 @param _z = \f$ (\rm{Re},\rm{Im}) \f$
54 @param real real part of complex number
55 @param imag imaginary part of complex number
57 static A_INLINE void a_complex_rect(a_complex *_z, a_float real, a_float imag)
59 _z->real = real;
60 _z->imag = imag;
63 /*!
64 @brief constructs a complex number from polar form
65 @param _z = \f$ (\rho\cos\theta,\rho\sin\theta{i}) \f$
66 @param rho a distance from a reference point
67 @param theta an angle from a reference direction
69 A_EXTERN void a_complex_polar(a_complex *_z, a_float rho, a_float theta);
71 /*!
72 @brief parse a string into a complex number
73 @param _z points to an instance structure for complex number
74 @param str complex number string to be parsed
75 @return number of parsed characters
77 A_EXTERN unsigned int a_complex_parse(a_complex *_z, char const *str);
79 /*!
80 @brief complex number x is equal to complex number y
81 @param x complex number on the left
82 @param y complex number on the right
83 @return result of comparison
85 A_EXTERN a_bool a_complex_eq(a_complex x, a_complex y);
87 /*!
88 @brief complex number x is not equal to complex number y
89 @param x complex number on the left
90 @param y complex number on the right
91 @return result of comparison
93 A_EXTERN a_bool a_complex_ne(a_complex x, a_complex y);
95 /* Properties of complex numbers */
97 /*!
98 @brief computes the natural logarithm of magnitude of a complex number
99 @param z a complex number
100 @return = \f$ \log\left|x\right| \f$
102 A_EXTERN a_float a_complex_logabs(a_complex z);
105 @brief computes the squared magnitude of a complex number
106 @param z a complex number
107 @return = \f$ a^2+b^2 \f$
109 A_EXTERN a_float a_complex_abs2(a_complex z);
112 @brief computes the magnitude of a complex number
113 @param z a complex number
114 @return = \f$ \sqrt{a^2+b^2} \f$
116 A_EXTERN a_float a_complex_abs(a_complex z);
119 @brief computes the phase angle of a complex number
120 @param z a complex number
121 @return = \f$ \arctan\frac{b}{a} \f$
123 A_EXTERN a_float a_complex_arg(a_complex z);
125 /* Complex arithmetic operators */
128 @brief computes the projection on Riemann sphere
129 @param _z = \f$ z \f$ or \f$ (\inf,\rm{copysign}(0,b)i) \f$
130 @param z a complex number
132 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
133 A_EXTERN void a_complex_proj(a_complex *_z, a_complex z);
134 #endif /* A_HAVE_INLINE */
135 A_EXTERN void a_complex_proj_(a_complex *_z);
136 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
137 A_INTERN void a_complex_proj(a_complex *_z, a_complex z)
139 a_complex_proj_(&z);
140 *_z = z;
142 #endif /* A_HAVE_INLINE */
145 @brief computes the complex conjugate
146 @param _z = \f$ (a,-b{i}) \f$
147 @param z a complex number
149 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
150 A_EXTERN void a_complex_conj(a_complex *_z, a_complex z);
151 #endif /* A_HAVE_INLINE */
152 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
153 A_INTERN void a_complex_conj(a_complex *_z, a_complex z)
155 _z->real = +z.real;
156 _z->imag = -z.imag;
158 #endif /* A_HAVE_INLINE */
159 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
160 A_EXTERN void a_complex_conj_(a_complex *_z);
161 #endif /* A_HAVE_INLINE */
162 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
163 A_INTERN void a_complex_conj_(a_complex *_z)
165 _z->imag = -_z->imag;
167 #endif /* A_HAVE_INLINE */
170 @brief computes the complex negative
171 @param _z = \f$ (-a,-b{i}) \f$
172 @param z a complex number
174 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
175 A_EXTERN void a_complex_neg(a_complex *_z, a_complex z);
176 #endif /* A_HAVE_INLINE */
177 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
178 A_INTERN void a_complex_neg(a_complex *_z, a_complex z)
180 _z->real = -z.real;
181 _z->imag = -z.imag;
183 #endif /* A_HAVE_INLINE */
184 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
185 A_EXTERN void a_complex_neg_(a_complex *_z);
186 #endif /* A_HAVE_INLINE */
187 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
188 A_INTERN void a_complex_neg_(a_complex *_z)
190 _z->real = -_z->real;
191 _z->imag = -_z->imag;
193 #endif /* A_HAVE_INLINE */
196 @brief addition of complex numbers \f[ (a+b i)+(c+d i)=(a+c)+(b+d)i \f]
197 @param _z = \f$ x + y \f$
198 @param x complex number on the left
199 @param y complex number on the right
201 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
202 A_EXTERN void a_complex_add(a_complex *_z, a_complex x, a_complex y);
203 #endif /* A_HAVE_INLINE */
204 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
205 A_INTERN void a_complex_add(a_complex *_z, a_complex x, a_complex y)
207 _z->real = x.real + y.real;
208 _z->imag = x.imag + y.imag;
210 #endif /* A_HAVE_INLINE */
211 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
212 A_EXTERN void a_complex_add_(a_complex *_z, a_complex z);
213 #endif /* A_HAVE_INLINE */
214 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
215 A_INTERN void a_complex_add_(a_complex *_z, a_complex z)
217 _z->real += z.real;
218 _z->imag += z.imag;
220 #endif /* A_HAVE_INLINE */
221 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
222 A_EXTERN void a_complex_add_real(a_complex *_z, a_complex x, a_float y);
223 #endif /* A_HAVE_INLINE */
224 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
225 A_INTERN void a_complex_add_real(a_complex *_z, a_complex x, a_float y)
227 _z->real = x.real + y;
228 _z->imag = x.imag;
230 #endif /* A_HAVE_INLINE */
231 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
232 A_EXTERN void a_complex_add_real_(a_complex *_z, a_float x);
233 #endif /* A_HAVE_INLINE */
234 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
235 A_INTERN void a_complex_add_real_(a_complex *_z, a_float x)
237 _z->real += x;
239 #endif /* A_HAVE_INLINE */
240 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
241 A_EXTERN void a_complex_add_imag(a_complex *_z, a_complex x, a_float y);
242 #endif /* A_HAVE_INLINE */
243 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
244 A_INTERN void a_complex_add_imag(a_complex *_z, a_complex x, a_float y)
246 _z->real = x.real;
247 _z->imag = x.imag + y;
249 #endif /* A_HAVE_INLINE */
250 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
251 A_EXTERN void a_complex_add_imag_(a_complex *_z, a_float x);
252 #endif /* A_HAVE_INLINE */
253 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
254 A_INTERN void a_complex_add_imag_(a_complex *_z, a_float x)
256 _z->imag += x;
258 #endif /* A_HAVE_INLINE */
261 @brief subtraction of complex numbers \f[ (a+b i)-(c+d i)=(a-c)+(b-d)i \f]
262 @param _z = \f$ x - y \f$
263 @param x complex number on the left
264 @param y complex number on the right
266 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
267 A_EXTERN void a_complex_sub(a_complex *_z, a_complex x, a_complex y);
268 #endif /* A_HAVE_INLINE */
269 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
270 A_INTERN void a_complex_sub(a_complex *_z, a_complex x, a_complex y)
272 _z->real = x.real - y.real;
273 _z->imag = x.imag - y.imag;
275 #endif /* A_HAVE_INLINE */
276 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
277 A_EXTERN void a_complex_sub_(a_complex *_z, a_complex z);
278 #endif /* A_HAVE_INLINE */
279 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
280 A_INTERN void a_complex_sub_(a_complex *_z, a_complex z)
282 _z->real -= z.real;
283 _z->imag -= z.imag;
285 #endif /* A_HAVE_INLINE */
286 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
287 A_EXTERN void a_complex_sub_real(a_complex *_z, a_complex x, a_float y);
288 #endif /* A_HAVE_INLINE */
289 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
290 A_INTERN void a_complex_sub_real(a_complex *_z, a_complex x, a_float y)
292 _z->real = x.real - y;
293 _z->imag = x.imag;
295 #endif /* A_HAVE_INLINE */
296 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
297 A_EXTERN void a_complex_sub_real_(a_complex *_z, a_float x);
298 #endif /* A_HAVE_INLINE */
299 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
300 A_INTERN void a_complex_sub_real_(a_complex *_z, a_float x)
302 _z->real -= x;
304 #endif /* A_HAVE_INLINE */
305 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
306 A_EXTERN void a_complex_sub_imag(a_complex *_z, a_complex x, a_float y);
307 #endif /* A_HAVE_INLINE */
308 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
309 A_INTERN void a_complex_sub_imag(a_complex *_z, a_complex x, a_float y)
311 _z->real = x.real;
312 _z->imag = x.imag - y;
314 #endif /* A_HAVE_INLINE */
315 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
316 A_EXTERN void a_complex_sub_imag_(a_complex *_z, a_float x);
317 #endif /* A_HAVE_INLINE */
318 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
319 A_INTERN void a_complex_sub_imag_(a_complex *_z, a_float x)
321 _z->imag -= x;
323 #endif /* A_HAVE_INLINE */
326 @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]
327 @param _z = \f$ x \times y \f$
328 @param x complex number on the left
329 @param y complex number on the right
331 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
332 A_EXTERN void a_complex_mul(a_complex *_z, a_complex x, a_complex y);
333 #endif /* A_HAVE_INLINE */
334 A_EXTERN void a_complex_mul_(a_complex *_z, a_complex z);
335 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
336 A_INTERN void a_complex_mul(a_complex *_z, a_complex x, a_complex y)
338 a_complex_mul_(&x, y);
339 *_z = x;
341 #endif /* A_HAVE_INLINE */
342 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
343 A_EXTERN void a_complex_mul_real(a_complex *_z, a_complex x, a_float y);
344 #endif /* A_HAVE_INLINE */
345 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
346 A_INTERN void a_complex_mul_real(a_complex *_z, a_complex x, a_float y)
348 _z->real = x.real * y;
349 _z->imag = x.imag * y;
351 #endif /* A_HAVE_INLINE */
352 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
353 A_EXTERN void a_complex_mul_real_(a_complex *_z, a_float x);
354 #endif /* A_HAVE_INLINE */
355 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
356 A_INTERN void a_complex_mul_real_(a_complex *_z, a_float x)
358 _z->real *= x;
359 _z->imag *= x;
361 #endif /* A_HAVE_INLINE */
362 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
363 A_EXTERN void a_complex_mul_imag(a_complex *_z, a_complex x, a_float y);
364 #endif /* A_HAVE_INLINE */
365 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
366 A_INTERN void a_complex_mul_imag(a_complex *_z, a_complex x, a_float y)
368 _z->real = -x.imag * y;
369 _z->imag = x.real * y;
371 #endif /* A_HAVE_INLINE */
372 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
373 A_EXTERN void a_complex_mul_imag_(a_complex *_z, a_float x);
374 #endif /* A_HAVE_INLINE */
375 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
376 A_INTERN void a_complex_mul_imag_(a_complex *_z, a_float x)
378 a_float const real = _z->real;
379 _z->real = -_z->imag * x;
380 _z->imag = real * x;
382 #endif /* A_HAVE_INLINE */
385 @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]
386 @param _z = \f$ x \div y \f$
387 @param x complex number on the left
388 @param y complex number on the right
390 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
391 A_EXTERN void a_complex_div(a_complex *_z, a_complex x, a_complex y);
392 #endif /* A_HAVE_INLINE */
393 A_EXTERN void a_complex_div_(a_complex *_z, a_complex z);
394 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
395 A_INTERN void a_complex_div(a_complex *_z, a_complex x, a_complex y)
397 a_complex_div_(&x, y);
398 *_z = x;
400 #endif /* A_HAVE_INLINE */
401 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
402 A_EXTERN void a_complex_div_real(a_complex *_z, a_complex x, a_float y);
403 #endif /* A_HAVE_INLINE */
404 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
405 A_INTERN void a_complex_div_real(a_complex *_z, a_complex x, a_float y)
407 _z->real = x.real / y;
408 _z->imag = x.imag / y;
410 #endif /* A_HAVE_INLINE */
411 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
412 A_EXTERN void a_complex_div_real_(a_complex *_z, a_float x);
413 #endif /* A_HAVE_INLINE */
414 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
415 A_INTERN void a_complex_div_real_(a_complex *_z, a_float x)
417 _z->real /= x;
418 _z->imag /= x;
420 #endif /* A_HAVE_INLINE */
421 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
422 A_EXTERN void a_complex_div_imag(a_complex *_z, a_complex x, a_float y);
423 #endif /* A_HAVE_INLINE */
424 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
425 A_INTERN void a_complex_div_imag(a_complex *_z, a_complex x, a_float y)
427 _z->real = -x.imag / y;
428 _z->imag = x.real / y;
430 #endif /* A_HAVE_INLINE */
431 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
432 A_EXTERN void a_complex_div_imag_(a_complex *_z, a_float x);
433 #endif /* A_HAVE_INLINE */
434 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
435 A_INTERN void a_complex_div_imag_(a_complex *_z, a_float x)
437 a_float const real = _z->real;
438 _z->real = -_z->imag / x;
439 _z->imag = real / x;
441 #endif /* A_HAVE_INLINE */
444 @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]
445 @param _z inverse or reciprocal \f$ \frac{1}{z} \f$
446 @param z a complex number
448 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
449 A_EXTERN void a_complex_inv(a_complex *_z, a_complex z);
450 #endif /* A_HAVE_INLINE */
451 A_EXTERN void a_complex_inv_(a_complex *_z);
452 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
453 A_INTERN void a_complex_inv(a_complex *_z, a_complex z)
455 a_complex_inv_(&z);
456 *_z = z;
458 #endif /* A_HAVE_INLINE */
460 /* Elementary Complex Functions */
463 @brief computes the complex square root
464 @param _z = \f$ \sqrt{z} \f$
465 @param z a complex number
467 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
468 A_EXTERN void a_complex_sqrt(a_complex *_z, a_complex z);
469 #endif /* A_HAVE_INLINE */
470 A_EXTERN void a_complex_sqrt_(a_complex *_z);
471 A_EXTERN void a_complex_sqrt_real(a_complex *_z, a_float x);
472 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
473 A_INTERN void a_complex_sqrt(a_complex *_z, a_complex z)
475 a_complex_sqrt_(&z);
476 *_z = z;
478 #endif /* A_HAVE_INLINE */
481 @brief complex number z raised to complex power a
482 @param _z = \f$ z^a \f$
483 @param z a complex number
484 @param a a complex number
486 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
487 A_EXTERN void a_complex_pow(a_complex *_z, a_complex z, a_complex a);
488 #endif /* A_HAVE_INLINE */
489 A_EXTERN void a_complex_pow_(a_complex *_z, a_complex a);
490 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
491 A_INTERN void a_complex_pow(a_complex *_z, a_complex z, a_complex a)
493 a_complex_pow_(&z, a);
494 *_z = z;
496 #endif /* A_HAVE_INLINE */
499 @brief complex number z raised to real power a
500 @param _z = \f$ z^a \f$
501 @param z a complex number
502 @param a a real number
504 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
505 A_EXTERN void a_complex_pow_real(a_complex *_z, a_complex z, a_float a);
506 #endif /* A_HAVE_INLINE */
507 A_EXTERN void a_complex_pow_real_(a_complex *_z, a_float a);
508 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
509 A_INTERN void a_complex_pow_real(a_complex *_z, a_complex z, a_float a)
511 a_complex_pow_real_(&z, a);
512 *_z = z;
514 #endif /* A_HAVE_INLINE */
517 @brief computes the complex base-e exponential
518 @param _z = \f$ e^z \f$
519 @param z a complex number
521 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
522 A_EXTERN void a_complex_exp(a_complex *_z, a_complex z);
523 #endif /* A_HAVE_INLINE */
524 A_EXTERN void a_complex_exp_(a_complex *_z);
525 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
526 A_INTERN void a_complex_exp(a_complex *_z, a_complex z)
528 a_complex_exp_(&z);
529 *_z = z;
531 #endif /* A_HAVE_INLINE */
534 @brief computes the complex natural logarithm
535 @param _z = \f$ \ln{z} \f$
536 @param z a complex number
538 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
539 A_EXTERN void a_complex_log(a_complex *_z, a_complex z);
540 #endif /* A_HAVE_INLINE */
541 A_EXTERN void a_complex_log_(a_complex *_z);
542 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
543 A_INTERN void a_complex_log(a_complex *_z, a_complex z)
545 a_complex_log_(&z);
546 *_z = z;
548 #endif /* A_HAVE_INLINE */
551 @brief computes the complex base-2 logarithm
552 @param _z = \f$ \log_{2}{z} \f$
553 @param z a complex number
555 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
556 A_EXTERN void a_complex_log2(a_complex *_z, a_complex z);
557 #endif /* A_HAVE_INLINE */
558 A_EXTERN void a_complex_log2_(a_complex *_z);
559 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
560 A_INTERN void a_complex_log2(a_complex *_z, a_complex z)
562 a_complex_log2_(&z);
563 *_z = z;
565 #endif /* A_HAVE_INLINE */
568 @brief computes the complex base-10 logarithm
569 @param _z = \f$ \lg{z} \f$
570 @param z a complex number
572 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
573 A_EXTERN void a_complex_log10(a_complex *_z, a_complex z);
574 #endif /* A_HAVE_INLINE */
575 A_EXTERN void a_complex_log10_(a_complex *_z);
576 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
577 A_INTERN void a_complex_log10(a_complex *_z, a_complex z)
579 a_complex_log10_(&z);
580 *_z = z;
582 #endif /* A_HAVE_INLINE */
585 @brief computes the complex base-b logarithm
586 @param _z = \f$ \log_{b}{z} \f$
587 @param z a complex number
588 @param b a complex number
590 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
591 A_EXTERN void a_complex_logb(a_complex *_z, a_complex z, a_complex b);
592 #endif /* A_HAVE_INLINE */
593 A_EXTERN void a_complex_logb_(a_complex *_z, a_complex b);
594 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
595 A_INTERN void a_complex_logb(a_complex *_z, a_complex z, a_complex b)
597 a_complex_logb_(&z, b);
598 *_z = z;
600 #endif /* A_HAVE_INLINE */
602 /* Complex Trigonometric Functions */
605 @brief computes the complex sine \f[ \sin(z)=\frac{\exp(z{i})-\exp(-z{i})}{2{i}} \f]
606 @param _z = \f$ \sin(z) \f$
607 @param z a complex number
609 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
610 A_EXTERN void a_complex_sin(a_complex *_z, a_complex z);
611 #endif /* A_HAVE_INLINE */
612 A_EXTERN void a_complex_sin_(a_complex *_z);
613 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
614 A_INTERN void a_complex_sin(a_complex *_z, a_complex z)
616 a_complex_sin_(&z);
617 *_z = z;
619 #endif /* A_HAVE_INLINE */
622 @brief computes the complex cosine \f[ \cos(z)=\frac{\exp(z{i})+\exp(-z{i})}{2} \f]
623 @param _z = \f$ \cos(z) \f$
624 @param z a complex number
626 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
627 A_EXTERN void a_complex_cos(a_complex *_z, a_complex z);
628 #endif /* A_HAVE_INLINE */
629 A_EXTERN void a_complex_cos_(a_complex *_z);
630 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
631 A_INTERN void a_complex_cos(a_complex *_z, a_complex z)
633 a_complex_cos_(&z);
634 *_z = z;
636 #endif /* A_HAVE_INLINE */
639 @brief computes the complex tangent \f[ \tan(z)=\frac{\sin(z)}{\cos(z)} \f]
640 @param _z = \f$ \tan(z) \f$
641 @param z a complex number
643 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
644 A_EXTERN void a_complex_tan(a_complex *_z, a_complex z);
645 #endif /* A_HAVE_INLINE */
646 A_EXTERN void a_complex_tan_(a_complex *_z);
647 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
648 A_INTERN void a_complex_tan(a_complex *_z, a_complex z)
650 a_complex_tan_(&z);
651 *_z = z;
653 #endif /* A_HAVE_INLINE */
656 @brief computes the complex secant \f[ \sec(z)=\frac{1}{\cos(z)} \f]
657 @param _z = \f$ \sec(z) \f$
658 @param z a complex number
660 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
661 A_EXTERN void a_complex_sec(a_complex *_z, a_complex z);
662 #endif /* A_HAVE_INLINE */
663 A_EXTERN void a_complex_sec_(a_complex *_z);
664 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
665 A_INTERN void a_complex_sec(a_complex *_z, a_complex z)
667 a_complex_sec_(&z);
668 *_z = z;
670 #endif /* A_HAVE_INLINE */
673 @brief computes the complex cosecant \f[ \csc(z)=\frac{1}{\sin(z)} \f]
674 @param _z = \f$ \csc(z) \f$
675 @param z a complex number
677 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
678 A_EXTERN void a_complex_csc(a_complex *_z, a_complex z);
679 #endif /* A_HAVE_INLINE */
680 A_EXTERN void a_complex_csc_(a_complex *_z);
681 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
682 A_INTERN void a_complex_csc(a_complex *_z, a_complex z)
684 a_complex_csc_(&z);
685 *_z = z;
687 #endif /* A_HAVE_INLINE */
690 @brief computes the complex cotangent \f[ \cot(z)=\frac{1}{\tan(z)} \f]
691 @param _z = \f$ \cot(z) \f$
692 @param z a complex number
694 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
695 A_EXTERN void a_complex_cot(a_complex *_z, a_complex z);
696 #endif /* A_HAVE_INLINE */
697 A_EXTERN void a_complex_cot_(a_complex *_z);
698 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
699 A_INTERN void a_complex_cot(a_complex *_z, a_complex z)
701 a_complex_cot_(&z);
702 *_z = z;
704 #endif /* A_HAVE_INLINE */
706 /* Inverse Complex Trigonometric Functions */
709 @brief computes the complex arc sine
710 @param _z = \f$ \arcsin(z) \f$
711 @param z a complex number
713 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
714 A_EXTERN void a_complex_asin(a_complex *_z, a_complex z);
715 #endif /* A_HAVE_INLINE */
716 A_EXTERN void a_complex_asin_(a_complex *_z);
717 A_EXTERN void a_complex_asin_real(a_complex *_z, a_float x);
718 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
719 A_INTERN void a_complex_asin(a_complex *_z, a_complex z)
721 a_complex_asin_(&z);
722 *_z = z;
724 #endif /* A_HAVE_INLINE */
727 @brief computes the complex arc cosine
728 @param _z = \f$ \arccos(z) \f$
729 @param z a complex number
731 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
732 A_EXTERN void a_complex_acos(a_complex *_z, a_complex z);
733 #endif /* A_HAVE_INLINE */
734 A_EXTERN void a_complex_acos_(a_complex *_z);
735 A_EXTERN void a_complex_acos_real(a_complex *_z, a_float x);
736 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
737 A_INTERN void a_complex_acos(a_complex *_z, a_complex z)
739 a_complex_acos_(&z);
740 *_z = z;
742 #endif /* A_HAVE_INLINE */
745 @brief computes the complex arc tangent
746 @param _z = \f$ \arctan(z) \f$
747 @param z a complex number
749 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
750 A_EXTERN void a_complex_atan(a_complex *_z, a_complex z);
751 #endif /* A_HAVE_INLINE */
752 A_EXTERN void a_complex_atan_(a_complex *_z);
753 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
754 A_INTERN void a_complex_atan(a_complex *_z, a_complex z)
756 a_complex_atan_(&z);
757 *_z = z;
759 #endif /* A_HAVE_INLINE */
762 @brief computes the complex arc secant \f[ \mathrm{arcsec}(z)=\mathrm{arccos}(\frac{1}{z}) \f]
763 @param _z = \f$ \mathrm{arcsec}(z) \f$
764 @param z a complex number
766 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
767 A_EXTERN void a_complex_asec(a_complex *_z, a_complex z);
768 #endif /* A_HAVE_INLINE */
769 A_EXTERN void a_complex_asec_(a_complex *_z);
770 A_EXTERN void a_complex_asec_real(a_complex *_z, a_float x);
771 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
772 A_INTERN void a_complex_asec(a_complex *_z, a_complex z)
774 a_complex_asec_(&z);
775 *_z = z;
777 #endif /* A_HAVE_INLINE */
780 @brief computes the complex arc cosecant \f[ \mathrm{arccsc}(z)=\mathrm{arcsin}(\frac{1}{z}) \f]
781 @param _z = \f$ \mathrm{arccsc}(z) \f$
782 @param z a complex number
784 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
785 A_EXTERN void a_complex_acsc(a_complex *_z, a_complex z);
786 #endif /* A_HAVE_INLINE */
787 A_EXTERN void a_complex_acsc_(a_complex *_z);
788 A_EXTERN void a_complex_acsc_real(a_complex *_z, a_float x);
789 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
790 A_INTERN void a_complex_acsc(a_complex *_z, a_complex z)
792 a_complex_acsc_(&z);
793 *_z = z;
795 #endif /* A_HAVE_INLINE */
798 @brief computes the complex arc cotangent \f[ \mathrm{arccot}(z)=\mathrm{arctan}(\frac{1}{z}) \f]
799 @param _z = \f$ \mathrm{arccot}(z) \f$
800 @param z a complex number
802 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
803 A_EXTERN void a_complex_acot(a_complex *_z, a_complex z);
804 #endif /* A_HAVE_INLINE */
805 A_EXTERN void a_complex_acot_(a_complex *_z);
806 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
807 A_INTERN void a_complex_acot(a_complex *_z, a_complex z)
809 a_complex_acot_(&z);
810 *_z = z;
812 #endif /* A_HAVE_INLINE */
814 /* Complex Hyperbolic Functions */
817 @brief computes the complex hyperbolic sine \f[ \sinh(z)=\frac{\exp(z)-\exp(-z)}{2} \f]
818 @param _z = \f$ \sinh(z) \f$
819 @param z a complex number
821 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
822 A_EXTERN void a_complex_sinh(a_complex *_z, a_complex z);
823 #endif /* A_HAVE_INLINE */
824 A_EXTERN void a_complex_sinh_(a_complex *_z);
825 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
826 A_INTERN void a_complex_sinh(a_complex *_z, a_complex z)
828 a_complex_sinh_(&z);
829 *_z = z;
831 #endif /* A_HAVE_INLINE */
834 @brief computes the complex hyperbolic cosine \f[ \cosh(z)=\frac{\exp(z)+\exp(-z)}{2} \f]
835 @param _z = \f$ \cosh(z) \f$
836 @param z a complex number
838 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
839 A_EXTERN void a_complex_cosh(a_complex *_z, a_complex z);
840 #endif /* A_HAVE_INLINE */
841 A_EXTERN void a_complex_cosh_(a_complex *_z);
842 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
843 A_INTERN void a_complex_cosh(a_complex *_z, a_complex z)
845 a_complex_cosh_(&z);
846 *_z = z;
848 #endif /* A_HAVE_INLINE */
851 @brief computes the complex hyperbolic tangent \f[ \tanh(z)=\frac{\sinh(z)}{\cosh(z)} \f]
852 @param _z = \f$ \tanh(z) \f$
853 @param z a complex number
855 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
856 A_EXTERN void a_complex_tanh(a_complex *_z, a_complex z);
857 #endif /* A_HAVE_INLINE */
858 A_EXTERN void a_complex_tanh_(a_complex *_z);
859 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
860 A_INTERN void a_complex_tanh(a_complex *_z, a_complex z)
862 a_complex_tanh_(&z);
863 *_z = z;
865 #endif /* A_HAVE_INLINE */
868 @brief computes the complex hyperbolic secant \f[ \mathrm{sech}(z)=\frac{1}{\cosh(z)} \f]
869 @param _z = \f$ \mathrm{sech}(z) \f$
870 @param z a complex number
872 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
873 A_EXTERN void a_complex_sech(a_complex *_z, a_complex z);
874 #endif /* A_HAVE_INLINE */
875 A_EXTERN void a_complex_sech_(a_complex *_z);
876 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
877 A_INTERN void a_complex_sech(a_complex *_z, a_complex z)
879 a_complex_sech_(&z);
880 *_z = z;
882 #endif /* A_HAVE_INLINE */
885 @brief computes the complex hyperbolic cosecant \f[ \mathrm{csch}(z)=\frac{1}{\sinh(z)} \f]
886 @param _z = \f$ \mathrm{csch}(z) \f$
887 @param z a complex number
889 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
890 A_EXTERN void a_complex_csch(a_complex *_z, a_complex z);
891 #endif /* A_HAVE_INLINE */
892 A_EXTERN void a_complex_csch_(a_complex *_z);
893 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
894 A_INTERN void a_complex_csch(a_complex *_z, a_complex z)
896 a_complex_csch_(&z);
897 *_z = z;
899 #endif /* A_HAVE_INLINE */
902 @brief computes the complex hyperbolic cotangent \f[ \mathrm{coth}(z)=\frac{1}{\tanh(z)} \f]
903 @param _z = \f$ \mathrm{coth}(z) \f$
904 @param z a complex number
906 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
907 A_EXTERN void a_complex_coth(a_complex *_z, a_complex z);
908 #endif /* A_HAVE_INLINE */
909 A_EXTERN void a_complex_coth_(a_complex *_z);
910 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
911 A_INTERN void a_complex_coth(a_complex *_z, a_complex z)
913 a_complex_coth_(&z);
914 *_z = z;
916 #endif /* A_HAVE_INLINE */
918 /* Inverse Complex Hyperbolic Functions */
921 @brief computes the complex arc hyperbolic sine
922 @param _z = \f$ \mathrm{arcsinh}(z) \f$
923 @param z a complex number
925 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
926 A_EXTERN void a_complex_asinh(a_complex *_z, a_complex z);
927 #endif /* A_HAVE_INLINE */
928 A_EXTERN void a_complex_asinh_(a_complex *_z);
929 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
930 A_INTERN void a_complex_asinh(a_complex *_z, a_complex z)
932 a_complex_asinh_(&z);
933 *_z = z;
935 #endif /* A_HAVE_INLINE */
938 @brief computes the complex arc hyperbolic cosine \f[ \mathrm{arccosh}(z)=\log(z-\sqrt{z^2-1}) \f]
939 @param _z = \f$ \mathrm{arccosh}(z) \f$
940 @param z a complex number
942 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
943 A_EXTERN void a_complex_acosh(a_complex *_z, a_complex z);
944 #endif /* A_HAVE_INLINE */
945 A_EXTERN void a_complex_acosh_(a_complex *_z);
946 A_EXTERN void a_complex_acosh_real(a_complex *_z, a_float x);
947 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
948 A_INTERN void a_complex_acosh(a_complex *_z, a_complex z)
950 a_complex_acosh_(&z);
951 *_z = z;
953 #endif /* A_HAVE_INLINE */
956 @brief computes the complex arc hyperbolic tangent
957 @param _z = \f$ \mathrm{arctanh}(z) \f$
958 @param z a complex number
960 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
961 A_EXTERN void a_complex_atanh(a_complex *_z, a_complex z);
962 #endif /* A_HAVE_INLINE */
963 A_EXTERN void a_complex_atanh_(a_complex *_z);
964 A_EXTERN void a_complex_atanh_real(a_complex *_z, a_float x);
965 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
966 A_INTERN void a_complex_atanh(a_complex *_z, a_complex z)
968 a_complex_atanh_(&z);
969 *_z = z;
971 #endif /* A_HAVE_INLINE */
974 @brief computes the complex arc hyperbolic secant \f[ \mathrm{arcsech}(z)=\mathrm{arccosh}(\frac{1}{z}) \f]
975 @param _z = \f$ \mathrm{arcsech}(z) \f$
976 @param z a complex number
978 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
979 A_EXTERN void a_complex_asech(a_complex *_z, a_complex z);
980 #endif /* A_HAVE_INLINE */
981 A_EXTERN void a_complex_asech_(a_complex *_z);
982 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
983 A_INTERN void a_complex_asech(a_complex *_z, a_complex z)
985 a_complex_asech_(&z);
986 *_z = z;
988 #endif /* A_HAVE_INLINE */
991 @brief computes the complex arc hyperbolic cosecant \f[ \mathrm{arccsch}(z)=\mathrm{arcsinh}(\frac{1}{z}) \f]
992 @param _z = \f$ \mathrm{arccsch}(z) \f$
993 @param z a complex number
995 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
996 A_EXTERN void a_complex_acsch(a_complex *_z, a_complex z);
997 #endif /* A_HAVE_INLINE */
998 A_EXTERN void a_complex_acsch_(a_complex *_z);
999 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
1000 A_INTERN void a_complex_acsch(a_complex *_z, a_complex z)
1002 a_complex_acsch_(&z);
1003 *_z = z;
1005 #endif /* A_HAVE_INLINE */
1008 @brief computes the complex arc hyperbolic cotangent \f[ \mathrm{arccoth}(z)=\mathrm{arctanh}(\frac{1}{z}) \f]
1009 @param _z = \f$ \mathrm{arccoth}(z) \f$
1010 @param z a complex number
1012 #if !defined A_HAVE_INLINE || defined(LIBA_COMPLEX_C)
1013 A_EXTERN void a_complex_acoth(a_complex *_z, a_complex z);
1014 #endif /* A_HAVE_INLINE */
1015 A_EXTERN void a_complex_acoth_(a_complex *_z);
1016 #if defined(A_HAVE_INLINE) || defined(LIBA_COMPLEX_C)
1017 A_INTERN void a_complex_acoth(a_complex *_z, a_complex z)
1019 a_complex_acoth_(&z);
1020 *_z = z;
1022 #endif /* A_HAVE_INLINE */
1024 #if defined(LIBA_COMPLEX_C)
1025 #undef A_INTERN
1026 #define A_INTERN static A_INLINE
1027 #endif /* LIBA_COMPLEX_C */
1028 #if defined(__cplusplus)
1029 } /* extern "C" */
1030 #endif /* __cplusplus */
1032 /*! @} A_COMPLEX */
1034 #endif /* a/complex.h */