Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f/h)_plan_dft_c2r_3d

Create a plan for the three-dimensional C2R transform of a single contiguous data array.

Interface Definition

C interface:

kml_fft_plan kml_fft_plan_dft_c2r_3d(int n0, int n1, int n2, kml_fft_complex *in, double *out, unsigned flags);

kml_fftf_plan kml_fftf_plan_dft_c2r_3d(int n0, int n1, int n2, kml_fftf_complex *in, float *out, unsigned flags);

kml_ffth_plan kml_ffth_plan_dft_c2r_3d(int n0, int n1, int n2, kml_ffth_complex *in, __fp16 *out, unsigned flags);

Fortran interface:

RES = KML_FFT_PLAN_DFT_C2R_3D( N0, N1, N2, IN, OUT, FLAGS);

RES = KML_FFTF_PLAN_DFT_C2R_3D( N0, N1, N2, IN, OUT, FLAGS);

RES = KML_FFTH_PLAN_DFT_C2R_3D( N0, N1, N2, IN, OUT, FLAGS);

Return Value

The function returns a structure pointer of the kml_fft(f/h)_plan type. This object can be passed to the kml_fft(f/h)_execute function as a parameter to perform FFT on the current input and output. This object can also be passed to the kml_fft(f/h)_execute_dft_c2r function as a parameter to perform FFT on new input and output.

If this function returns a non-null pointer, the plan has been successfully created. Otherwise, the plan fails to be created.

Parameters

Parameter

Data Type

Description

Input/Output

n0

int

Inputs the size of the first dimension in the FFT array. The constraint is n0 ≥ 1.

Input

n1

int

Inputs the size of the second dimension in the FFT array. The constraint is n1 ≥ 1.

Input

n2

int

Inputs the size of the third dimension in the FFT array. The constraint is n2 ≥ 1.

Input

in

  • Double precision: kml_fft_complex*
  • Single precision: kml_fftf_complex*
  • Half precision: kml_ffth_complex*

Inputs the data to be transformed.

Input

out

  • Double precision: double*
  • Single precision: float*
  • Half precision: __fp16*

Outputs the data generated using FFT.

Output

flags

unsigned int

Planning option, which describes the ESTIMATE or PATIENT mode.

KML_FFT_ESTIMATE: ESTIMATE mode

KML_FFT_PATIENT: PATIENT mode

Input

Dependencies

#include "kfft.h"

Examples

C interface:

    int n0 = 2; 
    int n1 = 3; 
    int n2 = 4; 
    double init[18][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}, 
        {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) * n0 * n1 * (n2 / 2 + 1)); 
    for (int i = 0; i < n0 * n1 * (n2 / 2 + 1); i++) { 
        in[i][0] = init[i][0]; 
        in[i][1] = init[i][1]; 
    } 
    double *out; 
    out = (double*)kml_fft_malloc(sizeof(double) * n0 * n1 * n2); 
    kml_fft_plan plan; 
    plan = kml_fft_plan_dft_c2r_3d(n0, n1, n2, in, out, KML_FFT_ESTIMATE); 
    kml_fft_execute_dft_c2r(plan, in, out); 
 
    kml_fft_free(in); 
    kml_fft_free(out); 
 
    /* 
     * out = {1.280000e+02, 1.440000e+02, 2.560000e+02, 4.000000e+02, 
     *        8.000000e+00, 4.428719e+01, 1.360000e+02, 6.771281e+01, 
     *        8.000000e+00, 9.971281e+01, 1.360000e+02, 1.228719e+01, 
     *        4.800000e+01, 0.000000e+00, -8.000000e+01, 0.000000e+00, 
     *        2.427180e+02, 1.541436e+02, 7.414359e+01, 1.541436e+02, 
     *        3.812820e+02, 1.818564e+02, 1.018564e+02, 1.818564e+02} 
     */

Fortran interface:

    INTEGER(C_INT) :: N0 = 2 
    INTEGER(C_INT) :: N1 = 3 
    INTEGER(C_INT) :: N2 = 4 
    REAL(C_DOUBLE), DIMENSION(18, 2) :: INIT 
    TYPE(KML_FFT_COMPLEX), POINTER :: IN 
    REAL(C_DOUBLE), POINTER :: OUT 
    TYPE(C_PTR) :: PIN, POUT 
    INTEGER(C_SIZE_T) :: CSIZE, RSIZE 
    CSIZE = N0 * N1 * (N2 / 2 + 1) 
    RSIZE = N0 * N1 * N2 
    PIN = KML_FFT_MALLOC(SIZEOF(16 * CSIZE)) 
    POUT = KML_FFT_MALLOC(8 * RSIZE) 
    CALL C_F_POINTER(PIN, IN, SHAPE=[CSIZE]) 
    CALL C_F_POINTER(POUT, OUT, SHAPE=[RSIZE]) 
    DATA INIT/120, 8, 0, 0, 0, -8, -8, -8, -16, 0, -40, -8, 120, 8, 0, 0, 0, -8,0, 8, 0, 16, 16, 8, 0, 8, 0, 16, 8, -8, 0, 8, 0, 16, 16, 8/ 
    INTEGER :: I = 1
    DO WHILE(I <= CSIZE) 
        IN(I)%R = INIT(I, 0) 
        IN(I)%I = INIT(I, 1) 
        I = I + 1
    END DO 
    TYPE(C_PTR) :: PLAN 
    PLAN = KML_FFT_PLAN_DFT_C2R_3D(N0, N1, N2, IN , OUT , KML_FFT_ESTIMATE);  
    CALL KML_FFT_EXECUTE_DFT_C2R(PLAN, IN, OUT); 
 
    CALL KML_FFT_DESTROY_PLAN(PLAN) 
    CALL KML_FFT_FREE(PIN) 
    CALL KML_FFT_FREE(POUT) 
    ! 
    ! OUT = /1.280000E+02, 1.440000E+02, 2.560000E+02, 4.000000E+02, 
    !        8.000000E+00, 4.428719E+01, 1.360000E+02, 6.771281E+01, 
    !        8.000000E+00, 9.971281E+01, 1.360000E+02, 1.228719E+01, 
    !        4.800000E+01, 0.000000E+00, -8.000000E+01, 0.000000E+00, 
    !        2.427180E+02, 1.541436E+02, 7.414359E+01, 1.541436E+02, 
    !        3.812820E+02, 1.818564E+02, 1.018564E+02, 1.818564E+02/ 
    !