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.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/math/vector_operation.hpp b/math/vector_operation.hpp
index 3f5532c..a856847 100644
--- a/math/vector_operation.hpp
+++ b/math/vector_operation.hpp
@@ -15,6 +15,25 @@ namespace opt_utilities
}
return result;
}
+
+ template <typename T>
+ T contract(const T& x1,const T& x2,...)
+ {
+ return x1*x2;
+ }
+
+ template <typename pT>
+ typename element_type_trait<pT>::element_type
+ contract(const pT& v1,const pT& v2,const typename element_type_trait<pT>::element_type&)
+ {
+ typename element_type_trait<pT>::element_type result(0);
+ for(int i=0;i<get_size(v1);++i)
+ {
+ result+=get_element(v1,i)*get_element(v2,i);
+ }
+ return result;
+ }
+
}
#endif