aboutsummaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-11-29 16:31:34 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-11-29 16:31:34 +0000
commit67688e30f4a5b3abfe34b3f96fd53168e3081242 (patch)
treea620bf1aa72bbbf2ebd56e0f4ec0d3108b112c4e /misc
parentad5e55b79bbe0debf81539c12b68df7f06d7e7dd (diff)
downloadopt-utilities-67688e30f4a5b3abfe34b3f96fd53168e3081242.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@99 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'misc')
-rw-r--r--misc/optvec.hpp40
1 files 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<typename T>
+ optvec<T> operator-(const optvec<T>& x1)
+ {
+
+ optvec<T> result(x1.size());
+ for(size_t i=0;i!=x1.size();++i)
+ {
+ result[i]=-x1[i];
+ }
+ return result;
}
@@ -193,6 +205,18 @@ namespace opt_utilities
}
template<typename T>
+ optvec<T> operator/(const T& x1,const optvec<T>& x2)
+ {
+
+ optvec<T> result(x1.size());
+ for(size_t i=0;i!=x1.size();++i)
+ {
+ result[i]=x1/x2[i];
+ }
+ return result;
+ }
+
+ template<typename T>
optvec<T>& operator/=(optvec<T>& x1,const optvec<T>& x2)
{
for(size_t i=0;i!=x1.size();++i)
@@ -240,9 +264,9 @@ namespace opt_utilities
#define DEF_VEC_FUNC(_func) template <typename T> \
- std::vector<T> _func(const opt_utilities::optvec<T>& x) \
+ opt_utilities::optvec<T> _func(const opt_utilities::optvec<T>& x) \
{ \
- std::vector<T> result(x.size()); \
+ opt_utilities::optvec<T> 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<typename T>
+ opt_utilities::optvec<T> pow(const opt_utilities::optvec<T>& x,const T& y)
+ {
+ opt_utilities::optvec<T> result(x.size());
+ for(int i=0;i!=result.size();++i)
+ {
+ result[i]=pow(x[i],y);
+ }
+ return result;
+ }
+
}