pub struct FftSetup { /* private fields */ }Expand description
Owned FFTSetup handle backed by the Swift bridge.
Implementations§
Source§impl FftSetup
impl FftSetup
Sourcepub fn new(log2n: usize, radix: i32) -> Option<Self>
pub fn new(log2n: usize, radix: i32) -> Option<Self>
Examples found in repository?
examples/01_vdsp_fft.rs (line 20)
5fn main() {
6 let added = add_f32(&[1.0, 2.0, 3.0], &[4.0, 5.0, 6.0]).expect("vector add failed");
7 assert!(added
8 .iter()
9 .zip([5.0_f32, 7.0, 9.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let dot = dot_f32(&[1.0, 2.0, 3.0], &[4.0, 5.0, 6.0]).expect("dot product failed");
13 assert!((dot - 32.0).abs() < 1.0e-6);
14
15 let hamm = hamming_window(8, 0);
16 let blk = blackman_window(8, 0);
17 assert_eq!(hamm.len(), 8);
18 assert_eq!(blk.len(), 8);
19
20 let setup = FftSetup::new(2, fft_radix::RADIX2).expect("failed to create FFT setup");
21 let mut real = vec![1.0_f32, 0.0, 0.0, 0.0];
22 let mut imag = vec![0.0_f32; 4];
23 setup
24 .fft_zip(&mut real, &mut imag, 2, fft_direction::FORWARD)
25 .expect("fft failed");
26
27 for value in &real {
28 assert!(
29 (*value - 1.0).abs() < 1.0e-5,
30 "unexpected FFT real output: {real:?}"
31 );
32 }
33 for value in &imag {
34 assert!(value.abs() < 1.0e-5, "unexpected FFT imag output: {imag:?}");
35 }
36
37 println!("vdsp smoke passed: added={added:?} dot={dot} fft_real={real:?}");
38}Sourcepub fn fft_zip(
&self,
real: &mut [f32],
imag: &mut [f32],
log2n: usize,
direction: i32,
) -> Result<()>
pub fn fft_zip( &self, real: &mut [f32], imag: &mut [f32], log2n: usize, direction: i32, ) -> Result<()>
Examples found in repository?
examples/01_vdsp_fft.rs (line 24)
5fn main() {
6 let added = add_f32(&[1.0, 2.0, 3.0], &[4.0, 5.0, 6.0]).expect("vector add failed");
7 assert!(added
8 .iter()
9 .zip([5.0_f32, 7.0, 9.0])
10 .all(|(actual, expected)| (*actual - expected).abs() < 1.0e-6));
11
12 let dot = dot_f32(&[1.0, 2.0, 3.0], &[4.0, 5.0, 6.0]).expect("dot product failed");
13 assert!((dot - 32.0).abs() < 1.0e-6);
14
15 let hamm = hamming_window(8, 0);
16 let blk = blackman_window(8, 0);
17 assert_eq!(hamm.len(), 8);
18 assert_eq!(blk.len(), 8);
19
20 let setup = FftSetup::new(2, fft_radix::RADIX2).expect("failed to create FFT setup");
21 let mut real = vec![1.0_f32, 0.0, 0.0, 0.0];
22 let mut imag = vec![0.0_f32; 4];
23 setup
24 .fft_zip(&mut real, &mut imag, 2, fft_direction::FORWARD)
25 .expect("fft failed");
26
27 for value in &real {
28 assert!(
29 (*value - 1.0).abs() < 1.0e-5,
30 "unexpected FFT real output: {real:?}"
31 );
32 }
33 for value in &imag {
34 assert!(value.abs() < 1.0e-5, "unexpected FFT imag output: {imag:?}");
35 }
36
37 println!("vdsp smoke passed: added={added:?} dot={dot} fft_real={real:?}");
38}Trait Implementations§
Auto Trait Implementations§
impl Freeze for FftSetup
impl RefUnwindSafe for FftSetup
impl Unpin for FftSetup
impl UnsafeUnpin for FftSetup
impl UnwindSafe for FftSetup
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more