Skip to content

Commit 3c46695

Browse files
committed
float32 support
1 parent 5991304 commit 3c46695

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ endif()
99

1010
option(DSPLIB_POOL_ALLOCATOR "Use pool allocator for vectors" OFF)
1111
option(DSPLIB_ASAN_ENABLED "Address sanitizer enabled" OFF)
12+
option(DSPLIB_USE_FLOAT32 "Use float32 for base type dsplib::real_t" OFF)
1213

1314
if (DSPLIB_ASAN_ENABLED)
1415
include(cmake/sanitizer.cmake)
1516
enable_address_sanitizer(TARGET dsplib)
1617
endif()
1718

1819
if (DSPLIB_POOL_ALLOCATOR)
19-
message(STATUS "dsplib: use pool allocator")
20+
message("dsplib: use pool allocator")
2021
target_compile_definitions(dsplib PUBLIC "DSPLIB_POOL_ALLOCATOR")
22+
endif()
23+
24+
if (DSPLIB_USE_FLOAT32)
25+
message("dsplib: base type dsplib::real_t = float32")
26+
target_compile_definitions(dsplib PUBLIC "DSPLIB_USE_FLOAT32")
27+
else()
28+
message("dsplib: base type dsplib::real_t = float64")
2129
endif()

include/dsplib/types.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ namespace dsplib {
4141

4242
//-------------------------------------------------------------------------------------------------
4343
//base scalar type
44+
#ifdef DSPLIB_USE_FLOAT32
45+
using real_t = float;
46+
#else
4447
using real_t = double;
45-
// using real_t = float;
48+
#endif
4649

4750
constexpr real_t pi = 3.141592653589793238463;
4851

0 commit comments

Comments
 (0)