FFTW (the Faster Fourier Transform in the West) is a standard C language assembly that quickly computes discrete Fourier, developed by MIT's M. Frigo and S. Johnson. One- or multi-dimensional real and complex data can be calculated as well as DFT of any size.
FFTW also includes parallel transformations for shared and distributed storage systems that automatically adapt to your machine, cache, storage size, and number of registers.
You can install the FFTW library on the mobile side of Raspberry Pi and Android to facilitate data domain transformation and processing.
The following is the specific installation and configuration process
1, first download fftw-3.3.8.tar.gz (http://www.fftw.org/download.htmlThis installation package connects the Raspberry Pi and goes to the board. Copy this file to the Raspberry Pi via samba.
2, use the tar zxvf fftw-3.3.8.tar.gz command to extract the file, and then create the fftw directory in the /usr/local directory (sudo mkdir /usr/local/fftw) is the installation directory of this library
3, into the decompressed fftw library directory, you need to install twice.
3-1) The first installation and configuration is as follows
./configure --enable-type-prefix --prefix=/usr/local/fftw --with-gcc --disable-fortran --enable-i386-hacks --enable-shared=yes
make
make install
Make clean (this is to prepare for the second installation)
3-2) The second installation and configuration are as follows
./configure --enable-float --enable-type-prefix --prefix=/usr/local/fftw --with-gcc --disable-fortran --enable-i386-hacks --enable-shared=yes
make
make install
There are four folders into /usr/local/fftw
Write the test program test_fftw.cpp for verification, the following is the test code
#include <complex>
#include <fftw3.h>
#include <math.h>
#include <iostream>
#include <fftw3.h>
#include <math.h>
#include <iostream>
#define N 10
using namespace std;
int main(int argc, char* argv[]){
fftw_complex in[N], out[N];
fftw_plan p;
p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_MEASURE);
for(int i = 0; i < N; i++){
in[i][0] = i;
in[i][1] = 0.0;
}
fftw_execute(p);
for(int i = 0; i < N; i++){
cout<< out[i][0] << " " << out[i][1] << endl;
}
complex<double> temp = 0.0;
for(int k = 0; k < N; k++){
double pi = 4 * atan(1.0);
temp += exp(complex<double>(0.0, -2.0 * pi * 3 * k / N)) * complex<double>(in[k][0], in[k][1]);
}
cout << "out[3] is " << temp << endl;
fftw_complex out1[N];
fftw_plan p1;
p1 = fftw_plan_dft_1d(N, out1, in, FFTW_BACKWARD, FFTW_MEASURE);
for(int i = 0; i < N; i++){
out1[i][0] = out[i][0];
out1[i][1] = out[i][1];
}
fftw_execute(p1);
for(int i = 0; i < N; i++){
cout << in[i][0] << " " << in[i][1] << endl;
}
fftw_destroy_plan(p);
fftw_destroy_plan(p1);
return 0;
}
cout << in[i][0] << " " << in[i][1] << endl;
}
fftw_destroy_plan(p);
fftw_destroy_plan(p1);
return 0;
}
Compiler g++ test_fftw.cpp -o test -lfftw3 -I /usr/local/fftw/include -L /usr/local/fftw/lib
./test running the program, the following is the result
From the results, it is known that the library has been successfully installed. The above is the whole process of installing the fftw library for the entire Raspberry Pi.
댓글 없음:
댓글 쓰기