static void jig_input(complex_t* input, complex_t* output, int n){ int i = 0; int size = bit_len(n); --size; for( i = 0; i < n ;++i){ output[bit_swap(i,size)] = input[i]; } }
Type *CreateRandomMessageType() { // Give each type 14 vars, the first four of which are condition flags. std::vector<const Type *> types; std::vector<CVQualifiers> qfers; std::vector<int> bit_len(14, -1); const Type *int_type = &Type::get_simple_type(eInt); CVQualifiers qfer(std::vector<bool>({false}), std::vector<bool>({false})); types.insert(types.end(), 4, int_type); qfers.insert(qfers.end(), 4, qfer); for (int idx = 0; idx < 10; ++idx) { types.push_back(Type::choose_random_simple()->to_unsigned()); bool is_vol = rnd_flipcoin(50); qfers.push_back(CVQualifiers( std::vector<bool>({false}), std::vector<bool>({is_vol}))); } return new Type(types, true, false, qfers, bit_len); }
int _fft(complex_t* input, complex_t* output, unsigned n){ jig_input(input,output,n); int level = 0; int num_levels = bit_len(n); int block_size = 2; for( level = num_levels-1; level != 0 ; --level){ int num_blocks = n / block_size; int segment = 0; complex_t Y_k,Z_k,W; complex_t* out; for(segment = 0; segment < num_blocks; ++segment){ out = output + segment*block_size; int i = 0; for( i = 0; i< block_size/2; ++i){ Y_k = out[i]; Z_k = out[i +block_size/2]; W = twiddle(block_size, i); complex_t temp; complex_mult(&W,&Z_k,&temp); out[i].re = Y_k.re + temp.re; out[i].im = Y_k.im + temp.im; out[i + block_size/2].re = Y_k.re - temp.re; out[i + block_size/2].im = Y_k.im - temp.im; } } block_size *= 2; } return 1; }