RTOpPack::SubVectorView<Scalar> getLocalSubVectorView( const Ordinal localOffset, const Ordinal localDim, const Scalar val) { Teuchos::ArrayRCP<Scalar> x_dat(localDim); std::fill_n(x_dat.begin(), localDim, val); return RTOpPack::SubVectorView<Scalar>( localOffset, localDim, x_dat, 1); }
RTOpPack::SubMultiVectorView<Scalar> getLocalSubMultiVectorView( const Ordinal localOffset, const Ordinal localDim, const Ordinal numCols, const Scalar val) { const Ordinal totalLen = localDim*numCols; Teuchos::ArrayRCP<Scalar> x_dat(totalLen); std::fill_n(x_dat.begin(), totalLen, val); return RTOpPack::SubMultiVectorView<Scalar>( localOffset, localDim, 0, numCols, x_dat, localDim); }
int main(int argc, char** argv) { const int N = atoi(argv[1]); // Output files for the data std::ofstream x_dat("../data/x.dat"); std::ofstream Y_dat("../data/Y.dat"); std::ofstream y_dat("../data/y.dat"); // "input" signal std::complex<double> x[N]; // The frequencies to create the sine wave double freq1 = 17.01/11025; double freq2 = 297.74/11025; double freq3 = 425.35/11025; double freq4 = 2637/11025; // Creating the sine wave for(int n = 0; n < N; ++n) { x[n] = cos(2*M_PI*freq1*n) + cos(2*M_PI*freq2*n) + cos(2*M_PI*freq3*n) + cos(2*M_PI*freq4*n); } // Ouput the sine wave to the output file for(int i = 0; i < N; ++i) { x_dat << x[i].real() << '\t' << x[i].imag() << std::endl; } // Compute the fft fft6(0, N, x); // Reorder the bits bit_reorder(x, N); // Output the data to the file for(int i = 0; i < N; ++i) { Y_dat << x[i].real() << '\t' << x[i].imag() << std::endl; } // Compute the ifft fft6(1, N, x); // reorder the bits bit_reorder(x, N); // Output the data to the file for(int i = 0; i < N; ++i) { y_dat << x[i].real() << '\t' << x[i].imag() << std::endl; } return 0; }