void remap_output( double wri[], const double t) { int i,j,k; double tvelocity; double tremap; complex double wexp; complex double phase; double complex *w2d; DEBUG_START_FUNC; w2d = (double complex *) fftw_malloc( sizeof(double complex) * (NY/2+1) * NZ ); if (w2d == NULL) ERROR_HANDLER( ERROR_CRITICAL, "No memory for w2d allocation"); #ifdef TIME_DEPENDANT_SHEAR tremap = time_shift(t); tvelocity = 0.0; #else tremap = time_shift(t); tvelocity = fmod(t, 2.0 * param.ly / (param.shear * param.lx)); #endif for( i = 0 ; i < NX/NPROC ; i++) { #ifdef WITH_2D fftw_execute_dft_r2c(fft_1d_forward, wri + i*(NY+2), w2d); #else fftw_execute_dft_r2c(fft_1d_forward, wri + i*(NZ+2)*NY, w2d); #endif for( j = 0 ; j < NY/2+1 ; j++) { phase = (double complex) ((2.0 * M_PI) / param.ly * ((double) j ) * ( ((double) (i + rank * (NX/NPROC)) / (double) NX ) * tremap - tvelocity / 2.0 ) * param.lx * param.shear); //printf("phase=%g + I %g\n",creal(phase), cimag(phase)); wexp = cexp( I * phase)/NY; //printf("wexp=%g + I %g\n",creal(wexp), cimag(wexp)); for( k = 0 ; k < NZ; k++) { w2d[ k + j * NZ ] = wexp * w2d[ k + j * NZ ]; } } #ifdef WITH_2D fftw_execute_dft_c2r(fft_1d_backward, w2d, wri + i*(NY+2)); #else fftw_execute_dft_c2r(fft_1d_backward, w2d, wri + i*(NZ+2)*NY); #endif } fftw_free(w2d); DEBUG_END_FUNC; return; }
static void equalizer_state_compute_impulse_response(EqualizerState *s){ void *fft_handle=ms_fft_init(s->nfft); ms_message("Spectral domain:"); dump_table(s->fft_cpx,s->nfft); ms_ifft(fft_handle,s->fft_cpx,s->fir); ms_fft_destroy(fft_handle); /* ms_message("Inverse fft result:"); dump_table(s->fir,s->fir_len); */ time_shift(s->fir,s->fir_len); /* ms_message("Time shifted:"); dump_table(s->fir,s->fir_len); */ norm_and_apodize(s->fir,s->fir_len); ms_message("Apodized impulse response:"); dump_table(s->fir,s->fir_len); s->needs_update=FALSE; }