---
title: kml_ffth_plan_dft_scale_r2c
description: "建立单个连续数据序列n维R2C变换的plan。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0315.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0315.html
indexId: 264eb27e7e48f75b7e8368713b05293c2a326127ce7bccefa8de88a66cb5d4a961
---
# kml_ffth_plan_dft_scale_r2c

建立单个连续数据序列n维R2C变换的plan。

#### 接口定义

C interface：

kml_ffth_plan kml_ffth_plan_dft_scale_r2c(int rank, const int *n, __fp16 *in, kml_ffth_float_complex *out, unsigned flags);


#### 返回值

函数返回一个kml_ffth_plan类型的结构体指针。将该对象作为参数传入kml_fft(f/h)_execute函数中，将对当前提供的输入in和输出out执行FFT变换。也可以通过将该对象作为参数传入kml_ffth_execute_dft_scale_r2c函数中以对新的输入in和输出out执行FFT变换。

如果函数返回非空指针，则表示plan创建成功，否则表示创建失败。


#### 参数

| 参数名 | 数据类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| rank | int | FFT变换的维度是rank，约束：1 <= rank <= 4。 | 输入 |
| n | const int\* | n为维度为rank的数组，包含FFT序列每一维度的大小，约束：n[i] >= 1, for i in 0 to rank \- 1。 | 输入 |
| in | \_\_fp16\* | 输入需要变换的数据。 | 输入 |
| out | kml\_ffth\_float\_complex\* | 输出快速傅里叶变换后的数据。 | 输出 |
| flags | unsigned int | planning选项，描述ESTIMATE模式或PATIENT模式。 KML\_FFT\_ESTIMATE：ESTIMATE模式 KML\_FFT\_PATIENT：PATIENT模式 | 输入 |


#### 依赖

C: "kfft.h"


#### 示例

C interface：

```
int rank = 2;
int *n;
n = (int*)kml_ffth_malloc(sizeof(int) * rank);
n[0] = 2;
n[1] = 4;
double init[8] = {1, 2, 3, 4, 5, 6, 7, 8};
double *in;
in = (__fp16*)kml_ffth_malloc(sizeof(__fp16) * n[0] * n[1]);
for (int i = 0; i < n[0] * n[1]; i++) {
in[i] = init[i];
}
kml_ffth_float_complex *out;
out = (kml_ffth_float_complex*)kml_ffth_malloc(sizeof(kml_ffth_float_complex) * n[0] * (n[1] / 2 + 1));
kml_ffth_plan plan;
plan = kml_ffth_plan_dft_scale_r2c(rank, n, in, out, KML_FFT_ESTIMATE);
kml_ffth_execute_dft_scale_r2c(plan, in, out);
kml_ffth_destroy_plan(plan);
kml_ffth_free(n);
kml_ffth_free(in);
kml_ffth_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}}
*/
```
