Skip to content

Commit 6b3ed47

Browse files
committed
Simple fft on complex signal example
1 parent 208758b commit 6b3ed47

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ path = "examples/acoustic_wave.rs"
7676
name = "conway"
7777
path = "examples/conway.rs"
7878

79+
[[example]]
80+
name = "fft"
81+
path = "examples/fft.rs"

examples/fft.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use arrayfire::*;
2+
use num::Complex;
3+
4+
type Complex32 = Complex<f32>;
5+
6+
#[allow(unused_must_use)]
7+
#[allow(unused_variables)]
8+
fn main() {
9+
set_device(0);
10+
info();
11+
let samples = 10;
12+
let dims = Dim4::new(&[samples, 1, 1, 1]);
13+
14+
let values = vec![
15+
Complex::new(0.0, 2.0),
16+
Complex::new(0.0, 2.0),
17+
Complex::new(0.0, 2.0),
18+
Complex::new(0.0, 2.0),
19+
Complex::new(0.0, 2.0),
20+
Complex::new(0.0, 2.0),
21+
Complex::new(0.0, 2.0),
22+
Complex::new(0.0, 2.0),
23+
Complex::new(0.0, 2.0),
24+
Complex::new(0.0, 2.0)
25+
];
26+
27+
let signal = Array::new(&values, dims);
28+
29+
af_print!("signal", signal);
30+
31+
// Used length of input signal as norm_factor
32+
let output = fft(&signal, 0.1, samples as i64);
33+
34+
af_print!("Output", output);
35+
}

0 commit comments

Comments
 (0)