|
|
@ -116,11 +116,11 @@ fn create_data_matrix(width: usize, |
|
|
|
data_matrix
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use a 1D DFT to cacluate the 2D DFT.
|
|
|
|
// Use a 1D DFT to calculate the 2D DFT.
|
|
|
|
//
|
|
|
|
// This is achieved by calculating the DFT for each row, then calculating the
|
|
|
|
// DFT for each column of DFT row data. This means that a 32x32 image with have
|
|
|
|
// 1024 1D DFT operations performed on it. (Slightly caclulation intensive)
|
|
|
|
// 1024 1D DFT operations performed on it. (Slightly calculation intensive)
|
|
|
|
//
|
|
|
|
// This operation is in place on the data in the provided vector
|
|
|
|
//
|
|
|
@ -204,23 +204,23 @@ fn test_2d_dft() { |
|
|
|
println!("{:?}", test_matrix[2]);
|
|
|
|
println!("{:?}", test_matrix[3]);
|
|
|
|
|
|
|
|
assert!(test_matrix[0][0] == 24_f64);
|
|
|
|
assert!(test_matrix[0][1] == 0_f64);
|
|
|
|
assert!(test_matrix[0][2] == 0_f64);
|
|
|
|
assert!(test_matrix[0][3] == 0_f64);
|
|
|
|
|
|
|
|
assert!(test_matrix[1][0] == 0_f64);
|
|
|
|
assert!(test_matrix[1][1] == 0_f64);
|
|
|
|
assert!(test_matrix[1][2] == -2_f64);
|
|
|
|
assert!(test_matrix[1][3] == 2_f64);
|
|
|
|
|
|
|
|
assert!(test_matrix[2][0] == 0_f64);
|
|
|
|
assert!(test_matrix[2][1] == -2_f64);
|
|
|
|
assert!(test_matrix[2][2] == -4_f64);
|
|
|
|
assert!(test_matrix[2][3] == -2_f64);
|
|
|
|
|
|
|
|
assert!(test_matrix[3][0] == 0_f64);
|
|
|
|
assert!(test_matrix[3][1] == 2_f64);
|
|
|
|
assert!(test_matrix[3][2] == -2_f64);
|
|
|
|
assert!(test_matrix[3][3] == 0_f64);
|
|
|
|
assert_eq!(test_matrix[0][0], 24_f64);
|
|
|
|
assert_eq!(test_matrix[0][1], 0_f64);
|
|
|
|
assert_eq!(test_matrix[0][2], 0_f64);
|
|
|
|
assert_eq!(test_matrix[0][3], 0_f64);
|
|
|
|
|
|
|
|
assert_eq!(test_matrix[1][0], 0_f64);
|
|
|
|
assert_eq!(test_matrix[1][1], 0_f64);
|
|
|
|
assert_eq!(test_matrix[1][2], -2_f64);
|
|
|
|
assert_eq!(test_matrix[1][3], 2_f64);
|
|
|
|
|
|
|
|
assert_eq!(test_matrix[2][0], 0_f64);
|
|
|
|
assert_eq!(test_matrix[2][1], -2_f64);
|
|
|
|
assert_eq!(test_matrix[2][2], -4_f64);
|
|
|
|
assert_eq!(test_matrix[2][3], -2_f64);
|
|
|
|
|
|
|
|
assert_eq!(test_matrix[3][0], 0_f64);
|
|
|
|
assert_eq!(test_matrix[3][1], 2_f64);
|
|
|
|
assert_eq!(test_matrix[3][2], -2_f64);
|
|
|
|
assert_eq!(test_matrix[3][3], 0_f64);
|
|
|
|
}
|