-
Notifications
You must be signed in to change notification settings - Fork 3
/
Complex.h
66 lines (52 loc) · 1.76 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
/*********************************************************
* Complex.h
* header file for complex data type, source codes are in
* Complex.c and fft.c
*********************************************************/
#ifndef __MY_COMPLEX__
#define __MY_COMPLEX__
/* data type */
typedef struct { float x; float y;} complex;
/* constants */
#define PI 3.1415926
#define Imag 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 *, float *);
/* integration */
float amp(float t1, float t2, float *data, int n);
void cumsum(float *a, int n, float dt);
/* windowing */
float *coswndw(int, float);
/* high-pass filtering */
void filter(complex *, int, float, float, float, int);
/* find max. absolute values in an array */
int findMaxAbs(float *cor, int n, float *amp);
/* remove rerend 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