pub fn nufft_type1(
x: &[f64],
samples: &[Complex64],
m: usize,
interp_type: InterpolationType,
epsilon: f64,
) -> FFTResult<Vec<Complex64>>
Expand description
Performs Non-Uniform Fast Fourier Transform (NUFFT) Type 1.
This function computes the FFT of data sampled at non-uniform locations. NUFFT Type 1 transforms from non-uniform samples to a uniform frequency grid.
§Arguments
x
- Non-uniform sample points (must be in range [-π, π])samples
- Complex sample values at the non-uniform pointsm
- Size of the output uniform gridinterp_type
- Interpolation type to useepsilon
- Desired precision (typically 1e-6 to 1e-12)
§Returns
- A complex-valued array containing the NUFFT on a uniform frequency grid
§Errors
Returns an error if the computation fails or inputs are invalid.
§Examples
use scirs2_fft::nufft::{nufft_type1, InterpolationType};
use num_complex::Complex64;
use std::f64::consts::PI;
// Create non-uniform sample points in [-π, π]
let n = 100;
let x: Vec<f64> = (0..n).map(|i| -PI + 1.8 * PI * i as f64 / (n as f64)).collect();
// Create sample values for a simple function (e.g., a Gaussian)
let samples: Vec<Complex64> = x.iter()
.map(|&xi| {
let real = (-xi.powi(2) / 2.0).exp();
Complex64::new(real, 0.0)
})
.collect();
// Compute NUFFT
let m = 128; // Output grid size
let result = nufft_type1(&x, &samples, m, InterpolationType::Gaussian, 1e-6).unwrap();
// The transform of a Gaussian is another Gaussian
assert!(result.len() == m);
§Notes
This is a basic implementation. For performance-critical applications, consider using a more optimized NUFFT library.