Skip to main content

FftSetup

Struct FftSetup 

Source
pub struct FftSetup { /* private fields */ }
Expand description

Owned FFTSetup handle backed by the Swift bridge.

Implementations§

Source§

impl FftSetup

Source

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}
Source

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§

Source§

impl Drop for FftSetup

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for FftSetup

Source§

impl Sync for FftSetup

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.