kml_fft(f)_plan_dft_1d
建立单个连续数据序列1维C2C变换的plan。
接口定义
C interface:
kml_fft_plan kml_fft_plan_dft_1d(int n, kml_fft_complex *in, kml_fft_complex *out, int sign, unsigned flags);
kml_fftf_plan kml_fftf_plan_dft_1d(int n, kml_fftf_complex *in, kml_fftf_complex *out, int sign, unsigned flags);
Fortran interface:
RES = KML_FFT_PLAN_DFT_1D(N, IN, OUT, SIGN, FLAGS);
RES = KML_FFTF_PLAN_DFT_1D(N, IN, OUT, SIGN, FLAGS);
返回值
函数返回一个kml_fft(f)_plan类型的结构体指针。将该对象作为参数传入kml_fft(f)_execute函数中使用,将对当前提供的输入in和输出out执行FFT变换;另外,也可以通过将该对象作为参数传入kml_fft(f)_execute_dft函数中以对新的输入in和输出out执行FFT变换。
如果函数返回非空指针,则表示plan执行成功,否则表示执行失败。
参数
参数名 |
数据类型 |
描述 |
输入/输出 |
---|---|---|---|
n |
int |
输入FFT序列的大小,约束:n≥1。 |
输入 |
in |
|
输入待变换的数据。 |
输入 |
out |
|
输出快速傅里叶变换后的数据。 |
输出 |
sign |
int |
描述正向变换或反向变换。
|
输入 |
flags |
unsigned int |
planning选项,未使用。 |
输入 |
依赖
C: "kfft.h"
示例
C interface:
int N = 16; kml_fft_complex *in; kml_fft_complex *out; kml_fft_plan plan; in = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * N); out = (kml_fft_complex*)kml_fft_malloc(sizeof(kml_fft_complex) * N); for (int i = 0; i < N; i++){ in[i][0] = (double)i; in[i][1] = (double)i; } plan = kml_fft_plan_dft_1d(N, in , out, KML_FFT_FORWARD, KML_FFT_ESTIMATE); kml_fft_execute_dft(plan, in, out); kml_fft_destroy_plan(plan); kml_fft_free(in); kml_fft_free(out); /* * out = {{1.200000e+02, 1.200000e+02}, {-4.821872e+01, 3.221872e+01}, * {-2.731371e+01, 1.131371e+01}, {-1.997285e+01, 3.972846e+00}, * {-1.600000e+01, 0.000000e+00}, {-1.334543e+01, -2.654571e+00}, * {-1.131371e+01, -4.686292e+00}, {-9.591299e+00, -6.408701e+00}, * {-8.000000e+00, -8.000000e+00}, {-6.408701e+00, -9.591299e+00}, * {-4.686292e+00, -1.131371e+01}, {-2.654571e+00, -1.334543e+01}, * {0.000000e+00, -1.600000e+01}, {3.972846e+00, -1.997285e+01}, * {1.131371e+01, -2.731371e+01}, {3.221872e+01, -4.821872e+01}} */
Fortran interface:
INTEGER(C_INT) :: N = 16 TYPE(KML_FFT_COMPLEX), POINTER :: IN, OUT TYPE(C_PTR) :: PIN, POUT TYPE(C_PTR) :: PLAN INTEGER(C_SIZE_T) :: SIZE SIZE = 16 * N PIN = KML_FFT_MALLOC(SIZE) POUT = KML_FFT_MALLOC(SIZE) CALL C_F_POINTER(PIN, IN, SHAPE=[N]) CALL C_F_POINTER(POUT, OUT, SHAPE=[N]) INTEGER :: I DO WHILE(I <= N) IN%R = I IN%I = I END DO PLAN = KML_FFT_PLAN_DFT_1D(N, IN , OUT, KML_FFT_FORWARD, KML_FFT_ESTIMATE) CALL KML_FFT_EXECUTE_DFT(PLAN, IN, OUT) CALL KML_FFT_DESTROY_PLAN(PLAN) CALL KML_FFT_FREE(PIN) CALL KML_FFT_FREE(POUT) ! ! OUT = \1.200000E+02, 1.200000E+0, -4.821872E+01, 3.221872E+01, ! -2.731371E+01, 1.131371E+01, -1.997285E+01, 3.972846E+00, ! -1.600000E+01, 0.000000E+00, -1.334543E+01, -2.654571E+00, ! -1.131371E+01, -4.686292E+00, -9.591299E+00, -6.408701E+00, ! -8.000000E+00, -8.000000E+00, -6.408701E+00, -9.591299E+00, ! -4.686292E+00, -1.131371E+01, -2.654571E+00, -1.334543E+01, ! 0.000000E+00, -1.600000E+01, 3.972846E+00, -1.997285E+01, ! 1.131371E+01, -2.731371E+01, 3.221872E+01, -4.821872E+01/ !
父主题: C2C变换