summaryrefslogtreecommitdiff
path: root/modules/codec/c++/math.hpp
blob: ddeea3f1300cf7f1ebf044e3d4f851004b926684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once

#include "data_math.hpp"

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;
}
}
}