From 67688e30f4a5b3abfe34b3f96fd53168e3081242 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Sun, 29 Nov 2009 16:31:34 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@99 ed2142bd-67ad-457f-ba7c-d818d4011675 --- misc/optvec.hpp | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/misc/optvec.hpp b/misc/optvec.hpp index 27fafde..925040d 100644 --- a/misc/optvec.hpp +++ b/misc/optvec.hpp @@ -97,6 +97,18 @@ namespace opt_utilities result[i]=x1[i]-x2; } return result; + } + + template + optvec operator-(const optvec& x1) + { + + optvec result(x1.size()); + for(size_t i=0;i!=x1.size();++i) + { + result[i]=-x1[i]; + } + return result; } @@ -192,6 +204,18 @@ namespace opt_utilities return result; } + template + optvec operator/(const T& x1,const optvec& x2) + { + + optvec result(x1.size()); + for(size_t i=0;i!=x1.size();++i) + { + result[i]=x1/x2[i]; + } + return result; + } + template optvec& operator/=(optvec& x1,const optvec& x2) { @@ -240,9 +264,9 @@ namespace opt_utilities #define DEF_VEC_FUNC(_func) template \ - std::vector _func(const opt_utilities::optvec& x) \ + opt_utilities::optvec _func(const opt_utilities::optvec& x) \ { \ - std::vector result(x.size()); \ + opt_utilities::optvec result(x.size()); \ for(int i=0;i!=result.size();++i) \ { \ result[i]=_func(x[i]); \ @@ -256,6 +280,18 @@ namespace std DEF_VEC_FUNC(cos); DEF_VEC_FUNC(log); DEF_VEC_FUNC(sqrt); + DEF_VEC_FUNC(exp); + template + opt_utilities::optvec pow(const opt_utilities::optvec& x,const T& y) + { + opt_utilities::optvec result(x.size()); + for(int i=0;i!=result.size();++i) + { + result[i]=pow(x[i],y); + } + return result; + } + } -- cgit v1.2.2