Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f/h)_plan_r2r_3d

Create a plan for the three-dimensional R2R transform of a single contiguous data sequence.

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);

kml_ffth_plan kml_ffth_plan_r2r_3d(int n0, int n1, int n2, __fp16 *in, __fp16 *out, kml_ffth_r2r_kind kind0, kml_ffth_r2r_kind kind1, kml_ffth_r2r_kind kind2, unsigned flags);

Fortran interface:

RES = KML_FFT_PLAN_R2R_3D(N0, N1, N2, IN, OUT, KIND0, KIND1, KIND2, FLAGS);

RES = KML_FFTF_PLAN_R2R_3D(N0, N1, N2, IN, OUT, KIND0, KIND1, KIND2, FLAGS);

RES = KML_FFTH_PLAN_R2R_3D(N0, N1, N2, IN, OUT, KIND0, KIND1, KIND2, FLAGS);

KML_FFT_REDFT11 and KML_FFT_RODFT11 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/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. You can also pass the object to the kml_fft(f/h)_execute_r2r 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 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

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

Inputs the data to be transformed.

Input

out

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

Outputs the data generated using FFT.

Output

kind0

  • Double precision: kml_fft_r2r_kind*
  • Single precision: kml_fftf_r2r_kind*
  • Half precision: kml_ffth_r2r_kind*

kind0 indicates the R2R transform type in the first dimension of an FFT sequence. It has the following options:

  • KML_FFT_R2HC
  • KML_FFT_HC2R
  • KML_FFT_DHT
  • KML_FFT_REDFT00
  • KML_FFT_REDFT01
  • KML_FFT_REDFT10
  • KML_FFT_REDFT11
  • KML_FFT_RODFT00
  • KML_FFT_RODFT01
  • KML_FFT_RODFT10
  • KML_FFT_RODFT11

Input

kind1

  • Double precision: kml_fft_r2r_kind*
  • Single precision: kml_fftf_r2r_kind*
  • Half precision: kml_ffth_r2r_kind*

kind1 indicates the R2R transform type in the second dimension of an FFT sequence. It has the following options:

  • KML_FFT_R2HC
  • KML_FFT_HC2R
  • KML_FFT_DHT
  • KML_FFT_REDFT00
  • KML_FFT_REDFT01
  • KML_FFT_REDFT10
  • KML_FFT_REDFT11
  • KML_FFT_RODFT00
  • KML_FFT_RODFT01
  • KML_FFT_RODFT10
  • KML_FFT_RODFT11

Input

kind2

  • Double precision: kml_fft_r2r_kind*
  • Single precision: kml_fftf_r2r_kind*
  • Half precision: kml_ffth_r2r_kind*

kind2 indicates the R2R transform type in the third dimension of an FFT sequence. It has the following options:

  • KML_FFT_R2HC
  • KML_FFT_HC2R
  • KML_FFT_DHT
  • KML_FFT_REDFT00
  • KML_FFT_REDFT01
  • KML_FFT_REDFT10
  • KML_FFT_REDFT11
  • KML_FFT_RODFT00
  • KML_FFT_RODFT01
  • KML_FFT_RODFT10
  • KML_FFT_RODFT11

Input

flags

unsigned int

Planning option, which describes the ESTIMATE or PATIENT mode.

KML_FFT_ESTIMATE: ESTIMATE mode

KML_FFT_PATIENT: PATIENT mode

Input

Dependencies

C: "kfft.h"

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) :: KIND2 = 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 = 1
    DO WHILE(I <=  SIZE) 
        IN(I) = INIT(I) 
        I = I + 1
    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/ 
    !