kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit e436cfdfb2df85f68f25a4127d1fd90af2d68368
parent 0c32e4a98977ef8e7d25c963e338745b7f9826ed
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Tue,  8 Nov 2016 06:35:10 +0300

python_plot.hpp: flush_to_zero function

Diffstat:
Minclude/kfr/io/python_plot.hpp | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/kfr/io/python_plot.hpp b/include/kfr/io/python_plot.hpp @@ -67,6 +67,12 @@ void python(const std::string& name, const std::string& code) std::system(("python \"" + filename + "\"").c_str()); } CMT_PRAGMA_GNU(GCC diagnostic pop) + +template <typename T> +inline T flush_to_zero(T value) +{ + return std::isfinite(value) ? value : 0; +} } inline std::string concat_args() { return {}; } @@ -108,7 +114,7 @@ void plot_show(const std::string& name, T&& x, const std::string& options = "") "import dspplot\n\n" "data = [\n"; for (size_t i = 0; i < array.size(); i++) - ss += as_string(fmt<'g', 20, 17>(array[i]), ",\n"); + ss += as_string(fmt<'g', 20, 17>(internal::flush_to_zero(array[i])), ",\n"); ss += "]\n"; ss += "dspplot.plot(" + concat_args("data", options) + ")\n";