-
Notifications
You must be signed in to change notification settings - Fork 0
/
fftm.go
39 lines (30 loc) · 876 Bytes
/
fftm.go
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
package engine
import (
"github.com/mumax/3/data"
"math"
)
// TODO: composition: fft(anyquant)
var FFTM fftm // FFT of m
func init() {
DeclROnly(FFTM.Name(), &FFTM, "FFT of m")
}
// FFT of m
type fftm struct{}
func (q *fftm) Get() (quant *data.Slice, recycle bool) {
dst := data.NewSlice(3, q.Mesh())
scale := float32(1 / math.Sqrt(float64(M.Mesh().NCell()))) // logical number of cells
for i := 0; i < 3; i++ {
fft := demagConv().FFT(M.buffer, vol, i, Bsat.LUT1(), regions.Gpu()) // fft buffer re-used in conv
comp := dst.Comp(i)
data.Copy(comp, fft)
arr := comp.Host()[0]
for i := range arr {
arr[i] *= scale
}
}
return dst, false
}
func (f *fftm) NComp() int { return 3 }
func (f *fftm) Name() string { return "mFFT" }
func (f *fftm) Unit() string { return "" }
func (f *fftm) Mesh() *data.Mesh { return &demagConv().FFTMesh }