linux有没有fft库函数,zynq linux ne10 函数库使用

这篇博客展示了如何利用NE10库进行浮点数快速傅里叶变换(FFT),并对比了NE10的R2C FFT结果与MATLAB的全采样点FFT输出。通过一个示例程序,博主详细解释了配置、初始化、执行FFT以及显示结果的过程,探讨了两者在采样点数上的差异。

1 函数类型

变换类型

数据类型

FFT长度

c2c FFT/IFFT

float/int32/int16

2^N (N is 2, 3….)

r2c FFT

float/int32/int16

2^N (N is 3, 4….)

c2r IFFT

float/int32/int16

2^N (N is 3, 4….)

2 定义的fft 相关的指针函数,如果运行程序的处理器有simd 结构,则运行 neon 实现的fft ,如果没有则运行c 实现的fft。

3 ne10 实现的fft 结果只有采样点数的一半儿,matlab 输出的fft 结果是所有的采样点数,具体看如下例子

#include #include #include "NE10.h"

#define SAMPLES 16

int real_fft_sample_main(void)

{

ne10_float32_t src[SAMPLES] = {}; // A source array of input data

ne10_fft_cpx_float32_t dst[(SAMPLES / 2) + 1] = {}; // A destination array for the transformed data

ne10_fft_r2c_cfg_float32_t cfg; // An FFT "configuration structure"

// Initialise Ne10, using hardware auto-detection to set library function pointers

if (ne10_init() != NE10_OK)

{

fprintf(stderr, "Failed to initialise Ne10.\n");

return 1;

}

// Prepare the real-to-complex single precision floating point FFT configuration

// structure for inputs of length `SAMPLES`. (You need only generate this once for a

// particular input size.)

cfg = ne10_fft_alloc_r2c_float32(SAMPLES);

// Generate test input values

for (int i = 0; i < SAMPLES; i++)

{

src[i] = (ne10_float32_t)rand() / RAND_MAX * 50.0f;

}

// Perform the FFT

ne10_fft_r2c_1d_float32(dst, src, cfg);

// Display the results

for (int i = 0; i < SAMPLES; i++)

{

printf( "IN[%2d]: %10.4f\t", i, src[i]);

if (i <= SAMPLES / 2)

printf("OUT[%2d]: %10.4f + %10.4fi", i, dst[i].r, dst[i].i);

printf("\n");

}

// Free the allocated configuration structure

ne10_fft_destroy_r2c_float32(cfg);

return 0;

}

997d5e03a3a7ec936930d724155dfd36.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值