maths: special case limit conditions of sinc

This commit is contained in:
Danny Robson 2015-02-05 20:29:47 +11:00
parent 4c41439a2e
commit b12d0b95fc

View File

@ -198,7 +198,7 @@ template <typename T>
constexpr T constexpr T
sincn [[gnu::pure]] (T x) sincn [[gnu::pure]] (T x)
{ {
return std::sin (constants<T>::PI * x) / (constants<T>::PI * x); return almost_zero (x) ? 1 : std::sin (constants<T>::PI * x) / (constants<T>::PI * x);
} }
@ -207,7 +207,7 @@ template <typename T>
constexpr T constexpr T
sincu [[gnu::pure]] (T x) sincu [[gnu::pure]] (T x)
{ {
return std::sin (x) / x; return almost_zero (x) ? 1 : std::sin (x) / x;
} }