-
Notifications
You must be signed in to change notification settings - Fork 1
/
window.c
97 lines (67 loc) · 2.08 KB
/
window.c
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
-------------------------------------------------------------------------
OBJECT NAME: window.c
FULL NAME: Window Functions
ENTRY POINTS: Bartlett()
Blackman()
Hamming()
Hanning()
Parzen()
Square()
Welch()
STATIC FNS: none
DESCRIPTION: Data windowing functions.
INPUT: index, window_size
OUTPUT: window value
REFERENCES: none
REFERENCED BY: spctrm.c
COPYRIGHT: University Corporation for Atmospheric Research, 1997-2022
-------------------------------------------------------------------------
*/
#include "define.h"
#include "spec.h"
/* -------------------------------------------------------------------- */
double Bartlett(int j, int N)
{
return(0.42 - 0.5 * cos(2.0 * M_PI * j / (N - 1)) +
0.08 * cos(4.0 * M_PI * j / (N - 1)));
} /* END BARTLETT */
/* -------------------------------------------------------------------- */
double Blackman(int j, int N)
{
return(0.42 - 0.5 * cos(2.0 * M_PI * j / (N - 1)) +
0.08 * cos(4.0 * M_PI * j / (N - 1)));
} /* END BLACKMAN */
/* -------------------------------------------------------------------- */
double Hamming(int j, int N)
{
return(0.54 - 0.46 * cos(2.0 * M_PI * j / (N - 1)));
} /* END HAMMING */
/* -------------------------------------------------------------------- */
double Hanning(int j, int N)
{
return(0.5 * (1.0 - cos(2.0 * M_PI * j / (N - 1))));
} /* END HANNING */
/* -------------------------------------------------------------------- */
double Parzen(int j, int N)
{
return(1.0 - fabs((j - 0.5 * (N - 1)) / (0.5 * (N + 1))));
} /* END PARZEN */
/* -------------------------------------------------------------------- */
double Square(int j, int N)
{
return(1.0);
} /* END SQUARE */
/* -------------------------------------------------------------------- */
double Triangle(int j, int N)
{
return(1.0 - fabs(1.0 - ((2.0 * j) / (N - 1)) ));
} /* END TRIANGLE */
/* -------------------------------------------------------------------- */
double Welch(int j, int N)
{
double rc;
rc = (j - 0.5 * (N - 1)) / (0.5 * (N + 1));
return(1.0 - rc * rc);
} /* END WELCH */
/* END WINDOW.C */