kml_fft(f)_plan_guru_dft
Create a plan for the n-dimensional C2C transform of multiple data sequences. The data sequence of const kml_fft_iodim * single FFT does not need to be contiguous and can be strided.
Interface Definition
C interface:
kml_fft_plan kml_fft_plan_guru_dft(int rank,
const kml_fft_iodim *dims,
int howmany_rank,
const kml_fft_iodim *howmany_dims,
kml_fft_complex *in,
kml_fft_complex *out,
int sign,
unsigned flags);
kml_fftf_plan kml_fftf_plan_guru_dft(int rank,
const kml_fftf_iodim *dims,
int howmany_rank,
const kml_fftf_iodim *howmany_dims,
kml_fftf_complex *in,
kml_fftf_complex *out,
int sign,
unsigned flags);
Fortran interface:
RES = KML_FFT_PLAN_GURU_DFT(RANK, DIMS, HOWMANY_RANK, HOWMANY_DIMS, IN, OUT, SIGN, FLAGS);
RES = KML_FFTF_PLAN_GURU_DFT(RANK, DIMS, HOWMANY_RANK, HOWMANY_DIMS, IN, OUT, SIGN, FLAGS);
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_dft 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 |
|---|---|---|---|
rank |
int |
Dimension of a single FFT sequence. The constraint is 1 <= rank <= 3. |
Input |
dims |
|
dims is a structure array whose size is rank. dims[i] contains the following members:
Constraint: dims[i].n >= 1, for i in 0 to rank - 1 |
Input |
howmany_rank |
int |
The memory allocation between multiple rank-dimension FFTs is described by the howmany_dims array of the howmany_rank dimension. howmany_rank indicates the number of dimensions required by the memory access mode of the start address of each rank-dimension FFT to be calculated. Constraint: 0 <= howmany_rank <= 3 |
Input |
howmany_dims |
|
howmany_dims is a structure array whose size is howmany_rank. howmany_dims[i] contains the following members:
|
Input |
in |
|
Inputs the data to be transformed. |
Input |
out |
|
Outputs the data generated using FFT. |
Output |
sign |
int |
Specifies forward or backward transform.
|
Input |
flags |
unsigned int |
A planning option, not in use. |
Input |
Dependencies
C: "kfft.h"
Fortran: "kfft.f03"
Examples
C interface:
int rank = 2;
kml_fft_iodim *dims;
dims = (kml_fft_iodim*)kml_fft_malloc(sizeof(kml_fft_iodim) * rank);
dims[0].n = 2;
dims[0].is = 3;
dims[0].os = 3;
dims[1].n = 3;
dims[1].is = 1;
dims[1].os = 1;
int howmany_rank = 1;
kml_fft_iodim *howmany_dims;
howmany_dims = (kml_fft_iodim*)kml_fft_malloc(sizeof(kml_fft_iodim) * howmany_rank);
howmany_dims[0].n = 2;
howmany_dims[0].is = 2 * 3;
howmany_dims[0].os = 2 * 3;
double init[12][2] = {{120, 0}, {8, 8}, {0, 0}, {0, 16}, {0, 16}, {-8, 8}, {-8, 0}, {-8, 8}, {-16, 0}, {0, -16}, {-40, 8}, {-8, -8}};
kml_fft_complex *in;
in = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * 12);
for (int i = 0; i < 12; i++) {
in[i].r = init[i][0];
in[i].i = init[i][1];
}
kml_fft_complex *out;
out = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * 12);
kml_fft_plan plan;
plan = kml_fft_plan_guru_dft(rank, dims, howmany_rank, howmany_dims, in, out, KML_FFT_FORWARD, KML_FFT_ESTIMATE);
kml_fft_execute_dft(plan, in, out);
kml_fft_destroy_plan(plan);
kml_fft_free(howmany_dims);
kml_fft_free(dims);
kml_fft_free(in);
kml_fft_free(out);
/*
* out = {{1.200000e+02, 4.800000e+01}, {1.338564e+02, -1.385641e+01},
* {1.061436e+02, 1.385641e+01}, {1.360000e+02, -3.200000e+01},
* {1.120000e+02, -8.000000e+00}, {1.120000e+02, -8.000000e+00},
* {-8.000000e+01, -8.000000e+00}, {4.878461e+01, 7.846097e-01},
* {7.215390e+00, -4.078461e+01}, {1.600000e+01, 2.400000e+01},
* {-2.692820e+01, -2.264102e+01}, {-1.307180e+01, 4.664102e+01}}
*/
Fortran interface:
INTEGER(C_INT) :: RANK = 2
INTEGER(C_INT) :: HOWMANY_RANK = 1
TYPE(KML_FFT_IODIM), POINTER :: DIMS(:), HOWMANY_DIMS(:)
REAL(C_DOUBLE), DIMENSION(12, 2) :: INIT
TYPE(KML_FFT_COMPLEX), POINTER :: IN(:), OUT(:)
TYPE(C_PTR) :: PIN, POUT, PDIMS, PHOWMANY_DIMS
INTEGER(C_SIZE_T) :: SIZE1, SIZE2, SIZE3
SIZE1 = 16 * 12
SIZE2 = 24 * RANK
SIZE3 = 24 * HOWMANY_RANK
PDIMS = KML_FFT_MALLOC(SIZE2)
PHOWMANY_DIMS = KML_FFT_MALLOC(SIZE3)
PIN = KML_FFT_MALLOC(SIZE1)
POUT = KML_FFT_MALLOC(SIZE1)
CALL C_F_POINTER(PIN, IN, SHAPE=[12])
CALL C_F_POINTER(POUT, OUT, SHAPE=[12])
CALL C_F_POINTER(PDIMS, DIMS, SHAPE=[RANK])
CALL C_F_POINTER(PHOWMANY_DIMS, HOWMANY_DIMS, SHAPE=[HOWMANY_RANK])
DIMS(0)%N = 2
DIMS(0)%IS = 3
DIMS(0)%OS = 3
DIMS(1)%N = 3
DIMS(1)%IS = 1
DIMS(1)%OS = 1
HOWMANY_DIMS(0)%N = 2
HOWMANY_DIMS(0)%IS = 2 * 3
HOWMANY_DIMS(0)%OS = 2 * 3
DATA INIT/120, 8, 0, 0, 0, -8, -8, -8, -16, 0, -40, -8, 0, 8, 0, 16, 16, 8, 0, 8, 0, -16, 8, -8/
INTEGER :: I
DO WHILE(I <= 12)
IN%R = INIT(I, 0)
IN%I = INIT(I, 1)
END DO
TYPE(C_PTR) :: PLAN
PLAN = KML_FFT_PLAN_GURU_DFT(RANK, DIMS, HOWMANY_RANK, HOWMANY_DIMS, IN, OUT, KML_FFT_FORWARD, KML_FFT_ESTIMATE)
CALL KML_FFT_EXECUTE_DFT(PLAN, IN, OUT)
CALL KML_FFT_DESTROY_PLAN(PLAN)
CALL KML_FFT_FREE(PHOWMANY_DIMS)
CALL KML_FFT_FREE(PDIMS)
CALL KML_FFT_FREE(PIN)
CALL KML_FFT_FREE(POUT)
!
! OUT = /1.200000E+02, 4.800000E+01, 1.338564E+02, -1.385641E+01,
! 1.061436E+02, 1.385641E+01, 1.360000E+02, -3.200000E+01,
! 1.120000E+02, -8.000000E+00, 1.120000E+02, -8.000000E+00,
! -8.000000E+01, -8.000000E+00, 4.878461E+01, 7.846097E-01,
! 7.215390E+00, -4.078461E+01, 1.600000E+01, 2.400000E+01,
! -2.692820E+01, -2.264102E+01, -1.307180E+01, 4.664102E+01/
!