int ndim; /**< Dimensions, including our subdimensions. */
int n; /**< Number of points in this dimension. */
int ifac[15]; /**< 15 bytes needed for cfft and rfft */
- struct gmx_fft *next; /**< Pointer to next dimension, or NULL. */
- real * work; /**< 1st 4n reserved for cfft, 1st 2n for rfft */
+ struct gmx_fft* next; /**< Pointer to next dimension, or NULL. */
+ real* work; /**< 1st 4n reserved for cfft, 1st 2n for rfft */
};
-int
-gmx_fft_init_1d(gmx_fft_t * pfft,
- int nx,
- int gmx_unused flags)
+int gmx_fft_init_1d(gmx_fft_t* pfft, int nx, int gmx_unused flags)
{
- gmx_fft_t fft;
+ gmx_fft_t fft;
if (pfft == nullptr)
{
}
*pfft = nullptr;
- if ( (fft = static_cast<struct gmx_fft *>(malloc(sizeof(struct gmx_fft)))) == nullptr)
+ if ((fft = static_cast<struct gmx_fft*>(malloc(sizeof(struct gmx_fft)))) == nullptr)
{
return ENOMEM;
}
fft->n = nx;
/* Need 4*n storage for 1D complex FFT */
- if ( (fft->work = static_cast<real *>(malloc(sizeof(real)*(4*nx)))) == nullptr)
+ if ((fft->work = static_cast<real*>(malloc(sizeof(real) * (4 * nx)))) == nullptr)
{
free(fft);
return ENOMEM;
};
-
-int
-gmx_fft_init_1d_real(gmx_fft_t * pfft,
- int nx,
- int gmx_unused flags)
+int gmx_fft_init_1d_real(gmx_fft_t* pfft, int nx, int gmx_unused flags)
{
- gmx_fft_t fft;
+ gmx_fft_t fft;
if (pfft == nullptr)
{
}
*pfft = nullptr;
- if ( (fft = static_cast<struct gmx_fft *>(malloc(sizeof(struct gmx_fft)))) == nullptr)
+ if ((fft = static_cast<struct gmx_fft*>(malloc(sizeof(struct gmx_fft)))) == nullptr)
{
return ENOMEM;
}
fft->n = nx;
/* Need 2*n storage for 1D real FFT */
- if ((fft->work = static_cast<real *>(malloc(sizeof(real)*(2*nx)))) == nullptr)
+ if ((fft->work = static_cast<real*>(malloc(sizeof(real) * (2 * nx)))) == nullptr)
{
free(fft);
return ENOMEM;
return 0;
}
-int
-gmx_fft_init_2d_real(gmx_fft_t * pfft,
- int nx,
- int ny,
- int flags)
+int gmx_fft_init_2d_real(gmx_fft_t* pfft, int nx, int ny, int flags)
{
- gmx_fft_t fft;
- int nyc = (ny/2 + 1);
- int rc;
+ gmx_fft_t fft;
+ int nyc = (ny / 2 + 1);
+ int rc;
if (pfft == nullptr)
{
*pfft = nullptr;
/* Create the X transform */
- if ( (fft = static_cast<struct gmx_fft *>(malloc(sizeof(struct gmx_fft)))) == nullptr)
+ if ((fft = static_cast<struct gmx_fft*>(malloc(sizeof(struct gmx_fft)))) == nullptr)
{
return ENOMEM;
}
- fft->n = nx;
+ fft->n = nx;
/* Need 4*nx storage for 1D complex FFT, and another
* 2*nx*nyc elements for complex-to-real storage in our high-level routine.
*/
- if ( (fft->work = static_cast<real *>(malloc(sizeof(real)*(4*nx+2*nx*nyc)))) == nullptr)
+ if ((fft->work = static_cast<real*>(malloc(sizeof(real) * (4 * nx + 2 * nx * nyc)))) == nullptr)
{
free(fft);
return ENOMEM;
fftpack_cffti1(nx, fft->work, fft->ifac);
/* Create real Y transform as a link from X */
- if ( (rc = gmx_fft_init_1d_real(&(fft->next), ny, flags)) != 0)
+ if ((rc = gmx_fft_init_1d_real(&(fft->next), ny, flags)) != 0)
{
free(fft);
return rc;
}
-int
-gmx_fft_1d (gmx_fft_t fft,
- enum gmx_fft_direction dir,
- void * in_data,
- void * out_data)
+int gmx_fft_1d(gmx_fft_t fft, enum gmx_fft_direction dir, void* in_data, void* out_data)
{
- int i, n;
- real * p1;
- real * p2;
+ int i, n;
+ real* p1;
+ real* p2;
n = fft->n;
if (n == 1)
{
- p1 = static_cast<real *>(in_data);
- p2 = static_cast<real *>(out_data);
+ p1 = static_cast<real*>(in_data);
+ p2 = static_cast<real*>(out_data);
p2[0] = p1[0];
p2[1] = p1[1];
}
*/
if (in_data != out_data)
{
- p1 = static_cast<real *>(in_data);
- p2 = static_cast<real *>(out_data);
+ p1 = static_cast<real*>(in_data);
+ p2 = static_cast<real*>(out_data);
/* n complex = 2*n real elements */
- for (i = 0; i < 2*n; i++)
+ for (i = 0; i < 2 * n; i++)
{
p2[i] = p1[i];
}
if (dir == GMX_FFT_FORWARD)
{
- fftpack_cfftf1(n, static_cast<real *>(out_data), fft->work+2*n, fft->work, fft->ifac, -1);
+ fftpack_cfftf1(n, static_cast<real*>(out_data), fft->work + 2 * n, fft->work, fft->ifac, -1);
}
else if (dir == GMX_FFT_BACKWARD)
{
- fftpack_cfftf1(n, static_cast<real *>(out_data), fft->work+2*n, fft->work, fft->ifac, 1);
+ fftpack_cfftf1(n, static_cast<real*>(out_data), fft->work + 2 * n, fft->work, fft->ifac, 1);
}
else
{
}
-
-int
-gmx_fft_1d_real (gmx_fft_t fft,
- enum gmx_fft_direction dir,
- void * in_data,
- void * out_data)
+int gmx_fft_1d_real(gmx_fft_t fft, enum gmx_fft_direction dir, void* in_data, void* out_data)
{
- int i, n;
- real * p1;
- real * p2;
+ int i, n;
+ real* p1;
+ real* p2;
n = fft->n;
if (n == 1)
{
- p1 = static_cast<real *>(in_data);
- p2 = static_cast<real *>(out_data);
+ p1 = static_cast<real*>(in_data);
+ p2 = static_cast<real*>(out_data);
p2[0] = p1[0];
if (dir == GMX_FFT_REAL_TO_COMPLEX)
{
*/
if (in_data != out_data)
{
- p1 = static_cast<real *>(in_data);
- p2 = static_cast<real *>(out_data);
+ p1 = static_cast<real*>(in_data);
+ p2 = static_cast<real*>(out_data);
- for (i = 0; i < 2*(n/2+1); i++)
+ for (i = 0; i < 2 * (n / 2 + 1); i++)
{
p2[i] = p1[i];
}
/* Elements 0 .. n-1 in work are used for ffac values,
* Elements n .. 2*n-1 are internal FFTPACK work space.
*/
- fftpack_rfftf1(n, static_cast<real *>(out_data), fft->work+n, fft->work, fft->ifac);
+ fftpack_rfftf1(n, static_cast<real*>(out_data), fft->work + n, fft->work, fft->ifac);
/*
* FFTPACK has a slightly more compact storage than we, time to
* convert it: ove most of the array one step up to make room for
* zero imaginary parts.
*/
- p2 = static_cast<real *>(out_data);
- for (i = n-1; i > 0; i--)
+ p2 = static_cast<real*>(out_data);
+ for (i = n - 1; i > 0; i--)
{
- p2[i+1] = p2[i];
+ p2[i + 1] = p2[i];
}
/* imaginary zero freq. */
p2[1] = 0;
/* Is n even? */
- if ( (n & 0x1) == 0)
+ if ((n & 0x1) == 0)
{
- p2[n+1] = 0;
+ p2[n + 1] = 0;
}
-
}
else if (dir == GMX_FFT_COMPLEX_TO_REAL)
{
* is more compact than ours (2 reals) it will fit, so compact it
* and copy on-the-fly to the output array.
*/
- p1 = static_cast<real *>(in_data);
- p2 = static_cast<real *>(out_data);
+ p1 = static_cast<real*>(in_data);
+ p2 = static_cast<real*>(out_data);
p2[0] = p1[0];
for (i = 1; i < n; i++)
{
- p2[i] = p1[i+1];
+ p2[i] = p1[i + 1];
}
- fftpack_rfftb1(n, static_cast<real *>(out_data), fft->work+n, fft->work, fft->ifac);
+ fftpack_rfftb1(n, static_cast<real*>(out_data), fft->work + n, fft->work, fft->ifac);
}
else
{
}
-int
-gmx_fft_2d_real (gmx_fft_t fft,
- enum gmx_fft_direction dir,
- void * in_data,
- void * out_data)
+int gmx_fft_2d_real(gmx_fft_t fft, enum gmx_fft_direction dir, void* in_data, void* out_data)
{
- int i, j, nx, ny, nyc;
- t_complex * data;
- real * work;
- real * p1;
- real * p2;
+ int i, j, nx, ny, nyc;
+ t_complex* data;
+ real* work;
+ real* p1;
+ real* p2;
nx = fft->n;
ny = fft->next->n;
/* Number of complex elements in y direction */
- nyc = (ny/2+1);
+ nyc = (ny / 2 + 1);
- work = fft->work+4*nx;
+ work = fft->work + 4 * nx;
if (dir == GMX_FFT_REAL_TO_COMPLEX)
{
*/
if (in_data != out_data)
{
- p1 = static_cast<real *>(in_data);
- p2 = static_cast<real *>(out_data);
+ p1 = static_cast<real*>(in_data);
+ p2 = static_cast<real*>(out_data);
for (i = 0; i < nx; i++)
{
for (j = 0; j < ny; j++)
{
- p2[i*nyc*2+j] = p1[i*ny+j];
+ p2[i * nyc * 2 + j] = p1[i * ny + j];
}
}
}
- data = static_cast<t_complex *>(out_data);
+ data = static_cast<t_complex*>(out_data);
/* y real-to-complex FFTs */
for (i = 0; i < nx; i++)
{
- gmx_fft_1d_real(fft->next, GMX_FFT_REAL_TO_COMPLEX, data+i*nyc, data+i*nyc);
+ gmx_fft_1d_real(fft->next, GMX_FFT_REAL_TO_COMPLEX, data + i * nyc, data + i * nyc);
}
/* Transform to get X data in place */
/* Complex-to-complex X FFTs */
for (i = 0; i < nyc; i++)
{
- gmx_fft_1d(fft, GMX_FFT_FORWARD, data+i*nx, data+i*nx);
+ gmx_fft_1d(fft, GMX_FFT_FORWARD, data + i * nx, data + i * nx);
}
/* Transpose back */
gmx_fft_transpose_2d(data, data, nyc, nx);
-
}
else if (dir == GMX_FFT_COMPLEX_TO_REAL)
{
*/
if (in_data != out_data)
{
- memcpy(work, in_data, sizeof(t_complex)*nx*nyc);
- data = reinterpret_cast<t_complex *>(work);
+ memcpy(work, in_data, sizeof(t_complex) * nx * nyc);
+ data = reinterpret_cast<t_complex*>(work);
}
else
{
/* in-place */
- data = reinterpret_cast<t_complex *>(out_data);
+ data = reinterpret_cast<t_complex*>(out_data);
}
/* Transpose to get X arrays */
/* Do X iFFTs */
for (i = 0; i < nyc; i++)
{
- gmx_fft_1d(fft, GMX_FFT_BACKWARD, data+i*nx, data+i*nx);
+ gmx_fft_1d(fft, GMX_FFT_BACKWARD, data + i * nx, data + i * nx);
}
/* Transpose to get Y arrays */
/* Do Y iFFTs */
for (i = 0; i < nx; i++)
{
- gmx_fft_1d_real(fft->next, GMX_FFT_COMPLEX_TO_REAL, data+i*nyc, data+i*nyc);
+ gmx_fft_1d_real(fft->next, GMX_FFT_COMPLEX_TO_REAL, data + i * nyc, data + i * nyc);
}
if (in_data != out_data)
/* Output (pointed to by data) is now in padded format.
* Pack it into out_data if we were doing an out-of-place transform.
*/
- p1 = reinterpret_cast<real *>(data);
- p2 = static_cast<real *>(out_data);
+ p1 = reinterpret_cast<real*>(data);
+ p2 = static_cast<real*>(out_data);
for (i = 0; i < nx; i++)
{
for (j = 0; j < ny; j++)
{
- p2[i*ny+j] = p1[i*nyc*2+j];
+ p2[i * ny + j] = p1[i * nyc * 2 + j];
}
}
}
return 0;
}
-void
-gmx_fft_destroy(gmx_fft_t fft)
+void gmx_fft_destroy(gmx_fft_t fft)
{
if (fft != nullptr)
{
}
}
-void gmx_fft_cleanup()
-{
-}
+void gmx_fft_cleanup() {}