Repository navigation
Expand file tree
/
Copy pathfftw.go
More file actions
219 lines (198 loc) · 9.33 KB
/
Copy pathfftw.go
File metadata and controls
219 lines (198 loc) · 9.33 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
package fftw
import (
"sync"
"unsafe"
"github.com/gonvee/fftw/internal/double"
"github.com/gonvee/fftw/internal/float"
)
// Protects planners from concurrent modification.
// http://www.fftw.org/doc/Thread-safety.html
var lock sync.Mutex
// Wrapper for fftwf_plan_many_dft:
// http://www.fftw.org/doc/Advanced-Complex-DFTs.html
// Panics if the plan cannot be created.
func PlanManyC2C(n []int, howmany int, in []complex64, inembed []int, istride, idist int,
out []complex64, onembed []int, ostride, odist int, sign int, flags Flag) Plan {
lock.Lock()
defer lock.Unlock()
p := float.PlanManyDft(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, sign, uint(flags))
checkPlan(p, n, howmany, inembed, istride, idist, onembed, ostride, odist, sign, uint(flags))
checkC2CSize(n, howmany, len(in), inembed, istride, idist, len(out), onembed, ostride, odist)
return &floatHandle{p, unsafe.Pointer(&in[0]), unsafe.Pointer(&out[0])}
}
// PlanC2C creates a complex-to-complex FFT plan of arbitrary rank. It panics when the plan can not be created.
//
// n holds the size of the transform dimensions, len(n) is the transform's rank.
//
// The in, out arrays are overwritten during planning (unless FFTW_ESTIMATE is used in the flags). If in == out, the transform is in-place and the input array is overwritten. If in != out, the two arrays must not overlap (but FFTW does not check for this condition).
//
// sign can be -1 (= FFTW_FORWARD) or +1 (= FFTW_BACKWARD).
//
// flags is a bitwise OR (‘|’) of zero or more Flags.
//
// See the fftwf_plan_dft documentation:
// http://www.fftw.org/doc/Complex-DFTs.html
func PlanC2C(n []int, in []complex64, out []complex64, sign int, flags Flag) Plan {
howmany := 1
idist := 0
odist := 0
istride := 1
ostride := 1
inembed := n
onembed := n
return PlanManyC2C(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, sign, flags)
}
// Wrapper for fftwf_plan_many_dft_r2c:
// http://www.fftw.org/doc/Advanced-Real_002ddata-DFTs.html
func PlanManyR2C(n []int, howmany int, in []float32, inembed []int, istride, idist int,
out []complex64, onembed []int, ostride, odist int, flags Flag) Plan {
lock.Lock()
defer lock.Unlock()
p := float.PlanManyDftR2C(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, uint(flags))
checkPlan(p, n, howmany, inembed, istride, idist, onembed, ostride, odist, FORWARD, uint(flags))
return &floatHandle{p, unsafe.Pointer(&in[0]), unsafe.Pointer(&out[0])}
}
// PlanR2C creates a real-to-complex FFT plan of arbitrary rank. It panics when the plan can not be created.
// The size of the output array is roughly half the size of the input array, see R2CSize.
//
// n holds the size of the transform dimensions, len(n) is the transform's rank.
//
// The in, out arrays are overwritten during planning (unless FFTW_ESTIMATE is used in the flags). If in == out, the transform is in-place and the input array is overwritten. If in != out, the two arrays must not overlap (but FFTW does not check for this condition).
//
// flags is a bitwise OR (‘|’) of zero or more Flags.
//
// See the fftw_plan_dft_r2c documentation:
// http://www.fftw.org/doc/Real_002ddata-DFTs.html
func PlanR2C(n []int, in []float32, out []complex64, flags Flag) Plan {
howmany := 1
idist := 0
odist := 0
istride := 1
ostride := 1
inembed := n
onembed := n
return PlanManyR2C(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, flags)
}
// PlanC2R creates a complex-to-real FFT plan of arbitrary rank. It panics when the plan can not be created.
//
// n holds the size of the transform dimensions, len(n) is the transform's rank.
//
// The in, out arrays are overwritten during planning (unless FFTW_ESTIMATE is used in the flags). If in == out, the transform is in-place and the input array is overwritten. If in != out, the two arrays must not overlap (but FFTW does not check for this condition).
//
// flags is a bitwise OR (‘|’) of zero or more Flags.
//
// See the fftw_plan_dft_r2c documentation:
// http://www.fftw.org/doc/Real_002ddata-DFTs.html
func PlanC2R(n []int, in []complex64, out []float32, flags Flag) Plan {
howmany := 1
idist := 0
odist := 0
istride := 1
ostride := 1
inembed := n
onembed := n
return PlanManyC2R(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, flags)
}
// Wrapper for fftwf_plan_many_dft_c2r:
// http://www.fftw.org/doc/Advanced-Real_002ddata-DFTs.html
func PlanManyC2R(n []int, howmany int, in []complex64, inembed []int, istride, idist int,
out []float32, onembed []int, ostride, odist int, flags Flag) Plan {
lock.Lock()
defer lock.Unlock()
p := float.PlanManyDftC2R(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, uint(flags))
checkPlan(p, n, howmany, inembed, istride, idist, onembed, ostride, odist, BACKWARD, uint(flags))
return &floatHandle{p, unsafe.Pointer(&in[0]), unsafe.Pointer(&out[0])}
}
// PlanZ2Z creates a complex-to-complex FFT plan of arbitrary rank. It panics when the plan can not be created.
//
// n holds the size of the transform dimensions, len(n) is the transform's rank.
//
// The in, out arrays are overwritten during planning (unless FFTW_ESTIMATE is used in the flags). If in == out, the transform is in-place and the input array is overwritten. If in != out, the two arrays must not overlap (but FFTW does not check for this condition).
//
// sign can be -1 (= FFTW_FORWARD) or +1 (= FFTW_BACKWARD).
//
// flags is a bitwise OR (‘|’) of zero or more Flags.
//
// See the fftw_plan_dft documentation:
// http://www.fftw.org/doc/Complex-DFTs.html
func PlanManyZ2Z(n []int, howmany int, in []complex128, inembed []int, istride, idist int,
out []complex128, onembed []int, ostride, odist int, sign int, flags Flag) Plan {
lock.Lock()
defer lock.Unlock()
p := double.PlanManyDft(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, sign, uint(flags))
checkPlan(p, n, howmany, inembed, istride, idist, onembed, ostride, odist, sign, uint(flags))
return &doubleHandle{p, unsafe.Pointer(&in[0]), unsafe.Pointer(&out[0])}
}
// Provides the functionality of fftw_plan_dft:
// http://www.fftw.org/doc/Complex-DFTs.html
func PlanZ2Z(n []int, in []complex128, out []complex128, sign int, flags Flag) Plan {
howmany := 1
idist := 0
odist := 0
istride := 1
ostride := 1
inembed := n
onembed := n
return PlanManyZ2Z(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, sign, flags)
}
// Wrapper for fftw_plan_many_dft_r2c:
// http://www.fftw.org/doc/Advanced-Real_002ddata-DFTs.html
func PlanManyD2Z(n []int, howmany int, in []float64, inembed []int, istride, idist int,
out []complex128, onembed []int, ostride, odist int, flags Flag) Plan {
lock.Lock()
defer lock.Unlock()
p := double.PlanManyDftR2C(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, uint(flags))
checkPlan(p, n, howmany, inembed, istride, idist, onembed, ostride, odist, FORWARD, uint(flags))
return &doubleHandle{p, unsafe.Pointer(&in[0]), unsafe.Pointer(&out[0])}
}
// Wrapper for fftw_plan_many_dft_c2r:
// http://www.fftw.org/doc/Advanced-Real_002ddata-DFTs.html
func PlanManyZ2D(n []int, howmany int, in []complex128, inembed []int, istride, idist int,
out []float64, onembed []int, ostride, odist int, flags Flag) Plan {
lock.Lock()
defer lock.Unlock()
p := double.PlanManyDftC2R(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, uint(flags))
checkPlan(p, n, howmany, inembed, istride, idist, onembed, ostride, odist, BACKWARD, uint(flags))
return &doubleHandle{p, unsafe.Pointer(&in[0]), unsafe.Pointer(&out[0])}
}
// PlanD2Z creates a real-to-complex FFT plan of arbitrary rank. It panics when the plan can not be created.
// The size of the output array is roughly half the size of the input array, see R2CSize.
//
// n holds the size of the transform dimensions, len(n) is the transform's rank.
//
// The in, out arrays are overwritten during planning (unless FFTW_ESTIMATE is used in the flags). If in == out, the transform is in-place and the input array is overwritten. If in != out, the two arrays must not overlap (but FFTW does not check for this condition).
//
// flags is a bitwise OR (‘|’) of zero or more Flags.
//
// See the fftw_plan_dft_r2c documentation:
// http://www.fftw.org/doc/Real_002ddata-DFTs.html
func PlanD2Z(n []int, in []float64, out []complex128, flags Flag) Plan {
howmany := 1
idist := 0
odist := 0
istride := 1
ostride := 1
inembed := n
onembed := n
return PlanManyD2Z(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, flags)
}
// PlanZ2D creates a complex-to-real FFT plan of arbitrary rank. It panics when the plan can not be created.
//
// n holds the size of the transform dimensions, len(n) is the transform's rank.
//
// The in, out arrays are overwritten during planning (unless FFTW_ESTIMATE is used in the flags). If in == out, the transform is in-place and the input array is overwritten. If in != out, the two arrays must not overlap (but FFTW does not check for this condition).
//
// flags is a bitwise OR (‘|’) of zero or more Flags.
//
// See the fftw_plan_dft_r2c documentation:
// http://www.fftw.org/doc/Real_002ddata-DFTs.html
func PlanZ2D(n []int, in []complex128, out []float64, flags Flag) Plan {
howmany := 1
idist := 0
odist := 0
istride := 1
ostride := 1
inembed := n
onembed := n
return PlanManyZ2D(n, howmany, in, inembed, istride, idist, out, onembed, ostride, odist, flags)
}