Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f)_plan_dft

Create a plan for the n-dimensional complex-to-complex (C2C) transform of a single contiguous data sequence.

Interface Definition

C interface:

kml_fft_plan kml_fft_plan_dft(int rank, const int *n, kml_fft_complex *in, kml_fft_complex *out, int sign, unsigned flags);

kml_fftf_plan kml_fftf_plan_dft(int rank, const int *n, kml_fftf_complex *in, kml_fftf_complex *out, int sign, unsigned flags);

Fortran interface:

RES = KML_FFT_PLAN_DFT(RANK, N, IN, OUT, SIGN, FLAGS);

RES = KML_FFTF_PLAN_DFT(RANK, N, IN, OUT, 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 to rank - 1.

Input

in

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

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

sign

int

Specifies forward or backward transform.

  • -1(KML_FFT_FORWARD): forward
  • +1(KML_FFT_BACKWARD): backward

Input

flags

unsigned int

A planning option, not in use.

Input

Dependencies

C: "kfft.h"

Fortran: "kfft.f03"

Examples

C interface:

    int rank = 2; 
    int *n; 
    n = (int*)kml_fft_malloc(sizeof(int) * rank); 
    n[0] = 2; 
    n[1] = 3; 
    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) * n[0] * n[1]); 
    for (int i = 0; i < n[0] * n[1]; 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) * n[0] * n[1]); 
    kml_fft_plan plan; 
    plan = kml_fft_plan_dft(rank, n, in, out, 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.200000e+02, 4.800000e+01}, {1.338564e+02, -1.385641e+01}, 
     *        {1.061436e+02, 1.385641e+01}, {1.360000e+02, -3.200000e+01}, 
     *        {1.120000e+02, -8.000000e+00}, {1.120000e+02, -8.000000e+00}} 
     */

Fortran interface:

    INTEGER(C_INT) :: RANK = 2 
    INTEGER(C_INT), DIMESION(*) :: N 
    N = KML_FFT_MALLOC(4 * RANK) 
    N(0) = 2 
    N(1) = 3 
    REAL(C_DOUBLE) :: INIT(6, 2) 
    TYPE(C_PTR) :: PLAN 
    TYPE(KML_FFT_COMPLEX), POINTER :: IN, OUT 
    TYPE(C_PTR) :: PIN, POUT 
    TYPE(C_SIZE_T) :: SIZE 
    SIZE = 16 * N(0) * N(1) 
    IN = KML_FFT_MALLOC(SIZE) 
    OUT = KML_FFT_MALLOC(SIZE) 
    CALL C_F_POINTER(PIN, IN, SHAPE=[N(1) * N(2)]) 
    CALL C_F_POINTER(POUT, OUT, SHAPE=[N(1) * N(2)]) 
    DATA INIT/120, 8, 0, 0, 0, -8, 0, 8, 0, 16, 16, 8/ 
    INTEGER I 
    DO WHILE(I <= N(0) * N(1))  
        IN(I)%R = INIT(I, 0) 
        IN(I)%I = INIT(I, 1) 
    END DO 
    PLAN = KML_FFT_PLAN_DFT(RANK, N, IN, OUT, KML_FFT_FORWARD, KML_FFT_ESTIMATE) 
    CALL KML_FFT_EXECUTE_DFT(PLAN, IN, OUT) 
 
    CALL KML_FFT_DESTROY_PLAN(PLAN) 
    CALL KML_FFT_FREE(N) 
    CALL KML_FFT_FREE(PIN) 
    CALL KML_FFT_FREE(POUT) 
 
    ! 
    ! OUT = /120.00000000000000D0, 133.85640646055103D0,  
    !        106.14359353944897D0, 136.00000000000000D0,  
    !        112.00000000000000D0, 112.00000000000000D0,  
    !        48.000000000000000D0, -13.856406460551021D0,  
    !        13.856406460551021D0, -32.000000000000000D0,  
    !        -8.0000000000000000D0, -8.0000000000000000D0/ 
    !