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 <stdio.h>
#include <stdlib.h>
#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;
}