Permalink
Browse files

condassign should now work also with adubs

  • Loading branch information...
1 parent 6e7e1dd commit 7a12389d9318fce678ea2b78007ba40ed6541101 @b45ch1 committed Feb 28, 2012
Showing with 326 additions and 257 deletions.
  1. +16 −16 adolc/src/py_adolc.cpp
  2. +16 −16 adolc/src/py_adolc.hpp
  3. +175 −137 adolc/tests/test_wrapped_functions.py
  4. +119 −88 adolc/wrapped_functions.py
View
@@ -195,7 +195,7 @@ void c_wrapped_hov_forward (short tape_tag, int M, int N, int D, int P, bpn::ar
for(int n = 0; n != N; ++n){
V[n] = &V1[ n * P];
}
-
+
double* W_data = (double*) nu::data(bpn_W);
double** W[M];
double* W1[M*P];
@@ -222,7 +222,7 @@ void c_wrapped_hov_wk_forward (short tape_tag, int M, int N, int D, int keep, in
for(int n = 0; n != N; ++n){
V[n] = &V1[ n * P];
}
-
+
double* W_data = (double*) nu::data(bpn_W);
double** W[M];
double* W1[M*P];
@@ -249,7 +249,7 @@ void c_wrapped_fov_reverse (short tape_tag, int M, int N, int Q, bpn::array &bp
for(int q = 0; q != Q; ++q){
U[q] = &U_data[M * q];
}
-
+
double* Z_data = (double*) nu::data(bpn_Z);
double* Z[Q];
for(int q = 0; q != Q; ++q){
@@ -280,7 +280,7 @@ void c_wrapped_hos_ti_reverse (short tape_tag, int M, int N, int D, bpn::array
}
hos_ti_reverse(tape_tag, M, N, D, U, Z);
}
-
+
void c_wrapped_hov_reverse (short tape_tag, int M, int N, int D, int Q, bpn::array &bpn_U, bpn::array &bpn_Z, bpn::array &bpn_nz){
double* U_data = (double*) nu::data(bpn_U);
@@ -314,11 +314,11 @@ void c_wrapped_hov_ti_reverse (short tape_tag, int M, int N, int D, int Q, bpn::
double* U_data = (double*) nu::data(bpn_U);
double** U[Q];
double* U1[Q*M];
-
+
for( int qn = 0; qn != Q*M; ++qn){
U1[qn] = &U_data[qn * (D+1)];
- }
-
+ }
+
for(int q = 0; q != Q; ++q){
U[q] = &U1[ q * M];
}
@@ -327,15 +327,15 @@ void c_wrapped_hov_ti_reverse (short tape_tag, int M, int N, int D, int Q, bpn::
double* Z_data = (double*) nu::data(bpn_Z);
double** Z[Q];
double* Z1[Q*N];
-
+
for( int qn = 0; qn != Q*N; ++qn){
Z1[qn] = &Z_data[qn * (D+1)];
- }
-
+ }
+
for(int q = 0; q != Q; ++q){
Z[q] = &Z1[ q * N];
}
-
+
/* nz is (Q,N) matrix */
short* nz_data = (short*) nu::data(bpn_nz);
short* nz[Q];
@@ -350,27 +350,27 @@ void c_wrapped_hov_ti_reverse (short tape_tag, int M, int N, int D, int Q, bpn::
void c_wrapped_hos_ov_reverse (short tape_tag, int M, int N, int D, int P, bpn::array &bpn_U, bpn::array &bpn_Z){
/* this function is experimental and likely not to work ... */
-
+
/* U is (M,D+1) array */
double* U_data = (double*) nu::data(bpn_U);
double* U[M];
for(int m = 0; m != M; ++m){
U[m] = &U_data[ m * (D+1)];
}
-
+
/* Z is (N, P, D+1) array???? */
double* Z_data = (double*) nu::data(bpn_Z);
double** Z[N];
double* Z1[N*P];
-
+
for( int np = 0; np != N*P; ++np){
Z1[np] = &Z_data[np * (D+1)];
}
-
+
for(int n = 0; n != N; ++n){
Z[n] = &Z1[ n * P];
}
-
+
hos_ov_reverse(tape_tag, M, N, D, P, U, Z);
}
View
@@ -207,13 +207,13 @@ BOOST_PYTHON_MODULE(_adolc)
using namespace boost::python;
import_array(); /* some kind of hack to get numpy working */
bpn::array::set_module_and_type("numpy", "ndarray"); /* some kind of hack to get numpy working */
-
+
scope().attr("__doc__") ="unused: moved docstring to adolc.py";
-
+
def("get_size_of_short", get_size_of_short);
def("get_size_of_int", get_size_of_int);
def("get_size_of_long", get_size_of_long);
-
+
def("trace_on",trace_on_default_argument);
def("trace_off",trace_off_default_argument);
@@ -245,7 +245,7 @@ BOOST_PYTHON_MODULE(_adolc)
def("hov_reverse", &c_wrapped_hov_reverse);
def("hov_ti_reverse", &c_wrapped_hov_ti_reverse);
def("hos_ov_reverse", &c_wrapped_hos_ov_reverse);
-
+
def("depends_on", &depends_on);
def("tape_to_latex", py_tape_doc);
@@ -254,7 +254,7 @@ BOOST_PYTHON_MODULE(_adolc)
def("exp", adub_exp_badouble, return_value_policy<manage_new_object>() );
def("log", adub_log_badouble, return_value_policy<manage_new_object>() );
def("sin", adub_sin_badouble, return_value_policy<manage_new_object>() );
- def("cos", adub_cos_badouble, return_value_policy<manage_new_object>() );
+ def("cos", adub_cos_badouble, return_value_policy<manage_new_object>() );
def("tan", adub_tan_badouble, return_value_policy<manage_new_object>() );
def("asin", adub_asin_badouble, return_value_policy<manage_new_object>() );
def("acos", adub_acos_badouble, return_value_policy<manage_new_object>() );
@@ -266,7 +266,7 @@ 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);
def("condassign", &wrapped_condassign_double_if_else);
def("condassign", &wrapped_condassign_adouble_if);
@@ -277,7 +277,7 @@ BOOST_PYTHON_MODULE(_adolc)
.add_property("val", &badouble::value)
.add_property("loc", &badouble::loc)
-
+
.def("is_independent", &badouble::operator<<=, return_internal_reference<>())
.def("__ilshift__", operator_eq_double, return_internal_reference<>())
.def("__ilshift__", operator_eq_badouble, return_internal_reference<>())
@@ -290,34 +290,34 @@ BOOST_PYTHON_MODULE(_adolc)
.def(self -= double() )
.def(self *= double() )
.def(self /= double() )
-
+
.def(self += int() )
.def(self -= int() )
.def(self *= int() )
- .def(self /= int() )
+ .def(self /= int() )
.def(self += self )
.def(self -= self )
.def(self *= self )
.def(self /= self )
-
+
.def(self < double() )
.def(self <= double() )
.def(self > double() )
.def(self >= double() )
-
+
.def(self < int() )
.def(self <= int() )
.def(self > int() )
- .def(self >= int() )
-
-
+ .def(self >= int() )
+
+
.def(self < self )
.def(self <= self )
.def(self > self )
.def(self >= self )
-
+
// .def(-self) using this unary operator somehow screws up LATER computations, i.e. the operator works correctly, but subsequent calculations screw up!!
// .def(+self)
@@ -342,7 +342,7 @@ BOOST_PYTHON_MODULE(_adolc)
.def("__mul__", adub_mul_badouble_double, return_value_policy<manage_new_object>())
.def("__div__", adub_div_badouble_double, return_value_policy<manage_new_object>())
.def("__truediv__", adub_div_badouble_double, return_value_policy<manage_new_object>())
-
+
.def("__pow__", adub_pow_badouble_double, return_value_policy<manage_new_object>())
.def("__pow__", adouble_pow_badouble_badouble, return_value_policy<manage_new_object>())
.def("__rpow__",adouble_pow_double_badouble, return_value_policy<manage_new_object>())
Oops, something went wrong.

0 comments on commit 7a12389

Please sign in to comment.