-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple fft on complex signal example
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |