Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f)_plan_dft_c2r_1d

Interface Definition

C interface:

kml_fft_plan kml_fft_plan_dft_c2r_1d(int n, kml_fft_complex *in, double *out, unsigned flags);

kml_fftf_plan kml_fftf_plan_dft_c2r_1d(int n, kml_fftf_complex *in, float *out, unsigned flags);

Fortran interface:

RES = KML_FFT_PLAN_DFT_C2R_1D( N, IN, OUT, FLAGS);

RES = KML_FFTF_PLAN_DFT_C2R_1D( N, 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_c2r 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

n

int

Inputs the FFT sequence size. The constraint is n ≥ 1.

Input

in

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

Inputs the data to be transformed.

Input

out

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

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 = 4; 
    double init[3][2] = {{120, 0}, {8, 8}, {0, 0}}; 
    kml_fft_complex *in; 
    in = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * (n0 / 2 + 1)); 
    for (int i = 0; i < (n0 / 2 + 1); i++) { 
        in[i].r = init[i][0]; 
        in[i].i = init[i][1]; 
    } 
    double *out; 
    out = (double*)kml_fft_malloc(sizeof(double) * n0); 
    kml_fft_plan plan; 
    plan = kml_fft_plan_dft_c2r_1d(n0, in, out, KML_FFT_ESTIMATE); 
    kml_fft_execute_dft_c2r(plan, in, out); 
 
    kml_fft_destroy_plan(plan); 
    kml_fft_free(in); 
    kml_fft_free(out); 
 
    /* 
     * out = {1.360000e+02, 1.040000e+02, 1.040000e+02, 1.360000e+02} 
     */

Fortran interface:

    INTEGER(C_INT) :: N0 = 4 
    REAL(C_DOUBLE), DIMENSION(3, 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 / 2 + 1) 
    RSIZE = N0 
    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, 8, 0/ 
    INTEGER :: I 
    DO WHILE(I <= CSIZE) 
        IN(I)%R = INIT(I, 0) 
        IN(I)%I = INIT(I, 1) 
    END DO 
    TYPE(C_PTR) :: PLAN 
    PLAN = KML_FFT_PLAN_DFT_C2R_1D(N0, 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.360000e+02, 1.040000e+02, 1.040000e+02, 1.360000e+02/ 
    !