Skip to content

Commit 4da2f2d

Browse files
committed
float32 support
1 parent 85c7a15 commit 4da2f2d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ option(DSPLIB_ASAN_ENABLED "Address sanitizer enabled" OFF)
88
option(DSPLIB_USE_FLOAT32 "Use float32 for base type dsplib::real_t" OFF)
99
option(DSPLIB_BUILD_TESTS "Build dsplib tests" OFF)
1010
option(DSPLIB_BUILD_EXAMPLES "Build dsplib examples" OFF)
11+
option(DSPLIB_POOL_ALLOCATOR "Use pool allocator for vectors" OFF)
1112

1213
file(GLOB_RECURSE DSPLIB_SOURCES
1314
"lib/*.cpp"
@@ -53,6 +54,11 @@ if (DSPLIB_IS_ROOT AND DSPLIB_BUILD_EXAMPLES)
5354
add_subdirectory(examples)
5455
endif()
5556

57+
if (DSPLIB_POOL_ALLOCATOR)
58+
message(STATUS "dsplib: use pool allocator")
59+
target_compile_definitions(dsplib PUBLIC "DSPLIB_POOL_ALLOCATOR")
60+
endif()
61+
5662
# version header
5763
set(DSPLIB_VERSION_DIR "${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}")
5864
configure_file(cmake/version.h.in ${DSPLIB_VERSION_DIR}/version.h @ONLY)

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,18 @@ arr_cmplx y6 = x1 * 2i;
5050
### Slicing
5151
The behavior of slices is as close as possible to numpy. Except for cases with invalid indexes, in which case numpy does not throw an exception.
5252
```cpp
53-
using namespace dsplib;
53+
arr_real x = {0, 1, 2, 3, 4, 5, 6};
54+
x.slice(0, 2) ///{0, 1}
55+
x.slice(2, -1) ///{2, 3, 4, 5}
56+
x.slice(-1, 0, -1) ///{6, 5, 4, 3, 2, 1}
57+
x.slice(-1, 0) ///OUT_OF_RANGE, but numpy returns []
58+
x.slice(0, -1, -1) ///OUT_OF_RANGE, but numpy returns []
59+
x.slice(-8, 7) ///OUT_OF_RANGE, but numpy returns [0 1 2 3 4 5 6]
60+
```
61+
62+
### Fast Fourier Transform:
63+
The FFT/IFFT calculation table is cached on first run. To eliminate this behavior, you can use the fft_plan object.
64+
```cpp
5465
arr_real x = randn(512);
5566
arr_cmplx y = fft(x);
5667
```
@@ -91,7 +102,7 @@ arr_real x2 = awgn(x1, 10);
91102
arr_real y = xcorr(x1, x2);
92103
```
93104

94-
Simple Spectrum Analyze (16-bit scale):
105+
### Simple Spectrum Analyze (16-bit scale):
95106
```cpp
96107
int nfft = 1024;
97108
arr_real x = randn(nfft) * 1000;

0 commit comments

Comments
 (0)