kml_fft(f)_plan_guru_split_dft
建立多组数据序列n维C2C变换的plan。其中,单个FFT的数据序列不需要是连续的,可以以跨步的形式提供。split类接口的输入和输出分别存储在实部和虚部数组中。
接口定义
C interface:
kml_fft_plan kml_fft_plan_guru_split_dft(int rank, const kml_fft_iodim *dims, int howmany_rank, const kml_fft_iodim *howmany_dims, double *ri, double *ii, double *ro, double *io, unsigned flags);
kml_fftf_plan kml_fftf_plan_guru_split_dft(int rank, const kml_fftf_iodim *dims, int howmany_rank, const kml_fftf_iodim *howmany_dims, float *ri, float *ii, float *ro, float *io, unsigned flags);
Fortran interface:
RES = KML_FFT_PLAN_GURU_SPLIT_DFT(RANK, DIMS, HOWMANY_RANK, HOWMANY_DIMS, RI, II, RO, IO, FLAGS);
RES = KML_FFTF_PLAN_GURU_SPLIT_DFT(RANK, DIMS, HOWMANY_RANK, HOWMANY_DIMS, RI, II, RO, IO, FLAGS);
返回值
函数返回一个kml_fft(f)_plan类型的结构体指针。将该对象作为参数传入kml_fft(f)_execute函数中使用,将对当前提供的输入ri,ii和输出ro,io执行FFT变换;另外,也可以通过将该对象作为参数传入kml_fft(f)_execute_split_dft函数中以对新的输入ri,ii和输出ro,io执行FFT变换。
如果函数返回非空指针,则表示plan执行成功,否则表示执行失败。
参数
参数名 |
数据类型 |
描述 |
输入/输出 |
---|---|---|---|
rank |
int |
单个FFT序列的维度。 约束:1≤rank≤3 |
输入 |
dims |
|
dims是大小为rank的结构体数组,dims[i]包含以下成员:
约束:dims[i].n≥1, for i in 0 to rank - 1 |
输入 |
howmany_rank |
int |
|
输入 |
howmany_dims |
|
howmany_dims是大小为howmany_rank的结构体数组,howmany_dims[i]包含以下成员:
|
输入 |
ri |
|
输入待变换数据的实部。 |
输入 |
ii |
|
输入待变换数据的虚部。 |
输入 |
ro |
|
输出待变换数据的实部。 |
输出 |
io |
|
输出待变换数据的虚部。 |
输出 |
flags |
unsigned int |
planning选项,未使用。 |
输入 |
依赖
C: "kfft.h"
Fortran: "kfft.f03"
示例
C interface:
int rank = 2; kml_fft_iodim *dims; dims = (kml_fft_iodim*)kml_fft_malloc(sizeof(kml_fft_iodim) * rank); dims[0].n = 2; dims[0].is = 3; dims[0].os = 3; dims[1].n = 3; dims[1].is = 1; dims[1].os = 1; int howmany_rank = 1; kml_fft_iodim *howmany_dims; howmany_dims = (kml_fft_iodim*)kml_fft_malloc(sizeof(kml_fft_iodim) * howmany_rank); howmany_dims[0].n = 2; howmany_dims[0].is = 2 * 3; howmany_dims[0].os = 2 * 3; double init[12][2] = {{120, 0}, {8, 8}, {0, 0}, {0, 16}, {0, 16}, {-8, 8}, {-8, 0}, {-8, 8}, {-16, 0}, {0, -16}, {-40, 8}, {-8, -8}}; double *ri; ri = (double*)kml_fft_malloc(sizeof(double) * 12); double *ii; ii = (double*)kml_fft_malloc(sizeof(double) * 12); for (int i = 0; i < 12; i++) { ri[i] = init[i][0]; ii[i] = init[i][1]; } double *ro; ro = (double*)kml_fft_malloc(sizeof(double) * 12); double *io; io = (double*)kml_fft_malloc(sizeof(double) * 12); kml_fft_plan plan; plan = kml_fft_plan_guru_split_dft(rank, dims, howmany_rank, howmany_dims, ri, ii, ro, io, KML_FFT_ESTIMATE); kml_fft_execute_split_dft(plan, ri, ii, ro, io); kml_fft_destroy_plan(plan); kml_fft_free(howmany_dims); kml_fft_free(dims); kml_fft_free(ri); kml_fft_free(ii); kml_fft_free(ro); kml_fft_free(io); /* * ro = {1.200000e+02, 1.338564e+02, 1.061436e+02, 1.360000e+02, * 1.120000e+02, 1.120000e+02, -8.000000e+01, 4.878461e+01, * 7.215390e+00, 1.600000e+01, -2.692820e+01, -1.307180e+01} */ /* * io = {4.800000e+01, -1.385641e+01, 1.385641e+01, -3.200000e+01, * -8.000000e+00, -8.000000e+00, -8.000000e+00, 7.846097e-01, * -4.078461e+01, 2.400000e+01, -2.264102e+01, 4.664102e+01} */
Fortran interface:
INTEGER(C_INT) :: RANK = 2 INTEGER(C_INT) :: HOWMANY_RANK = 1 TYPE(KML_FFT_IODIM), POINTER :: DIMS(:), HOWMANY_DIMS(:) REAL(C_DOUBLE), DIMENSION(12, 2) :: INIT TYPE(C_DOUBLE), POINTER :: RI(:), II(:), RO(:), IO(:) TYPE(C_PTR) :: PRI, PII, PRO, PIO, PDIMS, PHOWMANY_DIMS INTEGER(C_SIZE_T) :: SIZE1, SIZE2, SIZE3 SIZE1 = 8 * 12 SIZE2 = 24 * RANK SIZE3 = 24 * HOWMANY_RANK PDIMS = KML_FFT_MALLOC(SIZE2) PHOWMANY_DIMS = KML_FFT_MALLOC(SIZE3) PRI = KML_FFT_MALLOC(SIZE1) PII = KML_FFT_MALLOC(SIZE1) PRO = KML_FFT_MALLOC(SIZE1) PIO = KML_FFT_MALLOC(SIZE1) CALL C_F_POINTER(PRI, RI, SHAPE=[12]) CALL C_F_POINTER(PII, II, SHAPE=[12]) CALL C_F_POINTER(PRO, RO, SHAPE=[12]) CALL C_F_POINTER(PIO, IO, SHAPE=[12]) CALL C_F_POINTER(PDIMS, DIMS, SHAPE=[RANK]) CALL C_F_POINTER(PHOWMANY_DIMS, HOWMANY_DIMS, SHAPE=[HOWMANY_RANK]) DIMS(0)%N = 2 DIMS(0)%IS = 3 DIMS(0)%OS = 3 DIMS(1)%N = 3 DIMS(1)%IS = 1 DIMS(1)%OS = 1 HOWMANY_DIMS(0)%N = 2 HOWMANY_DIMS(0)%IS = 2 * 3 HOWMANY_DIMS(0)%OS = 2 * 3 DATA INIT/120, 8, 0, 0, 0, -8, -8, -8, -16, 0, -40, -8, 0, 8, 0, 16, 16, 8, 0, 8, 0, -16, 8, -8/ INTEGER I DO WHILE(I <= 12) RI(I) = INIT(I, 0) II(I) = INIT(I, 1) END DO TYPE(C_PTR) :: PLAN PLAN = KML_FFT_PLAN_GURU_SPLIT_DFT(RANK, DIMS, HOWMANY_RANK, HOWMANY_DIMS, RI, II, RO, IO, KML_FFT_ESTIMATE) CALL KML_FFT_EXECUTE_SPLIT_DFT(PLAN, RI, II, RO, IO) CALL KML_FFT_DESTROY_PLAN(PLAN) CALL KML_FFT_FREE(PHOWMANY_DIMS) CALL KML_FFT_FREE(PDIMS) CALL KML_FFT_FREE(PRI) CALL KML_FFT_FREE(PII) CALL KML_FFT_FREE(PRO) CALL KML_FFT_FREE(PIO) ! ! RO = /1.200000E+02, 1.338564E+02, 1.061436E+02, 1.360000E+02, ! 1.120000E+02, 1.120000E+02, -8.000000E+01, 4.878461E+01, ! 7.215390E+00, 1.600000E+01, -2.692820E+01, -1.307180E+01/ ! ! ! IO = /4.800000E+01, -1.385641E+01, 1.385641E+01, -3.200000E+01, ! -8.000000E+00, -8.000000E+00, -8.000000E+00, 7.846097E-01, ! -4.078461E+01, 2.400000E+01, -2.264102E+01, 4.664102E+01/ !
kml_fft(f)_plan_guru_split_dft返回的plan可以使用kml_fft(f)_execute计算plan时的输入,也可以使用kml_fft(f)_execute_split_dft计算不同的输入。plan时的输入不需要初始化,但是输入必须是合法的(不能为NULL)。