The first curriculum design of Digital Signal Processing, FFT
| Compiler | Platform | Target | C++11 | C++14 | C++17 |
|---|---|---|---|---|---|
| GCC 7 ~ GCC 11 | Linux x86-64 | -m64 |
Perfectly supported | Perfectly supported | Perfectly supported |
| Clang 12 | Linux x86-64 | -m64 |
Perfectly supported | Perfectly supported | Perfectly supported |
| MSVC 19.2 | Windows (64-bit) | x64 | Not supported | Supported | Supported |
| MSVC 19.2 | Windows (64-bit) | x86 | Not supported | Compiler warnings | Supported |
-
Build library
make build [options]
The
optionscan be:COMPILER: Specify the compiler you want to build with. The value can beg++orclang++.g++by default.CPP_STANDARD: Specify the C++ language standard. The value can be-std=c++11,-std=c++14,-std=c++17,-std=gnu++11,-std=gnu++14,-std=gnu++17, etc. The default value is-std=c++11.OPTIMIZATION: Specify the level of optimization. The value can be-O0,-O1,-Os, etc.-O2by default.WARNING_LEVEL: Specify the warning level. The default value is-Wall -Wpedantic -WextraPREDEFINED_MACRO: Specify predefined macros, such as-DUNICODE. Empty by default.
Example:
make build CPP_STANDARD=-std=c++17 COMPILER=clang++
Then the library will be in the
builddirectory. The binary library will bebuild/bin/libdspfft.aand its header file will be in thebuild/includedirectory. -
Build test program
make test [options]The
optionsis the same as that in 'Building library'. And whenPREDEFINED_MACROcontains-DTRANSFORM_TO_CRLF_NEWLINE, the program will generate MATLAB code with CRLF newline character (which is essential for MATLAB for Windows to run). Otherwise, the newline character will be LF.The executable file will be
build/test/main.out. -
Build all
make build_and_test [options]
This command is equivalent to:
make build [options] && make test [options]
-
Clean
make clean
This will clean up all files built.
Enter the directory src, open DSPFFT.sln with Visual Studio 2019 or later versions, choose a target platfrom (Release | x64 recommended) and then build the solution. Then run publish.cmd to publish libraries and test programs. The binary library will be publish\bin\dspfft.lib, whose header files will be in publish\include, and the executable file will be publish\test\homework.exe. Notice that publish.cmd is used for Release | x64 platfrom by default. To change platform, please edit it and change the value of the variable BINARY_DIR.
To clean up, you can run clean_publish.cmd.
The executable file is build/test/main.out on Linux and homework.exe on Windows. When running this program, you can pass parameters as follows:
--enable-time-comparing: Compare time consumed using FFT and that using DFT directly.--writing-matlab-code-to-file: Generate MATLAB Code and write it intoresult.m, which can be run by MATLAB.
You should include the header file dspfft.hpp in C++ and include dspfft.h in C. And link the library libdspfft.a on Linux and dspfft.lib on Windows.
The APIs are as follows:
Declared in <dspfft.hpp>. All APIs are in the namespace dspfft.
template <typename floating_type> ::std::vector<::std::complex<floating_type>> base_2_fft(const ::std::vector<::std::complex<floating_type>>& x)template <typename floating_type> ::std::vector<::std::complex<floating_type>> dft(const ::std::vector<::std::complex<floating_type>>& x)
Declared in <dspfft.h>. When included by C++ files, all APIs are in the namespace dspfft and all functions are declared with C language linkage (extern "C").
complexf,complexl,complexll: Structures of complex number forfloat,doubleandlong double.complexf *base_2_fftf(complexf *, size_t),complexl *base_2_fftl(complexl *, size_t),complexll *base_2_fftll(complexll *, size_t)complexf *dftf(complexf *, size_t),complexl *dftl(complexl *, size_t),complexll *dftll(complexll *, size_t)
- When using C language to call the library dspfft, you should link C++ runtime manually for this library is written in C++.
- If you want to run the test program on Linux and run the MATLAB Code generated with MATLAB for Windows, be sure to define
TRANSFORM_TO_CRLF_NEWLINEmacro when building to generate code with CRLF newline character.
语言: