kml_fft(f)_plan_dft_r2c_2d
建立单个连续数据序列2维R2C变换的plan。
接口定义
C interface:
kml_fft_plan kml_fft_plan_dft_r2c_2d(int n0, int n1, double *in, kml_fft_complex *out, unsigned flags);
kml_fftf_plan kml_fftf_plan_dft_r2c_2d(int n0, int n1, float *in, kml_fftf_complex *out, unsigned flags);
Fortran interface:
RES = KML_FFT_PLAN_DFT_R2C_2D(N0, N1, IN, OUT, FLAGS);
RES = KML_FFTF_PLAN_DFT_R2C_2D(N0, N1, IN, OUT, FLAGS);
返回值
函数返回一个kml_fft(f)_plan类型的结构体指针。将该对象作为参数传入kml_fft(f)_execute函数中使用,将对当前提供的输入in和输出out执行FFT变换;另外,也可以通过将该对象作为参数传入kml_fft(f)_execute_dft_r2c函数中以对新的输入in和输出out执行FFT变换。
如果函数返回非空指针,则表示plan执行成功,否则表示执行失败。
参数
参数名 |
数据类型 |
描述 |
输入/输出 |
---|---|---|---|
n0 |
int |
输入FFT序列第一维的大小,约束:n0 ≥ 1。 |
输入 |
n1 |
int |
输入FFT序列第二维的大小,约束:n1 ≥ 1。 |
输入 |
in |
|
输入待变换的数据。 |
输入 |
out |
|
输出快速傅里叶变换后的数据。 |
输出 |
flags |
unsigned int |
planning选项,未使用。 |
输入 |
依赖
C: "kfft.h"
Fortran: "kfft.f03"
示例
C interface:
int n0 = 2; int n1 = 4; double init[8] = {1, 2, 3, 4, 5, 6, 7, 8}; double *in; in = (double*)kml_fft_malloc(sizeof(double) * n0 * n1); for (int i = 0; i < n0 * n1; i++) { in[i] = init[i]; } kml_fft_complex *out; out = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * n0 * (n1 / 2 + 1)); kml_fft_plan plan; plan = kml_fft_plan_dft_r2c_2d(n0, n1, 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 = {{3.600000e+01, 0.000000e+00}, {-4.000000e+00, 4.000000e+00}, * {-4.000000e+00, 0.000000e+00}, {-1.600000e+01, 0.000000e+00}, * {0.000000e+00, 0.000000e+00}, {0.000000e+00, 0.000000e+00}} */
Fortran interface:
INTEGER(C_INT) :: N0 = 2 INTEGER(C_INT) :: N1 = 4 REAL(C_DOUBLE) :: INIT(8) 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 CSIZE = N0 * (N1 / 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 N/2, 4/ DATA INIT/1, 2, 3, 4, 5, 6, 7, 8/ INTEGER :: I DO WHILE(I <= RSIZE) IN(I) = INIT(I) END DO TYPE(C_PTR) :: PLAN PLAN = KML_FFT_PLAN_DFT_R2C_2D(N0, N1, 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 = /3.600000E+01, 0.000000E+00, -4.000000E+00, 4.000000E+00, ! -4.000000E+00, 0.000000E+00, -1.600000E+01, 0.000000E+00, ! 0.000000E+00, 0.000000E+00, 0.000000E+00, 0.000000E+00/ !