From 50c1088918286193661d22192ea709fce0424e7d Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 29 Sep 2015 18:06:52 +1000 Subject: [PATCH] coord/ops: add vector floor function --- coord/ops.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/coord/ops.hpp b/coord/ops.hpp index fddc3383..63d5cf84 100644 --- a/coord/ops.hpp +++ b/coord/ops.hpp @@ -22,6 +22,7 @@ #include "../types/bits.hpp" #include +#include namespace util { // forward declerations for traits @@ -323,6 +324,22 @@ namespace util { bool operator<= (K k, T t) { return max (k) <= t; } + + + /////////////////////////////////////////////////////////////////////////// + template class K> + typename std::enable_if< + std::is_floating_point::value, + K + >::type + floor (K k) + { + T (*floor_func)(T) = std::floor; + + K v; + std::transform (k.begin (), k.end (), v.begin (), floor_func); + return v; + } } #endif