---
title: CZT
description: "适合于计算当取样频率间隔（sampling frequency interval）与取样时间间隔（sampling time interval）乘积的倒数不等于信号的时频分布面积时的算法。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_hmpp_06_0143.html
sourcePath: /source/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_hmpp_06_0143.html
indexId: 2fa4fefe7395068ebd4a6475666b4caba3633cc3bcfe1d79a63920ea56ffbe9677
---
# CZT

适合于计算当取样频率间隔（sampling frequency interval）与取样时间间隔（sampling time interval）乘积的倒数不等于信号的时频分布面积时的算法。

计算公式为：，

上式等同于FFT。

函数接口声明如下：

主函数操作：

HmppResult HMPPS_CZT_32f(const float *src, int32_t srcLen, Hmpp32fc *dst, int32_t dstLen, Hmpp32fc w, Hmpp32fc a);

HmppResult HMPPS_CZT_64f(const double *src, int32_t srcLen, Hmpp64fc *dst, int32_t dstLen, Hmpp64fc w, Hmpp64fc a);

HmppResult HMPPS_CZT_32fc(const Hmpp32fc *src, int32_t srcLen, Hmpp32fc *dst, int32_t dstLen, Hmpp32fc w, Hmpp32fc a);

HmppResult HMPPS_CZT_64fc(const Hmpp64fc *src, int32_t srcLen, Hmpp64fc *dst, int32_t dstLen, Hmpp64fc w, Hmpp64fc a);

#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| src | 指向源向量指针。 | 非空 | 输入 |
| srcLen | 源向量元素个数。 | (0, INT\_MAX] | 输入 |
| dst | 指向目标向量指针。 | 非空 | 输入 |
| dstLen | 目标向量元素个数。 | (0, INT\_MAX] | 输出 |
| w | z平面螺旋轮各点之间的比值。 | 通常模长为1 | 输入 |
| a | z平面螺旋轮的起点。 | 通常模长为1 | 输入 |


#### 返回值

- 成功：返回HMPP_STS_NO_ERR。
- 失败：返回错误码。


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| HMPP\_STS\_NO\_ERR | 表示没有错误。 |
| HMPP\_STS\_NULL\_PTR\_ERR | 当指定指针为空时指示错误。 |
| HMPP\_STS\_SIZE\_ERR | 当srcLen或dstLen小于或等于0时指示错误。 |
| HMPP\_STS\_OVERFLOW\_ERR | 数据规模(srcLen, dstLen)过大。 |
| HMPP\_STS\_MALLOC\_FAILED | 运算过程中所需的内存分配失败。 |


#### 示例

```
void Convolve_Example()
{
const int srcLen = 10;
const int dstLen = 20;
float src[srcLen] = {9.244539, 0.686178, 4.528434, 7.181965, 6.123716, 5.890331, 2.779223, 1.576141, 3.751002, 8.829503};
Hmpp32fc dst[dstLen];
Hmpp32fc a = {0.306101, 0.951999};
Hmpp32fc w = {-0.562033, -0.827115};
HMPPS_CZT_32f(src, srcLen, dst, dstLen, w, a);
for (int i = 0; i < dstLen; ++i) {
printf("%.5f + %.5fi ", dst[i].re, dst[i].im);
}
}
```

运行结果：

```
7.35142 + 13.7323i, 14.6336 + 4.04731i, 6.05243 + 4.48011i, 17.1773 + -1.37873i, 10.6023 + -5.12952i, -3.68937 + 11.8929i, 2.38356 + -4.45827i, 5.83655 + 2.65852i, 17.3432 + 32.6026i, 5.83083 + 9.56965i, 16.495 + 1.73368i, 49.9786 + 6.41107i, 17.4045 + 2.00529i, 10.1817 + -10.0219i, 28.4027 + -31.2852i, 8.1634 + -4.72801i, 0.304818 + 0.486745i, -2.72213 + -18.6895i, 7.71386 + 4.53396i, 14.2174 + 5.30225i,
```
