android平台的几个计算FFT(Fastest Fourier Transform)的库

本文介绍了两个用于Android平台进行快速傅立叶变换(FFT)的库:fftw和ne10。fftw是一个广泛使用的库,提供了高效的FFT算法;而ne10则是由ARM公司提供的库,特别针对ARM架构进行了NEON优化。这两个库都提供了正向和反向FFT的实现,可用于信号处理和数据分析等场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

android平台的几个计算FFT(Fastest Fourier Transform)的库

1. fftw

官网:http://fftw.org

文档:http://fftw.org/fftw3_doc/

源码下载:https://github.com/FFTW/fftw3

下面这个例子是做傅立叶变换与反变换,省略了填充数据部分。实际需要给in[]赋值。

    fftwf_real *in;
    fftwf_complex *out;
    fftwf_plan p_r2c, p_c2r;

    in = (fftwf_real*) fftwf_malloc(sizeof(fftwf_real) * N);
    out = (fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex) * N);

    p_r2c = fftwf_plan_dft_r2c_1d(N, in, out, FFTW_ESTIMATE);
    p_c2r = fftwf_plan_dft_c2r_1d(N, out, in, FFTW_ESTIMATE);

    //正向
    fftwf_execute(p_r2c);
    //反向
    fftwf_execute(p_c2r);
        
    fftwf_destroy_plan(p_r2c);
    fftwf_destroy_plan(p_c2r);

    fftwf_free(in);
    fftwf_free(out);

 

2. ne10

这个是arm公司提供的,使用neon优化加速。支持armeabi-v7a,arm64两个架构。

官网:http://projectne10.org/

文档:http://projectne10.github.io/Ne10/doc/

 

源码下载:https://github.com/projectNe10/Ne10/tree/v1.2.1

下面这个例子和fftw那个差不多。

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"
    ne10_fft_r2c_cfg_float32_t icfg;

    // 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);
    icfg = ne10_fft_alloc_r2c_float32(SAMPLES);

    // Generate test input values

    // Perform the FFT
    ne10_fft_r2c_1d_float32(dst, src, cfg);
    // Perform the IFFT
    ne10_fft_c2r_1d_float32(src, dst, icfg);
    

    // Free the allocated configuration structure
    ne10_fft_destroy_r2c_float32(cfg);
    ne10_fft_destroy_r2c_float32(icfg);

 

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值