-
Notifications
You must be signed in to change notification settings - Fork 0
/
Complex.h
82 lines (66 loc) · 2.33 KB
/
Complex.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*********************************************************
* Complex.h
* header file for complex data type. Source codes are in
* Complex.c and fft.c
*
* Revision History:
* Lupei Zhu 06/20/94 Initial coding
*
*********************************************************/
#ifndef __MY_COMPLEX__
#define __MY_COMPLEX__
/* data type */
typedef struct { float x; float y;} complex;
/* constants */
#define PI 3.1415926
#define IMAGE cmplx(0., 1.)
#define One cmplx(1., 0.)
#define Zero cmplx(0., 0.)
/* basic operations */
complex cplus(complex a, complex b);
complex cmltp(complex a, complex b);
complex cngtv(complex a);
complex cinvs(complex a);
complex conjg(complex a);
complex dmltp(float a, complex b);
complex Csqrt(complex a);
complex cmplx(float x, float y);
complex cphase(complex w);
double ccabs(complex a);
/* fft */
void fft(complex *a, int n, float dt); /* dt>0: forw.; dt<0: inv */
void fftr(complex *x, int n, float dt);
/* convolution and correlation */
void cor(complex *a, complex *b, float dt, int nft);
void conv(float *, int, float *, int);
float *crscrl(int,float *,float *,int);
float maxCor(float *, float *, int, int, int *, float *);
float maxCorSlide(float *, float *, int, int, float, int *, float *);
/* integration, moving average, and differentiation */
float amp(float t1, float t2, float *data, int n);
float acc(float *data, int n, float t1, float t2, int half);
void cumsum(float *a, int n, float dt);
void maver(float *a, int n, int m); /* m-point moving average */
void diffrt(float *a, int n, float dt);
void sqr(float *a, int n);
void revers(float *a, int n);
/* windowing */
float *coswndw(int, float);
/* high-pass filtering */
void filter(complex *, int, float, float, float, int);
/* low-pass filtering */
void GaussLP(float *, int, float);
/* find max. values in an array, return the shift */
int findMax(float *a, int n, float *amp);
/* find max. absolute values in an array, return the shift */
int findMaxAbs(float *a, int n, float *amp);
/* remove trend a+b*x */
void rtrend(float *, int);
/* some operation on spectrum */
void fltGauss(complex *u, int n, float gauss);
void shiftSpec(complex *u, int n, float shift);
void specAdd(complex *a, complex *b, int n);
void specMul(complex *a, complex *b, int n);
void specScale(complex *a, float c, int n);
float specPwr(complex *u, int n);
#endif