kml_fft(f)_plan_r2r_1d
Create a plan for the one-dimensional R2R transform of a single contiguous data sequence.
Interface Definition
C interface:
kml_fft_plan kml_fft_plan_r2r_1d(int n, double *in, double *out, kml_fft_r2r_kind kind, unsigned flags);
kml_fftf_plan kml_fftf_plan_r2r_1d(int n, float *in, float *out, kml_fftf_r2r_kind kind, unsigned flags);
Fortran interface:
RES = KML_FFT_PLAN_R2R_ID(N, IN, OUT, KIND, 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 |
|---|---|---|---|
n |
int |
Inputs the FFT sequence size. The constraint is n ≥ 1. |
Input |
in |
|
Inputs the data to be transformed. |
Input |
out |
|
Outputs the data generated using FFT. |
Output |
kind |
|
kind indicates the R2R transform type of an FFT sequence. It has the following options:
|
Input |
flags |
unsigned int |
A planning option, not in use. |
Input |
Dependencies
C: "kfft.h"
Fortran: "kfft.f03"
Examples
C interface:
int N = 16;
double *in;
double *out;
kml_fft_plan plan;
in = (double*)kml_fft_malloc(sizeof(double) * N);
out = (double*)kml_fft_malloc(sizeof(double) * N);
for (int i = 0; i < N; i++){
in[i] = (double)i;
}
plan = kml_fft_plan_r2r_1d(N, in , out, KML_FFT_REDFT10, KML_FFT_ESTIMATE);
kml_fft_execute_r2r(plan, in, out);
kml_fft_destroy_plan(plan);
kml_fft_free(in);
kml_fft_free(out);
/*
* out = {2.400000e+02, -1.035857e+02, 0.000000e+00, -1.135629e+01,
* 0.000000e+00, -3.968777e+00, 0.000000e+00, -1.920738e+00,
* 0.000000e+00, -1.061666e+00, 0.000000e+00, -6.060758e-01,
* 0.000000e+00, -3.169964e-01, 0.000000e+00, -9.896796e-02}
*/
Fortran interface:
INTEGER(C_INT) :: N = 16
REAL(C_DOUBLE) :: INIT(16)
REAL(C_DOUBLE), POINTER :: IN(:), OUT(:)
TYPE(C_PTR) :: PIN, POUT
INTEGER(C_SIZE_T) :: SIZE
SIZE = N
DATA KIND/KML_FFT_DHT, KML_FFT_DHT/
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/1, 2, 3, 4, 5, 6, 7, 8/
INTEGER :: I
DO WHILE(I <= SIZE)
IN(I) = INIT(I)
END DO
TYPE(C_PTR) :: PLAN
PLAN = KML_FFT_PLAN_R2R_1D(N, IN , OUT, KML_FFT_REDFT10, 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 = /2.400000E+02, -1.035857E+02, 0.000000E+00, -1.135629E+01,
! 0.000000E+00, -3.968777E+00, 0.000000E+00, -1.920738E+00,
! 0.000000E+00, -1.061666E+00, 0.000000E+00, -6.060758E-01,
! 0.000000E+00, -3.169964E-01, 0.000000E+00, -9.896796E-02/
!