From 3c466952489bd88d9310ac8e47a0ad12dea6014e Mon Sep 17 00:00:00 2001 From: Vitaly Yulis Date: Mon, 15 Aug 2022 16:50:28 +0300 Subject: [PATCH] float32 support --- CMakeLists.txt | 10 +++++++++- include/dsplib/types.h | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc8460a..50e3ba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ 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) @@ -16,6 +17,13 @@ if (DSPLIB_ASAN_ENABLED) 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() \ No newline at end of file diff --git a/include/dsplib/types.h b/include/dsplib/types.h index 9051080..bb5bb09 100644 --- a/include/dsplib/types.h +++ b/include/dsplib/types.h @@ -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;