diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2010-10-14 17:32:33 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2010-10-14 17:32:33 +0000 |
commit | 28fcd862c8831dd4e29f744d162f9181a6e14ac8 (patch) | |
tree | 686bcc01ddb1724336df26b6e52c713e68303ba4 /math | |
parent | aa3e3a1d67927d338dc62125c342f06d27c8d91e (diff) | |
download | opt-utilities-28fcd862c8831dd4e29f744d162f9181a6e14ac8.tar.bz2 |
git-svn-id: file:///home/svn/opt_utilities@137 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'math')
-rw-r--r-- | math/vector_operation.hpp | 19 |
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 |