diff --git a/coord/ops.hpp b/coord/ops.hpp index 5d8d5c55..a60c880b 100644 --- a/coord/ops.hpp +++ b/coord/ops.hpp @@ -285,6 +285,18 @@ namespace util { //------------------------------------------------------------------------- + template < + size_t S, + typename T + > + T dot (const T (&a)[S], const T (&b)[S]) + { + T sum = 0; + for (size_t i = 0; i < S; ++i) + sum += a[i] * b[i]; + return sum; + } + template < size_t S, typename T, @@ -293,12 +305,31 @@ namespace util { > T dot (A a, B b) { - T sum { 0 }; - for (size_t i = 0; i < S; ++i) - sum += a[i] * b[i]; - return sum; + return dot (a.data, b.data); } + + template < + size_t S, + typename T, + template class K + > + T dot (K a, const T (&b)[S]) + { + return dot (a.data, b); + } + + template < + size_t S, + typename T, + template class K + > + T dot (const T (&a)[S], K b) + { + return dot (a, b.data); + } + + //------------------------------------------------------------------------- template < size_t S,