36#if !defined(_SPANDSP_COMPLEX_H_)
37#define _SPANDSP_COMPLEX_H_
61#if defined(HAVE_LONG_DOUBLE)
107#if defined(__cplusplus)
112static __inline__
complexf_t complex_setf(
float re,
float im)
122static __inline__
complex_t complex_set(
double re,
double im)
132#if defined(HAVE_LONG_DOUBLE)
133static __inline__ complexl_t complex_setl(
long double re,
long double im)
144static __inline__
complexi_t complex_seti(
int re,
int im)
154static __inline__
complexi16_t complex_seti16(int16_t re, int16_t im)
164static __inline__
complexi32_t complex_seti32(int32_t re, int32_t im)
194#if defined(HAVE_LONG_DOUBLE)
195static __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)
257static __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)
319static __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)
405static __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)
439static __inline__ complexl_t complex_conjl(
const complexl_t *x)
480static __inline__ int32_t poweri16(
const complexi16_t *x)
482 return (int32_t) x->
re*x->
re + (int32_t) x->
im*x->
im;
486static __inline__
float powerf(
const complexf_t *x)
492static __inline__
double power(
const complex_t *x)
498#if defined(HAVE_LONG_DOUBLE)
499static __inline__
long double powerl(
const complexl_t *x)
501 return x->re*x->re + x->im*x->im;
506#if defined(__cplusplus)
double im
Imaginary part.
Definition complex.h:58
double re
Real part.
Definition complex.h:56
float im
Imaginary part.
Definition complex.h:47
float re
Real part.
Definition complex.h:45
int16_t im
Imaginary part.
Definition complex.h:93
int16_t re
Real part.
Definition complex.h:91
int32_t im
Imaginary part.
Definition complex.h:104
int32_t re
Real part.
Definition complex.h:102
int re
Real part.
Definition complex.h:80
int im
Imaginary part.
Definition complex.h:82