Skip to content

Commit

Permalink
Simple fft on complex signal example
Browse files Browse the repository at this point in the history
  • Loading branch information
9prady9 committed May 30, 2019
1 parent 208758b commit 6b3ed47
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ path = "examples/acoustic_wave.rs"
name = "conway"
path = "examples/conway.rs"

[[example]]
name = "fft"
path = "examples/fft.rs"
35 changes: 35 additions & 0 deletions examples/fft.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use arrayfire::*;
use num::Complex;

type Complex32 = Complex<f32>;

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn main() {
set_device(0);
info();
let samples = 10;
let dims = Dim4::new(&[samples, 1, 1, 1]);

let values = vec![
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0),
Complex::new(0.0, 2.0)
];

let signal = Array::new(&values, dims);

af_print!("signal", signal);

// Used length of input signal as norm_factor
let output = fft(&signal, 0.1, samples as i64);

af_print!("Output", output);
}

0 comments on commit 6b3ed47

Please sign in to comment.