fftw

FFTW : how to prevent breaking aliasing rules?

若如初见. 提交于 2019-12-10 20:43:46
问题 I have a code which uses the std::complex<double> type. From FFTW Manual : if you have a variable complex<double> *x , you can pass it directly to FFTW via reinterpret_cast<fftw_complex*>(x) . However, when I do this in my code : tmp_spectrum = reinterpret_cast<std::complex<double>*>(fftw_alloc_complex(conf.spectrumSize())); plan_bw_temp = fftw_plan_dft_c2r_1d(conf.FFTSize(), reinterpret_cast<fftw_complex*>(tmp_spectrum), tmp_out, FFTW_ESTIMATE); I get dereferencing type-punned pointer might

Checking fftw3 with valgrind

允我心安 提交于 2019-12-10 19:17:23
问题 In one step of my program I need to convolve an image. To do that I am using the functions provided by fftw3 . When I run valgrind on my program I get this stack trace. My function is called convolve and it runs fftw3 's fftw_plan_dft_r2c_2d two times (once on the image, once on the convolution kernel. In order to make it more readable, I removed all addresses and process IDs. HEAP SUMMARY: in use at exit: 62,280 bytes in 683 blocks total heap usage: 178,271 allocs, 177,588 frees, 36,617,058

fftw shift zero-frequency to image center

半城伤御伤魂 提交于 2019-12-10 11:53:03
问题 I am struggling on the result of FFTW applied on image. I can do the Fourier transform and inverse Fourier transform on image, I am sure the two functions are working. Now I am trying to analyze the result of Fourier transform and try to apply a filter on it, etc. Currently I am confusing on the FT result. As I know the the zero-frequency should be on the top-left corner. I should shift it to the image center if I want to check frequency friendly. There are at least two way I have tested. one

How can I port code that uses numpy.fft.rfft from python to C++?

孤街醉人 提交于 2019-12-10 11:28:08
问题 I have code written in python. It computes positive part of FFT of real input using numpy. I need to port this code to C++. import numpy as np interp=[131.107, 133.089, 132.199, 129.905, 132.977] res=np.fft.rfft(interp) print res Result of rfft is [ 659.27700000+0.j, 1.27932533-1.4548977j, -3.15032533+2.1158917j] I tried to use OpenCV for 1D DFT: std::vector<double> fft; std::vector<double> interpolated = {131.107, 133.089, 132.199, 129.905, 132.977}; cv::dft( interpolated, fft ); for( auto

编译且移植FFTW3到Android手机上(1)

孤街浪徒 提交于 2019-12-10 10:37:04
本文主要对如何将FFTW3编译且移植到Android App上进行介绍,同时对各FFTW提供的一些快速傅里叶变换的方法在手机进行性能测试,总结出使用FFTW3进行小规模傅里叶变换的最佳方式。 文章重点内容有:FFTW configure;编译so库;ARM NEON优化;float加速;多线程 第1部分为快速入门版,如想查看更详细的使用说明,请查看 第2部分 : http://he-kai.com/?p=38 内容 准备工作: FFTW 3:Version 3.3.3 http://fftw.org/fftw-3.3.3.tar.gz Android App:我编写的示例程序 https://github.com/hekai/fftw_android 使用git或直接去github上下载此项目 Linux:我使用的是Ubuntu 12.04 64-bit NDK:android-ndk-r9c 64-bit 32-bit 点击合适版本下载 Eclipse:我使用的版本是3.7,版本不同关系不大,关键是安装好 ADT 插件,并在Eclipse中配置好SDK目录和NDK目录 快速入门: 1. 下载好 fftw-3.3.3.tar.gz 和 fftw_android 项目后,将目录结构按如下方式放置 —->parent folder —->fftw-3.3.3 —->fftw

Application is hanged after call nested function with Android NDK

穿精又带淫゛_ 提交于 2019-12-09 20:48:39
问题 I build Android project where I use Android NDK with LibXTract to extract audio features. LibXTract use fftw3 library. Project is consisted of button which runs simple example form libxtract: JNIEXPORT void JNICALL Java_com_androidnative1_NativeClass_showText(JNIEnv *env, jclass clazz) { float mean = 0, vector[] = {.1, .2, .3, .4, -.5, -.4, -.3, -.2, -.1}, spectrum[10]; int n, N = 9; float argf[4]; argf[0] = 8000.f; argf[1] = XTRACT_MAGNITUDE_SPECTRUM; argf[2] = 0.f; argf[3] = 0.f; xtract

Calculating convolution of two functions using FFT (FFTW)

非 Y 不嫁゛ 提交于 2019-12-09 07:16:09
问题 I'm trying to speed up a computation for a neural simulator using the FFT. The equation is: (1) \sum(j=1 to N) (w(i - j) * s_NMDA[j]) where s_NMDA is a vector of length N and w is defined by: (2) w(j) = tanh[1/(2 * sigma * p)] * exp(-abs(j) / (sigma * p)] where sigma and p are constants. (is there a better way to render equations on stackoverflow?) The calculation has to be done for N neurons. Since (1) only depends on the absolute distance abs(i - j), it should be possible to compute this

Computing the discrete fourier transform of audio data with FFTW

末鹿安然 提交于 2019-12-09 05:10:26
I am quite new to signal processing so forgive me if I rant on a bit. I have download and installed FFTW for windows. The documentation is ok but I still have queries. My overall aim is to capture raw audio data sampled at 44100 samps/sec from the sound card on the computer (this task is already implemented using libraries and my code), and then perform the DFT on blocks of this audio data. I am only interested in finding a range of frequency components in the audio and I will not be performing any inverse DFT. In this case, is a real to real transformation all that is necessary, hence the

How to add FFTW to an Android project using CMAKE

送分小仙女□ 提交于 2019-12-09 04:00:37
问题 I'm trying to add FFTW to my Android project using CMAKE, but I haven't been able to do so. If anyone has successfully added FFTW to their Android project, I would greatly appreciate any help, especially if it is done through cmake and not ndk-build. Here is the code that I currently have in my CMakeLists.txt file for adding FFTW to the project: set(buildDir ${CMAKE_CURRENT_BINARY_DIR}/build) add_subdirectory(C:/Users/reyna/Documents/HMC/Clinic/Test/fftw-3.3.8 ${buildDir}) set( FFTW3_DIR $

Accelerating FFTW pruning to avoid massive zero padding

匆匆过客 提交于 2019-12-08 22:08:18
问题 Suppose that I have a sequence x(n) which is K * N long and that only the first N elements are different from zero. I'm assuming that N << K , say, for example, N = 10 and K = 100000 . I want to calculate the FFT, by FFTW, of such a sequence. This is equivalent to having a sequence of length N and having a zero padding to K * N . Since N and K may be "large", I have a significant zero padding. I'm exploring if I can save some computation time avoid explicit zero padding. The case K = 2 Let us