Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f)_plan_dft_r2c_3d

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

Interface Definition

C interface:

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

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

Fortran interface:

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

RES = kml_fftf_plan_dft_r2c_2d(N0, N1, N2, IN, OUT, 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_r2c 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

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*

Inputs the data to be transformed.

Input

out

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

Outputs the data generated using FFT.

Output

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 = 3; 
    int n2 = 2; 
    double init[12] = {120, 8, 0, 0, 0, -8, -8, -8, -16, 0, -40, -8}; 
    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]; 
    } 
    kml_fft_complex *out; 
    out = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * n0 * n1 * (n2 / 2 + 1)); 
    kml_fft_plan plan; 
    plan = kml_fft_plan_dft_r2c_3d(n0, n1, n2, in, out, KML_FFT_ESTIMATE); 
    kml_fft_execute_dft_r2c(plan, in, out); 
 
    kml_fft_destroy_plan(plan); 
    kml_fft_free(in); 
    kml_fft_free(out); 
 
    /* 
     * out = {{4.000000e+01, 0.000000e+00}, {7.200000e+01, 0.000000e+00}, 
     *        {1.480000e+02, -3.464102e+01}, {1.320000e+02, -6.928203e+00}, 
     *        {1.480000e+02, 3.464102e+01}, {1.320000e+02, 6.928203e+00}, 
     *        {2.000000e+02, 0.000000e+00}, {1.680000e+02, 0.000000e+00}, 
     *        {1.160000e+02, 2.078461e+01}, {8.400000e+01, 2.078461e+01}, 
     *        {1.160000e+02, -2.078461e+01}, {8.400000e+01, -2.078461e+01}} 
     */

Fortran interface:

    INTEGER(C_INT) :: N0 = 2 
    INTEGER(C_INT) :: N1 = 3 
    INTEGER(C_INT) :: N2 = 2 
    REAL(C_DOUBLE) :: INIT(12) 
    REAL(C_DOUBLE), POINTER :: IN 
    TYPE(KML_FFT_COMPLEX), POINTER :: OUT 
    TYPE(C_PTR) :: PIN, POUT 
    INTEGER(C_SIZE_T) :: RSIZE, CSIZE 
    RSIZE = N0 * N1 * N2 
    CSIZE = N0 * N1 * (N2 / 2 + 1) 
    PIN = KML_FFT_MALLOC(8 * RSIZE) 
    POUT = KML_FFT_MALLOC(16 * CSIZE) 
    CALL C_F_POINTER(PIN, IN, SHAPE=[RSIZE]) 
    CALL C_F_POINTER(POUT, OUT, SHAPE=[CSIZE]) 
    DATA INIT/120, 8, 0, 0, 0, -8, -8, -8, -16, 0, -40, -8/ 
    INTEGER :: I 
    DO WHILE(I <= RSIZE) 
        IN(I) = INIT(I) 
    END DO 
     
    TYPE(C_PTR) :: PLAN 
    PLAN = KML_FFT_PLAN_DFT_R2C_3D(N0, N1, N2, IN, OUT, KML_FFT_ESTIMATE) 
    CALL KML_FFT_EXECUTE_DFT_R2C(PLAN, IN, OUT) 
 
    CALL KML_FFT_DESTROY_PLAN(PLAN) 
    CALL KML_FFT_FREE(PIN) 
    CALL KML_FFT_FREE(POUT) 
    ! 
    ! OUT = /4.000000E+01, 0.000000E+00, 7.200000E+01, 0.000000E+00, 
    !        1.480000E+02, -3.464102E+01, 1.320000E+02, -6.928203E+00, 
    !        1.480000E+02, 3.464102E+01, 1.320000E+02, 6.928203E+00, 
    !        2.000000E+02, 0.000000E+00, 1.680000E+02, 0.000000E+00, 
    !        1.160000E+02, 2.078461E+01, 8.400000E+01, 2.078461E+01, 
    !        1.160000E+02, -2.078461E+01, 8.400000E+01, -2.078461E+01/ 
    !