kml_fft(f)_plan_many_dft_c2r
建立howmany组数据序列n维C2R变换的plan。其中,单个FFT的数据序列不需要是连续的,可以以跨步的形式提供。
接口定义
C interface:
kml_fft_plan kml_fft_plan_many_dft_c2r(int rank, const int *n, int howmany, kml_fft_complex *in, const int *inembed, int istride, int idist, double *out, const int *onembed, int ostride, int odist, unsigned flags);
kml_fftf_plan kml_fftf_plan_many_dft_c2r(int rank, const int *n, int howmany, kml_fftf_complex *in, const int *inembed, int istride, int idist, float *out, const int *onembed, int ostride, int odist, unsigned flags);
Fortran interface:
RES = KML_FFT_PLAN_MANY_DFT_C2R(RANK, N, HOWMANY, IN, INEMBED, ISTRIDE, IDIST, OUT, ONEMBED, OSTRIDE, ODIST, FLAGS);
RES = KML_FFTF_PLAN_MANY_DFT_C2R(RANK, N, HOWMANY, IN, INEMBED, ISTRIDE, IDIST, OUT, ONEMBED, OSTRIDE, ODIST, FLAGS);
返回值
函数返回一个kml_fft(f)_plan类型的结构体指针。将该对象作为参数传入kml_fft(f)_execute函数中使用,将对当前提供的输入in和输出out执行FFT变换;另外,也可以通过将该对象作为参数传入kml_fft(f)_execute_dft_c2r函数中以对新的输入in和输出out执行FFT变换。
如果函数返回非空指针,则表示plan执行成功,否则表示执行失败。
参数
参数名 |
数据类型 |
描述 |
输入/输出 |
---|---|---|---|
rank |
int |
FFT变换的维度是rank,约束:1 ≤ rank ≤ 3。 |
输入 |
n |
const int* |
n是维度为rank的数组,包含FFT序列每一维度的大小,约束:n[i] ≥ 1, for i in 0 to rank - 1。 |
输入 |
howmany |
int |
howmany表示要多少个多维FFT变换。 |
输入 |
in |
|
输入待变换的数据。 |
输入 |
inembed |
const int* |
inembed是大小为rank的数组或者NULL,该数组表示FFT数据in存储的更大空间的每一维度的大小。 约束:inembed[i] ≥ n[i] for i in 0, rank-1 或者:如果inembed == NULL,则可以认为inembed与n相等 |
输入 |
istride |
int |
FFT输入序列的相继元素之间的间隔。 |
输入 |
idist |
int |
idist表示输入的每个FFT序列的间隔。 |
输入 |
out |
|
输出快速傅里叶变换后的数据。 |
输出 |
onembed |
const int* |
onembed是大小为rank的数组或者NULL,该数组表示FFT数据out存储的更大空间的每一维度的大小。 约束:onembed[i] ≥ n[i] for i in 0, rank-1 或者:如果onembed == NULL,则可以认为onembed与n相等 |
输入 |
ostride |
int |
FFT输出序列的相继元素之间的间隔。 |
输入 |
odist |
int |
odist表示输出的每个FFT序列的间隔。 |
输入 |
flags |
unsigned int |
planning选项,未使用。 |
输入 |
依赖
C: "kfft.h"
Fortran: "kfft.f03"
示例
C interface:
int rank = 1; int *n; n = (int*)kml_fft_malloc(sizeof(int) * rank); n[0] = 4; int howmany = 3; int istride = 1; int ostride = 1; int idist = n[0] / 2 + 1; int odist = 4; double init[9][2] = {{120, 0}, {8, 8}, {0, 0}, {0, 16}, {0, 16}, {-8, 8}, {-8, 0}, {-8, 8}, {-16, 0}}; kml_fft_complex *in; in = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * (n[0] / 2 + 1) * howmany); for (int i = 0; i < (n[0] / 2 + 1) * howmany; i++){ in[i][0] = init[i][0]; in[i][1] = init[i][1]; } double *out; out = (double*)kml_fft_malloc(sizeof(double) * n[0] * howmany); kml_fft_plan plan; plan = kml_fft_plan_many_dft_c2r(rank, n, howmany, in, NULL, istride, idist, out, NULL, ostride, odist, KML_FFT_ESTIMATE); kml_fft_execute_dft_c2r(plan, in, out); kml_fft_destroy_plan(plan); kml_fft_free(n); kml_fft_free(in); kml_fft_free(out); /* * out = {1.360000e+02, 1.040000e+02, 1.040000e+02, 1.360000e+02, * -8.000000e+00, -2.400000e+01, -8.000000e+00, 4.000000e+01, * -4.000000e+01, -8.000000e+00, -8.000000e+00, 2.400000e+01} */
Fortran interface:
INTEGER(C_INT) :: RANK = 1 INTEGER(C_INT) :: N(1) N(1) = 4 REAL(C_DOUBLE), DIMENSION(9, 2) :: INIT TYPE(KML_FFT_COMPLEX), POINTER :: IN(:), REAL(C_DOUBLE), POINTER :: OUT(:) INTEGER, POINTER :: INEMBED(:), ONEMBED(:) TYPE(C_PTR) :: PIN, POUT INTEGER(C_INT) :: HOWMANY = 3 INTEGER(C_INT) :: ISTRIDE = 1 INTEGER(C_INT) :: OSTRIDE = 1 INTEGER(C_INT) :: IDIST = 3 INTEGER(C_INT) :: ODIST = 4 INTEGER(C_SIZE_T) :: CSIZE, RSIZE CSIZE = 16 * 9 RSIZE = 8 * 12 PIN = KML_FFT_MALLOC(SIZE) POUT = KML_FFT_MALLOC(SIZE) CALL C_F_POINTER(PIN, IN, SHAPE=[9]) CALL C_F_POINTER(POUT, OUT, SHAPE=[12]) CALL C_F_POINTER(C_NULL_PTR, INEMBED, SHAPE=[0]) CALL C_F_POINTER(C_NULL_PTR, ONEMBED, SHAPE=[0]) DATA INIT/120, 8, 0, 0, 0, -8, -8, -8, -16, 0, 8, 0, 16, 16, 8, 0, 0, 0/ INTEGER I DO WHILE(I <= 9) IN(I)%R = INIT(I, 0) IN(I)%I = INIT(I, 1) END DO TYPE(C_PTR) :: PLAN PLAN = KML_FFT_PLAN_MANY_DFT_C2R(RANK, N, HOWMANY, IN, INEMBED, ISTRIDE, IDIST, OUT, ONEMBED, OSTRIDE, ODIST, 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, ! -8.000000E+00, -2.400000E+01, -8.000000E+00, 4.000000E+01, ! -4.000000E+01, -8.000000E+00, -8.000000E+00, 2.400000E+01/ !