aboutsummaryrefslogtreecommitdiffstats
path: root/math/vector_operation.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/vector_operation.hpp')
-rw-r--r--math/vector_operation.hpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/math/vector_operation.hpp b/math/vector_operation.hpp
new file mode 100644
index 0000000..481fdef
--- /dev/null
+++ b/math/vector_operation.hpp
@@ -0,0 +1,18 @@
+#ifndef VECTOR_OPERATION_HPP
+#define VECTOR_OPERATION_HPP
+#include <core/opt_traits.hpp>
+
+template <typename pT>
+typename element_type_trait<pT>::element_type
+inner_product(const pT& v1,const pT& v2)
+{
+ typename element_type_trait<pT>::element_type result;
+ for(int i=0;i<get_size(v1);++i)
+ {
+ result+=get_element(v1,i)*get_element(v2,i);
+ }
+ return result;
+}
+
+
+#endif