Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f)_plan_r2r_2d

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

Interface Definition

C interface:

kml_fft_plan kml_fft_plan_r2r_2d(int n0, int n1, double *in, double *out, kml_fft_r2r_kind kind0, kml_fft_r2r_kind kind1, unsigned flags);

kml_fftf_plan kml_fftf_plan_r2r_2d(int n0, int n1, float *in, float *out, kml_fftf_r2r_kind kind0, kml_fftf_r2r_kind kind1, unsigned flags);

Fortran interface:

RES = KML_FFT_PLAN_R2R_2D(N0, N1, IN, OUT, KIND0, KIND1, FLAGS);

RES = KML_FFTF_PLAN_R2R_2D(N0, N1, IN, OUT, KIND0, KIND1, 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

in

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

Inputs the data to be transformed.

Input

out

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

Outputs the data generated using FFT.

Output

kind0

  • Double precision: kml_fft_r2r_kind*
  • Single precision: kml_fftf_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*

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

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 = 4; 
    double init[8] = {120, 0, 8, 8, 0, 0, 1, 1}; 
    double *in; 
    in = (double*)kml_fft_malloc(sizeof(double) * n0 * n1); 
    for (int i = 0; i < n0 * n1; i++) { 
        in[i] = init[i]; 
    } 
    double *out; 
    out = (double*)kml_fft_malloc(sizeof(double) * n0 * n1); 
    kml_fft_r2r_kind kind0; 
    kml_fft_r2r_kind kind1; 
    kind0 = KML_FFT_DHT; 
    kind1 = KML_FFT_DHT;     
    kml_fft_plan plan; 
    plan = kml_fft_plan_r2r_2d(n0, n1, in, out, kind0, kind1, KML_FFT_ESTIMATE); 
    kml_fft_execute_r2r(plan, in, out); 
 
    kml_fft_destroy_plan(plan); 
    kml_fft_free(in); 
    kml_fft_free(out); 
 
    /* 
     * out = {1.380000e+02, 1.020000e+02, 1.200000e+02, 1.200000e+02, 
     *        1.340000e+02, 1.060000e+02, 1.200000e+02, 1.200000e+02} 
     */

Fortran interface:

    INTEGER(C_INT) :: N0 = 2 
    INTEGER(C_INT) :: N1 = 4 
    INTEGER(C_INT) :: KIND0 = KML_FFT_DHT 
    INTEGER(C_INT) :: KIND1 = KML_FFT_DHT 
    REAL(C_DOUBLE) :: INIT(8) 
    REAL(C_DOUBLE), POINTER :: IN(:), OUT(:) 
    TYPE(C_PTR) :: PIN, POUT 
    INTEGER(C_SIZE_T) :: SIZE 
    SIZE = N0 * N1 
    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, 1, 1/ 
    INTEGER :: I 
    DO WHILE(I <=  SIZE) 
        IN(I) = INIT(I) 
    END DO 
    TYPE(C_PTR) :: PLAN 
    PLAN = KML_FFT_PLAN_R2R_2D(N0, N1, IN, OUT, KIND0, KIND1, 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 = /1.380000e+02, 1.020000e+02, 1.200000e+02, 1.200000e+02, 
    !        1.340000e+02, 1.060000e+02, 1.200000e+02, 1.200000e+02/ 
    !