forked from arrayfire/arrayfire-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfft.rs
31 lines (25 loc) · 718 Bytes
/
fft.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use arrayfire::*;
use num::Complex;
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);
}