Prev Next whats_new_03

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@
Changes and Additions to CppAD During 2003

This section contains a list of the changes plus for (in reverse order by date). The purpose of this section is to assist you in learning about changes between various versions.

Some references to double should have been references to the base type (in reverse mode and in the Grad/ and Hess functions). This has been fixed.

The preprocessor symbol WIN32 was being used to determine if one was using Microsoft's C++ compiler. This symbol is predefined by the MinGW version of the GNU C++ compiler and hence CppAD had errors during installation using MinGW. This has been fixed by using the preprocessor symbol _MSC_VER to determine if one is using the Microsoft C++ compiler.

The extended system solvers OdeOne and OdeTwo have been removed from the distribution. In addition, the interface to the ODE solvers have been simplified.

Remove the CppADCreateTape macro and have the tapes created and grow automatically.

The old method where one directly accesses the tape has been removed and the following functions are no longer available:
TapeName.Independent(AD<Base> &indvar)
TapeName.Record(size_t order)
          bool Dependent(const AD<
Base> &var) const
TapeName.Dependent(const AD<Base> &var) const
TapeName.Total(void) const
TapeName.Required(void) const
TapeName.State(void) const
TapeName.Order(void) const
TapeName.Required(void) const
          bool Parameter(CppADvector< AD<
Base> > &u)

The change on 12-01 make the taping process simpler if one does not directly access CppADCreateTape. The examples were changed to not use TapeName . The following examples were skipped because they document the functions that access TapeName : DefFun.cpp, For.cpp, for_two.cpp, Rev.cpp, and rev_two.cpp.

There was a bug in f.Rev and f.RevTwo and when two dependent variables were always equal and shared the same location in the tape. This has been fixed.

The ODE Example was changed to tape the solution (and not use OdeOne or OdeTwo). This is simpler to use and the resulting speed tests gave much faster results.

The following function has been added:
     void Independent(const CppADvector<
Base> &x)
which will declare the independent variables and begin recording AD<Base> operations (see Independent ). The ADFun constructor was modified so that it stops the recording and erases that tape as well as creates the ADFun object. In addition, the tape no longer needs to be specified in the constructor.

Add StiffZero to set of ODE solvers.

The AbsGeq and LeqZero in LuSolve were changed to template functions so they could have default definitions in the case where the <= and >= operators are defined. This made the double and AD<double> use of LuSolve simpler because the user need not worry about these functions. On the other hand, it made the std::complex and AD<std::complex> use of LuSolve more complex.

The member function names for the fun argument to ODE were changed from fun.f to fun.Ode and from fun.g to fun.Ode_ini .

The table of contents was reorganized to provide a better grouping of the documentation.

The LuSolve utility is now part of the distribution and not just an example; i.e., it is automatically included by cppad.hpp.

