diff --git a/Cargo.toml b/Cargo.toml index e71d72a58..dff0e6647 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,3 +76,6 @@ path = "examples/acoustic_wave.rs" name = "conway" path = "examples/conway.rs" +[[example]] +name = "fft" +path = "examples/fft.rs" diff --git a/examples/fft.rs b/examples/fft.rs new file mode 100644 index 000000000..53d4316ab --- /dev/null +++ b/examples/fft.rs @@ -0,0 +1,35 @@ +use arrayfire::*; +use num::Complex; + +type Complex32 = Complex; + +#[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); +}