From 3e9f5efbe0cc80e4d4ed333154034e3937ea1a52 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 4 Feb 2015 15:44:31 +1100 Subject: [PATCH] maths: add sinc functions --- maths.hpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/maths.hpp b/maths.hpp index 40389da6..62311612 100644 --- a/maths.hpp +++ b/maths.hpp @@ -193,16 +193,21 @@ to_radians [[gnu::pure]] (T degrees) } -//----------------------------------------------------------------------------- -constexpr float -to_radians [[gnu::pure]] (float degrees) { - return degrees / 180 * static_cast (PI_f); +//! Normalised sinc function +template +constexpr T +sincn [[gnu::pure]] (T x) +{ + return std::sin (constants::PI * x) / (constants::PI * x); } -constexpr double -to_radians [[gnu::pure]] (double degrees) { - return degrees / 180 * PI_d; +//! Unnormalised sinc function +template +constexpr T +sincu [[gnu::pure]] (T x) +{ + return std::sin (x) / x; }