Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

started adding condassign functions, but

couldnt figure out yet how they are defined
(apparently not as written in the
documentation)
  • Loading branch information...
commit 3f088e06e5fc9dcd172c6952e3c4239bbb02d026 1 parent e1135c3
@b45ch1 authored
View
7 adolc/src/py_adolc.cpp
@@ -45,6 +45,13 @@ bp::dict wrapped_tapestats(short tape_tag){
return retval;
}
+double wrapped_condassign_double_if(double res, const double cond, const double arg1){
+ printf("cond = %f\n",cond);
+ condassign(res,cond,arg1);
+ return res;
+}
+
+
/* C STYLE CALLS OF FUNCTIONS */
/* easy to use drivers */
void c_wrapped_function (short tape_tag, int M, int N, bpn::array &bpn_x, bpn::array &bpn_y ){
View
17 adolc/src/py_adolc.hpp
@@ -56,6 +56,20 @@ extern adub ldexp ( const badouble&, int );
// extern adub frexp ( const badouble&, int* );
// extern adub erf ( const badouble& );
+// extern condassign( double &res, const double &cond, const double &arg1 );
+// extern condassign( double &res, const double &cond, const double &arg1, const double &arg2 );
+// extern condassign( adouble &res, const adouble &cond, const adouble &arg1, const adouble &arg2 );
+// extern condassign( adouble &res, const adouble &cond, const adouble &arg );
+
+double wrapped_condassign_double_if(double res, const double cond, const double arg1);
+double wrapped_condassign_double_if_else(double res, const double cond, const double arg1, const double arg2);
+
+adouble wrapped_condassign_adouble_if(adouble &res, const adouble &cond, const adouble &arg1);
+adouble wrapped_condassign_adouble_if_else(adouble &res, const adouble &cond, const adouble &arg1, const adouble &arg2);
+
+
+
+
/* THIN WRAPPER FOR OVERLOADED FUNCTIONS */
void trace_on_default_argument(short tape_tag){ trace_on(tape_tag,0);}
void trace_off_default_argument(){ trace_off(0);}
@@ -152,6 +166,7 @@ adub *adub_ceil_badouble (const badouble &rhs){ return new adub(ceil(rhs));}
adub *adub_floor_badouble (const badouble &rhs){ return new adub(floor(rhs));}
adub *adub_log10_badouble (const badouble &rhs){ return new adub(log10(rhs));}
+
/* binary */
adub *adub_add_badouble_badouble(const badouble &lhs, const badouble &rhs){ return new adub(operator+(lhs,rhs));}
adub *adub_sub_badouble_badouble(const badouble &lhs, const badouble &rhs){ return new adub(operator-(lhs,rhs));}
@@ -251,6 +266,8 @@ BOOST_PYTHON_MODULE(_adolc)
def("ceil", adub_ceil_badouble, return_value_policy<manage_new_object>() );
def("floor", adub_floor_badouble, return_value_policy<manage_new_object>() );
def("log10", adub_log10_badouble, return_value_policy<manage_new_object>() );
+
+ def("condassign", &wrapped_condassign_double_if);
class_<badouble>("badouble", init<const badouble &>())
View
18 adolc/tests/test_wrapped_functions.py
@@ -169,6 +169,24 @@ def test_numpyabs(self):
assert_almost_equal(afabs.val, numpy.abs(x))
#test_expression('fabs (a) : ', lambda x: numpy.fabs (x), a, a.val)
+
+
+ def test_condassign(self):
+ x = 3.
+ y = 4.
+ cond = 1.
+
+ x = condassign(x,cond,y)
+ assert x == 4.
+
+ x = 3.
+ y = 4.
+ cond = 0
+ x = condassign(x,cond,y)
+ print x
+ assert x == 3.
+
+
class LowLevelFunctionsTests ( TestCase ):
Please sign in to comment.
Something went wrong with that request. Please try again.