36 #if !defined(_SPANDSP_COMPLEX_H_)
37 #define _SPANDSP_COMPLEX_H_
61 #if defined(HAVE_LONG_DOUBLE)
107 #if defined(__cplusplus)
112 static __inline__
complexf_t complex_setf(
float re,
float im)
122 static __inline__
complex_t complex_set(
double re,
double im)
132 #if defined(HAVE_LONG_DOUBLE)
133 static __inline__ complexl_t complex_setl(
long double re,
long double im)
144 static __inline__
complexi_t complex_seti(
int re,
int im)
154 static __inline__
complexi16_t complex_seti16(int16_t re, int16_t im)
164 static __inline__
complexi32_t complex_seti32(int32_t re, int32_t im)
194 #if defined(HAVE_LONG_DOUBLE)
195 static __inline__ complexl_t complex_addl(
const complexl_t *x,
const complexl_t *y)
199 z.re = x->re + y->re;
200 z.im = x->im + y->im;
256 #if defined(HAVE_LONG_DOUBLE)
257 static __inline__ complexl_t complex_subl(
const complexl_t *x,
const complexl_t *y)
261 z.re = x->re - y->re;
262 z.im = x->im - y->im;
318 #if defined(HAVE_LONG_DOUBLE)
319 static __inline__ complexl_t complex_mull(
const complexl_t *x,
const complexl_t *y)
323 z.re = x->re*y->re - x->im*y->im;
324 z.im = x->re*y->im + x->im*y->re;
344 z.
re = (int16_t) ((int32_t) x->
re*(int32_t) y->
re - (int32_t) x->
im*(int32_t) y->
im);
345 z.
im = (int16_t) ((int32_t) x->
re*(int32_t) y->
im + (int32_t) x->
im*(int32_t) y->
re);
354 z.
re = (int16_t) (((int32_t) x->
re*(int32_t) y->
re - (int32_t) x->
im*(int32_t) y->
im) >> 15);
355 z.
im = (int16_t) (((int32_t) x->
re*(int32_t) y->
im + (int32_t) x->
im*(int32_t) y->
re) >> 15);
364 z.
re = x->
re*(int32_t) y->
re - x->
im*(int32_t) y->
im;
365 z.
im = x->
re*(int32_t) y->
im + x->
im*(int32_t) y->
re;
404 #if defined(HAVE_LONG_DOUBLE)
405 static __inline__ complexl_t complex_divl(
const complexl_t *x,
const complexl_t *y)
410 f = y->
re*y->re + y->im*y->im;
411 z.re = ( x->re*y->re + x->im*y->im)/f;
412 z.im = (-x->re*y->im + x->im*y->re)/f;
438 #if defined(HAVE_LONG_DOUBLE)
439 static __inline__ complexl_t complex_conjl(
const complexl_t *x)
480 static __inline__
float powerf(
const complexf_t *x)
486 static __inline__
double power(
const complex_t *x)
492 #if defined(HAVE_LONG_DOUBLE)
493 static __inline__
long double powerl(
const complexl_t *x)
495 return x->re*x->re + x->im*x->im;
500 #if defined(__cplusplus)