建立单个连续数据序列2维C2R变换的plan。
C interface:
kml_ffth_plan kml_ffth_plan_dft_c2r_scale_2d(int n0, int n1, kml_ffth_complex *in, float *out, unsigned flags);
函数返回一个kml_ffth_plan类型的结构体指针。将该对象作为参数传入kml_fft(f/h)_execute函数中使用,将对当前提供的输入in和输出out执行FFT变换;另外,也可以通过将该对象作为参数传入kml_ffth_execute_dft_scale_c2r函数中以对新的输入in和输出out执行FFT变换。
如果函数返回非空指针,则表示plan执行成功,否则表示执行失败。
参数名 |
数据类型 |
描述 |
输入/输出 |
---|---|---|---|
n0 |
int |
输入FFT序列第一维的大小,约束:n0 ≥ 1。 |
输入 |
n1 |
int |
输入FFT序列第二维的大小,约束:n1 ≥ 1。 |
输入 |
in |
kml_ffth_complex* |
输入待变换的数据。 |
输入 |
out |
float* |
输出快速傅里叶变换后的数据。 |
输出 |
flags |
unsigned int |
planning选项,描述ESTIMATE模式或PATIENT模式。 KML_FFT_ESTIMATE:ESTIMATE模式 KML_FFT_PATIENT:PATIENT模式 |
输入 |
C: "kfft.h"
C interface:
int n0 = 4; int n1 = 4; __fp16 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}}; kml_ffth_complex *in; in = (kml_ffth_complex*)kml_ffth_malloc(sizeof(kml_ffth_complex) * n0 * (n1 / 2 + 1)); for (int i = 0; i < n0 * (n1 / 2 + 1); i++){ in[i][0] = init[i][0]; in[i][1] = init[i][1]; } float *out; out = (float*)kml_ffth_malloc(sizeof(float) * n0 * n1); kml_ffth_plan plan; plan = kml_ffth_plan_dft_scale_c2r_2d(n0, n1, in , out , KML_FFT_ESTIMATE); kml_ffth_execute_dft_scale_c2r(plan, in, out); kml_ffth_destroy_plan(plan); kml_ffth_free(in); kml_ffth_free(out); /* * out = {0.000000e+00, 6.400000e+01, 1.600000e+02, 2.240000e+02, * 1.120000e+02, 1.600000e+01, 8.000000e+01, 1.760000e+02, * 1.920000e+02, 1.280000e+02, 3.200000e+01, 9.600000e+01, * 2.400000e+02, 2.080000e+02, 1.440000e+02, 4.800000e+01} */