kml_fft(f)_plan_many_dft
Create a plan for the n-dimensional C2C transform of howmany data sequences. The data sequence of a single FFT does not need to be contiguous and can be strided.
Interface Definition
C interface:
kml_fft_plan kml_fft_plan_many_dft(int rank,
const int *n,
int howmany,
kml_fft_complex *in,
const int *inembed,
int istride,
int idist,
kml_fft_complex *out,
const int *onembed,
int ostride,
int odist,
int sign,
unsigned flags);
kml_fftf_plan kml_fftf_plan_many_dft(int rank,
const int *n,
int howmany,
kml_fftf_complex *in,
const int *inembed,
int istride,
int idist,
kml_fftf_complex *out,
const int *onembed,
int ostride,
int odist,
int sign,
unsigned flags);
Fortran interface:
RES = KML_FFT_PLAN_MANY_DFT(RANK, N, HOWMANY, IN, INEMBED, ISTRIDE, IDIST, OUT, ONEMBED, OSTRIDE, ODIST, SIGN, FLAGS);
RES = KML_FFTF_PLAN_MANY_DFT(RANK, N, HOWMANY, IN, INEMBED, ISTRIDE, IDIST, OUT, ONEMBED, OSTRIDE, ODIST, 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 FFT. The constraint is 1 <= rank <= 3. |
Input |
n |
const int* |
Indicates an array whose dimension is rank, including the size of each dimension in the FFT sequence. The constraint is n[i] >= 1, for i in 0, rank - 1. |
Input |
howmany |
int |
howmany indicates how many multi-dimensional FFTs are needed. |
Input |
in |
|
Inputs the data to be transformed. |
Input |
inembed |
const int* |
inembed is an array whose size is rank or NULL. This array indicates the size of each dimension of a larger space for input FFT data storage. Constraint: inembed[i] >= n[i] for i in 0, rank-1. Or if inembed == NULL, inembed is equal to n. |
Input |
istride |
int |
Interval between successive elements of the i-th dimensional FFT input sequence. |
Input |
idist |
int |
idist indicates the interval between FFT input sequences. |
Input |
out |
|
Outputs the data generated using FFT. |
Output |
onembed |
const int* |
onembed is an array whose size is rank or NULL. This array indicates the size of each dimension of a larger space for output FFT data storage. Constraint: onembed[i] >= n[i] for i in 0, rank-1. Or if onembed == NULL, onembed is equal to n. |
Input |
ostride |
int |
Interval between successive elements of the i-th dimensional FFT output sequence. |
Input |
odist |
int |
odist indicates the interval between FFT output sequences. |
Input |
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 = 1;
int *n;
n = (int*)kml_fft_malloc(sizeof(int) * rank);
n[0] = 2;
int howmany = 3;
int istride = 1;
int ostride = 1;
int idist = 2;
int odist = 2;
double init[6][2] = {{120, 0}, {8, 8}, {0, 0}, {0, 16}, {0, 16}, {-8, 8}};
kml_fft_complex *in;
in = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * 6);
for (int i = 0; i < 6; 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) * 6);
kml_fft_plan plan;
plan = kml_fft_plan_many_dft(rank, n, howmany, in, NULL, istride, idist, out, NULL, ostride, odist, KML_FFT_FORWARD, KML_FFT_ESTIMATE);
kml_fft_execute_dft(plan, in, out);
kml_fft_destroy_plan(plan);
kml_fft_free(n);
kml_fft_free(in);
kml_fft_free(out);
/*
* out = {{1.280000e+02, 8.000000e+00}, {1.120000e+02, -8.000000e+00},
* {0.000000e+00, 1.600000e+01}, {0.000000e+00, -1.600000e+01},
* {-8.000000e+00, 2.400000e+01}, {8.000000e+00, 8.000000e+00}}
*/
Fortran interface:
INTEGER(C_INT) :: RANK = 1
INTEGER(C_INT) :: N(1)
N(1) = 2
REAL(C_DOUBLE), DIMENSION(6, 2) :: INIT
TYPE(KML_FFT_COMPLEX), POINTER :: IN(:), OUT(:)
INTEGER, POINTER :: INEMBED(:), ONEMBED(:)
TYPE(C_PTR) :: PIN, POUT
INTEGER(C_INT) :: HOWMANY = 3
INTEGER(C_INT) :: ISTRIDE = 1
INTEGER(C_INT) :: OSTRIDE = 1
INTEGER(C_INT) :: IDIST = 2
INTEGER(C_INT) :: ODIST = 2
INTEGER(C_SIZE_T) :: SIZE = 16 * 6
PIN = KML_FFT_MALLOC(SIZE)
POUT = KML_FFT_MALLOC(SIZE)
CALL C_F_POINTER(PIN, IN, SHAPE=[6])
CALL C_F_POINTER(POUT, OUT, SHAPE=[6])
CALL C_F_POINTER(C_NULL_PTR, INEMBED, SHAPE=[0])
CALL C_F_POINTER(C_NULL_PTR, ONEMBED, SHAPE=[0])
DATA INIT/120, 8, 0, 0, 0, -8, 0, 8, 0, 16, 16, 8/
INTEGER I
DO WHILE(I <= 6)
IN(I)%R = INIT(I, 0)
IN(I)%I = INIT(I, 1)
END DO
TYPE(C_PTR) :: PLAN
PLAN = KML_FFT_PLAN_MANY_DFT(RANK, N, HOWMANY, IN, INEMBED, ISTRIDE, IDIST, OUT, ONEMBED, OSTRIDE, ODIST, KML_FFT_FORWARD, KML_FFT_ESTIMATE);
CALL KML_FFT_EXECUTE_DFT(PLAN, IN, OUT)
CALL KML_FFT_DESTROY_PLAN(PLAN)
CALL KML_FFT_FREE(PIN)
CALL KML_FFT_FREE(POUT)
!
! OUT = /1.280000E+02, 8.000000E+00, 1.120000E+02, -8.000000E+00,
! 0.000000E+00, 1.600000E+01, 0.000000E+00, -1.600000E+01,
! -8.000000E+00, 2.400000E+01, 8.000000E+00, 8.000000E+00/
!