aboutsummaryrefslogtreecommitdiffstats
path: root/methods/powell/bas_util.hpp
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2008-12-15 07:26:12 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2008-12-15 07:26:12 +0000
commit1f4a944064bc42284c33e6b755353d191cf288e8 (patch)
treec8cb2253dea5f395e0f867aa6976433bd3eb00de /methods/powell/bas_util.hpp
downloadopt-utilities-1f4a944064bc42284c33e6b755353d191cf288e8.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@1 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'methods/powell/bas_util.hpp')
-rw-r--r--methods/powell/bas_util.hpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/methods/powell/bas_util.hpp b/methods/powell/bas_util.hpp
new file mode 100644
index 0000000..743dc3c
--- /dev/null
+++ b/methods/powell/bas_util.hpp
@@ -0,0 +1,63 @@
+#ifndef BAS_UTIL
+#define BAS_UTIL
+#include <core/opt_traits.hpp>
+namespace opt_utilities
+{
+ template <typename T>
+ T tabs(T x)
+ {
+ return T(x)<T(0)?T(-x):T(x);
+ }
+
+ template <typename T>
+ T sqr(T x)
+ {
+ return x*x;
+ }
+
+
+ template <typename T>
+ void shft3(T&a,T& b,T& c,T d)
+ {
+ opt_eq(a,b);
+ opt_eq(b,c);
+ opt_eq(c,d);
+ }
+
+ template <typename T>
+ void shft(T& a,T& b,T& c,T d)
+ {
+ opt_eq(a,b);
+ opt_eq(b,c);
+ opt_eq(c,d);
+ }
+ template <typename T>
+ void swap(T& ax,T& bx)
+ {
+ // swap(ax,bx);
+ T temp;
+ opt_eq(temp,ax);
+ opt_eq(ax,bx);
+ opt_eq(bx=temp);
+ }
+
+ template <typename T>
+ T sign(const T& a,const T& b)
+ {
+ return b>=0?T(a>=0?T(a):T(-a)):T(a>=0?T(-a):T(a));
+ }
+
+ template <typename T>
+ T max(T a,T b)
+ {
+ return b>a?T(b):T(a);
+ }
+
+ template <typename T>
+ void mov3(T& a,T& b,T& c, T& d,T& e,T& f)
+ {
+ opt_eq(a,d);opt_eq(b,e);opt_eq(c,f);
+ }
+}
+
+#endif