fft.h
655 Bytes
#ifndef STIM_FFT_H
#define STIM_FFT_H
namespace stim{
template<class T>
void circshift(T *out, const T *in, size_t xdim, size_t ydim, size_t xshift, size_t yshift){
size_t i, j, ii, jj;
for (i =0; i < xdim; i++) {
ii = (i + xshift) % xdim;
for (j = 0; j < ydim; j++) {
jj = (j + yshift) % ydim;
out[ii * ydim + jj] = in[i * ydim + j];
}
}
}
template<typename T>
void cpu_fftshift(T* out, T* in, size_t xdim, size_t ydim){
circshift(out, in, xdim, ydim, xdim/2, ydim/2);
}
template<typename T>
void cpu_ifftshift(T* out, T* in, size_t xdim, size_t ydim){
circshift(out, in, xdim, ydim, xdim/2, ydim/2);
}
}
#endif