The ODE solver was modified so that it can be used with any type (not just an AD type. This was useful for the speed testing. It is also useful for determining how the integrator steps should be before starting the tape.

The template argument Type was changed to Base where ever it was the base type of an AD class.

An speed_cppad/OdeSpeed.cpp/ test was added and some changes were made to the ODE interface in order to make it faster. The most significant change was in the specifications for the ODE function object fun .

The user defined unary function example example/UnaryFun.cpp was incorrect. It has been corrected and extended.

The CppAD::vector template class is now used where the std::vector template class was previously used. You can replace the CppAD::vector class with a vector template class of your choosing during the Install procedure.

The documentation for taping derivative calculations was improved as well as the corresponding example. In order to make this simpler, the example tape name DoubleTape was changed to ADdoubleTape (and the other example tape names were also changed).

The ODE utility was changed from an example to part of the distribution. In addition, it was extended so that it now supports taping the solution of the differential equations (case order equal zero) or solving the extended set of differential equations for both first and second derivatives (cases order equal one and two). In addition, an initial condition that depends on the parameter values is also allowed.

It is now legal to differentiate a parameter with respect to an independent variable (parameter derivatives are always equal to zero). This is an extension of the Reverse, Partial, ReverseTwo, and PartialTwo functions.

All the CppAD include files, except cppad.hpp were moved into an include subdirectory.

The ADFun template class was added so that one can save a tape recording and use it as a differentiable function. The ADFun functions supports directional derivatives in both Forward and Reverse mode where as the tape only supports partial derivatives.

The sqrt function was added to the unary_standard_math functions. In addition, a definition of the power function for the types float and double was automatically included in the CppAD namespace.

The Value function was changed so that it can be called when the tape is in the Empty state.

The atan function was added to the unary_standard_math functions.

In the notation below, zero and one are parameters that are exactly equal to zero and one. If the variables z and x were related in any of the following ways, they share can share the same record on the tape because they will have the same derivatives.
z = x + zero        z =  x * one
z = zero + x        z =  one * x
z = x - zero        z =  x / one
Furthermore, in the following cases, the result z is a parameter (equal to zero) and need not be recorded in the tape:
z = x * zero        z =  zero / x
z = zero * x
The arithmetic operators were all checked to make sure they did not add to the tape in these special cases. The total record count for the program in the Example directory was 552 before this change and 458 after.

The process of converting the tape to operators was completed. In order to make this conversion, the binary user defined functions were removed. (Bob Goddard suggested a very nice way to keep the unary functions.) Another significant change was made to the user interface during this procedure, the standard math library functions are now part of the CppAD distribution and not defined by the user.

The function TapeName.Total was added to make it easy to track how many tape records are used by the test suite. This will help with future optimization of the CppAD recording process.

There was a bug (found by Mike Dodds ) in the error checking of the TapeName.Erase function. If Erase was called twice in a row, and NDEBUG was false during compilation, the program would abort. This has been fixed.

A process of changing the tape from storing partial derivatives to storing operators has been started. This will make the tape smaller and it will enable the computation of higher derivatives with out having to tape the tape (see mul_level ). The Add, Subtract, Multiply and Divide operators have been converted. The user defined functions are presenting some difficulties, so this process has not yet been completed.

There was a bug in reverse mode when an dependent variable was exactly equal to an independent variable. In this case, it was possible for it to be located before other of the independent variables on the tape. These other independent variable partials were not initialized to zero before the reverse calculation and hence had what ever value was left by the previous mode calculation. This has been fixed and the Eq.cpp example has been changed to test for this case.

The following tape functions were changed to be declared const because they do not modify the tape in any way: State, Order, Required, Dependent, and Parameter .

The functions Grad and Hess were changed to use function objects instead of function pointers.

The higher order constructors (in standard valarray) were removed from the ODE example in order to avoid memory allocation of temporaries (and hence increase speed). In addition, the function objects in the ODE examples were changed to be const.

An ordinary differential equation solver was added. In addition, the extended system to differentiate the solution was included.

The linked list of AD variables was not being maintained correctly by the AD destructor. This was fixed by have the destructor use RemoveFromVarList to remove variables from the list. (RemoveFromVarList is a private AD member function not visible to the user.)

There is a new Faq question about evaluating derivatives at multiple values for the independent variables .

An example that uses AD< AD<double> > to compute higher derivatives was added.

The name GaussEliminate was changed to LuSolve to better reflect the solution method.

Changed the get_started.cpp and complex_poly.cpp examples so they use a template function with both base type and AD type arguments. (The resulting code is simpler and a good use of templates.)

A getting started example was added and the organization of the Examples was changed.

The AbsOfDoubleNotDefine flag is no longer used and it was removed from the Windows install instructions.

The 03-09-03 distribution did not have the proper date attached to it. The distribution script has been changed so that attaching the proper date is automated (i.e., this should not happen again).

A Frequently Asked Questions and Answers section was started.

Added the Value function which returns the base type value corresponding to an AD object.

A new version of Cygwin was installed on the development system (this may affect the timing tests reported in this document). In addition, LuSolve was changed to use back substitution instead of reduction to an identity matrix. This reduced the number of floating point operations corresponding to evaluation of the determinant. The following results correspond to the speed test of DetLu on a 9 by 9 matrix:
Version double Rate AD<double> Rate Gradient Rate Hessian Rate Tape Length
03-08-20 8,524 5,278 4,260 2,450 532
03-08-23 7,869 4,989 4,870 2,637 464

The unary minus operator was added to the AD operations.

The standard math function examples were extended to include the complex case.

The LuSolve routine what changed to use std::vector<Base> & arguments in place of Base * arguments. This removes the need to use new and delete with LuSolve.

When testing the speed of the change to using standard vector, it was noticed that the LuSolve routine was much slower. (see times for 03-08-16 below). This was do to computing the determinant instead of the log of the determinant. Converting back to the log of the determinant regained the high speeds. The following results correspond to the speed test of DetLu on a 9 by 9 matrix:
Version double Rate AD<double> Rate Gradient Rate Hessian Rate Tape Length
03-08-16 9,509 5,565 3,587 54 537
03-08-19 8,655 5,313 4,307 2,495 532

The macro CppADTapeOverflow was added so that CppAD can check for tape overflow even in the NDEBUG preprocessor flag is defined.

The LuSolve routine was extended to handle complex arguments. Because the complex absolute value function is nowhere differentiable, this required the allowing for user defined boolean valued functions with AD arguments . The examples lu_solve.cpp and GradLu.cpp were converted to a complex case.

The routine LuSolve was made more efficient so that it is more useful as a tool for differentiating linear algebra calculations. The following results correspond to the speed test of DetLu on a 9 by 9 matrix:
Version double Rate AD<double> Rate Gradient Rate Hessian Rate Tape Length
03-08-10 49,201 7,787 2,655 1,809 824
03-08-11 35,178 12,681 4,521 2,541 540
In addition the corresponding test case lu_solve.cpp was changed to a Hilbert matrix case.

A complex polynomial example was added.

The documentation and type conversion in LuSolve was improved.

The absolute value function was removed from the examples because some systems do not yet properly support double abs(double x) ,

Because the change to the multiplication operator had such a large positive effect, all of the arithmetic operators were modified to reduce the amount of information in the tape (where possible).

During Lu factorization, certain elements of the matrix are know to be zero or one and do not depend on the variables. The multiplication operator was modified to take advantage of this fact. This reduced the size of the tape and increased the speed for the calculation of the gradient and Hessian for the Lu determinant test of a 5 by 5 matrix as follows:
Version Tape Length Gradient Rate Hessian Rate
03-08-05 176 11,362 1,149
03-08-06 167 12,780 10,625

Fixed a mistake in the calculation of the sign of the determinant in the LuSolve example.

Added a the compiler flag
to the make files so that it could be removed on systems where the function
     double abs(double 
was defined in math.h.

The Grad and Hess functions were modified to handel the case where the function does not depend on the independent variables.

The LuSolve example was added to show how on can differentiate linear algebra calculations. In addition, it was used to add another set of speed tests .

The standard Math functions were added both as examples of defining atomic operations and to support mathematical operations for the AD<double> case.

The << operator was added to the AD template class for output to streams.

The compound assignment operators were added to the AD template class.

The name of the Speed/SpeedTest program was changed to Speed/Speed . In addition, Speed/SpeedRun was changed to Speed/SpeedTest.

The assignment operator was changed so the it returns a reference to the target. This allows for statements of the form
x = y = z;
i.e., multiple assignments.

If the AD copy constructor constructor or assignment operator used an independent variable for its source value, the result was also an independent variable. This has been fixed so that the result is a dependent variable in these cases.

The AD<Base> data structure was changed to include a doubly linked list of variables. This enabled the AD copy constructor constructor and assignment operator to create multiple references to the same place in the tape. This reduced the size of the tape and increased the speed for the calculation of the gradient and Hessian for the determinant of a 5 by 5 matrix as follows:
Version Tape Length Gradient Rate Hessian Rate
03-07-22 1668 1,363 53
03-07-26 436 3,436 213

The facility was added so that the user can define binary functions together with their derivatives. (This facility has been removed because it is better to define binary functions using AD variables.)

The Windows version make file directive /I ..\.. in example\Example.mak and Speed\Speed.mak was changed to /I .. (as it should have been).

The facility was added so that the user can define unary functions, together with their derivatives. For example, the standard math functions such as exp are good candidates for such definitions. (This feature has been replaced by and the standard math functions are now part of the AD types, see AD .)

The first Alpha for the Windows installation was released.

Computing the determinant of a minor of a matrix det_of_minor was documented as a realistic example using CppAD.

Fixed some non-standard constructions that caused problems with the installation on other machines.

Compiled and ran the tests under Microsoft Windows. (The Windows release should not take much more work.)

First Alpha release of CppAD and is being released under the Gnu Public License . It is intended for use by a Unix system. A Microsoft release is intended in the near future.
Input File: omh/appendix/whats_new/whats_new_03.omh