From 1f3b44a20ec69886793f98a33a14ab6b15b3cbc0 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 11 Aug 2016 16:32:48 +1000 Subject: [PATCH] vector: move vector::is_zero to coord::almost_zero --- coord/ops.hpp | 21 +++++++++++++++++++++ vector.cpp | 13 +------------ vector.hpp | 3 --- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/coord/ops.hpp b/coord/ops.hpp index c83efffa..10822a5b 100644 --- a/coord/ops.hpp +++ b/coord/ops.hpp @@ -312,6 +312,27 @@ namespace util { } + //------------------------------------------------------------------------- + template < + size_t S, + typename T, + template class K, + typename = std::enable_if_t< + is_coord_v, void + > + > + constexpr + bool + almost_zero (const K &k) + { + return std::all_of ( + std::cbegin (k), + std::cend (k), + [] (T t) { return almost_equal (t); } + ); + } + + /////////////////////////////////////////////////////////////////////////// // special operators diff --git a/vector.cpp b/vector.cpp index 35acbd6c..aa69f764 100644 --- a/vector.cpp +++ b/vector.cpp @@ -154,18 +154,7 @@ util::cartesian_to_spherical (vector<3,T> c) } -//----------------------------------------------------------------------------- -template -bool -util::vector::is_zero (void) const -{ - return std::all_of (std::begin (this->data), - std::end (this->data), - [] (T i) { return almost_zero (i); }); -} - - -//----------------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////////////// template const util::vector util::vector::UNIT (T{1}); diff --git a/vector.hpp b/vector.hpp index 8da8d598..d3760406 100644 --- a/vector.hpp +++ b/vector.hpp @@ -29,9 +29,6 @@ namespace util { { using coord::base::base; - // vector size - bool is_zero (void) const; - T difference (vector) const; T difference2 (vector) const;