File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ pub fn fft_with_opts_and_plan(
63
63
let twiddles_re = & mut planner. twiddles_re ;
64
64
let twiddles_im = & mut planner. twiddles_im ;
65
65
66
+ // We shouldn't be able to execute FFT if the # of twiddles isn't equal to the distance between pairs
67
+ assert ! ( twiddles_re. len( ) / 2 == reals. len( ) && twiddles_im. len( ) / 2 == imags. len( ) ) ;
68
+
66
69
for t in ( 0 ..n) . rev ( ) {
67
70
let dist = 1 << t;
68
71
let chunk_size = dist << 1 ;
@@ -123,6 +126,24 @@ mod tests {
123
126
fft_with_opts_and_plan ( & mut reals, & mut imags, & opts, & mut planner) ;
124
127
}
125
128
129
+ // a regression test to make sure planner is always compatible with fft execution
130
+ #[ should_panic]
131
+ #[ test]
132
+ fn wrong_num_points_in_planner ( ) {
133
+ let n = 16 ;
134
+ let num_points = 1 << n;
135
+
136
+ // this test will actually always fail at this stage
137
+
138
+ let mut planner = Planner :: new ( n, Direction :: Forward ) ;
139
+ let mut reals = vec ! [ 0.0 ; num_points] ;
140
+ let mut imags = vec ! [ 0.0 ; num_points] ;
141
+ let opts = Options :: guess_options ( reals. len ( ) ) ;
142
+
143
+ // but this call should panic as well
144
+ fft_with_opts_and_plan ( & mut reals, & mut imags, & opts, & mut planner) ;
145
+ }
146
+
126
147
#[ test]
127
148
fn fft_correctness ( ) {
128
149
let range = Range { start : 4 , end : 17 } ;
You can’t perform that action at this time.
0 commit comments