kml_fft(f)_plan_r2r_3d
Interface Definition
C interface:
kml_fft_plan kml_fft_plan_r2r_3d(int n0, int n1, int n2, double *in, double *out, kml_fft_r2r_kind kind0, kml_fft_r2r_kind kind1, kml_fft_r2r_kind kind2, unsigned flags);
kml_fftf_plan kml_fftf_plan_r2r_3d(int n0, int n1, int n2, float *in, float *out, kml_fftf_r2r_kind kind0, kml_fftf_r2r_kind kind1, kml_fftf_r2r_kind kind2, unsigned flags);
Fortran interface:
RES = KML_FFT_PLAN_R2R_3D(N0, N1, N2, IN, OUT, KIND0, KIND1, KIND2, FLAGS);
RES = KML_FFT_PLAN_R2R_3D(N0, N1, N2, IN, OUT, KIND0, KIND1, KIND2, FLAGS);
KML_FFT_REDFT11 and KML_FFT_ROODFT11 support only sequences whose length is an integer multiple of 4. Other transforms support only sequences whose length is an integer multiple of 2.
Return Value
The function returns a structure pointer of the kml_fft(f)_plan type. This object is used as a parameter in the kml_fft(f)_execute function to perform FFT on the current input and output. In addition, the object may also be added into the kml_fft(f)_execute_r2r function as a parameter to perform FFT on the new input and output.
If this function returns a non-null pointer, the plan has been successfully executed. Otherwise, the plan failed to be executed.
Parameters
Parameter |
Data Type |
Description |
Input/Output |
|---|---|---|---|
n0 |
int |
Inputs the size of the first dimension in the FFT sequence. The constraint is n0 ≥ 1. |
Input |
n1 |
int |
Inputs the size of the second dimension in the FFT sequence. The constraint is n1 ≥ 1. |
Input |
n2 |
int |
Inputs the size of the third dimension in the FFT sequence. The constraint is n2 ≥ 1. |
Input |
in |
|
Inputs the data to be transformed. |
Input |
out |
|
Outputs the data generated using FFT. |
Output |
kind0 |
|
kind0 indicates the R2R transform type in the first dimension of an FFT sequence. It has the following options:
|
Input |
kind1 |
|
kind1 indicates the R2R transform type in the second dimension of an FFT sequence. It has the following options:
|
Input |
kind2 |
|
kind2 indicates the R2R transform type in the third dimension of an FFT sequence. It has the following options:
|
Input |
flags |
unsigned int |
A planning option, not in use. |
Input |
Dependencies
C: "kfft.h"
Fortran: "kfft.f03"
Examples
C interface:
int n0 = 2;
int n1 = 2;
int n2 = 2;
double init[8] = {120, 0, 8, 8, 0, 0, 0, 16};
double *in;
in = (double*)kml_fft_malloc(sizeof(double) * n0 * n1 * n2);
for (int i = 0; i < n0 * n1 * n2; i++) {
in[i] = init[i];
}
double *out;
out = (double*)kml_fft_malloc(sizeof(double) * n0 * n1 * n2);
kml_fft_r2r_kind kind0 = KML_FFT_RODFT00;
kml_fft_r2r_kind kind1 = KML_FFT_RODFT01;
kml_fft_r2r_kind kind2 = KML_FFT_RODFT10;
kml_fft_plan plan;
plan = kml_fft_plan_r2r_3d(n0, n1, n2, in, out, kind0, kind1, kind2, KML_FFT_ESTIMATE);
kml_fft_execute_r2r(plan, in, out);
kml_fft_destroy_plan(plan);
kml_fft_free(in);
kml_fft_free(out);
/*
* out = {4.940759e+02, 5.324519e+02, 3.373085e+02, 6.433032e+02,
* 4.156922e+02, 6.433032e+02, 4.156922e+02, 5.324519e+02}
*/
Fortran interface:
INTEGER(C_INT) :: N0 = 2
INTEGER(C_INT) :: N1 = 2
INTEGER(C_INT) :: N2 = 2
INTEGER(C_INT) :: KIND0 = KML_FFT_RODFT00
INTEGER(C_INT) :: KIND1 = KML_FFT_RODFT00
INTEGER(C_INT) :: KIND1 = KML_FFT_RODFT00
REAL(C_DOUBLE) :: INIT(8)
REAL(C_DOUBLE), POINTER :: IN(:), OUT(:)
TYPE(C_PTR) :: PIN, POUT
INTEGER(C_SIZE_T) :: SIZE
SIZE = N0 * N1 * N2
PIN = KML_FFT_MALLOC(8 * SIZE)
POUT = KML_FFT_MALLOC(8 * SIZE)
CALL C_F_POINTER(PIN, IN, SHAPE=[SIZE])
CALL C_F_POINTER(POUT, OUT, SHAPE=[SIZE])
DATA INIT/120, 0, 8, 8, 0, 0, 0, 16/
INTEGER :: I
DO WHILE(I <= SIZE)
IN(I) = INIT(I)
END DO
TYPE(C_PTR) :: PLAN
PLAN = KML_FFT_PLAN_R2R_3D(N0, N1, N2, IN, OUT, KIND0, KIND1, KIND2, KML_FFT_ESTIMATE)
CALL KML_FFT_EXECUTE_R2R(PLAN, IN, OUT)
CALL KML_FFT_DESTROY_PLAN(PLAN)
CALL KML_FFT_FREE(PIN)
CALL KML_FFT_FREE(POUT)
!
! OUT = /4.940759e+02, 5.324519e+02, 3.373085e+02, 6.433032e+02,
! 4.156922e+02, 6.433032e+02, 4.156922e+02, 5.324519e+02/
!