coord/ops: add element sum overload
This commit is contained in:
parent
1f86925237
commit
f6ceb5cdee
@ -23,8 +23,8 @@
|
||||
#include "../maths.hpp"
|
||||
#include "../types/bits.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace util {
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@ -625,7 +625,24 @@ namespace util {
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <
|
||||
size_t S,
|
||||
typename T,
|
||||
template <size_t,typename> class K,
|
||||
typename = std::enable_if_t<
|
||||
is_coord_v<K>, void
|
||||
>
|
||||
>
|
||||
constexpr
|
||||
T
|
||||
sum (const K<S,T> k)
|
||||
{
|
||||
return sum (std::cbegin (k), std::cend (k));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define VECTOR_OP(OP) \
|
||||
template < \
|
||||
size_t S, \
|
||||
|
@ -34,5 +34,7 @@ main (void)
|
||||
auto vec = util::vector4f (0.5f);
|
||||
t.expect_eq (vec, util::normalised (vec), "normalisation of normalised vector");
|
||||
|
||||
t.expect_eq (sum (util::vector4f::ONES), 4.f, "elementwise summation");
|
||||
|
||||
return t.status ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user