matrix: add elementwise sum function overload
This commit is contained in:
parent
2daa70bae0
commit
1f86925237
@ -103,6 +103,11 @@ namespace util {
|
||||
matrix<S,T>
|
||||
abs (const matrix<S,T>&);
|
||||
|
||||
template <size_t S, typename T>
|
||||
constexpr
|
||||
T
|
||||
sum (const matrix<S,T>&);
|
||||
|
||||
template <typename T> using matrix3 = matrix<3,T>;
|
||||
template <typename T> using matrix4 = matrix<4,T>;
|
||||
|
||||
|
@ -118,3 +118,10 @@ util::abs (const util::matrix<S,T> &src)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <size_t S, typename T>
|
||||
constexpr
|
||||
T
|
||||
util::sum (const util::matrix<S,T> &src)
|
||||
{
|
||||
return sum (std::cbegin (src), std::cend (src));
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ main (void)
|
||||
{
|
||||
util::TAP::logger tap;
|
||||
|
||||
tap.expect_eq (sum (util::matrix4f::IDENTITY), 4.f, "element summation");
|
||||
|
||||
{
|
||||
// Identity matrix-vector multiplication
|
||||
auto v = util::vector4f { 1.f, 2.f, 3.f, 4.f };
|
||||
|
Loading…
Reference in New Issue
Block a user