# Changeset 2421

Ignore:
Timestamp:
Jun 4, 2012 8:35:01 AM (21 months ago)
Message:
1. Add the fabs function (as another name for abs function).
2. Bring cppad of ode speed test up to date, implement adolc version of ode.
3. Change m to p in ode_evaluate.

Location:
trunk
Files:
16 edited

Unmodified
Removed

• ## trunk/example/abs.cpp

 r2240 /* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under $begin abs.cpp$$spell fabs abs$$$index abs, example$$index fabs, example$$ $index example, abs$$index example, fabs$$$index test, abs$$index derivative, directional example$$ $index directional, derivative example$$index test, fabs$$$code {       bool ok = true; using CppAD::abs; using CppAD::AD; using CppAD::NearEqual; // range space vector size_t m = 3; size_t m = 6; CPPAD_TEST_VECTOR< AD > y(m); y[0]     = abs(x[0] - 1.); y[1]     = abs(x[0]); y[2]     = abs(x[0] + 1.); // y[3]     = fabs(x[0] - 1.); y[4]     = fabs(x[0]); y[5]     = fabs(x[0] + 1.); // create f: x -> y and stop tape recording ok &= (y[1] == 0.); ok &= (y[2] == 1.); // ok &= (y[3] == 1.); ok &= (y[4] == 0.); ok &= (y[5] == 1.); // forward computation of partials w.r.t. a positive x[0] direction dy    = f.Forward(p, dx); ok  &= (dy[0] == - dx[0]); ok  &= (dy[1] ==   0.   ); // used to be ok  &= (dy[1] == + dx[0]); ok  &= (dy[1] ==   0.   ); // used to be (dy[1] == + dx[0]); ok  &= (dy[2] == + dx[0]); // ok  &= (dy[3] == - dx[0]); ok  &= (dy[4] ==   0.   ); // used to be (dy[1] == + dx[0]); ok  &= (dy[5] == + dx[0]); // forward computation of partials w.r.t. a negative x[0] direction dy    = f.Forward(p, dx); ok  &= (dy[0] == - dx[0]); ok  &= (dy[1] ==   0.   ); // used to be ok  &= (dy[1] == - dx[0]); ok  &= (dy[1] ==   0.   ); // used to be (dy[1] == - dx[0]); ok  &= (dy[2] == + dx[0]); // ok  &= (dy[3] == - dx[0]); ok  &= (dy[4] ==   0.   ); // used to be (dy[1] == - dx[0]); ok  &= (dy[5] == + dx[0]); // reverse computation of derivative of y[0] p    = 1; CPPAD_TEST_VECTOR  w(m), dw(n); w[0] = 1.; w[1] = 0.; w[2] = 0.; w[0] = 1.; w[1] = 0.; w[2] = 0.; w[3] = 0.; w[4] = 0.; w[5] = 0.; dw   = f.Reverse(p, w); ok  &= (dw[0] == -1.); // reverse computation of derivative of y[1] w[0] = 0.; w[1] = 1.; w[2] = 0.; w[0] = 0.; w[1] = 1.; dw   = f.Reverse(p, w); ok  &= (dw[0] == 0.); // reverse computation of derivative of y[2] w[0] = 0.; w[1] = 0.; w[2] = 1.; // reverse computation of derivative of y[5] w[1] = 0.; w[5] = 1.; dw   = f.Reverse(p, w); ok  &= (dw[0] == 1.); // use a VecAD::reference object with abs // use a VecAD::reference object with abs and fabs CppAD::VecAD v(1); AD zero(0); v[zero]           = -1; AD result = abs(v[zero]); ok   &= NearEqual(result, 1., 1e-10, 1e-10); ok    &= NearEqual(result, 1., 1e-10, 1e-10); result = fabs(v[zero]); ok    &= NearEqual(result, 1., 1e-10, 1e-10); return ok;
• ## trunk/omh/whats_new_12.omh

 r2420 $dollar @$$spell fabs mul det_lu A memory leak and a bug in code cppad_mat_mul.cpp$$ were fixed (the bug was related to the change to$code CppAD::vector$$above). lnext The specifications for cref Runge45$$ where changes so that it uses the $code fabs$$function instead of the code <$$ operation. This enabled the a more precise statement about its$cref/operation sequence/Runge45/Operation Sequence/$$. lnext The code fabs$$ function as added to the CppAD standard math library (see $cref abs$$) and the cref/base type requirements/base_std_math/$$. This enables one to write code that works with$code AD$$as well as code double$$ without having to define $code abs$$for code double$$ arguments (and similarly for$code float$$). lend cref/operation sequence/glossary/Operation/Sequence/$$ does not depend on the repetition; see $cref/m == 0/ode_evaluate/m/m == 0/$$in its documentation. cref/p == 0/ode_evaluate/p/p == 0/$$ in its documentation.$lnext Use same argument for taping and derivative evaluation when