FilterGen
1.0.0
A library to design digital filters in embedded systems.
dh_complex.h
Go to the documentation of this file.
1
#ifndef DH_COMPLEX_H_INCLUDED
2
#define DH_COMPLEX_H_INCLUDED
3
9
#ifdef __cplusplus
10
extern
"C"
{
11
#endif
12
13
14
#ifndef _WIN32
15
16
#define COMPLEX double _Complex
17
#define MAKE_COMPLEX_NUMER(re,im) ((re) + (im) * I)
18
#define COMPLEX_ADD(x,y) ((x)+(y))
19
#define COMPLEX_SUB(x,y) ((x)-(y))
20
#define COMPLEX_MUL(x,y) ((x)*(y))
21
#define COMPLEX_DIV(x,y) ((x)/(y))
22
#define COMPLEX_INV(x) (1.0/(x))
23
#define COMPLEX_NEG(x) (-(x))
24
25
#else
26
27
#include "complex.h"
28
30
#define COMPLEX _Dcomplex
31
#define MAKE_COMPLEX_NUMER(re,im) _DCOMPLEX_((re),(im))
32
33
#define COMPLEX_ADD(x,y) MAKE_COMPLEX_NUMER((creal((x))+creal((y))), (cimag((x))+cimag((y))))
34
#define COMPLEX_SUB(x,y) MAKE_COMPLEX_NUMER((creal((x))-creal((y))), (cimag((x))-cimag((y))))
35
#define COMPLEX_MUL(x,y) _Cmulcc((x),(y))
36
#define COMPLEX_DIV(x,y) dh_complex_division((x),(y))
37
#define COMPLEX_INV(x) dh_complex_division(MAKE_COMPLEX_NUMER(1.0,0.0),(x))
38
#define COMPLEX_NEG(x) MAKE_COMPLEX_NUMER(-creal((x)), -cimag((x)))
39
40
inline
COMPLEX
dh_complex_division(
COMPLEX
num,
COMPLEX
deno) {
41
double
a = creal(num);
42
double
b = cimag(num);
43
double
x = creal(deno);
44
double
y = cimag(deno);
45
double
deno_sq = x*x+y*y;
46
return
MAKE_COMPLEX_NUMER( ((a*x+b*y)/deno_sq) , ((b*x-a*y)/deno_sq));
47
}
48
49
#endif
50
52
COMPLEX
complex_unit_circle
(
double
phi);
53
54
55
56
#ifdef __cplusplus
57
}
58
#endif
59
60
61
62
63
64
65
66
67
68
69
#endif
/* DH_COMPLEX_H_INCLUDED */
70
71
complex_unit_circle
COMPLEX complex_unit_circle(double phi)
COMPLEX
#define COMPLEX
Definition:
dh_complex.h:16
dh
dh_complex.h
Generated by
1.8.17