complex_vec_t fourier_transform::backwards(const complex_vec_t &in, size_t n) const { if(n==0){ n=in.size(); }else{ if(n>in.size()) throw std::invalid_argument("Output size must be less than or equal to input size."); } complex_vec_t result(in.size()); complex_t wn=root_of_unity(n); backwards_impl(n, wn, &in[0], 1, &result[0], 1); result.resize(n); return result; }
/** * computes element-by-element division of two matrices (matrix1 / matrix2) into result */ bool mat_dot_div(unsigned int nx1, unsigned int ny1, unsigned int nz1, const complex_vec_t& matrix1, unsigned int nx2, unsigned int ny2, unsigned int nz2, const complex_vec_t& matrix2, complex_vec_t& result) { if(nx1 != nx2 || ny1 != ny2 || nz1 != nz2 || matrix1.size() != matrix2.size()) { std::cerr << "error: matrix sizes are not the same for dot division operation" << std::endl; return false; } // if result.clear(); complex_vec_t::const_iterator i1 = matrix1.begin(); complex_vec_t::const_iterator i2 = matrix2.begin(); for(; i1 != matrix1.end(); ++ i1, ++ i2) { result.push_back((*i1) / (*i2)); } // for return true; } // mat_dot_div()
complex_vec_t fourier_transform::forwards(const complex_vec_t &in) const { size_t n=calc_padded_size(in.size()); complex_vec_t result(n); complex_t wn=root_of_unity(n); if(n==in.size()){ forwards_impl(n, wn, &in[0], 1, &result[0], 1); }else{ complex_vec_t buffer(in); buffer.resize(n, complex_t(0.0,0.0) ); forwards_impl(n, wn, &buffer[0], 1, &result[0], 1); } return result; }
/** * computes element-by-element product of two matrices into result */ bool mat_dot_prod(unsigned int x1_size, unsigned int y1_size, unsigned int z1_size, const complex_vec_t& matrix1, unsigned int x2_size, unsigned int y2_size, unsigned int z2_size, const complex_vec_t& matrix2, complex_vec_t& result) { if(x1_size != x2_size || y1_size != y2_size || z1_size != z2_size || matrix1.size() != matrix2.size()) { std::cerr << "error: matrix sizes are not the same for dot product operation" << std::endl; return false; } // if result.clear(); complex_vec_t::const_iterator i1 = matrix1.begin(); complex_vec_t::const_iterator i2 = matrix2.begin(); for(; i1 != matrix1.end(); ++ i1, ++ i2) { result.push_back((*i1) * (*i2)); } // for return true; } // mat_dot_prod()