summaryrefslogtreecommitdiff
path: root/modules/codec/c++/math.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/codec/c++/math.hpp')
-rw-r--r--modules/codec/c++/math.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/codec/c++/math.hpp b/modules/codec/c++/math.hpp
index dd9e49b..ddeea3f 100644
--- a/modules/codec/c++/math.hpp
+++ b/modules/codec/c++/math.hpp
@@ -4,9 +4,22 @@
namespace saw {
namespace math {
+/*
template<typename T, typename Encoding = encode::Native>
data<typename T::InnerType,Encoding> norm_2(const data<T,Encoding>& d){
return {};
}
+*/
+
+template<typename T, uint64_t D, typename Encoding = encode::Native>
+data<schema::Scalar<T>, Encoding> dot(const data<schema::Vector<T,D>, Encoding>& left, const data<schema::Vector<T,D>, Encoding>& right){
+ data<schema::Scalar<T>,Encoding> val;
+ auto& inner = val({});
+ for(uint64_t i = 0u; i < D; ++i){
+ inner = inner + left({{i}}) * right({{i}});
+ }
+
+ return val;
+}
}
}