Skip to content

Commit

Permalink
float32 support
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalsong committed Sep 3, 2022
1 parent 5991304 commit 3c46695
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ endif()

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

if (DSPLIB_ASAN_ENABLED)
include(cmake/sanitizer.cmake)
enable_address_sanitizer(TARGET dsplib)
endif()

if (DSPLIB_POOL_ALLOCATOR)
message(STATUS "dsplib: use pool allocator")
message("dsplib: use pool allocator")
target_compile_definitions(dsplib PUBLIC "DSPLIB_POOL_ALLOCATOR")
endif()

if (DSPLIB_USE_FLOAT32)
message("dsplib: base type dsplib::real_t = float32")
target_compile_definitions(dsplib PUBLIC "DSPLIB_USE_FLOAT32")
else()
message("dsplib: base type dsplib::real_t = float64")
endif()
5 changes: 4 additions & 1 deletion include/dsplib/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ namespace dsplib {

//-------------------------------------------------------------------------------------------------
//base scalar type
#ifdef DSPLIB_USE_FLOAT32
using real_t = float;
#else
using real_t = double;
// using real_t = float;
#endif

constexpr real_t pi = 3.141592653589793238463;

Expand Down

0 comments on commit 3c46695

Please sign in to comment.