MoonBit port of the imglib2-fft2 N-dimensional FFT algorithm
| Type | Meaning |
|---|---|
| RealImage | real valued N-dimensional image, Float samples |
| ComplexImage | complex valued N-dimensional image, interleaved (real, imaginary) Float pairs |
| Interval | axis aligned range of positions, one (min, max) pair per dimension |
let rfft = FftReal::new(8) // real valued, 8 samples
rfft.real_to_complex(-1, rx, cy) // rx: 8 reals, cy: 10 floats (5 bins)
rfft.complex_to_real(1, cy, ry) // cy: 10 floats, ry: 8 reals
let cfft = FftComplex::new(8)
cfft.complex_to_complex(-1, cx, cy) // cx/cy: 16 floats (8 complex values)
cfft.ifft(cy, cz) // the normalised inverse: cy in, cz outlet plan = FftPlan::create(8) // a plan of its own, not in the cache
plan.complex_to_complex(-1, cx, cy) // cx/cy: 16 floats, the same convention
plan.complex_to_complex_buffers(-1, re, im) // in place, double precisionfft(x) -> Array[Float] // the forward transform, unscaled
ifft(x) -> Array[Float] // the inverse transform, scaled by 1 / nnfft_small_real(n) == 2 * nfft_small((n + 1) / 2)
nfft_fast_real(n) == 2 * nfft_fast((n + 1) / 2)real_to_complex(input, output, range, dim, scale) -> Bool
complex_to_real(input, output, range, dim, scale) -> Bool
complex_to_complex(data, dim, forward, scale) -> Boolfft_real_to_complex(input) -> ComplexImage
fft_real_to_complex_with_fill(input, fill) -> ComplexImage
fft_complex_to_complex_forward(data) -> Unit
fft_complex_to_complex_inverse(data) -> Unit
fft_complex_to_real(input) -> RealImage
fft_complex_to_real_inplace(input, output) -> Unit
fft_complex_to_real_unpad(input, output_dims) -> RealImagepadding_interval_centered(input, padding) -> Interval
unpadding_interval_centered(input, dims) -> Interval
dimensions_real_to_complex_fast(dims, complex_sizes, real_sizes) -> Unit
dimensions_complex_to_real_fast(dims, complex_sizes, real_sizes) -> Unit
dimensions_complex_to_complex_fast(dims, sizes) -> Unit
dimensions_real_to_complex_small(dims, complex_sizes, real_sizes) -> Unit
dimensions_complex_to_real_small(dims, complex_sizes, real_sizes) -> Unit
dimensions_complex_to_complex_small(dims, sizes) -> Unit
verify_real_to_complex_fft_dimensions(real_size, complex_size) -> Bool
verify_complex_to_complex_fft_dimensions(size, other) -> Bool
complex_conjugate(data) -> Unit# 1. deterministic test inputs
python tools\gen_cases.py --out build\cases
# 2. lay the original bytecode out under its package path, so that the
# oracle can be compiled
python tools\stage_classes.py
# 3. run the original Java classes and capture their output
javac -nowarn -encoding UTF-8 `
-cp "build\classes;tools\lib\imglib2-6.1.0.jar;tools\lib\mines-jtk-20151125.jar" `
-d build\oracle tools\java\Oracle.java
java -cp "build\oracle;build\classes;tools\lib\imglib2-6.1.0.jar;tools\lib\mines-jtk-20151125.jar" `
Oracle build\cases\manifest.txt build\cases\java
# 4. turn the golden data into a MoonBit test
python tools\gen_parity.py --cases build\cases --out moonbit_fft\parity_wbtest.mbt
# 5. run the tests and refresh the published interface file
cd moonbit_fft ; moon fmt ; moon check --deny-warn ; moon test ; moon infopython tools\measure_deviation.pypython tools\check_jc2c.pypython tools\negative_control.pypython tools\verify_goodthomas.pypub struct FftComplex {
n : Int
}fn FftComplex::complex_to_complex(self : FftComplex, sign : Int, cx : Array[Float], cy : Array[Float]) -> Unitpub struct FftPlan {
// private fields
}pub struct FftReal {
nfft : Int
}fn complex_to_real(input : ComplexImage, output : RealImage, range : Interval?, dim : Int, scale : Bool) -> Boolfn nfft_fast(n : Int) -> Intfn nfft_fast_real(n : Int) -> Intfn nfft_small(n : Int) -> Intfn nfft_small_real(n : Int) -> Intfn nfft_valid(n : Int) -> Boolfn nfft_valid_real(nfft : Int) -> Boolfn real_to_complex(input : RealImage, output : ComplexImage, range : Interval?, dim : Int, scale : Bool) -> Boolfn verify_complex_to_complex_fft_dimensions(size : Int, other : Int) -> Boolfn verify_real_to_complex_fft_dimensions(real_size : Int, complex_size : Int) -> BoolInstall
Download zipMoonBit port of the imglib2-fft2 N-dimensional FFT algorithm