diff -Nru cppad-2015.00.00.9/AUTHORS cppad-2016.00.00.1/AUTHORS --- cppad-2015.00.00.9/AUTHORS 2014-12-31 18:38:05.000000000 +0000 +++ cppad-2016.00.00.1/AUTHORS 2015-12-31 14:01:01.000000000 +0000 @@ -1,19 +1,19 @@ Statement of CppAD Authorship and Copyright =========================================== -To date, 2015-01-01, Bradley M. Bell is the sole author of CppAD. +To date, 2016-01-01, Bradley M. Bell is the sole author of CppAD. While Bradley M. Bell worked for the University of Washington during the development of CppAD, the following are also true: -1. The CppAD package was not written or maintained as part of any sponsored +1. The CppAD package was not written or maintained as part of any sponsored grant at the University of Washington. -2. Bradley M. Bell was not paid by the University of Washington for the time +2. Bradley M. Bell was not paid by the University of Washington for the time he worked on CppAD. -3. Working on CppAD was not part of Bradley M. Bell's normal duties at for the +3. Working on CppAD was not part of Bradley M. Bell's normal duties at for the University of Washington. -Thus, in accordance with Section 2 of the University of Washington's copyright -policy (see the file uw_copy_040507.html in this directory) Bradley M. Bell is +Thus, in accordance with Section 2 of the University of Washington's copyright +policy (see the file uw_copy_040507.html in this directory) Bradley M. Bell is the copyright holder for CppAD. diff -Nru cppad-2015.00.00.9/bin/add_copyright.sh cppad-2016.00.00.1/bin/add_copyright.sh --- cppad-2015.00.00.9/bin/add_copyright.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/add_copyright.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: add_copyright.sh 3505 2014-12-26 15:06:54Z bradbell $ +# $Id: add_copyright.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -40,10 +40,10 @@ cat << EOF > bin/add_copyright.$$ // \$Id\$ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -52,14 +52,14 @@ EOF ;; - cmake) + cmake | txt) cat << EOF > bin/add_copyright.$$ -# \$Id:\$ +# \$Id\$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -71,12 +71,12 @@ sh) cat << EOF > bin/add_copyright.$$ #! /bin/bash -e -# \$Id:\$ +# \$Id\$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -112,3 +112,6 @@ # echo "mv bin/add_copyright.$$ $file_name" mv bin/add_copyright.$$ $file_name +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/batch_edit.sh cppad-2016.00.00.1/bin/batch_edit.sh --- cppad-2015.00.00.9/bin/batch_edit.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/batch_edit.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,67 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +move_sed='s|list_files.sh|ls_files.sh|' +move_list=' +' +cat << EOF > junk.sed +s|^# cppad_has_colpack, colpack_libs|&, cppad_lib| +s|^\\tSET( colpack_libs "ColPack" )|&\\ + SET( cppad_lib "cppad_lib" )| +s|^\\tSET( colpack_libs "" )|&\\ + SET( cppad_lib "" )| +s|^\\tcppad_lib\$|\\t\${cppad_lib}| +# +s|^ADD_SUBDIRECTORY(cppad_lib)|IF( colpack_prefix )\\ + &\\ +ENDIF( colpack_prefix)| +EOF +# ----------------------------------------------------------------------------- +if [ $0 != "bin/batch_edit.sh" ] +then + echo "bin/batch_edit.sh: must be executed from its parent directory" + exit 1 +fi +# ----------------------------------------------------------------------------- +# bash function that echos and executes a command +echo_eval() { + echo $* + eval $* +} +# ----------------------------------------------------------------------------- +cp bin/batch_edit.sh $HOME/trash/batch_edit.sh +git reset --hard +cp $HOME/trash/batch_edit.sh bin/batch_edit.sh +# --------------------------------------------------------------------------- +list_all=`git ls-files` +for file in $list_all +do + if [ "$file" != 'bin/batch_edit.sh' ] + then + echo_eval sed -f junk.sed -i $file + fi +done +# ---------------------------------------------------------------------------- +for old in $move_list +do + new=`echo $old | sed -e "$move_sed"` + echo_eval git mv $old $new +done +# ---------------------------------------------------------------------------- +# files that were hand edited and cached using 'git_new.sh to' +if [ -e new ] +then + echo_eval git_new.sh from +fi +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/check_all.sh cppad-2016.00.00.1/bin/check_all.sh --- cppad-2015.00.00.9/bin/check_all.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_all.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_all.sh 3123 2014-02-26 21:40:18Z bradbell $ +# $Id: check_all.sh 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -28,7 +28,7 @@ if [ "$msg" != '' ] then echo "$msg" - echo 'Warning: see check_all.err' + echo 'Warning: see check_all.err' exit 1 fi rm $top_srcdir/check_all.err @@ -47,6 +47,15 @@ rm check_all.log fi top_srcdir=`pwd` +echo "top_srcdir = $top_srcdir" +# +if ! random_zero_one=`expr $RANDOM % 2` +then + # expr exit status is 1 when the expression result is zero + # supress shell exit in this case + : +fi +echo "random_zero_one = $random_zero_one" # --------------------------------------------------------------------------- # circular shift program list and set program to first entry in list next_program() { @@ -54,6 +63,11 @@ program=`echo "$program_list" | sed -e 's| *\([^ ]*\).*|\1|'` } # --------------------------------------------------------------------------- +if [ -e "$HOME/prefix/cppad" ] +then + echo_log_eval rm -r $HOME/prefix/cppad +fi +# --------------------------------------------------------------------------- # Create package to run test in echo "bin/package.sh" bin/package.sh @@ -68,28 +82,21 @@ tarball="${list[0]}" skip="$skip other_tarball" else - choice=`echo $RANDOM % 2 | bc` - tarball="${list[$choice]}" + tarball="${list[$random_zero_one]}" fi -echo_log_eval rm -r cppad-$version +echo_log_eval rm -rf cppad-$version echo_log_eval tar -xzf $tarball echo_log_eval cd cppad-$version # ----------------------------------------------------------------------------- -list=" - $HOME/prefix/cppad - build -" -for name in $list -do - if [ -e "$name" ] - then - echo_log_eval rm -r $name - fi -done -echo_log_eval bin/run_cmake.sh --boost_vector +if [ "$random_zero_one" == '0' ] +then + echo_log_eval bin/run_cmake.sh --boost_vector +else + echo_log_eval bin/run_cmake.sh --deprecated +fi echo_log_eval cd build # ----------------------------------------------------------------------------- -echo_log_eval make check +echo_log_eval make check # ----------------------------------------------------------------------------- for package in adolc eigen ipopt fadbad sacado do @@ -132,7 +139,7 @@ # test_time=1,max_thread=4,mega_sum=1 next_program echo_log_eval ./$program harmonic 1 4 1 - # + # # test_time=2,max_thread=4,num_zero=20,num_sub=30,num_sum=500,use_ad=true next_program echo_log_eval ./$program multi_newton 2 4 20 30 500 true @@ -146,31 +153,31 @@ echo_log_eval ./$program multi_newton 1 2 3 12 1 true fi # -# print_for test +# print_for test if [ ! -e 'print_for/print_for' ] then skip="$skip print_for/print_for" else - echo_log_eval print_for/print_for + echo_log_eval print_for/print_for print_for/print_for | sed -e '/^Test passes/,$d' > junk.1.$$ print_for/print_for | sed -e '1,/^Test passes/d' > junk.2.$$ if diff junk.1.$$ junk.2.$$ then rm junk.1.$$ junk.2.$$ - echo_log_eval echo "print_for: OK" + echo_log_eval echo "print_for: OK" else echo_log_eval echo "print_for: Error" exit 1 fi fi # -echo_log_eval make install +echo_log_eval make install # if [ "$skip" != '' ] then echo_log_eval echo "check_all.sh: skip = $skip" exit 1 fi -# -echo_log_eval echo 'check_all.sh: OK' +# ---------------------------------------------------------------------------- +echo "$0: OK" exit 0 diff -Nru cppad-2015.00.00.9/bin/check_copyright.sh cppad-2016.00.00.1/bin/check_copyright.sh --- cppad-2015.00.00.9/bin/check_copyright.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_copyright.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,73 @@ +#! /bin/bash -e +# $Id: check_copyright.sh 3768 2015-12-28 18:58:35Z bradbell $ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +if [ $0 != "bin/check_copyright.sh" ] +then + echo "bin/check_copyright.sh: must be executed from its parent directory" + exit 1 +fi +if [ ! -e .git ] +then + echo 'This is not a git repository so cannot check copyright.' + echo 'check_copyright.sh: skipped' + exit 0 +fi +list=`git status | sed -n \ + -e '/^[#\t ]*deleted:/p' \ + -e '/^[#\t ]*modified:/p' \ + -e '/^[#\t ]*both modified:/p' \ + -e '/^[#\t ]*renamed:/p' \ + -e '/^[#\t ]*new file:/p' | \ + sed -e 's/^.*: *//' -e 's/ -> /\n/' | \ + sed -e '/makefile.in$/d' | + sort -u` +cat << EOF > check_copyright.1.$$ +# Change copyright second year to current year +s/Copyright (C) \\([0-9]*\\)-[0-9][0-9] Bradley M. Bell/Copyright (C) \\1-15 Bradley M. Bell/ +s/Copyright (C) \\([0-9]*\\)-20[0-9][0-9] Bradley M. Bell/Copyright (C) \\1-15 Bradley M. Bell/ +EOF +ok=true +for file in $list +do + if [ -e $file ] + then + sed -f check_copyright.1.$$ $file > check_copyright.2.$$ + if ! diff $file check_copyright.2.$$ > /dev/null + then + echo '----------------------------------------------------' + echo "check_copyright.sh: automatic changes to $file:" + if diff $file check_copyright.2.$$ + then + echo 'bin/check_copyright.sh: program error' + rm check_copyright.*.$$ + exit 1 + fi + ok='no' + if [ -x $file ] + then + mv check_copyright.2.$$ $file + chmod +x $file + else + mv check_copyright.2.$$ $file + fi + fi + fi +done +if [ "$ok" == 'no' ] +then + rm check_copyright.*.$$ + exit 1 +fi +rm check_copyright.*.$$ +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/check_define.sh cppad-2016.00.00.1/bin/check_define.sh --- cppad-2015.00.00.9/bin/check_define.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_define.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: check_define.sh 3308 2014-05-26 14:29:01Z bradbell $ +# $Id: check_define.sh 3757 2015-11-30 12:03:07Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -18,7 +18,9 @@ # ----------------------------------------------------------------------------- echo "Difference between '# define' names and '# undef' names" echo '-----------------------------------------------------------------------' -list=`bin/list_files.sh .hpp .hpp.in | sed -n -e '/^cppad\//p'` +list=`bin/list_files.sh | sed -n \ + -e '/^cppad\/.*\.hpp$/p' \ + -e '/^cppad\/.*\.hpp\.in$/p'` # for cmd in define undef do @@ -32,7 +34,7 @@ done if [ "$cmd" == 'define' ] then - sed -e '/_INCLUDED$/d' -i tmp.$$ + sed -e '/_HPP$/d' -i tmp.$$ fi sort -u tmp.$$ > $cmd.$$ rm tmp.$$ diff -Nru cppad-2015.00.00.9/bin/check_doxygen.sh cppad-2016.00.00.1/bin/check_doxygen.sh --- cppad-2015.00.00.9/bin/check_doxygen.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_doxygen.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_doxygen.sh 2921 2013-10-11 13:40:21Z bradbell $ +# $Id: check_doxygen.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -18,10 +18,9 @@ # ----------------------------------------------------------------------------- if [ ! -e "doxygen.err" ] then - echo "bin/check_doxygen.sh: cannot find doxygen.err" - exit 1 + bin/run_doxygen.sh fi -doxygen_version=`doxygen --version | +doxygen_version=`doxygen --version | sed -e 's|\.|*100+|' -e 's|\.|*10+|' -e 's|\..*||'` let doxygen_version=$doxygen_version if (( $doxygen_version <= 155 )) @@ -42,6 +41,7 @@ list=`head doxygen.err` if [ "$list" == "" ] then + echo "$O: OK" exit 0 fi echo bin/"check_doxygen.sh: Doxygen errors or warnings; see doxygen.err" @@ -49,4 +49,5 @@ then exit 0 fi +echo "$O: Error" exit 1 diff -Nru cppad-2015.00.00.9/bin/check_example.sh cppad-2016.00.00.1/bin/check_example.sh --- cppad-2015.00.00.9/bin/check_example.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_example.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_example.sh 3308 2014-05-26 14:29:01Z bradbell $ +# $Id: check_example.sh 3689 2015-05-27 05:59:24Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -17,12 +17,14 @@ fi # ----------------------------------------------------------------------------- echo "Checking that all examples are in omh/example_list.omh" -echo "-------------------------------------------------------" -file_list=`bin/list_files.sh | \ - sed -n -e '/example\//p' -e '/multi_thread\//p'` +echo "-------------------------------------------------------" +file_list=`bin/list_files.sh | sed -n \ + -e '/cppad_ipopt/d' \ + -e '/example\//p' \ + -e '/multi_thread\//p'` # sed < omh/example_list.omh > bin/check_example.$$ \ - -n -e '/\$begin ListAllExamples\$\$/,/\$end/p' + -n -e '/\$begin ListAllExamples\$\$/,/\$end/p' ok="yes" for file in $file_list do @@ -37,7 +39,7 @@ fi done rm bin/check_example.$$ -echo "-------------------------------------------------------" +echo "-------------------------------------------------------" if [ "$ok" = "yes" ] then echo "Ok: nothing is between the two dashed lines above" diff -Nru cppad-2015.00.00.9/bin/check_if.sh cppad-2016.00.00.1/bin/check_if.sh --- cppad-2015.00.00.9/bin/check_if.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_if.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_if.sh 3308 2014-05-26 14:29:01Z bradbell $ +# $Id: check_if.sh 3689 2015-05-27 05:59:24Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -19,9 +19,12 @@ # CppAD uses preprocessor '# if 0' comment blocks for temporary changes # that will to be removed before testing for check in. echo "Checking for '# if 0' and '# if NDEBUG' commands in source code" -echo "-------------------------------------------------------" +echo "-------------------------------------------------------" ok="yes" -list=`bin/list_files.sh .cpp .hpp .hpp.in` +list=`bin/list_files.sh | sed -n \ + -e '/\.cpp$/p' \ + -e '/\.hpp$/p' \ + -e '/\.hpp.in$/p'` for file in $list do if grep '^# *if *0 *$' $file > /dev/null @@ -37,7 +40,7 @@ ok="no" fi done -echo "-------------------------------------------------------" +echo "-------------------------------------------------------" if [ "$ok" = "no" ] then echo 'bin/check_if.sh: Error' diff -Nru cppad-2015.00.00.9/bin/check_include_def.sh cppad-2016.00.00.1/bin/check_include_def.sh --- cppad-2015.00.00.9/bin/check_include_def.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_include_def.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_include_def.sh 3308 2014-05-26 14:29:01Z bradbell $ +# $Id: check_include_def.sh 3757 2015-11-30 12:03:07Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -19,10 +19,10 @@ echo "Differences between include file names and ifndef at top directives." echo "Also make sure same ifndef not used by two different files." echo "-------------------------------------------------------------------" -list=`bin/list_files.sh .hpp` +list=`bin/list_files.sh | sed -n -e '/\.hpp$/p'` # -grep '^# *ifndef *CPPAD_[0-9a-zA-Z_]*_INCLUDED$' $list \ - | sed -e 's|.*# *ifndef *CPPAD_\([0-9a-zA-Z_]*\)_INCLUDED$|\1.HPP|' \ +grep '^# *ifndef *CPPAD_[0-9a-zA-Z_]*_HPP$' $list \ + | sed -e 's|.*# *ifndef *CPPAD_\([0-9a-zA-Z_]*\)_HPP$|\1.HPP|' \ | tr [a-zA-Z] [A-Za-z] \ | sort \ > bin/check_include_def.1.$$ diff -Nru cppad-2015.00.00.9/bin/check_include_file.sh cppad-2016.00.00.1/bin/check_include_file.sh --- cppad-2015.00.00.9/bin/check_include_file.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_include_file.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_include_file.sh 3308 2014-05-26 14:29:01Z bradbell $ +# $Id: check_include_file.sh 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -25,7 +25,9 @@ echo "bin/check_include_file.sh: unexpected bin/check_include_file.1.$$" exit 1 fi -list=`bin/list_files.sh .cpp .hpp` +list=`bin/list_files.sh | sed -n \ + -e '/\.cpp$/p' \ + -e '/\.hpp$/p'` for file in $list do sed -n -e '/^# *include * bin/check_include_file.2.$$ # # The following files should never be included: -# cppad/local/prototype_op.hpp +# cppad/local/prototype_op.hpp # cppad/example/eigen_plugin.hpp -# All other files should. +# All other files should. # The file cppad/configure.hpp may not yet be created. -bin/list_files.sh .hpp | sed -n -e '/cppad\//p' | \ +bin/list_files.sh | sed -n -e '/cppad\/.*\.hpp$/p' | \ sed \ -e '1,1s|^|cppad/configure.hpp\n|' \ -e '/cppad\/local\/prototype_op.hpp/d' \ - -e '/cppad\/example\/eigen_plugin.hpp/d' | \ - sort -u > bin/check_include_file.3.$$ + -e '/cppad\/example\/eigen_plugin.hpp/d' \ + -e '/cppad\/deprecated\//d' | \ + sort -u > bin/check_include_file.3.$$ # if diff bin/check_include_file.2.$$ bin/check_include_file.3.$$ then diff -Nru cppad-2015.00.00.9/bin/check_include_omh.sh cppad-2016.00.00.1/bin/check_include_omh.sh --- cppad-2015.00.00.9/bin/check_include_omh.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_include_omh.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_include_omh.sh 3526 2014-12-29 21:56:45Z bradbell $ +# $Id: check_include_omh.sh 3711 2015-08-20 14:57:57Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -20,7 +20,14 @@ echo "Checking difference between OMhelp include directives and file names." echo "----------------------------------------------------------------------" # super list of file names that are referenced by omhelp commands -bin/list_files.sh .c .cpp .hpp .omh .txt .am > bin/check_include_omh.1.$$ +bin/list_files.sh | sed -n \ + -e '/\.c$/p' \ + -e '/\.cpp$/p' \ + -e '/\.hpp$/p' \ + -e '/\.omh$/p' \ + -e '/\.txt$/p' \ + -e '/\.am$/p' \ + > bin/check_include_omh.1.$$ # # add *.sh files with omhelp documentation ls bin/get_*.sh >> bin/check_include_omh.1.$$ @@ -36,7 +43,7 @@ -e '/$childtable%/,/%$\$/p' \ -e '/$children%/,/%$\$/p' \ -e '/$contents%/,/%$\$/p' \ - -e '/$verbatim%/p' + -e '/$verbatim%/p' done sed < bin/check_include_omh.2.$$ > bin/check_include_omh.3.$$ \ -e 's/$childtable//' \ @@ -46,7 +53,7 @@ -e 's/%//' \ -e 's/$\$//' \ -e '/^ *$/d' \ - -e 's/^[ ]*//' \ + -e 's/^[ ]*//' \ -e 's|\\|/|g' # different="no" @@ -66,7 +73,8 @@ echo "-------------------------------------------------------------------" if [ $different = "yes" ] then - echo "Error: nothing should be between the two dashed lines above" + echo "Error: nothing should be between the two dashed lines above." + echo 'Perhaps this file is not and has not yet been added to repository ?' exit 1 else echo "Ok: nothing is between the two dashed lines above" diff -Nru cppad-2015.00.00.9/bin/check_jenkins.sh cppad-2016.00.00.1/bin/check_jenkins.sh --- cppad-2015.00.00.9/bin/check_jenkins.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_jenkins.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_jenkins.sh 2878 2013-07-29 17:42:41Z bradbell $ +# $Id: check_jenkins.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -36,4 +36,8 @@ echo_eval cd jenkins echo_eval svn update # ---------------------------------------------------------------------------- -echo_eval bin/jenkins.sh +redo_external='install' +echo_eval bin/jenkins.sh $redo_external +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/check_makefile.sh cppad-2016.00.00.1/bin/check_makefile.sh --- cppad-2015.00.00.9/bin/check_makefile.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_makefile.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_makefile.sh 3308 2014-05-26 14:29:01Z bradbell $ +# $Id: check_makefile.sh 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -17,9 +17,11 @@ fi # ----------------------------------------------------------------------------- echo "Checking include files listed in makefile.am" -echo "-------------------------------------------------------" -bin/list_files.sh .h .hpp | \ - sed -n -e '/cppad\//p' -e '/^cppad\/config\.h$/d' \ +echo "-------------------------------------------------------" +bin/list_files.sh .h .hpp | sed -n \ + -e '/^cppad\/deprecated\//d' \ + -e '/cppad\/.*\.h$/p' \ + -e '/cppad\/.*\.hpp$/p' \ > check_makefile.1.$$ echo 'cppad/configure.hpp' >> check_makefile.1.$$ sort -u check_makefile.1.$$ > check_makefile.2.$$ @@ -41,7 +43,7 @@ ok="no" fi rm check_makefile.*.$$ -echo "-------------------------------------------------------" +echo "-------------------------------------------------------" if [ "$ok" = "no" ] then echo "Error: nothing should be between the two dashed lines above" @@ -49,14 +51,14 @@ fi # ----------------------------------------------------------------------------- echo "Checking debugging flags in all makefile.am files." -echo "-------------------------------------------------------" +echo "-------------------------------------------------------" list=`find . -name makefile.am | \ sed -e '/\/build\//d' -e'/\/work\//d' -e 's|\./||'` ok="yes" for file in $list do case $file in - ( makefile.am | work/* | svn_dist/* ) + ( makefile.am | work/* | svn_dist/* ) ;; (multi_thread/makefile.am) @@ -130,7 +132,7 @@ ;; esac done -echo "-------------------------------------------------------" +echo "-------------------------------------------------------" if [ "$ok" = "yes" ] then echo "Ok: nothing is between the two dashed lines above" diff -Nru cppad-2015.00.00.9/bin/check_op_code.sh cppad-2016.00.00.1/bin/check_op_code.sh --- cppad-2015.00.00.9/bin/check_op_code.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_op_code.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_op_code.sh 3250 2014-05-14 15:31:30Z bradbell $ +# $Id: check_op_code.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -18,12 +18,15 @@ echo "bin/check_op_code.sh: checking that op codes are in alphabetical order:" # --------------------------------------------------------------------------- # check enum list of codes are in alphabetical order -sed -n -e '/^enum/,/^\tNumberOp$/p' cppad/local/op_code.hpp | \ - sed -e '/^enum/d' -e '/^\tNumberOp$/d' \ - -e 's/^[ ]*//' -e 's/Op[, ].*//' -e '/^\/\//d' > bin/op_code.1.$$ +sed -n -e '/^enum/,/^\tNumberOp /p' cppad/local/op_code.hpp | sed \ + -e '/^enum/d' \ + -e '/^\tNumberOp /d' \ + -e 's/^[ ]*//' \ + -e 's/Op[, ].*//' \ + -e '/^\/\//d' > bin/op_code.1.$$ # sort --ignore-case bin/op_code.1.$$ > bin/op_code.2.$$ -if ! diff bin/op_code.1.$$ bin/op_code.2.$$ +if ! diff bin/op_code.1.$$ bin/op_code.2.$$ then echo "check_op_code.sh: enum list is not in alphabetical order" rm bin/op_code.*.$$ @@ -34,12 +37,13 @@ sed -n -e '/NumArgTable\[\]/,/^[ \t]*};/p' cppad/local/op_code.hpp | \ sed \ -e '/NumArgTable\[\]/d' \ + -e '/NumberOp.*not used/d' \ -e '/^[ \t]*};/d' \ -e 's|^[ \t]*[0-9],* *// *||' \ -e 's|Op.*||' \ > bin/op_code.3.$$ # -if ! diff bin/op_code.1.$$ bin/op_code.3.$$ +if ! diff bin/op_code.1.$$ bin/op_code.3.$$ then echo "check_op_code.sh: NumArgTable list is not in alphabetical order" rm bin/op_code.*.$$ @@ -51,12 +55,12 @@ sed \ -e '/NumResTable\[\]/d' \ -e '/^[ \t]*};/d' \ - -e '/Last entry not used/d' \ + -e '/NumberOp.*not used/d' \ -e 's|^[ \t]*[0-9],* *// *||' \ -e 's|Op.*||' \ > bin/op_code.4.$$ # -if ! diff bin/op_code.1.$$ bin/op_code.4.$$ +if ! diff bin/op_code.1.$$ bin/op_code.4.$$ then echo "check_op_code.sh: NumResTable list is not in alphabetical order" echo "(or missing last line)" @@ -68,12 +72,13 @@ sed -n -e '/const char \*OpNameTable\[\]/,/^[ \t]*};/p' cppad/local/op_code.hpp | \ sed \ -e '/OpNameTable\[\]/d' \ + -e '/"Number".*not used/d' \ -e '/^[ \t]*};/d' \ -e 's|^[ \t]*"||' \ -e 's|".*||' \ > bin/op_code.5.$$ # -if ! diff bin/op_code.1.$$ bin/op_code.5.$$ +if ! diff bin/op_code.1.$$ bin/op_code.5.$$ then echo "check_op_code.sh: OpName list is not in alphabetical order" rm bin/op_code.*.$$ @@ -82,4 +87,6 @@ # ----------------------------------------------------------------------------- # clean up rm bin/op_code.*.$$ -echo "bin/check_op_code.sh: OK" +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/check_svn_id.sh cppad-2016.00.00.1/bin/check_svn_id.sh --- cppad-2015.00.00.9/bin/check_svn_id.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_svn_id.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_svn_id.sh 3495 2014-12-24 01:16:15Z bradbell $ +# $Id: check_svn_id.sh 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -17,26 +17,38 @@ fi # ----------------------------------------------------------------------------- echo "Checking for \$Id.*\$ in beginning of source code" -echo "-------------------------------------------------------" +echo "-------------------------------------------------------" ok="yes" -list=`bin/list_files.sh .hpp .cpp .omh .sh .in .am .txt | sed \ +list=`bin/list_files.sh | sed -n \ -e '/^gpl-3.0.txt$/d' \ -e '/^epl-v10.txt$/d' \ -e '/cppad\/local\/config.h.in$/d' \ -e '/^makefile.in$/d' \ -e '/^svn_commit.sh$/d' \ -e '/^git_commit.sh$/d' \ - -e '/\/makefile.in$/d' ` + -e '/\/makefile.in$/d' \ + -e '/\.hpp$/p' \ + -e '/\.cpp$/p' \ + -e '/\.omh$/p' \ + -e '/\.txt$/p' \ + -e '/\.sh$/p' \ + -e '/\.in$/p' \ + -e '/\.am$/p'` # for file in $list do - if ! head -2 $file | grep '$Id.*\$' > /dev/null + # deprecated link files have just one line + lines=`cat $file | wc -l` + if [ "$lines" != 1 ] then - echo "$file does not have '\$Id.*\$' in first two lines" - ok="no" + if ! head -2 $file | grep '$Id.*\$' > /dev/null + then + echo "$file does not have '\$Id.*\$' in first two lines" + ok="no" + fi fi done -echo "-------------------------------------------------------" +echo "-------------------------------------------------------" if [ "$ok" = "no" ] then echo "Error: nothing should be between the two dashed lines above" diff -Nru cppad-2015.00.00.9/bin/check_user_def.sh cppad-2016.00.00.1/bin/check_user_def.sh --- cppad-2015.00.00.9/bin/check_user_def.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_user_def.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,64 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +if [ $0 != "bin/check_user_def.sh" ] +then + echo "bin/check_user_def.sh: must be executed from its parent directory" + exit 1 +fi +# --------------------------------------------------------------------------- +echo 'Check user API preprocessor define symbols' +echo '-----------------------------------------------------------------------' +file_list=`bin/search.sh 'head CPPAD' | sed -e '/bin\/check_user_def.sh/d'` +symbol_list='' +for file in $file_list +do + symbol=`sed -n -e '/$head CPPAD/p' -e '/$subhead CPPAD/p' $file | sed \ + -e 's/^.*head \(CPPAD[a-zA-Z0-9_]*\).*/\1/'` + symbol_list="$symbol_list $symbol:$file" +done +for symbol_file in $symbol_list +do + symbol=`echo $symbol_file | sed -e 's|:.*||'` + file=`echo $symbol_file | sed -e 's|.*:||'` + if ! grep $symbol omh/preprocessor.omh > /dev/null + then + echo "The symbol $symbol" + echo "appears in $file omhelp documentation" + echo 'but does not appear in omh/preprocessor.omh' + exit 1 + fi +done +for symbol_file in $symbol_list +do + symbol=`echo $symbol_file | sed -e 's|:.*||'` + file=`echo $symbol_file | sed -e 's|.*:||'` + ok='false' + if grep "$symbol *in user api" cppad/local/undef.hpp > /dev/null + then + ok='true' + fi + if grep "$symbol *in deprecated api" cppad/local/undef.hpp > /dev/null + then + ok='true' + fi + if [ "$ok" == 'false' ] + then + echo "The symbol $symbol" + echo "appears in $file omhelp documentation" + echo "but is not listed as in user api in cppad/local/undef.hpp" + exit 1 + fi +done +echo '-----------------------------------------------------------------------' +echo "check_user_def.sh: OK" + diff -Nru cppad-2015.00.00.9/bin/check_verbatim.sh cppad-2016.00.00.1/bin/check_verbatim.sh --- cppad-2015.00.00.9/bin/check_verbatim.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/check_verbatim.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: check_verbatim.sh 3308 2014-05-26 14:29:01Z bradbell $ +# $Id: check_verbatim.sh 3770 2015-12-31 12:28:29Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -15,44 +15,70 @@ echo "bin/check_verbatim.sh: must be executed from its parent directory" exit 1 fi +cat << EOF > junk.sed +/\$verbatim[^a-z]/! b skip +N +s/^#[ \\t]// +s/^[ \\t]// +s/\\n#[ \\t]// +s/\\n[ \\t]// +s/\$verbatim%// +s/%.*// +p +: skip +EOF +special_case=' +bin/check_include_omh.sh +bin/check_verbatim.sh +bin/package.sh +cppad/local/cond_exp.hpp +introduction/exp_apx/exp_2.omh +introduction/exp_apx/exp_eps.omh +omh/license.omh +' # ----------------------------------------------------------------------------- # Make sure that OMhelp verbatim commands referr to same file as command -echo "Checking that OMhelp verbatim commands include from file they appear in." +echo "Checking that OMhelp verbatim commands include from file they appear in." echo "----------------------------------------------------------------------" -list=`bin/list_files.sh .c .cpp .hpp .omh .txt .am` +list=`bin/list_files.sh` different="no" -for file in $list +for file in $list do - line=`sed -n -e '/$verbatim[^a-z]/p' $file` - if [ "$line" != '' ] + ok='no' + for name in $special_case + do + if [ "$file" == "$name" ] + then + ok='yes' + fi + done + # + reference=`sed -n -f junk.sed $file` + if [ "$reference" == '' ] || [ "$reference" == "$file" ] + then + ok='yes' + fi + # + ext=`echo $file | sed -e 's|.*\.||'` + if [ "$ext" == 'omh' ] then - reference=`echo $line | sed -e 's|$verbatim%\([^%]*\)%.*|\1|'` - # - file_root=`echo $file | sed \ - -e 's|.*/||' -e 's|_hpp\.omh||' -e 's|\.[^.]*$||'` - # - ref_root=`echo $reference | sed \ - -e 's|.*/||' -e 's|\.[^.]*$||'` - # - if [ "$file_root" != "$ref_root" ] + file_root=`echo $file | sed -e 's|.*/||' -e 's|_hpp\.omh|.hpp|'` + ref_root=`echo $reference | sed -e 's|.*/||'` + if [ "$file_root" == "$ref_root" ] then - # special cases - ok='false' - if [ "$file_root" == 'cond_exp' ] && [ "$ref_root" == 'atan2' ] - then - ok='true' - fi - if [ "$file_root" == 'license' ] && [ "$ref_root" == 'epl-v10' ] - then - ok='true' - fi - # - if [ "$ok" == 'false' ] - then - echo "\$verbatim in $file references $reference" - different="yes" - fi + ok='yes' fi + file_root=`echo $file | sed -e 's|.*/||' -e 's|\.omh|.hpp|'` + if [ "$file_root" == "$ref_root" ] + then + ok='yes' + fi + fi + # + if [ "$ok" == 'no' ] + then + echo "\$verbatim in $file references $reference" + different="yes" fi done echo "-------------------------------------------------------------------" @@ -61,6 +87,6 @@ echo "Error: nothing should be between the two dashed lines above" exit 1 else - echo "Ok: nothing is between the two dashed lines above" + echo "OK: nothing is between the two dashed lines above" exit 0 fi diff -Nru cppad-2015.00.00.9/bin/clean_tar.sh cppad-2016.00.00.1/bin/clean_tar.sh --- cppad-2015.00.00.9/bin/clean_tar.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/clean_tar.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -62,10 +62,13 @@ for file in $list do echo_eval rm $file -done +done version=`date +%Y%m%d` name=`pwd | sed -e 's|.*/||'` cd .. cp -r $name $name-$version echo_eval tar -czf $name-$version.tgz $name-$version rm -rf $name-$version +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/colpack.sh cppad-2016.00.00.1/bin/colpack.sh --- cppad-2015.00.00.9/bin/colpack.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/colpack.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: colpack.sh 3115 2014-02-23 12:24:38Z bradbell $ +# $Id: colpack.sh 3768 2015-12-28 18:58:35Z bradbell $ if [ "$1" != 'forward' ] && [ "$1" != 'reverse' ] then - echo 'usage: ./colpack.sh option' - echo 'where option is "forward" or "reverse"' - exit 1 + echo 'usage: ./colpack.sh option' + echo 'where option is "forward" or "reverse"' + exit 1 fi if [ "$1" == 'forward' ] then @@ -25,7 +25,7 @@ fi echo 'create: build/colpack/colpack.cpp' cat<< EOF > build/colpack/colpack.cpp -// Example using BipartiteGraphPartialColoringInterface +// Example using BipartiteGraphPartialColoringInterface // to generate the seed matrix for Jacobian #include "ColPackHeaders.h" @@ -34,7 +34,7 @@ { size_t i, j, k; using std::cout; - using std::endl; + using std::endl; //* 32x9 matrix size_t i_RowCount = 32; @@ -104,14 +104,14 @@ } - // Step 1: Read the sparsity pattern of the given Jacobian matrix + // Step 1: Read the sparsity pattern of the given Jacobian matrix // (adolc format) and create the corresponding bipartite graph ColPack::BipartiteGraphPartialColoringInterface g( SRC_MEM_ADOLC, JP.data(), i_RowCount, i_ColumnCount ); g.PrintBipartiteGraph(); - // Step 2: Do Partial-Distance-Two-Coloring + // Step 2: Do Partial-Distance-Two-Coloring // of the bipartite graph with the specified ordering g.PartialDistanceTwoColoring( "SMALLEST_LAST", "$color_variant" @@ -122,7 +122,7 @@ // Step 3: From the coloring information, create and return seed matrix int ip1_SeedRowCount; int ip1_SeedColumnCount; - double** RSeed = + double** RSeed = g.GetSeedMatrix(&ip1_SeedRowCount, &ip1_SeedColumnCount); int rows = ip1_SeedRowCount; int cols = ip1_SeedColumnCount; @@ -150,3 +150,6 @@ -o colpack # echo_eval valgrind --leak-check=yes ./colpack +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/commit.sed cppad-2016.00.00.1/bin/commit.sed --- cppad-2015.00.00.9/bin/commit.sed 2014-01-07 14:37:12.000000000 +0000 +++ cppad-2016.00.00.1/bin/commit.sed 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -# Changes to be made at each commit (with the exception of */makefile.in) -# Note that bin/commit.sh and bin/commit.sed are also excluded. -# -# Change copyright second year to current year -s/Copyright (C) \([0-9]*\)-[0-9][0-9] Bradley M. Bell/Copyright (C) \1-14 Bradley M. Bell/ -s/Copyright (C) \([0-9]*\)-20[0-9][0-9] Bradley M. Bell/Copyright (C) \1-14 Bradley M. Bell/ diff -Nru cppad-2015.00.00.9/bin/commit.sh cppad-2016.00.00.1/bin/commit.sh --- cppad-2015.00.00.9/bin/commit.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/commit.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,253 +0,0 @@ -#! /bin/bash -e -# $Id: commit.sh 3214 2014-03-18 20:50:38Z bradbell $ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell -# -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. -# -# A copy of this license is included in the COPYING file of this distribution. -# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -# ----------------------------------------------------------------------------- -# INSTRUCTIONS: -# Directly below is where you specify which files are commited and make -# comments about the commit. Lines with no '@' characters, are general -# comments not connected to a specific file. Lines containing an '@' character -# are "file name" followed by a specific comment for that file. -cat << EOF > bin/commit.user.$$ -General comments about this commit go here (delete this line). - -dir/file.ext@ optional comment about this file. -EOF -# ----------------------------------------------------------------------------- -if [ ! -e "bin/commit.sh" ] -then - echo "bin/commit.sh: must be executed from its parent directory" - rm bin/commit.*.$$ - exit 1 -fi -# ----------------------------------------------------------------------- -if [ "$1" != 'list' ] && [ "$1" != 'edit' ] && [ "$1" != 'run' ] -then -cat << EOF -usage: bin/commit.sh list - bin/commit.sh edit - bin/commit.sh run - -list: -output a list of the files that have changes svn knows about. - -edit: -Edit the list of files at the top of bin/commit.sh to be the same as - bin/commit.sh list -would output. In addition, display the changes to bin/commit.sh. This -will include the new files in the list since the last edit of bin/commit.sh. -You should then by hand edit bin/commit.sh, to add comments about the changes. -See INSTRUCTIONS, at the beginning of this file: - -run: -commits changes to the list of files in bin/commit.sh -(provided that you reply y to the [y/n] prompt that bin/commit.sh generates). -The files bin/commit.sh and bin/commit.sed cannot be commited this way; use - svn commit -m "your log message" bin/commit.sh bin/commit.sed -for commits to these files. -EOF - rm bin/commit.*.$$ - exit 1 -fi -# ----------------------------------------------------------------------- -for file in bin/commit.sed -do - abort=`svn status $file` - if [ "$abort" != "" ] - then - echo "svn status $file" - svn status $file - echo "bin/commit.sh: aborting because $file changed" - rm bin/commit.*.$$ - exit 1 - fi -done -# ----------------------------------------------------------------------- -yy=`date +%y` -if ! grep "[-]$yy" bin/commit.sed > /dev/null -then - echo 'commit.sed worng year in it. Fix it and commit it separately' - exit 1 -fi -# ----------------------------------------------------------------------- -# check for abort do to unknown files -unknown=`svn status | sed -n -e '/^[?]/p' | \ - sed -e 's/^[?]//' -e "/bin\/commit.*.$$/d" -e '/\/new$/d'` -msg="aborting because the following files are unknown to svn" -print_msg="no" -for file in $unknown -do - if [ ! -e "$file.in" ] - then - if [ "$print_msg" == "no" ] - then - echo "bin/commit.sh: $msg" - print_msg="yes" - fi - echo $file - fi -done -if [ "$print_msg" == "yes" ] -then - rm bin/commit.*.$$ - exit 1 -fi -# ------------------------------------------------- -# list of files that changed -svn status | sed -n -e '/^[ADMRC][ADMRC]* /p' -e '/^ [ADMRC] /p' | \ - sed -e 's/^[ADMRC ][ADMRC ][+ ]*//' \ - -e '/^bin\/commit.sh$/d' -e '/^bin\/commit.sed$/d' | \ - sort -u > bin/commit.list.$$ -# ------------------------------------------------- -if [ "$1" == 'list' ] -then - cat bin/commit.list.$$ - rm bin/commit.*.$$ - exit 0 -fi -# ------------------------------------------------- -if [ "$1" == 'edit' ] -then - abort="no" - list=`cat bin/commit.list.$$` - for file in $list - do - # exclude */makefile.in from edits in bin/commit.sed - local_file=`echo $file | sed -e 's|.*/||'` - file_ext=`echo $file | sed -e 's|.*\.||'` - if [ -f "$file" ] && [ "$local_file" != "makefile.in" ] - then - sed -f bin/commit.sed $file > bin/commit.tmp.$$ - if ! diff $file bin/commit.tmp.$$ > /dev/null - then - echo "---------------------------------------" - echo "bin/commit.sh: automatic changes to $file:" - if diff $file bin/commit.tmp.$$ - then - echo "bin/commit.sh: program error" - rm bin/commit.*.$$ - exit 1 - fi - abort="yes" - if [ -x $file ] - then - mv bin/commit.tmp.$$ $file - chmod +x $file - else - mv bin/commit.tmp.$$ $file - fi - fi - fi - done - if [ "$abort" == "yes" ] - then - echo "bin/commit.sh: aborting because of automatic edits above." - echo "If these edits are ok, rerun bin/commit.sh edit" - rm bin/commit.*.$$ - exit 1 - fi - # - # use backslash so this instruction does not edit itself - echo 'cp bin/commit.sh bin/commit.sh.old' - cp bin/commit.sh bin/commit.sh.old - # - echo "creating new bin/commit.sh" - for file in $list - do - if ! grep "^$file@" bin/commit.sh > /dev/null - then - sed \ - -e "/^# INSTRUCTIONS/,/^EOF/s|^EOF|$file@\n&|" \ - -i bin/commit.sh - fi - done - # - # remove files that are no longer different - list=`sed -e '/@/! d' -e 's/@.*//' bin/commit.user.$$` - for file in $list - do - if ! grep "^$file\$" bin/commit.list.$$ > /dev/null - then - file=`echo $file | sed -e 's|/|\\\\/|g'` - sed -e "/^$file@/d" -i bin/commit.sh - fi - done - # - echo "------------------------------------" - echo "diff bin/commit.sh.old bin/commit.sh" - if diff bin/commit.sh.old bin/commit.sh - then - echo "bin/commit.sh edit: no changes to bin/commit.sh" - fi - echo "------------------------------------" - echo "chmod +x bin/commit.sh" - chmod +x bin/commit.sh - # - rm bin/commit.*.$$ - exit 0 -fi -# ----------------------------------------------------------------------- -if [ "$1" != 'run' ] -then - echo "bin/commit.sh: program error" - exit 1 -fi -list=`sed -e '/@/! d' -e 's/@.*//' bin/commit.user.$$` -msg=`sed -e '/@ *$/d' -e 's|.*/\([^/]*@\)|\1|' -e 's|@|:|' bin/commit.user.$$` -# -if (echo $list | grep 'bin/commit.sh$' > /dev/null) -then - echo "bin/commit.sh: cannot be used to commit changes to itself." - echo "remove it from the list of files in bin/commit.sh" - rm bin/commit.*.$$ - exit 1 -fi -# -if (echo $list | grep 'bin/commit.sed$' > /dev/null) -then - echo "bin/commit.sh: cannot be used to commit changes to bin/commit.sed" - echo "remove it from the list of files in bin/commit.sh" - rm bin/commit.*.$$ - exit 1 -fi -# -rm bin/commit.*.$$ -# -echo "svn commit -m \"" -echo "$msg" -echo "\" \\" -echo "$list" -read -p "is this ok [y/n] ?" response -if [ "$response" != "y" ] -then - exit 1 -fi -for file in $list -do - if [ -f $file ] - then - echo "svn propset svn:keywords \"Id\" $file" - svn propset svn:keywords "Id" $file - fi -done -# -if ! svn commit -m "$msg" $list -then - echo "bin/commit.sh: commit failed" - exit 1 -fi -# -echo "mv bin/commit.sh commit.sh.old" -mv bin/commit.sh commit.sh.old -# -echo "svn revert bin/commit.sh" -svn revert bin/commit.sh -# -exit 0 diff -Nru cppad-2015.00.00.9/bin/cygwin_package.sh cppad-2016.00.00.1/bin/cygwin_package.sh --- cppad-2015.00.00.9/bin/cygwin_package.sh 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/bin/cygwin_package.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: cygwin_package.sh 2506 2012-10-24 19:36:49Z bradbell $ +# $Id: cygwin_package.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -16,7 +16,7 @@ exit 1 fi # ----------------------------------------------------------------------------- -# experimental script for cygwin packaging of CppAD +# experimental script for cygwin packaging of CppAD # # version and release number # @@ -33,7 +33,7 @@ # # determine the most recent version in the Download directory # -version=`ls /cygdrive/c/Download/cppad-20*.gpl.tgz | +version=`ls /cygdrive/c/Download/cppad-20*.gpl.tgz | sed -n -e 's|.*/||' -e 's|cppad-||' -e 's|.gpl.tgz||' -e '$,$p'` if [ "$version" == 20061208 ] then @@ -50,7 +50,7 @@ exit 1 fi # -# extract the gpl version of the distribution +# extract the gpl version of the distribution # file="/cygdrive/c/Download/cppad-$version.gpl.tgz" if [ ! -e $file ] @@ -109,10 +109,10 @@ sdesc: "C++ algorithmic differentiation by operator overloading" # ldesc: "C++ algorithmic differentiation by operator overloading. -Forward and reverse mode as well as derivatives of arbitrary order +Forward and reverse mode as well as derivatives of arbitrary order are supported. See the documentation for this version ( /usr/share/doc/cppad-$version-$release/cppad.htm ) -or the CppAD home page +or the CppAD home page ( http://http://www.coin-or.org/CppAD/ ) for more details." EOF @@ -169,10 +169,10 @@ DOC/(installunix.xml or installunix.htm) Contains documentation for the configure options which can be used to build -the examples and tests for CppAD (using the source distribution). +the examples and tests for CppAD (using the source distribution). EOF # -# change configure.ac +# change configure.ac # echo "Begin: modify configure.ac and files that depend on it." echo "sed < cppad-$version-$release/configure.ac > configure.ac \\" @@ -191,7 +191,7 @@ exit 1 fi if ! cd cppad-$version-$release -then +then exit 1 fi if ! aclocal @@ -225,7 +225,7 @@ # create the cppad-$version.patch file # diff -N -r -u -p \ - ../cppad-$version cppad-$version-$release > cppad-$version.patch + ../cppad-$version cppad-$version-$release > cppad-$version.patch # # create the cppad-$version-$release/CYGWIN-PATCHES sub-directory # @@ -234,7 +234,7 @@ then exit 1 fi -if ! cp $readme_file cppad-$version-$release/CYGWIN-PATCHES/cppad.README +if ! cp $readme_file cppad-$version-$release/CYGWIN-PATCHES/cppad.README then exit 1 fi @@ -255,7 +255,7 @@ exit 1 fi echo "bzip2 -z -f cppad-$version-$release-src.tar" -if ! bzip2 -z -f cppad-$version-$release-src.tar +if ! bzip2 -z -f cppad-$version-$release-src.tar then exit 1 fi @@ -312,7 +312,7 @@ exit 1 fi echo "bzip2 -z -f cppad-$version-$release.tar" -if ! bzip2 -z -f cppad-$version-$release.tar +if ! bzip2 -z -f cppad-$version-$release.tar then exit 1 fi @@ -374,7 +374,7 @@ fi echo "cd ../.." if ! cd ../.. -then +then exit 1 fi dir="test_src/cppad-$version-$release/introduction/get_started" @@ -406,7 +406,7 @@ htm xml " -for file in $file_list +for file in $file_list do for ext in $ext_list do @@ -417,7 +417,7 @@ exit 1 fi done -done +done echo "End: test if source install" # # Test binary install -------------------------------------------------------- @@ -502,7 +502,7 @@ htm xml " -for file in $file_list +for file in $file_list do for ext in $ext_list do @@ -513,11 +513,11 @@ exit 1 fi done -done +done echo "End: test if binary install" # # Clean up ------------------------------------------------------------------ -# +# echo "cd .." if ! cd .. then @@ -544,7 +544,7 @@ exit 1 fi # +# ---------------------------------------------------------------------------- # Done -# echo bin/"cygwin_package.sh: passed all its tests" exit 0 diff -Nru cppad-2015.00.00.9/bin/dir_copy.sh cppad-2016.00.00.1/bin/dir_copy.sh --- cppad-2015.00.00.9/bin/dir_copy.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/dir_copy.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: dir_copy.sh 2683 2012-12-30 18:17:03Z bradbell $ +# $Id: dir_copy.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -15,7 +15,7 @@ echo "bin/dir_copy.sh: must be executed from its parent directory" exit 1 fi -if [ "$3" == "" ] +if [ "$3" == "" ] then echo "usage: bin/dir_copy.sh file_list direction dir" echo " file_list: a file containing a list of file names to copy," @@ -76,4 +76,6 @@ cp $directory/$path $path done fi +# ---------------------------------------------------------------------------- +echo "$0: OK" exit 0 diff -Nru cppad-2015.00.00.9/bin/doxyfile.sh cppad-2016.00.00.1/bin/doxyfile.sh --- cppad-2015.00.00.9/bin/doxyfile.sh 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/bin/doxyfile.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: doxyfile.sh 3238 2014-04-28 13:40:39Z bradbell $ +# $Id: doxyfile.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -25,11 +25,14 @@ version="$1" error_file="$2" output_directory="$3" +# PREDEFINED:see http://www.stack.nl/~dimitri/doxygen/manual/preprocessing.html # 2DO: change EXTRACT_ALL to NO so get warnings for undocumented functions. echo "create bin/doxyfile.$$" cat << EOF > bin/doxyfile.$$ ALWAYS_DETAILED_SEC = YES BUILTIN_STL_SUPPORT = YES +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES EXTRACT_ALL = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_PRIVATE = YES @@ -37,6 +40,7 @@ EXTRACT_ANON_NSPACES = YES FILE_PATTERNS = *.hpp *.cpp FULL_PATH_NAMES = NO +GENERATE_HTML = YES GENERATE_LATEX = NO GENERATE_TREEVIEW = YES INHERIT_DOCS = NO @@ -46,10 +50,14 @@ ./cppad/local \ ./cppad/ipopt \ ./cppad_ipopt/src \ + ./cppad_lib \ + ./cppad/utility \ ./speed/src LATEX_BATCHMODE = YES +MACRO_EXPANSION = YES MULTILINE_CPP_IS_BRIEF = YES OUTPUT_DIRECTORY = $output_directory +PREDEFINED = "__cplusplus=201103" "CPPAD_USE_CPLUSPLUS_2011=1" PROJECT_NAME = "CppAD: A C++ Algorithmic Differentiation Package" PROJECT_NUMBER = $version QT_AUTOBRIEF = YES @@ -84,3 +92,6 @@ # echo "rm bin/doxyfile.$$" rm bin/doxyfile.$$ +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/get_adolc.sh cppad-2016.00.00.1/bin/get_adolc.sh --- cppad-2015.00.00.9/bin/get_adolc.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/get_adolc.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: get_adolc.sh 3488 2014-12-19 12:04:15Z bradbell $ +# $Id: get_adolc.sh 3730 2015-09-23 15:56:53Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -19,15 +19,12 @@ # $$ # # $section Download and Install Adolc in Build Directory$$ -# $index adolc, download and install$$ -# $index download, install adolc$$ -# $index install, adolc$$ # # $head Syntax$$ # $code bin/get_adolc.sh$$ # # $head Purpose$$ -# If you are using Unix, this command will download and install +# If you are using Unix, this command will download and install # $href%https://projects.coin-or.org/ADOL-C%ADOL-C%$$ in the # CppAD $code build$$ directory. # @@ -36,7 +33,7 @@ # $code ColPack$$ (coloring algorithms used for sparse matrix derivatives). # # $head Distribution Directory$$ -# This command must be executed in the +# This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ @@ -74,7 +71,14 @@ # http://list.coin-or.org/pipermail/adol-c/2014-December/001023.html version='2.4.1' web_page="http://www.coin-or.org/download/source/ADOL-C" -prefix=`pwd`'/build/prefix' +cppad_dir=`pwd` +prefix="$cppad_dir/build/prefix" +installed_flag="build/external/adolc-${version}.installed" +if [ -e "$installed_flag" ] +then + echo "$installed_flag exists: Skipping get_adolc.sh" + exit 0 +fi # -------------------------------------------------------------------------- if [ -e /usr/lib64 ] then @@ -109,12 +113,7 @@ # ----------------------------------------------------------------------------- if which autoconf >& /dev/null then - ac_version=`autoconf --version | sed -n -e '/^autoconf/p' | \ - sed -e 's|[^0-9]*\([0-9.]*\)[.]\([0-9]*\).*|\1 * 100 + \2|' | bc` - if [ "$ac_version" -ge 267 ] - then - echo_eval autoreconf -f -i - fi + echo_eval autoreconf --install --force fi # ----------------------------------------------------------------------------- if [ ! -e build ] @@ -134,4 +133,5 @@ echo_eval ../configure $flags echo_eval make install # ----------------------------------------------------------------------------- +echo_eval touch $cppad_dir/$installed_flag echo "get_adolc: OK" diff -Nru cppad-2015.00.00.9/bin/get_colpack.sh cppad-2016.00.00.1/bin/get_colpack.sh --- cppad-2015.00.00.9/bin/get_colpack.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/get_colpack.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: get_colpack.sh 3017 2013-12-01 09:49:25Z bradbell $ +# $Id: get_colpack.sh 3730 2015-09-23 15:56:53Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -19,20 +19,17 @@ # $$ # # $section Download and Install ColPack in Build Directory$$ -# $index colpack, download and install$$ -# $index download, install colpack$$ -# $index install, colpack$$ # # $head Syntax$$ # $code bin/get_colpack.sh$$ # # $head Purpose$$ -# If you are using Unix, this command will download and install -# $href%http://www.cs.odu.edu/~dnguyen/dox/colpack/html/%ColPack%$$ in the +# If you are using Unix, this command will download and install +# $href%http://cscapes.cs.purdue.edu/dox/ColPack/html/%ColPack%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ -# This command must be executed in the +# This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ @@ -66,7 +63,14 @@ echo 'Download colpack to build/external and install it to build/prefix' version='1.0.9' web_page='http://cscapes.cs.purdue.edu/download/ColPack' -prefix=`pwd`'/build/prefix' +cppad_dir=`pwd` +prefix="$cppad_dir/build/prefix" +installed_flag="build/external/colpack-${version}.installed" +if [ -e "$installed_flag" ] +then + echo "$installed_flag exists: Skipping get_colpack.sh" + exit 0 +fi # -------------------------------------------------------------------------- if [ -e /usr/lib64 ] then @@ -96,7 +100,7 @@ then echo_eval rm aclocal.m4 ltmain.sh echo_eval libtoolize - echo_eval autoreconf --force + echo_eval autoreconf --install --force fi # ----------------------------------------------------------------------------- # @@ -116,4 +120,5 @@ # echo_eval make install # ----------------------------------------------------------------------------- +echo_eval touch $cppad_dir/$installed_flag echo "get_colpack: OK" diff -Nru cppad-2015.00.00.9/bin/get_eigen.sh cppad-2016.00.00.1/bin/get_eigen.sh --- cppad-2015.00.00.9/bin/get_eigen.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/get_eigen.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: get_eigen.sh 3658 2015-02-22 13:56:28Z bradbell $ +# $Id: get_eigen.sh 3730 2015-09-23 15:56:53Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -20,18 +20,18 @@ # $section Download and Install Eigen in Build Directory$$ # $index eigen, download and install$$ # $index download, install eigen$$ -# $index install, eigen$$ +# $index install, eigen$$ # # $head Syntax$$ # $code bin/get_eigen.sh$$ # # $head Purpose$$ -# If you are using Unix, this command will download and install +# If you are using Unix, this command will download and install # $href%http://eigen.tuxfamily.org%Eigen%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ -# This command must be executed in the +# This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ @@ -65,7 +65,14 @@ echo 'Download eigen to build/external and install it to build/prefix' version='3.2.0' web_page='https://bitbucket.org/eigen/eigen/get' -prefix=`pwd`'/build/prefix' +cppad_dir=`pwd` +prefix="$cppad_dir/build/prefix" +installed_flag="build/external/eigen-${version}.installed" +if [ -e "$installed_flag" ] +then + echo "$installed_flag exists: Skipping get_eigen.sh" + exit 0 +fi # ----------------------------------------------------------------------------- # determine which version of cmake to use cmake --version | sed -n \ @@ -123,7 +130,6 @@ echo_eval mv $git_name eigen-$version fi # ----------------------------------------------------------------------------- -# echo_eval cd eigen-$version if [ ! -e build ] then @@ -133,5 +139,6 @@ echo_eval $cmake_program .. -DCMAKE_INSTALL_PREFIX=$prefix echo_eval make install echo_eval ln -s $prefix/include/eigen3/Eigen $prefix/include/Eigen -# +# ----------------------------------------------------------------------------- +echo_eval touch $cppad_dir/$installed_flag echo "get_eigen.sh: OK" diff -Nru cppad-2015.00.00.9/bin/get_fadbad.sh cppad-2016.00.00.1/bin/get_fadbad.sh --- cppad-2015.00.00.9/bin/get_fadbad.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/get_fadbad.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: get_fadbad.sh 2915 2013-10-10 02:07:49Z bradbell $ +# $Id: get_fadbad.sh 3730 2015-09-23 15:56:53Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -19,18 +19,18 @@ # $section Download and Install Fadbad in Build Directory$$ # $index fadbad, download and install$$ # $index download, install fadbad$$ -# $index install, fadbad$$ +# $index install, fadbad$$ # # $head Syntax$$ # $code bin/get_fadbad.sh$$ # # $head Purpose$$ -# If you are using Unix, this command will download and install +# If you are using Unix, this command will download and install # $href%http://www.fadbad.com%Fadbad%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ -# This command must be executed in the +# This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ @@ -58,7 +58,14 @@ echo 'Download fadbad to build/external and install it to build/prefix' version='2.1' web_page='http://www.fadbad.com/download' -prefix=`pwd`'/build/prefix' +cppad_dir=`pwd` +prefix="$cppad_dir/build/prefix" +installed_flag="build/external/fadbad-${version}.installed" +if [ -e "$installed_flag" ] +then + echo "$installed_flag exists: Skipping get_fadbad.sh" + exit 0 +fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then @@ -84,5 +91,6 @@ echo_eval rm -r "$prefix/include/FADBAD++" fi echo_eval cp -r FADBAD++ "$prefix/include/FADBAD++" -# +# ----------------------------------------------------------------------------- +echo_eval touch $cppad_dir/$installed_flag echo "get_fadbad.sh: OK" diff -Nru cppad-2015.00.00.9/bin/get_ipopt.sh cppad-2016.00.00.1/bin/get_ipopt.sh --- cppad-2015.00.00.9/bin/get_ipopt.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/get_ipopt.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: get_ipopt.sh 3408 2014-11-27 15:17:20Z bradbell $ +# $Id: get_ipopt.sh 3730 2015-09-23 15:56:53Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -20,18 +20,18 @@ # $section Download and Install Ipopt in Build Directory$$ # $index ipopt, download and install$$ # $index download, install ipopt$$ -# $index install, ipopt$$ +# $index install, ipopt$$ # # $head Syntax$$ # $code bin/get_ipopt.sh$$ # # $head Purpose$$ -# If you are using Unix, this command will download and install +# If you are using Unix, this command will download and install # $href%http://www.coin-or.org/projects/Ipopt.xml%Ipopt%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ -# This command must be executed in the +# This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ @@ -65,7 +65,14 @@ echo 'Download ipopt to build/external and install it to build/prefix' version='3.11.9' web_page='http://www.coin-or.org/download/source/Ipopt' -prefix=`pwd`'/build/prefix' +cppad_dir=`pwd` +prefix="$cppad_dir/build/prefix" +installed_flag="build/external/ipopt-${version}.installed" +if [ -e "$installed_flag" ] +then + echo "$installed_flag exists: Skipping get_ipopt.sh" + exit 0 +fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then @@ -99,7 +106,7 @@ then echo_eval cd ThirdParty/$package echo_eval "./get.$package" - echo_eval touch "get.$package.done" + echo_eval touch "get.$package.done" echo_eval cd ../.. fi done @@ -114,8 +121,8 @@ echo_eval ./configure \ --enable-debug \ --prefix="$prefix" \ - --libdir="$prefix/$libdir" + --libdir="$prefix/$libdir" +echo_eval make install # ----------------------------------------------------------------------------- -echo_eval make install -# +echo_eval touch $cppad_dir/$installed_flag echo "get_ipopt.sh: OK" diff -Nru cppad-2015.00.00.9/bin/get_sacado.sh cppad-2016.00.00.1/bin/get_sacado.sh --- cppad-2015.00.00.9/bin/get_sacado.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/get_sacado.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: get_sacado.sh 3658 2015-02-22 13:56:28Z bradbell $ +# $Id: get_sacado.sh 3730 2015-09-23 15:56:53Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -21,18 +21,18 @@ # $section Download and Install Sacado in Build Directory$$ # $index sacado, download and install$$ # $index download, install sacado$$ -# $index install, sacado$$ +# $index install, sacado$$ # # $head Syntax$$ # $code bin/get_sacado.sh$$ # # $head Purpose$$ -# If you are using Unix, this command will download and install +# If you are using Unix, this command will download and install # $href%http://trilinos.sandia.gov/packages/sacado%Sacado%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ -# This command must be executed in the +# This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ @@ -64,9 +64,17 @@ } # ----------------------------------------------------------------------------- echo 'Download sacado to build/external and install it to build/prefix' -version="trilinos-11.12.1-Source" +version="11.12.1" +trilinos_dir="trilinos-$version-Source" web_page="http://trilinos.org/oldsite/download/files" -prefix=`pwd`'/build/prefix' +cppad_dir=`pwd` +prefix="$cppad_dir/build/prefix" +installed_flag="build/external/trilinos-${version}.installed" +if [ -e "$installed_flag" ] +then + echo "$installed_flag exists: Skipping get_sacado.sh" + exit 0 +fi # ----------------------------------------------------------------------------- # determine which version of cmake to use cmake --version | sed -n \ @@ -97,6 +105,7 @@ exit 1 fi # ----------------------------------------------------------------------------- +# libdir if [ -e /usr/lib64 ] then libdir='lib64' @@ -115,31 +124,50 @@ fi echo "coin_lapack_blas=$coin_lapack_blas" # ----------------------------------------------------------------------------- +# change into build/external directory if [ ! -d build/external ] then echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- -if [ ! -e "$version.tar.gz" ] +# create the trilions source directory and change into it +if [ ! -e "$trilinos_dir.tar.gz" ] then - echo_eval wget --no-check-certificate $web_page/$version.tar.gz + echo_eval wget --no-check-certificate $web_page/$trilinos_dir.tar.gz fi -for package in Sacado Teuchos Trilinois +for package in Sacado Teuchos Trilinois do echo_eval rm -rf $prefix/include/$package* -done -if [ ! -e "$version" ] +done +if [ ! -e "$trilinos_dir" ] then - echo_eval tar -xzf $version.tar.gz + echo_eval tar -xzf $trilinos_dir.tar.gz + # ------------------------------------------------------------------------ + # patch the cmake/tribits/modules/FindPythonInterp.cmake file + file="$trilinos_dir/cmake/tribits/modules/FindPythonInterp.cmake" + line='[HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\2.8\\\\' + line="${line}InstallPath]" + if [ -e "$file" ] + then + echo "patch $file" + sed \ + -e 's|NAMES \(python2.7 python2.6\)|NAMES python2.8 \1|' \ + -e "s|^\( *\)\[HKEY_LOCAL_MACHINE.*2\.7.*|\1$line\n&|" \ + -i $file + fi + # ------------------------------------------------------------------------ fi -# -echo_eval cd $version +echo_eval cd $trilinos_dir +# ----------------------------------------------------------------------------- +# change into build sub-directory if [ ! -e build ] then echo_eval mkdir build fi echo_eval cd build +# ----------------------------------------------------------------------------- +# cmake command and install if [ "$coin_lapack_blas" == 'yes' ] then echo_eval $cmake_program \ @@ -163,5 +191,6 @@ ../ fi echo_eval make install -# +# ----------------------------------------------------------------------------- +echo_eval touch $cppad_dir/$installed_flag echo "get_sacado.sh: OK" diff -Nru cppad-2015.00.00.9/bin/git_ignore.sh cppad-2016.00.00.1/bin/git_ignore.sh --- cppad-2015.00.00.9/bin/git_ignore.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/git_ignore.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -59,7 +59,7 @@ for name in $top_dir_list do echo "$name" | sed -e 's|^./||' -e 's|@|*|g' >> .gitignore -done +done echo '# all directories' >> .gitignore for name in $all_dir_list do @@ -77,6 +77,6 @@ echo "$dir/$name.*" | sed -e 's|^./||' -e 's|@|*|g' >> .gitignore done done -# +# ---------------------------------------------------------------------------- echo 'git_ignore.sh: OK' -exit 0 +exit 0 diff -Nru cppad-2015.00.00.9/bin/grep_source.sh cppad-2016.00.00.1/bin/grep_source.sh --- cppad-2015.00.00.9/bin/grep_source.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/grep_source.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e # \$Id:\$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -34,7 +34,7 @@ \( -name '*.sh' \) | \ sed -e 's|\./||' -e '/^work\//d' -e '/^svn_dist\//d' ` # -list="$list +list="$list configure.ac " if [ "$1" == "-i" ] @@ -54,3 +54,6 @@ grep $flag "$pattern" $file fi done +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/jenkins.sh cppad-2016.00.00.1/bin/jenkins.sh --- cppad-2015.00.00.9/bin/jenkins.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/jenkins.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: jenkins.sh 3658 2015-02-22 13:56:28Z bradbell $ +# $Id: jenkins.sh 3758 2015-11-30 15:29:22Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -15,17 +15,11 @@ echo "bin/jenkins.sh: must be executed from its parent directory" exit 1 fi -if [ "$1" != 'none' ] && [ "$1" != 'build' ] && [ "$1" != 'install' ] +if [ "$1" != '' ] then - echo 'bin/junk.sh: redo_external' - echo 'where redo_external is one of: build, install, none' - echo - echo 'build: download build and install all the externals' - echo 'install: reuse as much of previous build as possible' - echo 'none: uses the previous install (fastest option)' + echo 'bin/junk.sh no longer has any arguments' exit 1 fi -redo_external="$1" # ----------------------------------------------------------------------------- # distribution directory corresponding to this version of CppAD trunk_dir=`pwd` @@ -66,52 +60,37 @@ # ----------------------------------------------------------------------- g++ --version # ----------------------------------------------------------------------- -# Build and install external packages -if [ "$redo_external" != 'none' ] -then - # ------------------------------------------------------------------- - # this comand cleans out the previous install for all externals - echo_eval rm -rf build/prefix - # ------------------------------------------------------------------- - if [ "$redo_extrnal" == 'build' ] - then - # This command causes a new download, and compile for all externals - echo_eval rm -rf build/external - fi - # ------------------------------------------------------------------- - # Running bin/get_fadbad.sh will install include files in - # $trunk_dir/build/prefix/include/FADBAD++ - log_eval bin/get_fadbad.sh - # ------------------------------------------------------------------- - # Running bin/get_eigen.sh will install include files in - # $trunk_dir/build/prefix/include/Eigen - log_eval bin/get_eigen.sh - # ------------------------------------------------------------------- - # Running bin/get_ipopt.sh will install include files in - # $trunk_dir/build/prefix/include/coin - # and library files in - # $trunk_dir/build/prefix/$libdir - # where $libdir is 'lib64' if /usr/lib64 exists and 'lib' otherwise. - log_eval bin/get_ipopt.sh - # ------------------------------------------------------------------- - # Running bin/get_sacado.sh will install include files in - # $trunk_dir/build/prefix/include - # and library files in - # $trunk_dir/build/prefix/$libdir - log_eval bin/get_sacado.sh - # ------------------------------------------------------------------- - # Running bin/get_colpack.sh will install library files in - # $trunk_dir/build/prefix/$libdir - log_eval bin/get_colpack.sh - # ------------------------------------------------------------------- - # Running bin/get_acolc.sh will install include files in - # $trunk_dir/build/prefix/include/adolc - # and library files in - # $trunk_dir/build/prefix/$libdir - log_eval bin/get_adolc.sh - # ------------------------------------------------------------------- -fi -# ----------------------------------------------------------------------- +# Running bin/get_fadbad.sh ensures its include files are in +# $trunk_dir/build/prefix/include/FADBAD++ +log_eval bin/get_fadbad.sh +# ------------------------------------------------------------------- +# Running bin/get_eigen.sh ensures its include files are in +# $trunk_dir/build/prefix/include/Eigen +log_eval bin/get_eigen.sh +# ------------------------------------------------------------------- +# Running bin/get_ipopt.sh ensures its include files are in +# $trunk_dir/build/prefix/include/coin +# and library files in +# $trunk_dir/build/prefix/$libdir +# where $libdir is 'lib64' if /usr/lib64 exists and 'lib' otherwise. +log_eval bin/get_ipopt.sh +# ------------------------------------------------------------------- +# Running bin/get_sacado.sh ensures its include files are in +# $trunk_dir/build/prefix/include +# and library files in +# $trunk_dir/build/prefix/$libdir +log_eval bin/get_sacado.sh +# ------------------------------------------------------------------- +# Running bin/get_colpack.sh ensures its library files are in +# $trunk_dir/build/prefix/$libdir +log_eval bin/get_colpack.sh +# ------------------------------------------------------------------- +# Running bin/get_acolc.sh ensures its include files are in +# $trunk_dir/build/prefix/include/adolc +# and library files in +# $trunk_dir/build/prefix/$libdir +log_eval bin/get_adolc.sh +# ------------------------------------------------------------------- system_name=`uname | sed -e 's|\(......\).*|\1|'` if [ "$system_name" == 'CYGWIN' ] then @@ -120,7 +99,7 @@ export LD_LIBRARY_PATH="$trunk_dir/build/prefix/$libdir" fi # ----------------------------------------------------------------------- -# Use trunk_dir/../build to build and test CppAD (no reuse) +# Use trunk_dir/build/auto_tools to build and test CppAD (no reuse) echo_eval cd build echo_eval rm -rf auto_tools echo_eval mkdir auto_tools diff -Nru cppad-2015.00.00.9/bin/list_files.sh cppad-2016.00.00.1/bin/list_files.sh --- cppad-2015.00.00.9/bin/list_files.sh 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/bin/list_files.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,43 +1,32 @@ #! /bin/bash -e -# $Id: list_files.sh 3308 2014-05-26 14:29:01Z bradbell $ +# $Id: list_files.sh 3770 2015-12-31 12:28:29Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- +# list files in repository (not deleted) +# ----------------------------------------------------------------------------- if [ $0 != "bin/list_files.sh" ] then echo "bin/list_files.sh: must be executed from its parent directory" exit 1 fi -# -if [ "$1" == '' ] -then -cat << EOF -usage: list_files.sh ext_1 [ ext_2 ... ] - -lists files with the specified extensions excluding those of the form: -*/new/*, build/*, doc/*, doxydoc/*, */test_one.cpp, /junk\$ext, */temp\$ext - -where \$ext takes the values ext_1, ext_2, ... -File and directory names do not begin with './'. -EOF -fi -for ext in $* +# ----------------------------------------------------------------------------- +list=`git ls-files` +git ls-files -d > list_files.$$ +for file in $list do - # should change '.' to '[.]' before executing sed comand below - find . -name "*$ext" | sed \ - -e '/[/]new[/]/d' \ - -e '/build[/]/d' \ - -e '/doc[/]/d' \ - -e '/doxydoc[/]/d' \ - -e '/[/]test_one.cpp$/d' \ - -e "/[/]junk$ext"'$/d' \ - -e "/[/]temp$ext"'$/d' \ - -e 's|^[.]/||' + if ! grep "$file" list_files.$$ > /dev/null + then + echo $file + fi done +rm list_files.$$ +# ---------------------------------------------------------------------------- +exit 0 diff -Nru cppad-2015.00.00.9/bin/mv_branch.sh cppad-2016.00.00.1/bin/mv_branch.sh --- cppad-2015.00.00.9/bin/mv_branch.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/mv_branch.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,136 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +if [ "$0" != "bin/mv_branch.sh" ] +then + echo 'bin/mv_branch.sh: must be executed from its parent directory' + exit 1 +fi +if [ ! -e '.git/svn' ] +then + echo 'bin/mv_branch.sh: must be executed in the git_svn repository' + exit 1 +fi +if [ "$2" == '' ] +then + echo 'usage: bin/mv_branch.sh old_branch_name new_branch_name' + exit 1 +fi +old_branch_name="$1" +new_branch_name="$2" +repository='https://projects.coin-or.org/svn/CppAD' +old_branch_path="branches/$old_branch_name" +new_branch_path="branches/$new_branch_name" +# ----------------------------------------------------------------------------- +# bash function that echos and executes a command +pause() { + response='' + while [ "$response" != 'y' ] && [ "$response" != 'n' ] + do + read -p 'Continue [y/n] ' response + done + if [ "$response" != 'y' ] + then + exit 1 + fi +} +echo_eval() { + echo $* + eval $* +} +# ----------------------------------------------------------------------------- +if [ "$old_branch_name" == "$new_branch_name" ] +then + echo "mv_branch.sh: old and new branch names are the same" + exit 1 +fi +for branch_path in $old_branch_path $new_branch_path +do + for name in 'master' 'trunk' + do + if [ "$branch_path" == "$name" ] + then + echo "mv_branch.sh: neither old or new branch path can be $name" + exit 1 + fi + done +done +old_fetch="$old_branch_path:refs/remotes/svn/$old_branch_path" +if ! grep "fetch *= *$old_fetch" .git/config > /dev/null +then + echo "mv_branch.sh: cannot find $old_branch_path in ./git/config" + exit 1 +fi +svn_remote_dir=".git/svn/refs/remotes/svn" +dir=`echo $new_branch_path | sed -e 's|/[^/]*$||'` +if [ ! -e "$svn_remote_dir/$dir" ] +then + echo 'mv_branch.sh: Must first create the directory' + echo " $svn_remote_dir/$dir" + exit 1 +fi +dir=`echo $new_branch_name | sed -e 's|/.*||'` +if [ "$dir" != "$new_branch_name" ] +then + if ! svn list $repository/branches | grep "$dir/" > /dev/null + then + echo 'mv_branch.sh: Must frist create the directory' + echo " $repository/branches/$dir" + fi +fi +# ----------------------------------------------------------------------------- +# make sure repsitories are in sync +echo_eval git fetch github +echo "git show-ref --hash $old_branch_name | head -1" +git show-ref --hash $old_branch_name | head -1 +echo_eval git show-ref --hash github/$old_branch_name +pause +# ----------------------------------------------------------------------------- +# svn +msg="Moving $old_branch_path to $new_branch_path" +cmd="svn mv $repository/$old_branch_path $repository/$new_branch_path" +echo "$cmd -m \"$msg\"" +$cmd -m "$msg" +pause +# ---------------------------------------------------------------------------- +# change the name locally +echo_eval git branch -m $old_branch_name $new_branch_name +pause +# ---------------------------------------------------------------------------- +# change the remote github name for the branch +echo_eval git push github --set-upstream $new_branch_name +echo_eval git push github :$old_branch_name +pause +# ---------------------------------------------------------------------------- +# change the remote svn name for the branch +# +# backup current version of .git/config +index='1' +while [ -e .git/config.$index ] +do + index=`expr $index + 1` +done +echo_eval cp .git/config .git/config.$index +# +# change the svn fetch command +new_fetch="$new_branch_path:refs/remotes/svn/$new_branch_path" +# +sed -e "s|$old_fetch|$new_fetch|" -i .git/config +echo_eval diff .git/config.$index .git/config +pause +# +# move the svn fetch infromation +svn_remote_dir=".git/svn/refs/remotes/svn" +echo_eval mv $dir/$old_branch_path $dir/$new_branch_path +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/new_branch.sh cppad-2016.00.00.1/bin/new_branch.sh --- cppad-2015.00.00.9/bin/new_branch.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/new_branch.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,111 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +if [ "$0" != "bin/new_branch.sh" ] +then + echo 'bin/new_branch.sh: must be executed from its parent directory' + exit 1 +fi +if [ "$1" == '' ] || [ "$2" == 'trunk' ] +then + echo 'usage: bin/new_branch.sh svn_branch_path' + echo 'copies the current trunk to svn_branch_path' + exit 1 +fi +svn_branch_path="$1" +# ----------------------------------------------------------------------------- +# bash function that echos and executes a command +echo_eval() { + echo $* + eval $* +} +# ----------------------------------------------------------------------------- +# some settings +svn_repository='https://projects.coin-or.org/svn/CppAD' +work_directory='build/work' +# ----------------------------------------------------------------------------- +# check that remote master is in sync +hash_origin=`git show-ref origin/master | sed -e 's|^\([0-9a-f]*\).*|\1|'` +hash_list=`git show-ref master | sed -e 's|^\([0-9a-f]*\).*|\1|'` +for hash in $hash_list +do + if [ "$hash" != "$hash_origin" ] + then + echo_eval git show-ref master + echo 'exiting because hash codes are different' + exit 1 + fi +done +# ----------------------------------------------------------------------------- +# make sure work directory exists +if [ ! -d "$work_directory" ] +then + echo_eval mkdir -p "$work_directory" +fi +# ----------------------------------------------------------------------------- +# checkout svn version of directory +svn_directory="$work_directory/svn" +if [ -e "$svn_directory" ] +then + echo 'Use existing svn direcory' + echo " $svn_directory" + read -p '? [y/n] ' response + if [ "$response" != 'y' ] + then + echo_eval rm -r $svn_directory + else + echo_eval svn revert --recursive $svn_directory + echo_eval svn update $svn_directory + svn_status=`svn status $svn_directory | \ + sed -n -e '/^\?/p' | sed -e 's|^\? *||'` + for file_name in $svn_status + do + echo_eval rm $file_name + done + fi +fi +if [ ! -e "$svn_directory" ] +then + echo_eval svn checkout $svn_repository/trunk $svn_directory +fi +# ---------------------------------------------------------------------------- +# git hash code corresponding to current version of trunk +svn_revision=`svn info $svn_directory | \ + sed -n -e '/^Last Changed Rev:/p' | sed -e 's|^Last Changed Rev: *||'` +hash_svn=`svn log -r $svn_revision $svn_directory | \ + sed -n -e '/^end *hash *code:/p' | sed -e 's|^end *hash *code: *||'` +if [ "$hash_origin" != "$hash_svn" ] +then + echo "$hash_origin hash code for master" + echo "$hash_svn hash code for trunk" + echo 'Exiting because hash codes are different.' + echo 'Use the following command to fix this' + echo ' bin/push_git2svn.py trunk' + exit 1 +fi +# ----------------------------------------------------------------------------- +echo_eval git checkout master +git_branch_name=`echo $svn_branch_path | sed -e 's|^branches/||'` +echo_eval git branch $git_branch_name +echo_eval git checkout $git_branch_name +git push --set-upstream origin $git_branch_name +# ----------------------------------------------------------------------------- +cat << EOF > $svn_directory/new_branch.log +copy trunk to: $svn_branch_path +start hash code: $hash_origin +end hash code: $hash_origin +EOF +echo_eval svn copy --file new_branch.log \ + $svn_repository/trunk $svn_repository/$svn_branch_path +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/new_release.sh cppad-2016.00.00.1/bin/new_release.sh --- cppad-2015.00.00.9/bin/new_release.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/new_release.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: new_release.sh 3661 2015-02-23 22:19:20Z bradbell $ +# $Id: new_release.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -23,7 +23,7 @@ # ----------------------------------------------------------------------------- svn_repository="https://projects.coin-or.org/svn/CppAD" stable_version="20150000" -release='9' +release='4' release_version="$stable_version.$release" # ----------------------------------------------------------------------------- # Check release version @@ -106,7 +106,7 @@ then echo_eval mkdir -p build fi -echo_eval cd build +echo_eval cd build echo_eval svn checkout $svn_repository/conf conf # echo_eval cd conf @@ -119,3 +119,6 @@ # echo "Use the command the following command to finish the process" echo " svn commit -m \"$msg\" build/conf/projDesc.xml" +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/new_stable.sh cppad-2016.00.00.1/bin/new_stable.sh --- cppad-2015.00.00.9/bin/new_stable.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/new_stable.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: new_stable.sh 3510 2014-12-27 20:39:05Z bradbell $ +# $Id: new_stable.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -10,6 +10,9 @@ # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- +echo 'Need to change this from using git-svn to using push_git2svn.sh' +echo 'See bin/new_release.sh.' +exit 1 if [ "$0" != "bin/new_stable.sh" ] then echo "bin/new_stable.sh: must be executed from its parent directory" @@ -35,9 +38,9 @@ rep_trunk="$repository/trunk" rep_stable="$repository/stable/$stable_version" # ----------------------------------------------------------------------------- -if [ "$copy_from_trunk" = "redo" ] +if [ "$copy_from_trunk" = "redo" ] then - # delete old stable copy + # delete old stable copy msg="Replacing old stable/$stable_version." echo "svn delete $rep_stable -m \"$msg\"" svn delete $rep_stable -m "$msg" @@ -60,18 +63,18 @@ then sed -e "s|^\turl *=.*|&\n\tfetch = $fetch|" -i .git/config fi -# +# # fetch the branch echo_eval git svn fetch # ----------------------------------------------------------------------------- # checkout the new stable version -if git branch | grep "$stable_version" +if git branch | grep "$stable_version" then git checkout $stable_version else echo_eval git checkout -b $stable_version svn/stable/$stable_version fi -# make sure that bin/new_stable.sh corresponds to current master version +# make sure that bin/new_stable.sh corresponds to current master version # (may not be same as version in repository that was copied). echo_eval git show master:bin/new_stable.sh > bin/new_stable.sh # @@ -90,21 +93,23 @@ echo "automatic editing: $stable_version/build.sh" sed -i build.sh -e 's/^version_type=.*/version_type="stable"/' # -# Set download documentation to use web version of corresponding release +# Set download documentation to use web version of corresponding release echo "automatic editing of omh/install/download.omh" dir="http://www.coin-or.org/download/source/CppAD" sed -i omh/install/download.omh \ - -e "s|cppad-$release_version.[eg]pl.tgz|\n$dir/&%\n&|" + -e "s|cppad-$release_version.[eg]pl.tgz|\n$dir/&%\n&|" # # Instructions -------------------------------------------------------------- cat << EOF -1: Review differences using git. If you find problems, fix both +1: Review differences using git. If you find problems, fix both master and $new_stable versions of bin/new_stable.sh. 3: Run the following commands: bin/check_all.sh -4: If errors occur, fix both master and $new_stable version of +4: If errors occur, fix both master and $new_stable version of bin/new_stable.sh and goto 3. 5: Run the script - bin/new_release.sh + bin/new_release.sh EOF +# ---------------------------------------------------------------------------- +echo "$0: OK" exit 0 diff -Nru cppad-2015.00.00.9/bin/new_test.sh cppad-2016.00.00.1/bin/new_test.sh --- cppad-2015.00.00.9/bin/new_test.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/new_test.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: new_test.sh 2506 2012-10-24 19:36:49Z bradbell $ +# $Id: new_test.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -31,10 +31,10 @@ file=`echo $file_path | sed -e 's|.*/||'` # echo "cd $dir" -cd $dir +cd $dir # # extract the program that runs all tests and name of this new test -program=`sed -n -e '/_SOURCES/p' makefile.am | +program=`sed -n -e '/_SOURCES/p' makefile.am | sed -e 's|^\t*\(.*\)_SOURCE.*|\1|'` name=`grep '^bool *[a-zA-Z0-9_]*( *void *)' $file | tail -1 | \ sed -e 's|^bool *\([a-zA-Z0-9_]*\)( *void *)|\1|'` @@ -96,3 +96,6 @@ echo echo "Should hand edit to sort new entries in following files:" echo "$change_list" +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/package.sh cppad-2016.00.00.1/bin/package.sh --- cppad-2015.00.00.9/bin/package.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/package.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: package.sh 3494 2014-12-22 14:10:44Z bradbell $ +# $Id: package.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -59,24 +59,15 @@ echo_log_eval bin/version.sh get echo_log_eval bin/version.sh copy # ---------------------------------------------------------------------------- -# Run automated checking of file names in original source directory -# (check_include_omh.sh uses files built by cmake) -list=" - check_define.sh - check_example.sh - check_if.sh - check_include_def.sh - check_include_file.sh - check_include_omh.sh - check_makefile.sh - check_op_code.sh - check_replace.sh - check_svn_id.sh - check_verbatim.sh -" -for check in $list +# Run automated checks for the form bin/check_*.sh with a few exceptions. +# Note that check_include_omh.sh uses files built by cmake. +list=`ls bin/check_* | sed \ + -e '/check_all.sh/d' \ + -e '/check_jenkins.sh/d' \ + -e '/check_svn_dist.sh/d'` +for check in $list do - echo_log_eval bin/$check + echo_log_eval $check done # ---------------------------------------------------------------------------- # Check for doxygen errors @@ -98,40 +89,7 @@ echo_log_eval mkdir -p $package_dir # ----------------------------------------------------------------------------- # Source file that are coppied to the package directory -file_list=`find . \ - \( -name '*.ac' \) -or \ - \( -name '*.am' \) -or \ - \( -name '*.c' \) -or \ - \( -name '*.cmake' \) -or \ - \( -name '*.cpp' \) -or \ - \( -name '*.h' \) -or \ - \( -name '*.hpp' \) -or \ - \( -name '*.html' \) -or \ - \( -name '*.in' \) -or \ - \( -name '*.omh' \) -or \ - \( -name '*.pc' \) -or \ - \( -name '*.py' \) -or \ - \( -name '*.sed' \) -or \ - \( -name '*.sh' \) -or \ - \( -name '*.txt' \) | sed \ - -e '/\/new\//d' \ - -e '/\.\/build\//d' \ - -e '/bug\/build\//d' \ - -e '/\/junk\.[a-z]*$/d' \ - -e '/\/temp\.[a-z]*$/d' \ - -e 's|^\./||'` -other_files=" - AUTHORS - ChangeLog - configure - config.guess - config.sub - COPYING - depcomp - INSTALL - NEWS - README -" +file_list=`bin/list_files.sh` # # Copy the files, creating sub-directories when necessary echo_log_eval echo "copy files to $package_dir" @@ -148,11 +106,11 @@ log_eval cp $file $package_dir/$file done echo_log_eval echo "remove certain files from $package_dir" -for file in $remove_list +for file in $remove_list do if [ -e $package_dir/$file ] then - echo_log_eval rm $package_dir/$file + echo_log_eval rm $package_dir/$file fi done # ---------------------------------------------------------------------------- @@ -162,7 +120,7 @@ # Only include the *.xml verison of the documentation in distribution # So remove the table at the top (but save the original doc.omh file). if ! grep < doc.omh > /dev/null \ - 'This comment is used to remove the table below' + 'This comment is used to remove the table below' then echo "Missing comment expected in doc.omh" exit 1 @@ -198,3 +156,6 @@ fi echo_log_eval bin/gpl_license.sh cppad-$version build build fi +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/proj_desc.py cppad-2016.00.00.1/bin/proj_desc.py --- cppad-2015.00.00.9/bin/proj_desc.py 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/proj_desc.py 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,179 @@ +#! /bin/python3 +# $Id +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +# dictionary of replacements +# +import collections +replace_dict = collections.OrderedDict() +replace_dict['projectName'] = 'CppAD' +replace_dict['projectRepo'] = 'CppAD' +# +replace_dict['projectDescription'] = ''' +Given a C++ algorithm that computes function values, +CppAD generates an algorithm that computes corresponding derivative values. +''' +# +replace_dict['projectShortDescription'] =''' +A tool for differentiation of C++ functions. +''' +# +replace_dict['projectManager'] ='Brad Bell, http://www.seanet.com/~bradbell' +replace_dict['projectHomePage'] = 'http://www.coin-or.org/CppAD' +# +replace_dict['projectLicense'] = ''' +Eclipse Public License 1.0, or GNU General Public License 3.0 +''' +replace_dict['projectLicenseURL'] = ''' +http://www.opensource.org/licenses/alphabetica +''' +replace_dict['coinLinkedProjects'] = '' +replace_dict['projectLanguage'] = 'C++' +replace_dict['activityStatus'] = 'Active' +replace_dict['maturityLevel'] = '4' +replace_dict['stableVersionNumber'] = '20150000' +replace_dict['releaseNumber'] = '20150000.8' +replace_dict['projectCategories'] = 'Optimization utility' +replace_dict['documentation'] = 'http://www.coin-or.org/CppAD/Doc' +replace_dict['sourceCodeDownload'] = ''' +http://www.coin-or.org/download/source/CppAD +''' +replace_dict['mailingList'] = ''' +http://list.coin-or.org/mailman/listinfo/cppad +''' +# ---------------------------------------------------------------------------- +# +# +other_package = collections.OrderedDict( [ +('ADOL-C', 'http://www.coin-or.org/projects/ADOL-C.xml'), +('Boost uBlas vector', 'http://www.boost.org/doc/libs'), +('Boost Thread', 'http://www.boost.org/doc/libs'), +('ColPack', 'http://cscapes.cs.purdue.edu/dox/ColPack/html'), +('Eigen', 'http://eigen.tuxfamily.org'), +('FADBAD', 'http://www.fadbad.com/fadbad.htm'), +('Ipopt', 'http://www.coin-or.org/projects/Ipopt.xml'), +('OpenMP', 'http://openmp.org/wp'), +('Pthread', + 'http,//pubs.opengroup.org/onlinepubs/009695399/basedefs/pthread.h.html'), +('Sacado', 'http://trilinos.org/packages/sacado') +] ) +text='\n' +for name in other_package : + url = other_package[name] + text += ' \n' + text += ' ' + name + '\n' + text += ' ' + url + '\n' + text += ' Optional\n' + text += ' \n' +replace_dict['otherLinkedPackages'] = text +# ----------------------------------------------------------------------------- +# +tested_platform = collections.OrderedDict( [ +('Linux', 'gcc'), +('Cygwin', 'gcc'), +('Microsoft Windows', 'MSVC++') +] ) +text='\n' +for system in tested_platform : + compiler = tested_platform[system] + text += ' \n' + text += ' ' + system + '\n' + text += ' ' + compiler + '\n' + text += ' \n' +replace_dict['testedPlatforms'] = text +# ----------------------------------------------------------------------------- +import sys +import re +import os +import subprocess +# ----------------------------------------------------------------------------- +# command line arguments +usage = '\tbin/proj_desc.py\n' +narg = len(sys.argv) +if sys.argv[0] != 'bin/proj_desc.py' : + msg = 'bin/proj_desc.py must be executed from its parent directory' + sys.exit(usage + msg) +if narg != 1 : + msg = 'expected 0 but found ' + str(narg-1) + ' command line arguments' + sys.exit(usage + msg) +# ----------------------------------------------------------------------------- +def system_cmd(cmd) : + try : + output = subprocess.check_output( + cmd, + stderr=subprocess.STDOUT, + shell=True + ) + except subprocess.CalledProcessError as info : + msg = str( info.output , 'ascii' ) + msg += '\nbin/proj_desc.py exiting because command above failed' + sys.exit(msg) + return str( output, 'ascii' ) +# ----------------------------------------------------------------------------- +# update cppad_conf_dir +# +cppad_conf_dir = os.environ['HOME'] + '/cppad.svn/conf' +if os.path.exists(cppad_conf_dir ) : + cmd = 'svn update ' + cppad_conf_dir + print( cmd ) +else : + cmd = 'svn checkout https://projects.coin-or.org/svn/CppAD/conf ' + cmd += cppad_conf_dir + print( cmd ) +# ----------------------------------------------------------------------------- +# get the current verison of the file +# +file_name = cppad_conf_dir + '/projDesc.xml' +file_ptr = open(file_name, 'r') +file_data = file_ptr.read() +file_ptr.close() +# ----------------------------------------------------------------------------- +# Do the replacemnets +# +# fix stableVersionNumber and releaseNumber (remove enclosing comment block) +pattern = '' +replace = '' +file_data = re.sub(pattern, replace, file_data) +# +for key in replace_dict : + value = replace_dict[key] + start = '<' + key + '>' + end = '' + pattern = '[ \t]*' + start + '[a-zA-Z\s]*' + end + replace = start + value + end + file_data = re.sub(pattern, replace, file_data) +# +# projectCategories is a special case +key = 'projectCategories' +value = replace_dict[key] +start = '<' + key + '>' +end = '' +pattern = '[ \t]*' + start + '[ \t]*' +file_data = re.sub(pattern, replace, file_data) +# +pattern = '[ \t]*' + end + '[ \t]*' +replace = start + '\n \n ' +replace += value + '\n \n' + end +file_data = re.sub(pattern, replace, file_data) +# ----------------------------------------------------------------------------- +# replace input file +file_name = cppad_conf_dir + '/projDesc.xml' +file_ptr = open(file_name, 'w') +file_ptr.write(file_data) +file_ptr.close() +# ----------------------------------------------------------------------------- +msg = 'check results in\n\t' + file_name + '\nand then execute' +msg += '\n\tsvn commit -m "see bin/proj_desc.py" \\\n\t' + file_name +print(msg) + diff -Nru cppad-2015.00.00.9/bin/push_git2svn.py cppad-2016.00.00.1/bin/push_git2svn.py --- cppad-2015.00.00.9/bin/push_git2svn.py 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/bin/push_git2svn.py 2016-02-09 08:31:58.000000000 +0000 @@ -4,18 +4,30 @@ # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# imports from __future__ import print_function +# ----------------------------------------------------------------------------- +# list of svn commands to execute in the svn directory before make changes +# indicated by git directory; some example commands are included below +svn_commands = [ + # 'svn mkdir cppad/utility', + # 'svn move cppad/*.hpp cppad/utility', + # 'svn move cppad/utility/cppad.hpp cppad/cppad.hpp', + # 'svn move cppad/utility/base_require.hpp cppad/base_require.hpp', + # 'svn move omh/library.omh omh/utility.omh' +] +# ----------------------------------------------------------------------------- +# imports import sys import os import re import subprocess +import pdb # ----------------------------------------------------------------------------- # command line arguments usage = '\tbin/push_git2svn.py svn_branch_path\n' @@ -71,6 +83,15 @@ msg += '\nbin/push_git2svn.py exiting because command above failed' sys.exit(msg) return output + +id_pattern = re.compile(r'^.*\$Id.*$', re.MULTILINE) +white_pattern = re.compile(r'[ \t]+$', re.MULTILINE) +date_pattern = re.compile(r'2003-[0-9][0-9]', re.MULTILINE) +def ignore_data(data) : + data = re.sub(id_pattern, '', data) + data = re.sub(white_pattern, '', data) + data = re.sub(date_pattern, '', data) + return data # ----------------------------------------------------------------------------- # determine git_branch_name if svn_branch_path == 'trunk' : @@ -84,7 +105,7 @@ git_branch_path = 'branches/' + svn_branch_path # ----------------------------------------------------------------------------- # hash code for the git branch -cmd = 'git show-ref origin/' + git_branch_name +cmd = 'git show-ref origin/' + git_branch_name git_hash_code = system(cmd) pattern = ' refs/remotes/origin/' + git_branch_name git_hash_code = git_hash_code.replace(pattern, '') @@ -96,7 +117,7 @@ # checkout svn version of directory svn_directory = work_directory + '/svn' if os.path.isdir(svn_directory) : - question = 'Use existing svn directory:\n\t' + question = 'Use existing svn directory:\n\t' question += svn_directory + '\n' question += 'or remove it and check out a new copy ? [use/new] ' choice_list = [ 'use' , 'new' ] @@ -124,6 +145,13 @@ cmd += svn_repository + '/' + svn_branch_path + ' ' + svn_directory print_system(cmd) # ---------------------------------------------------------------------------- +tmp = os.getcwd() +os.chdir( svn_directory ) +for cmd in svn_commands : + assert cmd.startswith('svn') + print_system(cmd) +os.chdir( tmp ) +# ---------------------------------------------------------------------------- # git hash code corresponding to verison in svn directory cmd = 'svn info ' + svn_directory svn_info = system(cmd) @@ -151,10 +179,14 @@ # list of files for the svn and git directories svn_pattern = re.compile(svn_directory + '/') svn_file_list = [] +svn_dir_list = [] for directory, dir_list, file_list in os.walk(svn_directory) : ok = ( directory.find('/.svn/') == -1 ) ok = ok and ( not directory.endswith('/.svn') ) if ok : + if directory != svn_directory : + local_name = re.sub(svn_pattern, '', directory) + svn_dir_list.append(local_name) for name in file_list : local_name = directory + '/' + name local_name = re.sub(svn_pattern, '', local_name) @@ -162,56 +194,76 @@ # git_pattern = re.compile(git_directory + '/') git_file_list = [] +git_dir_list = [] for directory, dir_list, file_list in os.walk(git_directory) : index = directory.find('/.svn/') assert index == -1 + if directory != git_directory : + local_name = re.sub(git_pattern, '', directory) + git_dir_list.append(local_name) for name in file_list : local_name = directory + '/' + name local_name = re.sub(git_pattern, '', local_name) git_file_list.append( local_name ) # ----------------------------------------------------------------------------- # list of files that have been created and deleted -created_list=[] +created_file_list=[] for name in git_file_list : if not name in svn_file_list : - created_list.append(name) + created_file_list.append(name) # -deleted_list=[] +deleted_file_list=[] for name in svn_file_list : if not name in git_file_list : - deleted_list.append(name) - + deleted_file_list.append(name) +# ----------------------------------------------------------------------------- +# list of directories that have been created and deleted +created_dir_list=[] +for name in git_dir_list : + if not name in svn_dir_list : + created_dir_list.append(name) +# +deleted_dir_list=[] +for name in svn_dir_list : + if not name in git_dir_list : + deleted_dir_list.append(name) # ----------------------------------------------------------------------------- # automated svn commands -id_pattern = re.compile(r'^.*\$Id.*$', re.MULTILINE) # -for git_file in created_list : +for git_dir in created_dir_list : + cmd = 'svn mkdir ' + svn_directory + '/' + git_dir + print_system(cmd) +# +for git_file in created_file_list : git_f = open(git_directory + '/' + git_file, 'rb') git_data = git_f.read() git_f.close() - git_data = re.sub(id_pattern, '', git_data) + git_data = ignore_data(git_data) # found = False - for svn_file in deleted_list : + for svn_file in deleted_file_list : svn_f = open(svn_directory + '/' + svn_file, 'rb') svn_data = svn_f.read() svn_f.close() - svn_data = re.sub(id_pattern, '', svn_data) + svn_data = ignore_data(svn_data) # if svn_data == git_data : assert not found cmd = 'svn copy ' + svn_directory + '/' + svn_file + ' \\\n\t' cmd += svn_directory + '/' + git_file print_system(cmd) + cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' + cmd += svn_directory + '/' + git_file + system(cmd) found = True if not found : cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' - cmd += svn_directory + '/' + git_file + cmd += svn_directory + '/' + git_file system(cmd) cmd = 'svn add ' + svn_directory + '/' + git_file print_system(cmd) # -for svn_file in deleted_list : +for svn_file in deleted_file_list : svn_file_path = svn_directory + '/' + svn_file if os.path.isfile(svn_file_path) : cmd = 'svn delete --force ' + svn_file_path @@ -219,23 +271,27 @@ # for git_file in git_file_list : do_cp = True - do_cp = do_cp and git_file not in created_list + do_cp = do_cp and git_file not in created_file_list if git_file in svn_file_list : git_f = open(git_directory + '/' + git_file, 'rb') git_data = git_f.read() git_f.close() - git_data = re.sub(id_pattern, '', git_data) + git_data = ignore_data(git_data) # svn_f = open(svn_directory + '/' + git_file, 'rb') svn_data = svn_f.read() svn_f.close() - svn_data = re.sub(id_pattern, '', svn_data) + svn_data = ignore_data(svn_data) # do_cp = do_cp and git_data != svn_data if do_cp : cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' - cmd += svn_directory + '/' + git_file + cmd += svn_directory + '/' + git_file system(cmd) +# +for svn_dir in deleted_dir_list : + cmd = 'svn rm ' + svn_directory + '/' + svn_dir + print_system(cmd) # ----------------------------------------------------------------------------- data = 'merge to branch: ' + svn_branch_path + '\n' data += 'from repository: ' + git_repository + '\n' diff -Nru cppad-2015.00.00.9/bin/reduce_index.py cppad-2016.00.00.1/bin/reduce_index.py --- cppad-2015.00.00.9/bin/reduce_index.py 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/reduce_index.py 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,146 @@ +#! /bin/python3 +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +import sys +import os +import re +# ----------------------------------------------------------------------------- +# list of words that should be excluded from mindex comamnds +exclude_list = 'a an and as at by for in of or to'.split() +# ----------------------------------------------------------------------------- +def split_words(string) : + pattern = '(\s|,)' + replace = ' ' + string = re.sub(pattern, replace, string) + return string.split() +# ----------------------------------------------------------------------------- +if sys.argv[0] != 'bin/reduce_index.py' : + msg = 'bin/reduce_index.py: must be executed from its parent directory' + sys.exit(msg) +# +usage = 'usage: reduce_index.py file_name' +narg = len(sys.argv) +if narg != 2 : + msg = '\n\tFound ' + str(narg-1) + ' command line arguments (expected 1).' + sys.exit(usage + msg) +file_name = sys.argv[1] +# ----------------------------------------------------------------------------- +if not os.path.exists(file_name) : + msg = 'bin/reduce_index.py: cannot find file_name = ' + file_name + sys.exit(msg) +f_in = open(file_name, 'r') +file_data = f_in.read() +f_in.close() +f_out = open(file_name, 'w') +# ----------------------------------------------------------------------------- +# some useful patterns +begin_pattern = re.compile('[$]begin ([^$]*)[$][$]') +end_pattern = re.compile('[$]end') +section_pattern = re.compile('[$](section)\s([^$]*)[$][$]') +index_pattern = re.compile('[$][mc]{0,1}(index) ([^$]*)[$][$]') +cmd_pattern = re.compile('[$]([a-z]*) ([^$]*)[$][$]') +# ----------------------------------------------------------------------------- +def remove_index_cmd(string) : + result = str() + rest = string + next_index = index_pattern.search(rest) + while next_index != None : + result += rest[ : next_index.start() ] + rest = rest[ next_index.end() : ] + if len(rest) > 0 : + if rest[0] == '\n' : + rest = rest[1 : ] + next_index = index_pattern.search(rest) + result += rest + return result +# +# for each omhelp section in the file +file_rest = file_data +while len(file_rest) > 0 : + # start of this section + next_begin = begin_pattern.search(file_rest) + if next_begin == None : + f_out.write( file_rest ) + file_rest = str() + else : + # end of this section + next_end = end_pattern.search(file_rest) + if next_end == None : + sys.exit( 'No $end after' + next_begin(0) ) + if next_end.end() < next_begin.end() : + sys.exit( 'No $end after' + next_begin(0) ) + # data for this section + section_data = file_rest [ : next_end.end() ] + file_rest = file_rest [ next_end.end() : ] + # + # get list of automatically generated index words for this section + section_rest = section_data + auto_list = list() + while len(section_rest) > 0 : + next_cmd = cmd_pattern.search(section_rest) + if next_cmd == None : + section_rest = str() + else : + section_rest = section_rest[ next_cmd.end() : ] + cmd = next_cmd.group(1) + if cmd in [ 'section', 'head', 'subhead' ] : + for word in split_words( next_cmd.group(2) ) : + auto_list.append( word.lower() ) + # + # list of index words not in automatically generated list + section_rest = section_data + index_list = list() + exclude_list += auto_list + for word in auto_list : + if word.endswith('s') : + exclude_list.append( word[: -1] ) + else : + exclude_list.append( word + 's' ) + while len(section_rest) > 0 : + next_index = index_pattern.search(section_rest) + if next_index == None : + section_rest = str() + else : + section_rest = section_rest[ next_index.end() : ] + for word in split_words( next_index.group(2) ) : + word_lower = word.lower() + if not ( word_lower in exclude_list ) : + index_list.append(word) + exclude_list.append(word_lower) + # keep words that are not in start of other words + keep_index = list() + for word_1 in index_list : + ok_1 = True + for word_2 in index_list : + if word_2.startswith(word_1 + '_') : + ok_1 = False + if word_2.endswith('_' + word_1) : + ok_1 = False + if ok_1 : + keep_index.append(word_1) + # + # write out data to the end of section command + section_cmd = section_pattern.search(section_data) + data = remove_index_cmd( section_data[ : section_cmd.end() ] ) + f_out.write( data ) + if len(keep_index) > 0 : + index_cmd = '$mindex' + for word in keep_index : + index_cmd += ' ' + word + index_cmd += '$$' + f_out.write( '\n' + index_cmd ) + data = remove_index_cmd( section_data[ section_cmd.end() : ] ) + f_out.write( data ) +# ----------------------------------------------------------------------------- +f_out.close() +print('reduce_index.py OK: ' + file_name ) +sys.exit(0) diff -Nru cppad-2015.00.00.9/bin/reduce_index.sh cppad-2016.00.00.1/bin/reduce_index.sh --- cppad-2015.00.00.9/bin/reduce_index.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/reduce_index.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,40 @@ +#! /bin/bash -e +# $Id:$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +if [ $0 != "bin/reduce_index.sh" ] +then + echo "bin/reduce_index.sh: must be executed from its parent directory" + exit 1 +fi +if [ "$1" == '' ] +then + echo 'usage: bin/reduce_index.sh days' + echo ' where days is an integer, runs bin/reduce_index.py' + echo 'on all files checked in within the specified number of days.' +fi +days="$1" +list=`git log --pretty=format: --name-only --since="$days days ago" | sed \ + -e '/^ *$/d' \ + -e '/^makefile\./d' -e '/\/makefile\./d' \ + -e '/^CMakeLists.txt/d' -e '/\/CMakeLists.txt/d' \ + -e '/^bin\/reduce_index.py/d'` +for file in $list +do + if [ -e $file ] + then + git checkout $file + bin/reduce_index.py $file + fi +done +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/run_cmake.sh cppad-2016.00.00.1/bin/run_cmake.sh --- cppad-2015.00.00.9/bin/run_cmake.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/run_cmake.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: run_cmake.sh 3526 2014-12-29 21:56:45Z bradbell $ +# $Id: run_cmake.sh 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -25,12 +25,38 @@ verbose='no' standard='c++11' debug_speed='no' +deprecated='no' profile_speed='no' clang='no' +no_colpack='no' +no_ipopt='no' +no_sparse_list='no' +no_documentation='no' testvector='boost' while [ "$1" != "" ] do - if [ "$1" == '--verbose' ] + if [ "$1" == '--help' ] + then + cat << EOF +usage: bin/run_cmake.sh: \\ + [--help] \\ + [--verbose] \\ + [--c++98] \\ + [--debug_speed] \\ + [--deprecated] \\ + [--profile_speed] \\ + [--clang ] \\ + [--no_colpack] \\ + [--no_ipopt] \\ + [--no_sparse_list] \\ + [--no_documentation] \\ + [--_vector] +The --help option just prints this message and exits. +The value above must be one of: cppad, boost, or eigen. + +EOF + exit 0 + elif [ "$1" == '--verbose' ] then verbose='yes' elif [ "$1" == '--c++98' ] @@ -40,6 +66,9 @@ then debug_speed='yes' profile_speed='no' + elif [ "$1" == '--deprecated' ] + then + deprecated='yes' elif [ "$1" == '--profile_speed' ] then profile_speed='yes' @@ -47,6 +76,18 @@ elif [ "$1" == '--clang' ] then clang='yes' + elif [ "$1" == '--no_colpack' ] + then + no_colpack='yes' + elif [ "$1" == '--no_ipopt' ] + then + no_ipopt='yes' + elif [ "$1" == '--no_sparse_list' ] + then + no_sparse_list='yes' + elif [ "$1" == '--no_documentation' ] + then + no_documentation='yes' elif [ "$1" == '--cppad_vector' ] then testvector='cppad' @@ -57,17 +98,7 @@ then testvector='eigen' else - cat << EOF -usage: bin/run_cmake.sh: \\ - [--verbose] \\ - [--c++98] \\ - [--debug_speed] \\ - [--profile_speed] \\ - [--clang ] \\ - [--_vector] - -where is cppad, boost, or eigen -EOF + echo "$1 is an invalid option, try bin/run_cmake.sh --help" exit 1 fi shift @@ -76,13 +107,11 @@ if [ "$debug_speed" == 'yes' ] then sed -e 's|^SET(CMAKE_BUILD_TYPE .*|SET(CMAKE_BUILD_TYPE DEBUG)|' \ - -i speed/CMakeLists.txt -elif [ "$profile_speed" == 'yes' ] -then - sed -e 's|^SET(CMAKE_BUILD_TYPE .*|SET(CMAKE_BUILD_TYPE MinSizeRel)|' \ + -e 's|^# SET(CMAKE_CXX_FLAGS_DEBUG|SET(CMAKE_CXX_FLAGS_DEBUG|' \ -i speed/CMakeLists.txt else sed -e 's|^SET(CMAKE_BUILD_TYPE .*|SET(CMAKE_BUILD_TYPE RELEASE)|' \ + -e 's|^SET(CMAKE_CXX_FLAGS_DEBUG|# SET(CMAKE_CXX_FLAGS_DEBUG|' \ -i speed/CMakeLists.txt fi # --------------------------------------------------------------------------- @@ -91,6 +120,10 @@ echo_eval mkdir build fi echo_eval cd build +if [ -e CMakeCache.txt ] +then + echo_eval rm CMakeCache.txt +fi # --------------------------------------------------------------------------- # clean all variables in cmake cache cmake_args='-U .+' @@ -98,11 +131,11 @@ if [ "$verbose" == 'yes' ] then # echo each command that make executes - cmake_args="$cmake_args -D CMAKE_VERBOSE_MAKEFILE=1" + cmake_args="$cmake_args -D CMAKE_VERBOSE_MAKEFILE=YES" fi # ----------------------------------------------------------------------------- -# cmake_install_prefix -cmake_args="$cmake_args -D cmake_install_prefix=$HOME/prefix/cppad" +# cppad_prefix +cmake_args="$cmake_args -D cppad_prefix=$HOME/prefix/cppad" # # cmake_install_includedirs if [ -d '/usr/include' ] @@ -114,6 +147,11 @@ if [ -d '/usr/share' ] then cmake_args="$cmake_args -D cmake_install_datadir=share" +fi +# +# cmake_install_docdir +if [ -d '/usr/share' ] && [ "$no_documentation" == 'no' ] +then cmake_args="$cmake_args -D cmake_install_docdir=share/doc" fi # @@ -127,7 +165,16 @@ fi # # {package}_prefix -for package in fadbad colpack adolc eigen ipopt sacado +package_list='fadbad adolc eigen sacado' +if [ "$no_colpack" == 'no' ] +then + package_list="$package_list colpack" +fi +if [ "$no_ipopt" == 'no' ] +then + package_list="$package_list ipopt" +fi +for package in $package_list do dir=$HOME/prefix/$package if [ -d "$dir" ] @@ -136,11 +183,19 @@ fi done # +# sparse_list +if [ "$no_sparse_list" == 'yes' ] +then + cmake_args="$cmake_args -D cppad_sparse_list=NO" +else + cmake_args="$cmake_args -D cppad_sparse_list=YES" +fi +# # cppad_cxx_flags cppad_cxx_flags="-Wall -pedantic-errors -std=$standard" if [ "$testvector" != 'eigen' ] then - cppad_cxx_flags="$cppad_cxx_flags -Wshadow" + cppad_cxx_flags="$cppad_cxx_flags -Wshadow" fi cmake_args="$cmake_args -D cppad_cxx_flags='$cppad_cxx_flags'" # @@ -151,9 +206,21 @@ cmake_args="$cmake_args -D CMAKE_CXX_COMPILER=clang++" fi # +# profile +if [ "$profile_speed" == 'yes' ] +then + cmake_args="$cmake_args -D cppad_profile_flag=-pg" +fi +# +# deprecated +if [ "$deprecated" == 'yes' ] +then + cmake_args="$cmake_args -D cppad_deprecated=YES" +else + cmake_args="$cmake_args -D cppad_deprecated=NO" +fi +# # simple options -cmake_args="$cmake_args -D cppad_implicit_ctor_from_any_type=NO" -cmake_args="$cmake_args -D cppad_sparse_list=YES" cmake_args="$cmake_args -D cppad_testvector=$testvector" cmake_args="$cmake_args -D cppad_tape_id_type='int32_t'" cmake_args="$cmake_args -D cppad_tape_addr_type=int32_t" @@ -161,4 +228,6 @@ # echo_eval cmake $cmake_args .. # +# ---------------------------------------------------------------------------- +echo "$0: OK" exit 0 diff -Nru cppad-2015.00.00.9/bin/search.sh cppad-2016.00.00.1/bin/search.sh --- cppad-2015.00.00.9/bin/search.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/search.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: search.sh 3212 2014-03-18 13:05:24Z bradbell $ +# $Id: search.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -22,21 +22,12 @@ exit 1 fi pattern="$1" -dir_list=' - bin - cppad - cppad_ipopt - example - introduction - multi_thread - omh - pkgconfig - print_for - speed - test_more -' -# -grep -l -r "$pattern" $dir_list | \ - sed -e '/\/makefile.in/d' -e '/test_one.exe/d' -e '/\/new\//d' -grep -l "$pattern" makefile.am CMakeLists.txt doc.omh | \ - sed -e '/\/makefile.in/d' -e '/test_one.exe/d' -e '/\/new\//d' +# ----------------------------------------------------------------------------- +list=`bin/list_files.sh | sed \ + -e '/^configure$/d' \ + -e '/^makefile.in$/d' \ + -e '/\/makefile.in$/d' \ + -e '/^compile/d'` +grep -l "$pattern" $list +# ---------------------------------------------------------------------------- +exit 0 diff -Nru cppad-2015.00.00.9/bin/special_version.sh cppad-2016.00.00.1/bin/special_version.sh --- cppad-2015.00.00.9/bin/special_version.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/special_version.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: special_version.sh 2506 2012-10-24 19:36:49Z bradbell $ +# $Id: special_version.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -93,8 +93,8 @@ file='cppad/configure.hpp' text="# define CPPAD_PACKAGE_STRING" svn revert $file -echo "sed -i $file -e \"s|^$text.*|\1 \"cppad-$version\"|\"" -sed -i $file -e "s|^\($text\) .*|\1 \"cppad-$version\"|" +echo "sed -i $file -e \"s|^$text.*|\1 \"cppad-$version\"|\"" +sed -i $file -e "s|^\($text\) .*|\1 \"cppad-$version\"|" # echo "mkdir work ; cd work" mkdir work ; cd work @@ -108,9 +108,12 @@ read -p "options: " options echo "../configure $options" read -p "Is this ok [y/n] ?" response -done +done echo "../configure $options" ../configure $options # echo "cd multi_thread ; make test" cd multi_thread ; make test +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/speed_branch.sh cppad-2016.00.00.1/bin/speed_branch.sh --- cppad-2015.00.00.9/bin/speed_branch.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/speed_branch.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,84 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +if [ ! -e "bin/speed_branch.sh" ] +then + echo "bin/speed_branch.sh: must be executed from its parent directory" + exit 1 +fi +if [ "$2" == '' ] +then +cat << EOF +usage: bin/speed_branch.sh branch_one branch_two [option_1 [option_2 ...] ] +where the possible options are: + onetape, colpack, optimize, atomic, memory, boolsparsity, colpack +EOF + exit 1 +fi +branch_one="$1" +branch_two="$2" +# ---------------------------------------------------------------------------- +shift +shift +option_list='none' +for option in $* +do + if [ "$option_list" == 'none' ] + then + option_list="$option" + else + option_list="${option_list}_$option" + fi +done +# ---------------------------------------------------------------------------- +# bash function that echos and executes a command +echo_eval() { + echo $* + eval $* +} +# ----------------------------------------------------------------------------- +if [ ! -d '.git' ] +then + echo 'speed_branch.sh: only implemented for git repository' + exit 1 +fi +# ----------------------------------------------------------------------------- +dir='build/speed/cppad' +for branch in $branch_one $branch_two +do + if [ -e "build/speed/cppad/$branch.$option_list.out" ] + then + echo "Using existing build/speed/cppad/$branch.$option_list.out" + else + echo_eval git checkout $branch + # + echo "bin/run_cmake.sh > $branch.log" + bin/run_cmake.sh > $branch.log + # + cd $dir + # + echo "make check_speed_cppad >> $branch.log" + make check_speed_cppad >> ../../../$branch.log + # + echo "./speed_cppad speed 123 $* > $branch.$option_list.out" + ./speed_cppad speed 123 $* > $branch.$option_list.out + # + cd ../../.. + fi +done +# compare the results +echo " one=$branch_one , two=$branch_two" +bin/speed_diff.sh \ + $dir/$branch_one.$option_list.out $dir/$branch_two.$option_list.out +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/speed_diff.sh cppad-2016.00.00.1/bin/speed_diff.sh --- cppad-2015.00.00.9/bin/speed_diff.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/speed_diff.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: speed_diff.sh 3488 2014-12-19 12:04:15Z bradbell $ +# $Id: speed_diff.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -51,3 +51,6 @@ # cat speed_diff.$$ | sort -u rm speed_diff.$$ +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/speed_new.sh cppad-2016.00.00.1/bin/speed_new.sh --- cppad-2015.00.00.9/bin/speed_new.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/speed_new.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: speed_new.sh 3463 2014-12-12 10:59:18Z bradbell $ +# $Id: speed_new.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ cat << EOF usage: bin/speed_new.sh option_1 option_2 ... where the possible options are: - onetape, colpack, optimize, atomic, memory, boolsparsity + onetape, colpack, optimize, atomic, memory, boolsparsity, colpack Use the special value 'none' for no options EOF exit 1 @@ -41,7 +41,19 @@ echo "It contains new source code for the cppad/local (can be empty)." exit 1 fi -# Source code files that are changing +# ----------------------------------------------------------------------------- +if [ -d '.git' ] +then + revert_cmd='git checkout' +elif [ -d .svn ] +then + revert_cmd='svn revert' +else + echo 'speed_new.sh: Cannot find ./.git or ./.svn' + exit 1 +fi +# ----------------------------------------------------------------------------- +# Source code files that are changing new_cppad=`cd cppad/new ; ls` new_local=`cd cppad/local/new ; ls` if [ "$new_cppad" == "" ] && [ "$new_local" == "" ] @@ -58,8 +70,8 @@ then for file in $new_cppad do - echo "svn revert cppad/$file" - if ! svn revert cppad/$file + echo "$revert_cmd cppad/$file" + if ! $revert_cmd cppad/$file then echo "assuming cppad/$file not in repository" fi @@ -70,8 +82,8 @@ then for file in $new_local do - echo "svn revert cppad/local/$file" - if ! svn revert cppad/local/$file + echo "$revert_cmd cppad/local/$file" + if ! $revert_cmd cppad/local/$file then echo "assuming cppad/local/$file not in repository" fi @@ -83,7 +95,7 @@ cd build; make check_speed_cppad; cd speed/cppad # # run speed test for the current version - echo "./speed_cppad speed 123 $tmp $* > cur_speed.out" + echo "./speed_cppad speed 123 $* > cur_speed.out" ./speed_cppad speed 123 $* > cur_speed.out # echo "cd ../../.." @@ -137,3 +149,6 @@ # echo "cat run.out | sort -u" cat run.out | sort -u +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/svn_ignore.sh cppad-2016.00.00.1/bin/svn_ignore.sh --- cppad-2015.00.00.9/bin/svn_ignore.sh 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/bin/svn_ignore.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: svn_ignore.sh 3492 2014-12-21 16:23:41Z bradbell $ +# $Id: svn_ignore.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -43,4 +43,6 @@ svn propset svn:ignore --recursive -F bin/svn_ignore.$$ . rm bin/svn_ignore.$$ # -exit 0 +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/svn_merge.sh cppad-2016.00.00.1/bin/svn_merge.sh --- cppad-2015.00.00.9/bin/svn_merge.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/svn_merge.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,7 +1,7 @@ #! /bin/bash -e -# $Id: svn_merge.sh 3301 2014-05-24 05:20:21Z bradbell $ +# $Id: svn_merge.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -31,7 +31,7 @@ # accept='--accept theirs-full' # accept='' accept='--accept theirs-full' -# +# # Location of the repository repository='https://projects.coin-or.org/svn/CppAD' # @@ -40,14 +40,14 @@ # # Version of the repository corresponding to from_branch just before changes Start=3219 -# +# # Version of the repository corresponding to from_branch after the changes End=3300 # # the svn merge command cmd="svn merge $accept $dry_run -r $Start:$End $repository/$from_branch" echo "$cmd" -eval $cmd +eval $cmd # # restore original version of this file mv bin/svn_merge.sh.$$ bin/svn_merge.sh @@ -55,3 +55,6 @@ # get the current status echo "svn status > svn_merge.log" svn status > svn_merge.log +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/tag_month.sh cppad-2016.00.00.1/bin/tag_month.sh --- cppad-2015.00.00.9/bin/tag_month.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bin/tag_month.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,96 @@ +#! /bin/bash -e +# $Id:$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +if [ $0 != "bin/tag_month.sh" ] +then + echo "bin/tag_month.sh: must be executed from its parent directory" + exit 1 +fi +svn_repository="https://projects.coin-or.org/svn/CppAD" +# -------------------------------------------------------------------------- +# make sure that master is currently checked out +git_branch=`git branch | sed -e '/^\*/! d' -e 's|^\* *||'` +if [ "$git_branch" != 'master' ] +then + echo 'tag_month.sh: master is not currently checkout out' + exit 1 +fi +# -------------------------------------------------------------------------- +# make sure that version is consistent and all changes are checked in +bin/version.sh copy > /dev/null +git_status=`git status -s` +if [ "$git_status" != '' ] +then + echo 'tag_month.sh: master has changes that are not checked in' + exit 1 +fi +# -------------------------------------------------------------------------- +# check that version corresponds to first of a month +dd=`bin/version.sh get | sed -e 's|......\([0-9][0-9]\)|\1|' ` +if [ "$dd" != '01' ] +then + echo 'tag_month.sh: verison does not correspond to first day of a month' + exit 1 +fi +# -------------------------------------------------------------------------- +# date of last change to svn repository +svn_date=`svn log $svn_repository/trunk --limit 1 | grep '^r[0-9]* *|' | \ + sed -e 's/^[^|]*|[^|]*| *\([0-9-]*\).*/\1/' -e 's|-||g'` +# -------------------------------------------------------------------------- +# get and check hash codes +# +local_hash=`git show-ref master | sed -e '/\/origin\//d' -e 's| refs.*||'` +remote_hash=`git show-ref master | sed -e '/\/origin\//! d' -e 's| refs.*||'` +svn_hash=`svn log $svn_repository/trunk --limit 1 | \ + grep 'end *hash *code:' | sed -e 's|end *hash *code: *||'` +# +if [ "$local_hash" != "$remote_hash" ] +then + echo "tag_month.sh: master changes haven't been pushed to git repository" + echo "local_hash = $local_hash" + echo "remote_hash = $remote_hash" + exit 1 +fi +if [ "$remote_hash" != "$svn_hash" ] +then + echo "tag_month.sh: master changes haven't been pushed to svn repository" + echo "remote_hash = $remote_hash" + echo "svn_hash = $svn_hash" + exit 1 +fi +# ----------------------------------------------------------------------------- +# If this version has already been tagged, delete the tag +version=`bin/version.sh get` +if git tag --list | grep "$version" +then + read -p "Delete preious tag for version $version [y/n] ?" response + if [ "$response" != 'y' ] + then + echo 'tag_month.sh: aborting because tag already exists' + exit 1 + fi + git tag -d $version + git push --delete origin $version +fi +# +echo "git tag -a \\" +echo "-m \"Last changes copied to $svn_repository/trunk on $svn_date\" \\" +echo "$version $svn_hash" +git tag -a \ + -m "Last changes copied to $svn_repository/trunk on $svn_date" \ + $version $svn_hash +# +echo "git push origin $version" +git push origin $version +# ---------------------------------------------------------------------------- +echo "$0: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bin/trace.sh cppad-2016.00.00.1/bin/trace.sh --- cppad-2015.00.00.9/bin/trace.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/trace.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: trace.sh 3392 2014-10-06 12:46:42Z bradbell $ +# $Id: trace.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -20,11 +20,11 @@ file="cppad/local/$name.hpp" # ok='yes' -if [ "$option" != '0' ] && [ "$option" != '1' ] +if [ "$option" != '0' ] && [ "$option" != '1' ] then ok='no' fi -echo "grep '_TRACE [01]' $file" +echo "grep '_TRACE [01]' $file" if ! grep '_TRACE [01]' $file > /dev/null then ok='no' @@ -42,4 +42,6 @@ echo "old: $old" echo "new: $new" # +# ---------------------------------------------------------------------------- +echo "$0: OK" exit 0 diff -Nru cppad-2015.00.00.9/bin/version.sh cppad-2016.00.00.1/bin/version.sh --- cppad-2015.00.00.9/bin/version.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bin/version.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: version.sh 3479 2014-12-17 14:03:11Z bradbell $ +# $Id: version.sh 3693 2015-06-01 13:55:14Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -25,7 +25,7 @@ exit 1 fi echo_eval() { - echo $* + echo $* eval $* } # ----------------------------------------------------------------------------- @@ -44,8 +44,9 @@ if diff CMakeLists.txt.old CMakeLists.txt then echo 'No change in CMakeLists.txt' - exit 1 fi + echo_eval rm CMakeLists.txt.old + # echo 'bin/version.sh set: OK' exit 0 fi @@ -57,7 +58,7 @@ then echo 'bin/version.sh: Cannot find verison number in CMakeLists.txt' exit 1 -fi +fi if [ "$1" == 'get' ] then echo "$version" @@ -86,9 +87,9 @@ -e "s/config.status [0-9]\{8\}[.0-9]*/config.status $version/g" \ -e "s/\$as_me [0-9]\{8\}[.0-9]*/\$as_me $version/g" \ -e "s/Generated by GNU Autoconf.*$version/&./" \ - -i.old configure + -i.old configure list=' - omh/install/unix.omh + omh/install/auto_tools.omh omh/install/download.omh doc.omh ' @@ -98,7 +99,7 @@ -e "s/cppad-[0-9]\{8\}\.[0-9]*\(\.[eg]pl\)/cppad-$version\1/" \ -e "s/cppad-[0-9]\{8\}[0-9.]*\:/cppad-$version:/" \ -i.old $file -done +done list=" $list AUTHORS diff -Nru cppad-2015.00.00.9/bug/boost_equals.sh cppad-2016.00.00.1/bug/boost_equals.sh --- cppad-2015.00.00.9/bug/boost_equals.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bug/boost_equals.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,83 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +cat << EOF +This is a simpler case that has the same error message as ./boost_lu.sh. +The gist of the message: + /usr/include/boost/numeric/ublas/detail/matrix_assign.hpp:33:35: + error: no match for ‘operator<’ + ... snip ... + return norm_inf (e1 - e2) < epsilon * +EOF +cat << EOF > bug.$$ + +# include +# include +int main() { + typedef CppAD::AD T; + using boost::numeric::ublas::norm_inf; + + boost::numeric::ublas::matrix a(5,5); + T epsilon = static_cast( std::numeric_limits::epsilon() ); + T min_norm = static_cast( std::numeric_limits::min() ); + T norm = norm_inf(a); + bool equals = norm < epsilon; + std::cout << "equals = " << equals << std::endl; + // + // using boost::numeric::ublas::detail::equals; + // std::cout << "equals = " << equals(a, a, epsilon, min_norm) << std::endl; + return 0; +} +EOF +# ----------------------------------------------------------------------------- +if [ ! -e build ] +then + mkdir build +fi +cd build +echo "$0" +name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` +mv ../bug.$$ $name.cpp +echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name >& $name.log" +if ! g++ -I../.. --std=c++11 -g $name.cpp -o $name >& $name.log +then + cat << EOF > $name.sed +s|\\[|&\\n|g +s|\\]|&\\n|g +s|[‘{}]|&\\n|g +s|[a-zA-Z0-9_]* *=|\\n&|g +# +s|boost::numeric::ublas::||g +s|/usr/include/boost/numeric/ublas/||g +# +s|CppAD::AD *|AD|g +s|, basic_unit_lower<> >||g +s|, basic_upper<> >||g +s|scalar_minus|scalar_minus_AD|g +EOF + echo "sed -f $name.sed $name.log > ../$name.log" + sed -f $name.sed $name.log > ../$name.log + echo "$name.sh: Compliation Error: see $name.log" + exit 1 + exit 1 +fi +# +echo "./$name" +if ! ./$name +then + echo + echo "$name.sh: Execution Error" + exit 1 +fi +echo +echo "$name.sh: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bug/boost_lu.sh cppad-2016.00.00.1/bug/boost_lu.sh --- cppad-2015.00.00.9/bug/boost_lu.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bug/boost_lu.sh 2016-02-09 08:31:59.000000000 +0000 @@ -0,0 +1,155 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +cat << EOF +This test results in a very long error message with boost-1.55.0 and +gcc-4.9.2. Here is the gist of the message: + /usr/include/boost/numeric/ublas/detail/matrix_assign.hpp:33:35: + error: no match for ‘operator<’ + ... snip ... + return norm_inf (e1 - e2) < epsilon * + ^ +The folowing change to + /usr/include/boost/numeric/ublas/detail/matrix_assign.hpp +seems to fix the problem: + +Old Text: + return norm_inf (e1 - e2) < epsilon * + std::max (std::max (norm_inf (e1), norm_inf (e2)), min_norm); +New Text: + S norm_1 = norm_inf(e1); + S norm_2 = norm_inf(e2); + S norm_diff = norm_inf(e1 - e2); + return norm_diff < epsilon * std::max( std::max(norm_1, norm_2) , min_norm ); +EOF +cat << EOF > bug.$$ +#include + +# define NUMERIC_LIMITS_FUN(name) \ + static CppAD::AD name(void) \ + { return static_cast< CppAD::AD > ( \ + std::numeric_limits::name() \ + ); \ + } + +# define NUMERIC_LIMITS_BOOL(name) \ + static const bool name = \ + std::numeric_limits::name; + +# define NUMERIC_LIMITS_INT(name) \ + static const int name = \ + std::numeric_limits::name; + + + +namespace std { + /// Specialization of numeric_limits< CppAD::AD > + template <> + class numeric_limits< CppAD::AD > { + public: + // has_denorm + static const float_denorm_style has_denorm = + std::numeric_limits::has_denorm; + // round_style + static const float_round_style round_style = + std::numeric_limits::round_style; + + // bool + NUMERIC_LIMITS_BOOL(is_specialized); + NUMERIC_LIMITS_BOOL(is_signed); + NUMERIC_LIMITS_BOOL(is_integer); + NUMERIC_LIMITS_BOOL(is_exact); + NUMERIC_LIMITS_BOOL(has_infinity); + NUMERIC_LIMITS_BOOL(has_quiet_NaN); + NUMERIC_LIMITS_BOOL(has_signaling_NaN); + NUMERIC_LIMITS_BOOL(has_denorm_loss); + NUMERIC_LIMITS_BOOL(is_iec559); + NUMERIC_LIMITS_BOOL(is_bounded); + NUMERIC_LIMITS_BOOL(is_modulo); + NUMERIC_LIMITS_BOOL(traps); + NUMERIC_LIMITS_BOOL(tinyness_before); + + // int + NUMERIC_LIMITS_INT(digits); + NUMERIC_LIMITS_INT(digits10); + NUMERIC_LIMITS_INT(radix); + NUMERIC_LIMITS_INT(min_exponent); + NUMERIC_LIMITS_INT(min_exponent10); + NUMERIC_LIMITS_INT(max_exponent); + NUMERIC_LIMITS_INT(max_exponent10); + + /// functions + NUMERIC_LIMITS_FUN( epsilon) + NUMERIC_LIMITS_FUN( min ) + NUMERIC_LIMITS_FUN( max ) + }; +} + +#include +int main() { + typedef CppAD::AD T; + boost::numeric::ublas::matrix a(5,5); + boost::numeric::ublas::permutation_matrix pert(5); + // lu decomposition + const std::size_t s = lu_factorize(a, pert); + + return 0; +} +EOF +# ----------------------------------------------------------------------------- +if [ ! -e build ] +then + mkdir build +fi +cd build +echo "$0" +name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` +mv ../bug.$$ $name.cpp +echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name >& $name.log" +if ! g++ -I../.. --std=c++11 -g $name.cpp -o $name >& $name.log +then + cat << EOF > $name.sed +s|\\[|&\\n|g +s|\\]|&\\n|g +s|[‘{}]|&\\n|g +s|[a-zA-Z0-9_]* *=|\\n&|g +# +s|boost::numeric::ublas::||g +s|/usr/include/boost/numeric/ublas/||g +# +s|CppAD::AD *|AD|g +s|, basic_unit_lower<> >||g +s|, basic_upper<> >||g +s|scalar_minus|scalar_minus_AD|g +s|triangular_adaptor<\\([^<>]*\\)>|triangular_\\1|g +s|triangular_matrix_AD_ulower|AD_ulower|g +s|triangular_matrix_AD_upper|AD_upper|g +s|matrix_matrix_prod *|AD_prod_ulower_upper|g +s| *||g +s|matrix_matrix_binary|AD_prod_ulower_upper|g +EOF + echo "sed -f $name.sed $name.log > ../$name.log" + sed -f $name.sed $name.log > ../$name.log + echo "$name.sh: Compliation Error: see $name.log" + exit 1 +fi +# +echo "./$name" +if ! ./$name +then + echo + echo "$name.sh: Execution Error" + exit 1 +fi +echo +echo "$name.sh: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bug/cond_exp.sh cppad-2016.00.00.1/bug/cond_exp.sh --- cppad-2015.00.00.9/bug/cond_exp.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bug/cond_exp.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,111 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +cat << EOF +This example works for type zdouble, but not double. +We want it to work for type double so as to avoid the overhead of zdouble. + +f(x) = 1 / x[0] if x[0] > 0 else 0.0 +EOF +cat << EOF > bug.$$ +#include +namespace { + template + bool test_float(void) + { + bool ok = true; + using CppAD::vector; + Float eps = Float( 10. * std::numeric_limits::epsilon() ); + + typedef CppAD::AD a1float; + typedef CppAD::AD a2float; + + // -------------------------------------------------------------------- + // create a1f = f(x) + vector a2x(1), a2y(1); + a2x[0] = a2float( 5.0 ); + Independent(a2x); + + a2float a2zero = a2float(0.0); + a2float a2one = a2float(1.0); + a2y[0] = CondExpGt(a2x[0], a2zero, a2one / a2x[0], a2zero); + + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + // -------------------------------------------------------------------- + // create g = f'(x) + vector a1x(1), a1dy(1), a1w(1); + a1x[0] = 2.0; + a1w[0] = 1.0; + Independent(a1x); + + a1f.Forward(0, a1x); + a1dy = a1f.Reverse(1, a1w); + + CppAD::ADFun g; + g.Dependent(a1x, a1dy); + // -------------------------------------------------------------------- + // check g where f(x) = 1 / x + vector x(1), y(1); + x[0] = 2.0; + y = g.Forward(0, x); + ok &= CppAD::NearEqual(y[0], - Float(1.0) / (x[0] * x[0]), eps, eps); + // -------------------------------------------------------------------- + // check g at edge case where 1 / x is infinity + x[0] = 0.0; + y = g.Forward(0, x); + ok &= CppAD::NearEqual(y[0], Float(0.0), eps, eps); + // -------------------------------------------------------------------- + return ok; + } +} +int main(void) +{ bool ok = true; + if( test_float() ) + std::cout << "zdouble: OK" << std::endl; + else + { ok = false; + std::cout << "zdouble: Error" << std::endl; + } + if( test_float() ) + std::cout << "double: OK" << std::endl; + else + { ok = false; + std::cout << "double: Error" << std::endl; + } + if( ! ok ) + return 1; + return 0; +} +EOF +# ----------------------------------------------------------------------------- +if [ ! -e build ] +then + mkdir build +fi +cd build +echo "$0" +name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` +mv ../bug.$$ $name.cpp +echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name" +g++ -I../.. --std=c++11 -g $name.cpp -o $name +# +echo "./$name" +if ! ./$name +then + echo + echo "$name.sh: Error" + exit 1 +fi +echo +echo "$name.sh: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bug/cppad_cg.sh cppad-2016.00.00.1/bug/cppad_cg.sh --- cppad-2015.00.00.9/bug/cppad_cg.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bug/cppad_cg.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,175 @@ +#! /bin/bash -e +# $Id:$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +#! /bin/bash -e +web_page='https://github.com/joaoleal/CppADCodeGen.git' +# ----------------------------------------------------------------------------- +# bash function that echos and executes a command +echo_eval() { + echo $* + eval $* +} +# ----------------------------------------------------------------------------- +cat << EOF +This is not a bug but rather a demonstration of using conditional expressions +with CppADCodeGen + https://github.com/joaoleal/CppADCodeGen/ +EOF +# +if [ ! -e build ] +then + echo_eval mkdir -p build +fi +echo_eval cd build +cat << EOF > cppad_cg.cpp +# include +# include +int main(void) +{ typedef CppAD::cg::CG cg_double; + typedef CppAD::AD acg_double; + + // declare independent variables for f(x) + size_t nx = 2; + CppAD::vector ax(nx); + ax[0] = 2.0; + ax[1] = 3.0; + CppAD::Independent(ax); + + // create dependent variables and values for f(x) + // f(x) = x[0] / x[1] if (x[0] > 0 and x[1] >= x[0]) else 1.0 + size_t nz = 1; + CppAD::vector az(nz); + acg_double acg_zero = acg_double(0.0); + acg_double acg_one = acg_double(1.0); + acg_double acg_temp_1 = CondExpGt(ax[1], ax[0], ax[0] / ax[1], acg_one); + acg_double acg_temp_2 = CondExpGt(ax[0], acg_zero, acg_temp_1, acg_one); + az[0] = acg_temp_2; + + // create AD function mapping independent to dependent variables + CppAD::ADFun F(ax, az); + + // create the source code generator for function g(x) + CppAD::cg::CodeHandler G; + + // declare the independent variables for g(x) + CppAD::vector cg_x(nx); + G.makeVariables(cg_x); + + // Compute the dependent variables and values for g(x) + size_t ny = nz * nx; + CppAD::vector cg_y(ny); + cg_y = F.Jacobian(cg_x); + + // Mapping from variables in this program to variables in source_code + // independent variable = x + // dependent variable = y + // temporary variable = v + CppAD::cg::LanguageC langC("double"); + CppAD::cg::LangCDefaultVariableNameGenerator nameGen; + + // generate the source code + std::ostringstream source_code; + G.generateCode(source_code, langC, cg_y, nameGen); + + // string corresponding to source code + std::string source_str = source_code.str(); + + // C souce code corresponding to y = g(x) + std::cout << source_str; + + return 0; +} +EOF +# +# Compile and run cppad_cg.cpp +echo_eval g++ \ + -g \ + -std=c++11 \ + -I$HOME/prefix/cppad_cg/include \ + -I../.. \ + cppad_cg.cpp -o cppad_cg +# +# Determine the maximum v index +v_max_index=`./cppad_cg | sed \ + -e '/^ *v\[[0-9]*\]/! d' \ + -e 's|^ *v\[\([0-9]*\)\].*|\1|' | sort | tail -1` +# +# +# Wrap y = g(x) in C++ function and test it +cat << EOF > tst_cppad_cg.cpp +# include +namespace { + using CppAD::zdouble; + typedef CppAD::vector zvector; + // + // f(x) = x[0] / x[1] if (x[0] > 0 and x[1] >= x[0]) else 1.0 + // g(x) = d/dx f(x) + void g(const zvector& x, zvector& y) + { zvector v($v_max_index + 1); +EOF +./cppad_cg | sed -e 's|^ *|\t\t|' >> tst_cppad_cg.cpp +cat << EOF >> tst_cppad_cg.cpp + return; + } +} +int main(void) +{ // initialize flag + bool ok = true; + // numerical precision for tests + zdouble eps = 10. * std::numeric_limits::epsilon(); + // number of components in vectors + size_t nx = 2; + size_t nz = 1; + size_t ny = nz * nx; + zdouble zero = 0.0; + // + // compute y = g(x) case where x[0] == 0.0 + zvector x(nx), y(ny); + x[0] = 0.0; + x[1] = 0.0; + g(x, y); + // + // check results + ok &= CppAD::NearEqual(y[0], zero, eps, eps); + ok &= CppAD::NearEqual(y[1], zero, eps, eps); + // + // compute y = g(x) case where g(x) = x[0] / x[1] + x[0] = 2.0; + x[1] = 3.0; + g(x, y); + // + // check results + ok &= CppAD::NearEqual(y[0], 1.0/x[1], eps, eps); + ok &= CppAD::NearEqual(y[1], -x[0]/(x[1]*x[1]), eps, eps); + // + if( ! ok ) + return 1; + return 0; +} +EOF +# +# Compile test +echo_eval g++ \ + -g \ + -std=c++11 \ + -I../.. \ + tst_cppad_cg.cpp -o tst_cppad_cg +# +if ! ./tst_cppad_cg +then + file="$HOME/install/cppad_cg/build/tst_cppad_cg.cpp" + echo "install_cppad_cg.sh: Error" + exit 1 +fi +# +echo 'cppad_cg.sh: OK' +exit 0 diff -Nru cppad-2015.00.00.9/bug/eigen_quad.sh cppad-2016.00.00.1/bug/eigen_quad.sh --- cppad-2015.00.00.9/bug/eigen_quad.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bug/eigen_quad.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,98 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +# bash function that echos and executes a command +echo_eval() { + echo $* + eval $* +} +# ----------------------------------------------- +cat << EOF +Function: +f(x) = x^T * Q * x / 2 + +Note that the derivative of f(x) is given by: +f'(x) = [ x^T * Q + (Q * x)^T ] / 2 + = x^T * (Q * Q^T) / 2 +EOF +# ----------------------------------------------- +if [ ! -e build ] +then + mkdir build +fi +cd build +echo "$0" +name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` +# +cat << EOF > $name.cpp +# include +# include +# include + +int main() +{ bool ok = true; + + using CppAD::AD; + using CppAD::ADFun; + using CppAD::Independent; + using Eigen::Matrix; + using Eigen::Dynamic; + using Eigen::VectorXd; + + typedef Matrix< AD , Dynamic, Dynamic > a_MatrixXd; + typedef Matrix< AD , Dynamic , 1> a_VectorXd; + + int size = 2, i , j; + + a_VectorXd a_x(size); + VectorXd x(size); + + x << 1, 2; + for(i = 0; i < size; i++) { + a_x[i] = x[i]; + } + + a_MatrixXd a_Q(size, size); + a_Q << 1, 2, 3, 4; + + Independent(a_x); + AD a_two = 2.0; + a_VectorXd a_y = (a_x.transpose() * a_Q * a_x) / a_two; + + // create f: x -> y and stop tape recording + ADFun f(a_x, a_y); + + VectorXd jac = f.Jacobian(x); + a_MatrixXd a_check_jac = a_x.transpose() * (a_Q + a_Q.transpose()) / a_two; + + + std::cout << "True f'(x) = " << a_check_jac << std::endl; + std::cout << "CppAD f'(x) = " << jac.transpose() << std::endl; + + return 0; +} +EOF +if [ -e "$name" ] +then + echo_eval rm $name +fi +echo_eval g++ \ + $name.cpp \ + -I../.. \ + -I$HOME/prefix/eigen/include \ + -g \ + -O0 \ + -std=c++11 \ + -Wno-shadow \ + -Wno-deprecated-declarations \ + -o $name +echo_eval ./$name diff -Nru cppad-2015.00.00.9/bug/numeric_limit.sh cppad-2016.00.00.1/bug/numeric_limit.sh --- cppad-2015.00.00.9/bug/numeric_limit.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bug/numeric_limit.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,175 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +if [ ! -e ../cppad/configure.hpp ] +then + echo 'numeric_limits.sh: must first run bin/run_cmake.sh' + echo 'from parent directory.' + exit 1 +fi +cat << EOF +This is not a bug, but rather a test of specialization of numeric_limits +for AD types. +EOF +cat << EOF > bug.$$ +# include + +/*! +\\def CPPAD_STD_NUMERIC_LIMITS(Other, Base) +This macro defines the specialization std::numeric_limits +to have the same values and functions as the existing specialization +std::numeric_limits. +*/ +# define CPPAD_STD_NUMERIC_LIMITS(Other, Base) \\ +namespace std {\\ + template <> class numeric_limits\\ + {\\ + public:\\ + static const bool is_specialized =\\ + numeric_limits::is_specialized;\\ + static const bool is_signed =\\ + numeric_limits::is_signed;\\ + static const bool is_integer =\\ + numeric_limits::is_integer;\\ + static const bool is_exact =\\ + numeric_limits::is_exact;\\ + static const bool has_infinity =\\ + numeric_limits::has_infinity;\\ + static const bool has_quiet_NaN =\\ + numeric_limits::has_quiet_NaN;\\ + static const bool has_signaling_NaN =\\ + numeric_limits::has_signaling_NaN;\\ + static const bool has_denorm_loss =\\ + numeric_limits::has_denorm_loss;\\ + static const bool is_iec559 =\\ + numeric_limits::is_iec559;\\ + static const bool is_bounded =\\ + numeric_limits::is_bounded;\\ + static const bool is_modulo =\\ + numeric_limits::is_modulo;\\ + static const bool traps =\\ + numeric_limits::traps;\\ + static const bool tinyness_before =\\ + numeric_limits::tinyness_before;\\ + static const int digits =\\ + numeric_limits::digits;\\ + static const int digits10 =\\ + numeric_limits::digits10;\\ + static const int radix =\\ + numeric_limits::radix;\\ + static const int min_exponent =\\ + numeric_limits::min_exponent;\\ + static const int min_exponent10 =\\ + numeric_limits::min_exponent10;\\ + static const int max_exponent =\\ + numeric_limits::max_exponent;\\ + static const int max_exponent10 =\\ + numeric_limits::max_exponent10;\\ + static const Base min(void)\\ + { return static_cast( numeric_limits::min() ); }\\ + static const Base max(void)\\ + { return static_cast( numeric_limits::max() ); }\\ + static const Base epsilon(void)\\ + { return static_cast( numeric_limits::epsilon() ); }\\ + static const Base round_error(void)\\ + { return static_cast( numeric_limits::round_error() ); }\\ + static const Base infinity(void)\\ + { return static_cast( numeric_limits::infinity() ); }\\ + static const Base quiet_NaN(void)\\ + { return static_cast( numeric_limits::quiet_NaN() ); }\\ + static const Base signaling_NaN(void)\\ + { return static_cast( numeric_limits::signaling_NaN() ); }\\ + static const Base denorm_min(void)\\ + { return static_cast( numeric_limits::denorm_min() ); }\\ + static const float_denorm_style has_denorm =\\ + numeric_limits::has_denorm;\\ + static const float_round_style round_style =\\ + numeric_limits::round_style;\\ + };\\ +} +CPPAD_STD_NUMERIC_LIMITS(double, CppAD::AD) + +# define PRINT_VAL(name) \\ +std::cout << #name << " = " \\ +<< std::numeric_limits< CppAD::AD >::name << std::endl; + +# define PRINT_FUN(name) \\ +std::cout << #name << " = " \\ +<< std::numeric_limits< CppAD::AD >::name() << std::endl; + +int main(void) +{ bool ok = true; + // + PRINT_VAL(is_specialized) + PRINT_VAL(is_signed) + PRINT_VAL(is_integer) + PRINT_VAL(is_exact) + PRINT_VAL(has_infinity) + PRINT_VAL(has_quiet_NaN) + PRINT_VAL(has_signaling_NaN) + PRINT_VAL(has_denorm_loss) + PRINT_VAL(is_iec559) + PRINT_VAL(is_bounded) + PRINT_VAL(is_modulo) + PRINT_VAL(traps) + PRINT_VAL(tinyness_before) + // int + PRINT_VAL(digits) + PRINT_VAL(digits10) + PRINT_VAL(radix) + PRINT_VAL(min_exponent) + PRINT_VAL(min_exponent10) + PRINT_VAL(max_exponent) + PRINT_VAL(max_exponent10) + // function + PRINT_FUN(min) + PRINT_FUN(max) + PRINT_FUN(epsilon) + PRINT_FUN(round_error) + PRINT_FUN(infinity) + PRINT_FUN(quiet_NaN) + PRINT_FUN(signaling_NaN) + PRINT_FUN(denorm_min) + // other + PRINT_VAL(has_denorm) + PRINT_VAL(round_style) + // C++11 only + // PRINT_VAL(max_digits10) + // PRINT_FUN(lowest) + // + if( ok ) + return 0; + return 1; +} +EOF +# ----------------------------------------------------------------------------- +if [ ! -e build ] +then + mkdir build +fi +cd build +echo "$0" +name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` +mv ../bug.$$ $name.cpp +echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name" +g++ -I../.. --std=c++11 -g $name.cpp -o $name +# +echo "./$name" +if ! ./$name +then + echo + echo "$name.sh: Error" + exit 1 +fi +echo +echo "$name.sh: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bug/sparsity.sh cppad-2016.00.00.1/bug/sparsity.sh --- cppad-2015.00.00.9/bug/sparsity.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bug/sparsity.sh 2016-02-09 08:31:59.000000000 +0000 @@ -0,0 +1,90 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +gigabytes='1.0' # memory limit in gigabytes +# ----------------------------------------------------------------------------- +kilobytes=`echo "($gigabytes * 10^9) / 1024" | bc` +ulimit -Sv $kilobytes +cat << EOF +This is testing the idea that + vector< std::set > sparsity; +is inefficient compared to + vector row, col; +The results on one system for this script are: + ./sparsity set 1e7 elapsed_seconds = 3.62206 + ./sparsity set 2e7 std::bad_alloc + ./sparsity vec 2e7 elapsed_seconds = 1.34243 + ./sparsity vec 4e7 std::bad_alloc +EOF +cat << EOF > bug.$$ +# include + +int main(int argc, char *argv[]) +{ using CppAD::elapsed_seconds; + if( argc != 3 ) + { std::cerr << "usage: $0 (set|vec) n" << std::endl; + return 1; + } + bool set = std::strcmp(argv[1], "set") == 0; + bool vec = std::strcmp(argv[1], "vec") == 0; + bool ok = vec || set; + if( ! ok ) + { std::cerr << "usage: $0 (set|vec) n" << std::endl; + return 1; + } + size_t n = size_t( std::atof( argv[2] ) ); + const char* label; + elapsed_seconds(); + try + { + if( set ) + { std::vector< std::set > my_set(n); + for(size_t i = 0; i < n; i++) + my_set[i].insert(i); + } + else + { std::vector row; + std::vector col; + for(size_t i = 0; i < n; i++) + { row.push_back(i); + col.push_back(i); + } + } + for(int i = 0; i < argc; i++) + std::cout << argv[i] << " "; + std::cout << "elapsed_seconds = " << elapsed_seconds() << std::endl; + } + catch( std::bad_alloc& ba ) + { + for(int i = 0; i < argc; i++) + std::cout << argv[i] << " "; + std::cout << ba.what() << std::endl; + } + return 0; +} +EOF +# ----------------------------------------------------------------------------- +if [ ! -e build ] +then + mkdir build +fi +cd build +echo "$0" +name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` +mv ../bug.$$ $name.cpp +echo "g++ -I../.. -DNDEBUG --std=c++11 $name.cpp -o $name" +g++ -I../.. -DNDEBUG --std=c++11 $name.cpp -o $name +# +./$name set 1e7 +./$name set 2e7 +./$name vec 2e7 +./$name vec 4e7 diff -Nru cppad-2015.00.00.9/bug/template.sh cppad-2016.00.00.1/bug/template.sh --- cppad-2015.00.00.9/bug/template.sh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/bug/template.sh 2016-02-09 08:31:58.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: template.sh 3370 2014-09-28 10:52:36Z bradbell $ +# $Id: template.sh 3719 2015-09-02 18:41:58Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -14,17 +14,19 @@ Description EOF cat << EOF > bug.$$ -# include +# include int main(void) -{ // C++ source code +{ bool ok = true; using std::cout; - - cout << "1. svn copy template.sh .sh\n"; - cout << "2. Edit .sh replacing description and C++ source code\n"; + // + cout << "1. copy template.sh to .sh\n"; + cout << "2. Edit .sh replacing description and C++ source code\n"; cout << "3. Run ./.sh\n"; cout << "where is a name that describes the bug\n"; - - return 0; + // + if( ok ) + return 0; + return 1; } EOF # ----------------------------------------------------------------------------- @@ -40,9 +42,12 @@ g++ -I../.. --std=c++11 -g $name.cpp -o $name # echo "./$name" -if ./$name +if ! ./$name then - echo "OK" -else - echo "Error" + echo + echo "$name.sh: Error" + exit 1 fi +echo +echo "$name.sh: OK" +exit 0 diff -Nru cppad-2015.00.00.9/bug/test_install.sh cppad-2016.00.00.1/bug/test_install.sh --- cppad-2015.00.00.9/bug/test_install.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/bug/test_install.sh 2016-02-09 08:31:58.000000000 +0000 @@ -0,0 +1,72 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +cat << EOF +This is not a bug but rather a test of installing with + cppad_prefix=$HOME/prefix +EOF +cat << EOF > bug.$$ +# include +int main(void) +{ bool ok = true; + using std::cout; + using CppAD::AD; + // + CPPAD_TESTVECTOR( AD ) ax(1), ay(1); + ax[0] = 1.0; + CppAD::Independent(ax); + ay[0] = sin( ax[0] ); + CppAD::ADFun f(ax, ay); + // + std::vector< std::set > p(1); + p[0].insert(0); + CppAD::vector< size_t > row(1), col(1); + row[0] = 0; + col[0] = 0; + CppAD::sparse_jacobian_work work; + work.color_method = "colpack"; + CPPAD_TESTVECTOR(double) x(1), jac(1); + x[0] = 2.0; + f.SparseJacobianForward(x, p, row, col, jac, work); + // + ok &= jac[0] == std::cos( x[0] ); + // + if( ok ) + return 0; + return 1; +} +EOF +# ----------------------------------------------------------------------------- +if [ ! -e build ] +then + mkdir build +fi +cd build +echo "$0" +name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` +mv ../bug.$$ $name.cpp +cmd="g++ -I $HOME/prefix/cppad/include --std=c++11 -g $name.cpp -o $name" +cmd="$cmd -L $HOME/prefix/cppad/lib64 -lcppad_lib" +cmd="$cmd -L $HOME/prefix/colpack/lib64 -lColPack" +echo "$cmd" +eval $cmd +# +echo "./$name" +if ! ./$name +then + echo + echo "$name.sh: Error" + exit 1 +fi +echo +echo "$name.sh: OK" +exit 0 diff -Nru cppad-2015.00.00.9/build.sh cppad-2016.00.00.1/build.sh --- cppad-2015.00.00.9/build.sh 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/build.sh 2016-02-09 08:31:53.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: build.sh 3509 2014-12-27 20:38:37Z bradbell $ +# $Id: build.sh 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -13,7 +13,7 @@ # prefix directories for the corresponding packages ADOLC_DIR=$HOME/prefix/adolc BOOST_DIR=/usr -CPPAD_DIR=$HOME/prefix/cppad +CPPAD_DIR=$HOME/prefix/cppad EIGEN_DIR=$HOME/prefix/eigen FADBAD_DIR=$HOME/prefix/fadbad IPOPT_DIR=$HOME/prefix/ipopt @@ -54,7 +54,7 @@ mkdir build fi # ----------------------------------------------------------------------------- -# Today's date in yyyy-mm-dd decimal digit format where +# Today's date in yyyy-mm-dd decimal digit format where # yy is year in century, mm is month in year, dd is day in month. yyyy_mm_dd=`date +%F` # @@ -63,9 +63,9 @@ then version=`bin/version.sh get` else - version=`grep '^ *AC_INIT(' configure.ac | - sed -e 's/[^,]*, *\([^ ,]*\).*/\1/'` - yyyy_mm_dd=`echo $version | + version=`grep '^ *AC_INIT(' configure.ac | + sed -e 's/[^,]*, *\([^ ,]*\).*/\1/' -e 's|\[||' -e 's|\]||'` + yyyy_mm_dd=`echo $version | sed -e 's|\..*||' -e 's|\(....\)\(..\)|\1-\2-|'` fi # @@ -80,27 +80,27 @@ if [ "$1" = "version" ] then echo 'bin/version.sh copy' - bin/version.sh copy + bin/version.sh copy # echo "OK: ./build.sh version" exit 0 fi # ----------------------------------------------------------------------------- -if [ "$1" = "automake" ] +if [ "$1" = "automake" ] then # # check that autoconf and automake output are in original version makefile_in=`sed configure.ac \ - -n \ - -e '/END AC_CONFIG_FILES/,$d' \ - -e '1,/AC_CONFIG_FILES/d' \ - -e 's|/makefile$|&.in|' \ - -e '/\/makefile.in/p'` + -n \ + -e '/END AC_CONFIG_FILES/,$d' \ + -e '1,/AC_CONFIG_FILES/d' \ + -e 's|/makefile$|&.in|' \ + -e '/\/makefile.in/p'` auto_output=" - depcomp - install-sh - missing - configure + depcomp + install-sh + missing + configure config.guess config.sub $makefile_in @@ -136,7 +136,7 @@ # echo "libtoolize -c -f -i" # if ! libtoolize -c -f -i # then - # exit 1 + # exit 1 # fi # echo "autoconf" @@ -178,7 +178,7 @@ " if [ -e $ADOLC_DIR/include/adolc ] then - dir_list="$dir_list + dir_list="$dir_list ADOLC_DIR=$ADOLC_DIR" fi if [ -e $BOOST_DIR/include/boost ] @@ -191,26 +191,26 @@ fi if [ -e $EIGEN_DIR/include/Eigen ] then - dir_list="$dir_list + dir_list="$dir_list EIGEN_DIR=$EIGEN_DIR" #_build_test_only: dir_list="$dir_list --with-eigenvector" fi if [ -e $FADBAD_DIR/include/FADBAD++ ] then - dir_list="$dir_list + dir_list="$dir_list FADBAD_DIR=$FADBAD_DIR" fi if [ -e $IPOPT_DIR/include/coin/IpIpoptApplication.hpp ] then - dir_list="$dir_list + dir_list="$dir_list IPOPT_DIR=$IPOPT_DIR" fi if [ -e $SACADO_DIR/include/Sacado.hpp ] then - dir_list="$dir_list + dir_list="$dir_list SACADO_DIR=$SACADO_DIR" fi - # Use =int (a signed type) to do more checking for + # Use =int (a signed type) to do more checking for # slicing from size_t to addr_t. special_types="" #_build_test_only: special_types="TAPE_ADDR_TYPE=int TAPE_ID_TYPE=int" @@ -227,7 +227,7 @@ CXX_FLAGS=\"$cxx_flags\" \\ $special_types OPENMP_FLAGS=-fopenmp \\ --with-sparse_list --with-Documentation \\ ---with-implicit_ctor +--with-deprecated EOF # ../configure > $log_dir/$log_file \ @@ -235,7 +235,7 @@ CXX_FLAGS="$cxx_flags" \ $special_types OPENMP_FLAGS=-fopenmp \ --with-sparse_list --with-Documentation \ - --with-implicit_ctor + --with-deprecated # for file in $configure_file_list do @@ -247,14 +247,14 @@ exit 0 fi # ----------------------------------------------------------------------------- -if [ "$1" = "dist" ] +if [ "$1" = "dist" ] then # ---------------------------------------------------------------------- # Things to do in the original source directory # ---------------------------------------------------------------------- echo "Only include the *.xml version of the documentation in distribution" if ! grep < doc.omh > /dev/null \ - 'This comment is used to remove the table below' + 'This comment is used to remove the table below' then echo "Missing comment expected in doc.omh" exit 1 @@ -273,7 +273,7 @@ if ! bin/run_omhelp.sh xml then echo "mv doc.omh.save doc.omh" - mv doc.omh.save doc.omh + mv doc.omh.save doc.omh exit 1 fi # @@ -294,7 +294,7 @@ check_svn_id.sh check_verbatim.sh " - for check in $list + for check in $list do echo "bin/$check" bin/$check @@ -310,7 +310,7 @@ echo "rm -rf cppad-$version" rm -rf cppad-$version fi - for file in cppad-*.tgz + for file in cppad-*.tgz do if [ -e $file ] then @@ -338,7 +338,7 @@ fi # ----------------------------------------------------------------------------- # omhelp comes after dist because dist only includes one help output -if [ "$1" = "omhelp" ] +if [ "$1" = "omhelp" ] then if ! grep < doc.omh > /dev/null \ 'This comment is used to remove the table below' @@ -370,7 +370,7 @@ exit 0 fi # ----------------------------------------------------------------------------- -if [ "$1" = "gpl" ] +if [ "$1" = "gpl" ] then # create GPL licensed version echo "bin/gpl_license.sh cppad-$version build build" @@ -380,7 +380,7 @@ exit 0 fi # ----------------------------------------------------------------------------- -if [ "$1" = "copy2doc" ] +if [ "$1" = "copy2doc" ] then for ext in epl gpl do @@ -421,7 +421,7 @@ exit 0 fi # ----------------------------------------------------------------------------- -if [ "$1" = "test" ] +if [ "$1" = "test" ] then log_dir=`pwd` log_file="build_test.log" @@ -463,13 +463,13 @@ echo "sed -i -e 's|^#_build_test_only:||' build.sh" sed -i -e 's|^#_build_test_only:||' build.sh # - echo "./build.sh configure >> $log_file" + echo "./build.sh configure >> $log_file" ./build.sh configure >> $log_dir/$log_file # # test user documentation echo "bin/run_omhelp.sh xml >> $log_file" bin/run_omhelp.sh xml >> $log_dir/$log_file - # + # # test developer documentation echo "./build.sh doxygen >> $log_file" ./build.sh doxygen >> $log_dir/$log_file @@ -481,7 +481,7 @@ echo "cd build" >> $log_dir/$log_file cd build # - dir=`pwd` + dir=`pwd` echo "To see progress in the 'make test' log file use" echo " ../temp.sh ( OK | All | tail | follow | file )" cat << EOF > $log_dir/../temp.sh @@ -533,7 +533,7 @@ # # ignore warning in eigen (that has been reported) if grep ': *warning:' make_test.log - then + then echo "There are warnings in $dir/make_test.log" exit 1 fi @@ -568,7 +568,7 @@ options requires ------- -------- version: set version in AUTHORS, configure.ac, configure, ... -omhelp: build all formats of user documentation in doc/*. +omhelp: build all formats of user documentation in doc/*. automake: run the tools required by autoconf and automake. configure:run the configure script in the build directory. automake dist: create the distribution file build/cppad-version.epl.tgz. configure diff -Nru cppad-2015.00.00.9/cmake/command_line_arg.cmake cppad-2016.00.00.1/cmake/command_line_arg.cmake --- cppad-2015.00.00.9/cmake/command_line_arg.cmake 2014-12-30 15:36:27.000000000 +0000 +++ cppad-2016.00.00.1/cmake/command_line_arg.cmake 2015-01-25 18:06:55.000000000 +0000 @@ -1,4 +1,4 @@ -# $Id: command_line_arg.cmake 3529 2014-12-30 15:36:27Z bradbell $ +# $Id: command_line_arg.cmake 3615 2015-01-25 18:06:55Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # @@ -39,5 +39,5 @@ ENDIF( NOT ( ${type} STREQUAL "STRING" ) ) # SET(${variable} "${default}" CACHE ${type} "${description}") - MESSAGE(STATUS "${variable} = \"${${variable}}\"") + MESSAGE(STATUS "${variable} = ${${variable}}") ENDMACRO( command_line_arg ) diff -Nru cppad-2015.00.00.9/CMakeLists.txt cppad-2016.00.00.1/CMakeLists.txt --- cppad-2015.00.00.9/CMakeLists.txt 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/CMakeLists.txt 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: CMakeLists.txt 3661 2015-02-23 22:19:20Z bradbell $ +# $Id: CMakeLists.txt 3786 2016-02-08 13:14:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -13,16 +13,17 @@ # Some constants # ============================================================================= # Set the minimum required version of cmake for this project. -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +# see http://www.cmake.org/pipermail/cmake/2013-January/053213.html +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) # cppad_version is used by set_version.sh to get the version number. -SET(cppad_version "20150000.9" ) +SET(cppad_version "20160000.1" ) SET(cppad_url "http://www.coin-or.org/CppAD" ) SET(cppad_description "Differentiation of C++ Algorithms" ) -# Set name of this project and create the variables -# cppad_BINARY_DIR and cppad_SOURCE_DIR. +# Set name of this project and create the variables +# cppad_BINARY_DIR and cppad_SOURCE_DIR. # project(projectname [CXX] [C] [Java]) PROJECT(cppad) @@ -38,9 +39,9 @@ # ============================================================================= # CHECK_CXX_SOURCE_COMPILES(source variable) # Checks whether the code given in source will compile, link and run and -# return zero status. You can set -# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_FLAGS and CMAKE_REQUIRED_INCLUDES -# accordingly if additional libraries or compiler flags are required. +# return zero status. You can set +# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_FLAGS and CMAKE_REQUIRED_INCLUDES +# accordingly if additional libraries or compiler flags are required. INCLUDE(CheckCXXSourceRuns) # ============================================================================ @@ -48,7 +49,7 @@ # ============================================================================ # dos_path_to_unix(dos_path unix_path) INCLUDE(cmake/dos_path_to_unix.cmake) -# +# # add_to_list(variable_list constant_value) INCLUDE(cmake/add_to_list.cmake) # @@ -70,53 +71,57 @@ # command line arguments # ============================================================================= # cmake_install_datadir -command_line_arg(cmake_install_datadir share STRING +command_line_arg(cmake_install_datadir share STRING "directory, below prefix, where cmake installs cppad data files" ) # ----------------------------------------------------------------------------- # cmake_install_docdir -command_line_arg(cmake_install_docdir "" STRING +command_line_arg(cmake_install_docdir NOTFOUND STRING "directory, below prefix, where cmake installs cppad documentation files" ) # ----------------------------------------------------------------------------- # cmake_install_includedirs -command_line_arg(cmake_install_includedirs include STRING +command_line_arg(cmake_install_includedirs include STRING "directories, below prefix, where cmake installs include files" ) # ----------------------------------------------------------------------------- # cmake_install_libdirs -command_line_arg(cmake_install_libdirs lib STRING +command_line_arg(cmake_install_libdirs lib STRING "directories, below prefix, where cmake installs library files" ) # ----------------------------------------------------------------------------- -# cmake_install_prefix -command_line_arg(cmake_install_prefix /usr PATH +# cppad_prefix +command_line_arg(cppad_prefix /usr PATH "cppad install prefix" ) -SET(CMAKE_INSTALL_PREFIX "${cmake_install_prefix}" - CACHE PATH "value copied from cmake_install_prefix" FORCE +SET(CMAKE_INSTALL_PREFIX "${cppad_prefix}" + CACHE PATH "value copied from cppad_prefix" FORCE ) +IF( cmake_install_prefix ) + MESSAGE(FATAL_ERROR + "cmake_install_prefix has been changed to cppad_prefix" + ) +ENDIF( cmake_install_prefix ) # ----------------------------------------------------------------------------- -# cmake_install_postfix -command_line_arg(cmake_install_postfix NOTFOUND STRING +# cppad_postfix +command_line_arg(cppad_postfix NOTFOUND STRING "cppad install postfix" ) +IF( cmake_install_postfix ) + MESSAGE(FATAL_ERROR + "cmake_install_postfix has been changed to cppad_postfix" + ) +ENDIF( cmake_install_postfix ) # ----------------------------------------------------------------------------- # cppad_cxx_flags -command_line_arg(cppad_cxx_flags NOTFOUND STRING - "extra flags used with cppad source (besides debug and release flags)" +command_line_arg(cppad_cxx_flags NOTFOUND STRING + "compile flags used with cppad (besides debug, release, and profile flags)" ) # ----------------------------------------------------------------------------- -# cppad_documentation -command_line_arg(cppad_documentation "" STRING - "install cppad documentation: use camke_install_docdir instead" -) -STRING(COMPARE NOTEQUAL "${cppad_documentation}" "" cppad_documentation_error) -IF( cppad_documentation_error ) - MESSAGE(FATAL_ERROR -"cppad_documentation is no longer an option, use cmake_install_docdir instead" - ) -ENDIF( cppad_documentation_error ) +# cppad_profile_flag +command_line_arg(cppad_profile_flag NOTFOUND STRING + "compile flag used to compoile and link a profile version of a program" +) # ----------------------------------------------------------------------------- # External package prefixes # @@ -138,93 +143,73 @@ # sacado_prefix optional_package(sacado_prefix "sacado install prefix") # ----------------------------------------------------------------------------- -# cppad_has_colpack +# cppad_has_colpack, colpack_libs, cppad_lib # IF( colpack_prefix ) SET(cppad_has_colpack 1) + SET( colpack_libs "ColPack" ) + SET( cppad_lib "cppad_lib" ) ELSE( colpack_prefix ) SET(cppad_has_colpack 0) + SET( colpack_libs "" ) + SET( cppad_lib "" ) ENDIF( colpack_prefix ) # ============================================================================= # automated system configuration # ============================================================================= -# cppad_install_includedir -SET(cppad_install_includedir NOTFOUND) -FOREACH(dir ${cmake_install_includedirs}) - IF( NOT cppad_install_includedir ) - SET(cppad_install_includedir ${dir}) - ENDIF( NOT cppad_install_includedir ) -ENDFOREACH(dir ${cmake_install_includedirs}) -# ----------------------------------------------------------------------------- -# cppad_install_libdir -SET(cppad_install_libdir NOTFOUND) -FOREACH(dir ${cmake_install_libdirs}) - IF( NOT cppad_install_libdir ) - SET(cppad_install_libdir ${dir}) - ENDIF( NOT cppad_install_libdir ) -ENDFOREACH(dir ${cmake_install_libdirs}) -# ----------------------------------------------------------------------------- # cppad_cxx_flags_sacado IF( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" ) SET(cppad_cxx_flags_sacado "${cppad_cxx_flags} -D HAS_C99_TR1_CMATH" ) ELSE( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" ) SET(cppad_cxx_flags_sacado ${cppad_cxx_flags} ) ENDIF( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" ) -MESSAGE(STATUS "cppad_cxx_flags_sacado = ${cppad_cxx_flags_sacado}") -# ----------------------------------------------------------------------------- -# cppad_cxx_flags_skip_eigen -STRING(REGEX REPLACE - "(.*)-Wshadow(.*)" "\\1-Wno-shadow\\2" +IF( sacado_prefix ) + MESSAGE(STATUS "cppad_cxx_flags_sacado = ${cppad_cxx_flags_sacado}") +ENDIF( sacado_prefix ) +# ----------------------------------------------------------------------------- +# cppad_cxx_flags_eigen +STRING(REGEX REPLACE + "(.*)-Wshadow(.*)" "\\1-Wno-shadow -Wno-deprecated-declarations\\2" cppad_cxx_flags_eigen "${cppad_cxx_flags}" ) -MESSAGE(STATUS "cppad_cxx_flags_eigen = ${cppad_cxx_flags_eigen}") -# ----------------------------------------------------------------------------- -# cppad_cxx_flags_skip_fadbad -STRING(REGEX REPLACE - "(.*)-Wshadow(.*)" "\\1-Wno-shadow\\2" +IF( eigen_prefix ) + MESSAGE(STATUS "cppad_cxx_flags_eigen = ${cppad_cxx_flags_eigen}") +ENDIF( eigen_prefix ) +# ----------------------------------------------------------------------------- +# cppad_cxx_flags_fadbad +STRING(REGEX REPLACE + "(.*)-Wshadow(.*)" "\\1-Wno-shadow\\2" cppad_cxx_flags_fadbad "${cppad_cxx_flags}" ) -MESSAGE(STATUS "cppad_cxx_flags_fadbad = ${cppad_cxx_flags_fadbad}") -# ----------------------------------------------------------------------------- -# cppad_abs_includedir, cppad_abs_libdir, cppad_abs_datadir, cppad_abs_docdir -# -# cppad_abs_docdir is not used if cmake_install_docdir is "" -# -IF ( cmake_install_postfix ) - SET(cppad_abs_includedir -"${cmake_install_prefix}/${cppad_install_includedir}/${cmake_install_postfix}" - CACHE INTERNAL "cppad install include file directory" FORCE - ) - SET(cppad_abs_libdir -"${cmake_install_prefix}/${cppad_install_libdir}/${cmake_install_postfix}" - CACHE INTERNAL "cppad install library file directory" FORCE - ) - SET(cppad_abs_datadir -"${cmake_install_prefix}/${cmake_install_datadir}/${cmake_install_postfix}" - CACHE INTERNAL "cppad install data file directory" FORCE - ) - SET(cppad_abs_docdir -"${cmake_install_prefix}/${cmake_install_docdir}/${cmake_install_postfix}" - CACHE INTERNAL "cppad install data file directory" FORCE - ) -ELSE ( cmake_install_postfix ) - SET(cppad_abs_includedir - "${cmake_install_prefix}/${cppad_install_includedir}" - CACHE INTERNAL "cppad install include file directory" FORCE - ) - SET(cppad_abs_libdir - "${cmake_install_prefix}/${cppad_install_libdir}" - CACHE INTERNAL "cppad install library file directory" FORCE - ) - SET(cppad_abs_datadir - "${cmake_install_prefix}/${cmake_install_datadir}" - CACHE INTERNAL "cppad install data file directory" FORCE - ) - SET(cppad_abs_docdir - "${cmake_install_prefix}/${cmake_install_docdir}" - CACHE INTERNAL "cppad install data file directory" FORCE - ) -ENDIF ( cmake_install_postfix ) +IF( fadbad_prefix ) + MESSAGE(STATUS "cppad_cxx_flags_fadbad = ${cppad_cxx_flags_fadbad}") +ENDIF( fadbad_prefix ) +# ----------------------------------------------------------------------------- +# CMAKE_CXX_FLAGS +# remove Visual Studio C++ warning level if specified in cppad_cxx_flags +IF ( cppad_cxx_flags MATCHES "/W[0-9]" ) + STRING( REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ) +ENDIF ( cppad_cxx_flags MATCHES "/W[0-9]" ) +MESSAGE(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}") +# ----------------------------------------------------------------------------- +# set cppad_abs_${middle_name} for middle_name equal to: +# includedir, liddir, datadir, docdir +FOREACH(middle_names includedirs libdirs datadir docdir) + STRING(REGEX REPLACE "dirs" "dir" middle_name ${middle_names}) + SET(middle_value NOTFOUND) + FOREACH(dir ${cmake_install_${middle_names}}) + IF( NOT middle_value ) + SET(middle_value ${dir}) + ENDIF( NOT middle_value ) + ENDFOREACH(dir ${cmake_install_${middle_names}}) + # + SET(tmp "${cppad_prefix}/${middle_value}" ) + IF ( cppad_postfix ) + SET(cppad_abs_${middle_name} ${tmp}/${cppad_postfix}) + ELSE ( cppad_postfix ) + SET(cppad_abs_${middle_name} ${tmp}) + ENDIF ( cppad_postfix ) +ENDFOREACH(middle_names includedirs libdirs datadir docdir) # ----------------------------------------------------------------------------- # boost_prefix FIND_PACKAGE(Boost) @@ -241,10 +226,10 @@ ) # # extract part before last backslash - STRING(REGEX REPLACE - "([^ ]*)/[^/ ]*" "\\1" - boost_prefix "${boost_include_dir}" - ) + STRING(REGEX REPLACE + "([^ ]*)/[^/ ]*" "\\1" + boost_prefix "${boost_include_dir}" + ) MESSAGE(STATUS "boost_prefix = ${boost_prefix}") # # add boost include directories @@ -283,9 +268,9 @@ # ipopt_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') pkg_check_modules(ipopt ipopt) IF( NOT ipopt_FOUND ) - MESSAGE(FATAL_ERROR + MESSAGE(FATAL_ERROR "For all directories dir in cmake_install_libdirs, cannot find the file - ipopt_prefix/dir/pkgconfig/ipopt.pc + ipopt_prefix/dir/pkgconfig/ipopt.pc where ipopt_prefix = ${ipopt_prefix} cmake_install_libdirs = ${cmake_install_libdirs} @@ -296,7 +281,7 @@ # ============================================================================= # Currently building tests as normal executables # ============================================================================= -# The CMakeLists.txt file in the specified source directory is processed +# The CMakeLists.txt file in the specified source directory is processed # before the current input file continues beyond this command. # add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) # @@ -305,6 +290,9 @@ # ADD_SUBDIRECTORY(cppad) ADD_SUBDIRECTORY(pkgconfig) +IF( colpack_prefix ) + ADD_SUBDIRECTORY(cppad_lib) +ENDIF( colpack_prefix) # ADD_SUBDIRECTORY(compare_c) add_to_list(check_depends check_compare_c) @@ -349,25 +337,23 @@ # Note a trailing / in the source directory name drops the source directory # name during the copy. # -# During install copy all the cppad include files to -# ${cppad_abs_includedir}/cppad -INSTALL( - DIRECTORY "cppad/" - DESTINATION ${cppad_abs_includedir}/cppad - FILES_MATCHING PATTERN "*.h" -) -INSTALL( - DIRECTORY "cppad/" +# During install copy all the cppad include files to +# ${cppad_abs_includedir}/cppad +INSTALL( + DIRECTORY "${CMAKE_SOURCE_DIR}/cppad/" DESTINATION ${cppad_abs_includedir}/cppad FILES_MATCHING PATTERN "*.hpp" ) -INSTALL( - FILES "cppad/local/cppad_colpack.cpp" - DESTINATION ${cppad_abs_datadir}/cppad -) # # During install copy doc direcrory to cppad_abs_docdir/cppad -STRING( COMPARE NOTEQUAL "${cmake_install_docdir}" "" cppad_documentation ) -IF ( cppad_documentation ) +IF ( cmake_install_docdir ) INSTALL( DIRECTORY "doc/" DESTINATION ${cppad_abs_docdir}/cppad ) -ENDIF ( cppad_documentation ) +ENDIF ( cmake_install_docdir ) +# +IF( ${cppad_deprecated} ) + # During install copy deprecated include files + INSTALL( + DIRECTORY "${CMAKE_SOURCE_DIR}/cppad/deprecated/" + DESTINATION ${cppad_abs_includedir}/cppad + ) +ENDIF( ${cppad_deprecated} ) diff -Nru cppad-2015.00.00.9/compare_c/makefile.am cppad-2016.00.00.1/compare_c/makefile.am --- cppad-2015.00.00.9/compare_c/makefile.am 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/compare_c/makefile.am 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2580 2012-11-17 22:01:48Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -11,7 +11,7 @@ # ----------------------------------------------------------------------------- # automake input file # See ./CMakeLists.txt for specifications. -# +# BUILT_SOURCES = det_by_minor_c.c det_by_minor_cpp.cpp det_by_minor_c.c: det_by_minor.c cp $(srcdir)/det_by_minor.c det_by_minor_c.c @@ -24,11 +24,11 @@ # erase configures choice of flags DEFS = # -# AM_CXXFLAGS = -g -# AM_CFLAGS = -g +# AM_CXXFLAGS = -g +# AM_CFLAGS = -g # -AM_CXXFLAGS = -O2 -DNDEBUG -AM_CFLAGS = -O2 -DNDEBUG +AM_CXXFLAGS = -O2 -DNDEBUG +AM_CFLAGS = -O2 -DNDEBUG # check_PROGRAMS = det_by_minor_c det_by_minor_cpp # diff -Nru cppad-2015.00.00.9/compare_c/makefile.in cppad-2016.00.00.1/compare_c/makefile.in --- cppad-2015.00.00.9/compare_c/makefile.in 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/compare_c/makefile.in 2016-02-09 08:31:52.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = det_by_minor_c$(EXEEXT) det_by_minor_cpp$(EXEEXT) subdir = compare_c -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -161,6 +170,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -264,26 +274,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -322,12 +335,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -335,18 +348,18 @@ # ----------------------------------------------------------------------------- # automake input file # See ./CMakeLists.txt for specifications. -# +# BUILT_SOURCES = det_by_minor_c.c det_by_minor_cpp.cpp # EXTRA_DIST = \ det_by_minor.c # -# AM_CXXFLAGS = -g -# AM_CFLAGS = -g +# AM_CXXFLAGS = -g +# AM_CFLAGS = -g # -AM_CXXFLAGS = -O2 -DNDEBUG -AM_CFLAGS = -O2 -DNDEBUG +AM_CXXFLAGS = -O2 -DNDEBUG +AM_CFLAGS = -O2 -DNDEBUG # det_by_minor_c_SOURCES = det_by_minor_c.c det_by_minor_cpp_SOURCES = det_by_minor_cpp.cpp @@ -367,7 +380,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu compare_c/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu compare_c/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -642,6 +654,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + det_by_minor_c.c: det_by_minor.c cp $(srcdir)/det_by_minor.c det_by_minor_c.c det_by_minor_cpp.cpp: det_by_minor.c diff -Nru cppad-2015.00.00.9/compile cppad-2016.00.00.1/compile --- cppad-2015.00.00.9/compile 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/compile 2015-08-18 14:42:15.000000000 +0000 @@ -0,0 +1,347 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2012-10-14.11; # UTC + +# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff -Nru cppad-2015.00.00.9/config.guess cppad-2016.00.00.1/config.guess --- cppad-2015.00.00.9/config.guess 2014-11-28 03:07:22.000000000 +0000 +++ cppad-2016.00.00.1/config.guess 2015-08-09 16:12:42.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2015 Free Software Foundation, Inc. -timestamp='2014-03-23' +timestamp='2015-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -24,12 +24,12 @@ # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # -# Originally written by Per Bothner. +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # -# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` @@ -50,7 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -579,8 +579,9 @@ else IBM_ARCH=powerpc fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi diff -Nru cppad-2015.00.00.9/config.sub cppad-2016.00.00.1/config.sub --- cppad-2015.00.00.9/config.sub 2014-11-28 03:07:22.000000000 +0000 +++ cppad-2016.00.00.1/config.sub 2015-08-09 16:12:42.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2015 Free Software Foundation, Inc. -timestamp='2014-07-28' +timestamp='2015-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ # of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -68,7 +68,7 @@ version="\ GNU config.sub ($timestamp) -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -260,7 +260,7 @@ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ - | fido | fr30 | frv \ + | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ @@ -302,6 +302,7 @@ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ + | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ @@ -312,6 +313,7 @@ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) @@ -326,6 +328,9 @@ c6x) basic_machine=tic6x-unknown ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none @@ -436,6 +441,7 @@ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ + | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -773,6 +779,9 @@ basic_machine=m68k-isi os=-sysv ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; m68knommu) basic_machine=m68k-unknown os=-linux diff -Nru cppad-2015.00.00.9/configure cppad-2016.00.00.1/configure --- cppad-2015.00.00.9/configure 2015-02-23 22:19:20.000000000 +0000 +++ cppad-2016.00.00.1/configure 2016-02-08 13:14:26.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for cppad 20150000.9. +# Generated by GNU Autoconf 2.69 for cppad 20160000.1. # # Report bugs to . # @@ -580,8 +580,8 @@ # Identity of this package. PACKAGE_NAME='cppad' PACKAGE_TARNAME='cppad' -PACKAGE_VERSION='20150000.9' -PACKAGE_STRING='cppad 20150000.9' +PACKAGE_VERSION='20160000.1' +PACKAGE_STRING='cppad 20160000.1' PACKAGE_BUGREPORT='cppad@list.coin-or.org' PACKAGE_URL='' @@ -622,7 +622,7 @@ # include #endif" -ac_unique_file="cppad/CppAD.h" +ac_unique_file="cppad/cppad.hpp" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS @@ -631,9 +631,9 @@ eigen_prefix adolc_prefix cppad_SOURCE_DIR -cppad_requires -cppad_libs -cppad_cflags +cppad_pkgconfig_requires +cppad_pkgconfig_libs +cppad_pkgconfig_cflags cppad_url cppad_version cppad_description @@ -666,42 +666,26 @@ EGREP GREP CPP -cppad_compiler_has_erf +cppad_has_high_resolution_clock +cppad_use_cplusplus_2011 cppad_has_cstdint_8_to_64 cppad_has_rvalue cppad_has_nullptr +cppad_has_mkstemp cppad_has_colpack +cppad_cxx_flags CppAD_HAVE_AR_FALSE CppAD_HAVE_AR_TRUE -ac_ct_AR -AR CppAD_PKG_CONFIG_FALSE CppAD_PKG_CONFIG_TRUE have_pkg_config ac_ct_FC FCFLAGS FC -am__fastdepCC_FALSE -am__fastdepCC_TRUE -CCDEPMODE -ac_ct_CC -CFLAGS -CC am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE -am__nodep -AMDEPBACKSLASH -AMDEP_FALSE -AMDEP_TRUE -am__quote -am__include -DEPDIR -OBJEXT -EXEEXT ac_ct_CXX -CPPFLAGS -LDFLAGS CXXFLAGS CXX cppad_tape_id_type @@ -739,13 +723,34 @@ CppAD_POSTFIX_FALSE CppAD_POSTFIX_TRUE POSTFIX_DIR -cppad_implicit_ctor_from_any_type +cppad_deprecated +CppAD_DEPRECATED_FALSE +CppAD_DEPRECATED_TRUE cppad_internal_sparse_set cppad_eigenvector cppad_boostvector cppad_stdvector CppAD_DOCUMENTATION_FALSE CppAD_DOCUMENTATION_TRUE +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +am__nodep +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +ac_ct_AR +AR am__untar am__tar AMTAR @@ -819,6 +824,7 @@ enable_option_checking enable_silent_rules enable_maintainer_mode +enable_dependency_tracking with_SpeedExample with_profiling with_Speed @@ -833,12 +839,16 @@ with_eigenvector with_sparse_set with_sparse_list -with_implicit_ctor -enable_dependency_tracking +with_deprecated ' ac_precious_vars='build_alias host_alias target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS POSTFIX_DIR ADOLC_DIR EIGEN_DIR @@ -853,12 +863,7 @@ TAPE_ID_TYPE CXX CXXFLAGS -LDFLAGS -LIBS -CPPFLAGS CCC -CC -CFLAGS FC FCFLAGS CPP' @@ -1402,7 +1407,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures cppad 20150000.9 to adapt to many kinds of systems. +\`configure' configures cppad 20160000.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1472,7 +1477,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of cppad 20150000.9:";; + short | recursive ) echo "Configuration of cppad 20160000.1:";; esac cat <<\_ACEOF @@ -1485,11 +1490,11 @@ --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer - --enable-msvc Prefer (i)cl/ifort/link over GNU on MinGW/Cygwin. --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build + --enable-msvc Prefer (i)cl/ifort/link over GNU on MinGW/Cygwin. Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1507,10 +1512,17 @@ --with-eigenvector default is no --with-sparse_set default is not specified --with-sparse_list default is not specified - --with-implicit_ctor include an implicit AD constructor from any + --with-deprecated include an implicit AD constructor from any type Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory POSTFIX_DIR postfix directory for CppAD installation ADOLC_DIR value of configure prefix directory during Adolc install EIGEN_DIR value of configure prefix directory during Eigen install @@ -1529,13 +1541,6 @@ type used for addresses in AD tapes CXX C++ compiler command CXXFLAGS C++ compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CC C compiler command - CFLAGS C compiler flags FC Fortran compiler command FCFLAGS Fortran compiler flags CPP C preprocessor @@ -1606,7 +1611,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -cppad configure 20150000.9 +cppad configure 20160000.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1620,10 +1625,10 @@ ## Autoconf initialization. ## ## ------------------------ ## -# ac_fn_cxx_try_compile LINENO -# ---------------------------- +# ac_fn_c_try_compile LINENO +# -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_compile () +ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext @@ -1643,7 +1648,7 @@ fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || + test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 @@ -1656,12 +1661,12 @@ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval -} # ac_fn_cxx_try_compile +} # ac_fn_c_try_compile -# ac_fn_c_try_compile LINENO -# -------------------------- +# ac_fn_cxx_try_compile LINENO +# ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () +ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext @@ -1681,7 +1686,7 @@ fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || + test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 @@ -1694,7 +1699,7 @@ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval -} # ac_fn_c_try_compile +} # ac_fn_cxx_try_compile # ac_fn_fc_try_compile LINENO # --------------------------- @@ -2235,7 +2240,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by cppad $as_me 20150000.9, which was +It was created by cppad $as_me 20160000.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2649,7 +2654,7 @@ -am__api_version='1.13' +am__api_version='1.15' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do @@ -2850,8 +2855,8 @@ ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in @@ -2870,7 +2875,7 @@ $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -3125,7 +3130,7 @@ # Define the identity of the package. PACKAGE='cppad' - VERSION='20150000.9' + VERSION='20160000.1' cat >>confdefs.h <<_ACEOF @@ -3159,8 +3164,8 @@ # mkdir_p='$(MKDIR_P)' -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' @@ -3176,122 +3181,1380 @@ +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. -{ $as_echo "$as_me:${as_lineno-$LINENO}: *** Check command line arguments that are longer used ****" >&5 -$as_echo "$as_me: *** Check command line arguments that are longer used ****" >&6;} - -if test "$CPP_ERROR_WARN" != "" ; then - as_fn_error $? "The CPP_ERROR_WARN configure option is now CXX_FLAGS" "$LINENO" 5 -fi +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. -# Check whether --with-SpeedExample was given. -if test "${with_SpeedExample+set}" = set; then : - withval=$with_SpeedExample; SpeedExample="yes" -else - SpeedExample="no" +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . -fi +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. -if test "$SpeedExample" = "yes" ; then - as_fn_error $? "--with-SpeedExample not necessary, see install instructions." "$LINENO" 5 +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi fi -# Check whether --with-profiling was given. -if test "${with_profiling+set}" = set; then : - withval=$with_profiling; profiling="yes" -else - profiling="no" -fi +# check if we have ar program +have_ar='yes' +DEPDIR="${am__leading_dot}deps" -if test "$profiling" = "yes" ; then - as_fn_error $? "--with-profiling not necessary, see install instructions." "$LINENO" 5 -fi +ac_config_commands="$ac_config_commands depfiles" -# Check whether --with-Speed was given. -if test "${with_Speed+set}" = set; then : - withval=$with_Speed; Speed="yes" -else - Speed="no" +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from 'make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac fi -if test "$Speed" = "yes" ; then - as_fn_error $? "--with-Speed not necessary, see install instructions." "$LINENO" 5 -fi -# Check whether --with-Introduction was given. -if test "${with_Introduction+set}" = set; then : - withval=$with_Introduction; Introduction="yes" -else - Introduction="no" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; fi -if test "$Introduction" = "yes" ; then - as_fn_error $? "--with-Introduction not necessary, see install instructions." "$LINENO" 5 +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' fi - -# Check whether --with-Example was given. -if test "${with_Example+set}" = set; then : - withval=$with_Example; Example="yes" + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' else - Example="no" - + AMDEP_TRUE='#' + AMDEP_FALSE= fi -if test "$Example" = "yes" ; then - as_fn_error $? "--with-Example not necessary, see install instructions." "$LINENO" 5 -fi -# Check whether --with-TestMore was given. -if test "${with_TestMore+set}" = set; then : - withval=$with_TestMore; TestMore="yes" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 else - TestMore="no" - -fi - -if test "$TestMore" = "yes" ; then - as_fn_error $? "--with-TestMore not necessary, see install instructions." "$LINENO" 5 -fi - -# Check whether --with-PrintFor was given. -if test "${with_PrintFor+set}" = set; then : - withval=$with_PrintFor; PrintFor="yes" + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. else - PrintFor="no" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS fi - -if test "$PrintFor" = "yes" ; then - as_fn_error $? "--with-PrintFor not necessary, see install instructions." "$LINENO" 5 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: ****** Check command line arguments that are used ***********" >&5 -$as_echo "$as_me: ****** Check command line arguments that are used ***********" >&6;} - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-msvc" >&5 -$as_echo_n "checking --enable-msvc... " >&6; } -# Check whether --enable-msvc was given. -if test "${enable_msvc+set}" = set; then : - enableval=$enable_msvc; enable_msvc=$enableval +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - enable_msvc=no - + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_msvc" >&5 -$as_echo "$enable_msvc" >&6; } - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --prefix" >&5 -$as_echo_n "checking --prefix... " >&6; } -if test "$prefix" = "NONE" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOME" >&5 -$as_echo "$HOME" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $prefix" >&5 -$as_echo "$prefix" >&6; } +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } +if ${am_cv_prog_cc_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar lib "link -lib" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AR" && break + done +fi +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar lib "link -lib" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_AR" && break +done + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi + +: ${AR=ar} + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 +$as_echo_n "checking the archiver ($AR) interface... " >&6; } +if ${am_cv_ar_interface+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + am_cv_ar_interface=ar + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int some_variable = 0; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 + (eval $am_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -eq 0; then + am_cv_ar_interface=ar + else + am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 + (eval $am_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -eq 0; then + am_cv_ar_interface=lib + else + am_cv_ar_interface=unknown + fi + fi + rm -f conftest.lib libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 +$as_echo "$am_cv_ar_interface" >&6; } + +case $am_cv_ar_interface in +ar) + ;; +lib) + # Microsoft lib, so override with the ar-lib wrapper script. + # FIXME: It is wrong to rewrite AR. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__AR in this case, + # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something + # similar. + AR="$am_aux_dir/ar-lib $AR" + ;; +unknown) + have_ar='no' + ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: have_ar = $have_ar" >&5 +$as_echo "$as_me: have_ar = $have_ar" >&6;} + +{ $as_echo "$as_me:${as_lineno-$LINENO}: *** Check command line arguments that are longer used ****" >&5 +$as_echo "$as_me: *** Check command line arguments that are longer used ****" >&6;} + +if test "$CPP_ERROR_WARN" != "" ; then + as_fn_error $? "The CPP_ERROR_WARN configure option is now CXX_FLAGS" "$LINENO" 5 +fi + +# Check whether --with-SpeedExample was given. +if test "${with_SpeedExample+set}" = set; then : + withval=$with_SpeedExample; SpeedExample="yes" +else + SpeedExample="no" + +fi + +if test "$SpeedExample" = "yes" ; then + as_fn_error $? "--with-SpeedExample not necessary, see install instructions." "$LINENO" 5 +fi + +# Check whether --with-profiling was given. +if test "${with_profiling+set}" = set; then : + withval=$with_profiling; profiling="yes" +else + profiling="no" + +fi + +if test "$profiling" = "yes" ; then + as_fn_error $? "--with-profiling not necessary, see install instructions." "$LINENO" 5 +fi + +# Check whether --with-Speed was given. +if test "${with_Speed+set}" = set; then : + withval=$with_Speed; Speed="yes" +else + Speed="no" + +fi + +if test "$Speed" = "yes" ; then + as_fn_error $? "--with-Speed not necessary, see install instructions." "$LINENO" 5 +fi + +# Check whether --with-Introduction was given. +if test "${with_Introduction+set}" = set; then : + withval=$with_Introduction; Introduction="yes" +else + Introduction="no" + +fi + +if test "$Introduction" = "yes" ; then + as_fn_error $? "--with-Introduction not necessary, see install instructions." "$LINENO" 5 +fi + +# Check whether --with-Example was given. +if test "${with_Example+set}" = set; then : + withval=$with_Example; Example="yes" +else + Example="no" + +fi + +if test "$Example" = "yes" ; then + as_fn_error $? "--with-Example not necessary, see install instructions." "$LINENO" 5 +fi + +# Check whether --with-TestMore was given. +if test "${with_TestMore+set}" = set; then : + withval=$with_TestMore; TestMore="yes" +else + TestMore="no" + +fi + +if test "$TestMore" = "yes" ; then + as_fn_error $? "--with-TestMore not necessary, see install instructions." "$LINENO" 5 +fi + +# Check whether --with-PrintFor was given. +if test "${with_PrintFor+set}" = set; then : + withval=$with_PrintFor; PrintFor="yes" +else + PrintFor="no" + +fi + +if test "$PrintFor" = "yes" ; then + as_fn_error $? "--with-PrintFor not necessary, see install instructions." "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: ****** Check command line arguments that are used ***********" >&5 +$as_echo "$as_me: ****** Check command line arguments that are used ***********" >&6;} + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-msvc" >&5 +$as_echo_n "checking --enable-msvc... " >&6; } +# Check whether --enable-msvc was given. +if test "${enable_msvc+set}" = set; then : + enableval=$enable_msvc; enable_msvc=$enableval +else + enable_msvc=no + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_msvc" >&5 +$as_echo "$enable_msvc" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --prefix" >&5 +$as_echo_n "checking --prefix... " >&6; } +if test "$prefix" = "NONE" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOME" >&5 +$as_echo "$HOME" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $prefix" >&5 +$as_echo "$prefix" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-Documentation" >&5 @@ -3426,24 +4689,32 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-implicit_ctor" >&5 -$as_echo_n "checking --with-implicit_ctor... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-deprecated" >&5 +$as_echo_n "checking --with-deprecated... " >&6; } -# Check whether --with-implicit_ctor was given. -if test "${with_implicit_ctor+set}" = set; then : - withval=$with_implicit_ctor; implicit_ctor="yes" +# Check whether --with-deprecated was given. +if test "${with_deprecated+set}" = set; then : + withval=$with_deprecated; deprecated="yes" else - implicit_ctor="no" + deprecated="no" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $deprecated" >&5 +$as_echo "$deprecated" >&6; } + if test "$deprecated" = 'yes' ; then + CppAD_DEPRECATED_TRUE= + CppAD_DEPRECATED_FALSE='#' +else + CppAD_DEPRECATED_TRUE='#' + CppAD_DEPRECATED_FALSE= fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $implicit_ctor" >&5 -$as_echo "$implicit_ctor" >&6; } -if test "$implicit_ctor" = "yes" ; then - cppad_implicit_ctor_from_any_type="1" +if test "$deprecated" = "yes" ; then + cppad_deprecated="1" else - cppad_implicit_ctor_from_any_type="0" + cppad_deprecated="0" fi @@ -3644,7 +4915,7 @@ if test "$MAX_NUM_THREADS" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAX_NUM_THREADS" >&5 $as_echo "$MAX_NUM_THREADS" >&6; } - if test "$MAX_NUM_THREADS" -lt "4" ; then + if test "$MAX_NUM_THREADS" -lt "4" ; then as_fn_error $? " MAX_NUM_THREADS=$MAX_NUM_THREADS is less than 4 " "$LINENO" 5 fi @@ -3687,7 +4958,7 @@ ok="yes" fi if test "$ok" == "no" ; then - as_fn_error $? "$addr_t is not a valid choice for TAPE_ADDR_TYPE + as_fn_error $? "$addr_t is not a valid choice for TAPE_ADDR_TYPE " "$LINENO" 5 fi @@ -3721,7 +4992,7 @@ ok="yes" fi if test "$ok" == "no" ; then - as_fn_error $? "$tape_id_t is not a valid choice for TAPE_ID_TYPE + as_fn_error $? "$tape_id_t is not a valid choice for TAPE_ID_TYPE " "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: ********** End Checking Command Line arguments ***************" >&5 @@ -3825,305 +5096,55 @@ if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 -$as_echo_n "checking whether the C++ compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : +else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C++ compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 -$as_echo_n "checking for C++ compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; + test -n "$ac_ct_CXX" && break +done - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no + if test "x$ac_ct_CXX" = x; then + CXX="g++" else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C++ compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac + test $ac_status = 0; } done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : @@ -4206,107 +5227,44 @@ int main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf +{ -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi else - AMDEP_TRUE='#' - AMDEP_FALSE= + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi fi - - +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= @@ -4786,6 +5744,65 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } +if ${am_cv_prog_cc_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 @@ -5176,168 +6193,7 @@ fi - -if test -n "$ac_tool_prefix"; then - for ac_prog in ar lib "link -lib" - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AR" && break - done -fi -if test -z "$AR"; then - ac_ct_AR=$AR - for ac_prog in ar lib "link -lib" -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AR="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_AR" && break -done - - if test "x$ac_ct_AR" = x; then - AR="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -fi - -: ${AR=ar} - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 -$as_echo_n "checking the archiver ($AR) interface... " >&6; } -if ${am_cv_ar_interface+:} false; then : - $as_echo_n "(cached) " >&6 -else - am_cv_ar_interface=ar - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int some_variable = 0; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 - (eval $am_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -eq 0; then - am_cv_ar_interface=ar - else - am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 - (eval $am_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -eq 0; then - am_cv_ar_interface=lib - else - am_cv_ar_interface=unknown - fi - fi - rm -f conftest.lib libconftest.a - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 -$as_echo "$am_cv_ar_interface" >&6; } - -case $am_cv_ar_interface in -ar) - ;; -lib) - # Microsoft lib, so override with the ar-lib wrapper script. - # FIXME: It is wrong to rewrite AR. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__AR in this case, - # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something - # similar. - AR="$am_aux_dir/ar-lib $AR" - ;; -unknown) - as_fn_error $? "could not determine $AR interface" "$LINENO" 5 - ;; -esac - - if test "$AR" = "ar"; then + if test "$have_ar" = 'yes' ; then CppAD_HAVE_AR_TRUE= CppAD_HAVE_AR_FALSE='#' else @@ -5345,24 +6201,31 @@ CppAD_HAVE_AR_FALSE= fi -if test "$AR" != "ar"; then +if test "$have_ar" = 'no'; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot build any libraries because ar is missing; e.g,, speed/* not built " >&5 $as_echo "$as_me: WARNING: cannot build any libraries because ar is missing; e.g,, speed/* not built " >&2;} fi +cppad_cxx_flags="-g -O0" + cppad_has_colpack=0 +cppad_has_mkstemp=1 + + cppad_has_nullptr=0 cppad_has_rvalue=0 cppad_has_cstdint_8_to_64=0 -cppad_compiler_has_erf=0 +cppad_use_cplusplus_2011=0 + +cppad_has_high_resolution_clock=0 ac_ext=c @@ -7051,11 +7914,11 @@ cppad_pkgconfig_libs_value="$cppad_pkgconfig_libs_value -lcppad_ipopt" cppad_pkgconfig_requires_value="ipopt" fi -cppad_cflags="$cppad_pkgconfig_cflags_value" +cppad_pkgconfig_cflags="$cppad_pkgconfig_cflags_value" -cppad_libs="$cppad_pkgconfig_libs_value" +cppad_pkgconfig_libs="$cppad_pkgconfig_libs_value" -cppad_requires="$cppad_pkgconfig_requires_value" +cppad_pkgconfig_requires="$cppad_pkgconfig_requires_value" cppad_SOURCE_DIR=${ABS_TOP_SRCDIR} @@ -7246,10 +8109,22 @@ am__EXEEXT_FALSE= fi +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${CppAD_DOCUMENTATION_TRUE}" && test -z "${CppAD_DOCUMENTATION_FALSE}"; then as_fn_error $? "conditional \"CppAD_DOCUMENTATION\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${CppAD_DEPRECATED_TRUE}" && test -z "${CppAD_DEPRECATED_FALSE}"; then + as_fn_error $? "conditional \"CppAD_DEPRECATED\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${CppAD_POSTFIX_TRUE}" && test -z "${CppAD_POSTFIX_FALSE}"; then as_fn_error $? "conditional \"CppAD_POSTFIX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -7282,10 +8157,6 @@ as_fn_error $? "conditional \"CppAD_OPENMP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error $? "conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -7711,7 +8582,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by cppad $as_me 20150000.9, which was +This file was extended by cppad $as_me 20160000.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7768,7 +8639,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -cppad config.status 20150000.9 +cppad config.status 20160000.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru cppad-2015.00.00.9/configure.ac cppad-2016.00.00.1/configure.ac --- cppad-2015.00.00.9/configure.ac 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/configure.ac 2016-02-09 08:31:53.000000000 +0000 @@ -1,6 +1,6 @@ -dnl $Id: configure.ac 3661 2015-02-23 22:19:20Z bradbell $ +dnl $Id: configure.ac 3786 2016-02-08 13:14:26Z bradbell $ dnl --------------------------------------------------------------------------- -dnl CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +dnl CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell dnl dnl CppAD is distributed under multiple licenses. This distribution is under dnl the terms of the @@ -12,7 +12,7 @@ dnl dnl Process this file with autoconf to produce a configure script. dnl package version bug-report -AC_INIT([cppad], [20150000.9], [cppad@list.coin-or.org]) +AC_INIT([cppad], [20160000.1], [cppad@list.coin-or.org]) AM_SILENT_RULES([yes]) dnl By defalut disable maintainer mode when running configure; @@ -32,6 +32,11 @@ dnl http://lists.gnu.org/archive/html/automake/2010-08/msg00113.html AM_INIT_AUTOMAKE([nostdinc subdir-objects -Wall]) +# check if we have ar program +have_ar='yes' +AM_PROG_AR([have_ar='no']) +AC_MSG_NOTICE([have_ar = $have_ar]) + dnl ---------------------------------------------------------------------- AC_MSG_NOTICE([*** Check command line arguments that are longer used ****]) @@ -208,21 +213,22 @@ fi -dnl Are we including an implicit constructor from any type ----------- -AC_MSG_CHECKING([--with-implicit_ctor]) -AC_ARG_WITH(implicit_ctor, +dnl Are we including deprecated features in the install----------- +AC_MSG_CHECKING([--with-deprecated]) +AC_ARG_WITH(deprecated, AC_HELP_STRING( - [--with-implicit_ctor], + [--with-deprecated], [include an implicit AD constructor from any type] ), - [implicit_ctor="yes"], - [implicit_ctor="no"] + [deprecated="yes"], + [deprecated="no"] ) -AC_MSG_RESULT([$implicit_ctor]) -if test "$implicit_ctor" = "yes" ; then - AC_SUBST(cppad_implicit_ctor_from_any_type, "1") +AC_MSG_RESULT([$deprecated]) +AM_CONDITIONAL(CppAD_DEPRECATED, test "$deprecated" = 'yes' ) +if test "$deprecated" = "yes" ; then + AC_SUBST(cppad_deprecated, "1") else - AC_SUBST(cppad_implicit_ctor_from_any_type, "0") + AC_SUBST(cppad_deprecated, "0") fi dnl The postfix directiory corresponding to CppAD ------------------------ @@ -364,7 +370,7 @@ ) if test "$MAX_NUM_THREADS" != "" ; then AC_MSG_RESULT([$MAX_NUM_THREADS]) - if test "$MAX_NUM_THREADS" -lt "4" ; then + if test "$MAX_NUM_THREADS" -lt "4" ; then AC_MSG_ERROR( [ MAX_NUM_THREADS=$MAX_NUM_THREADS is less than 4 ] ) @@ -403,7 +409,7 @@ ok="yes" fi if test "$ok" == "no" ; then - AC_MSG_ERROR( + AC_MSG_ERROR( [$addr_t is not a valid choice for TAPE_ADDR_TYPE] ) fi @@ -435,7 +441,7 @@ ok="yes" fi if test "$ok" == "no" ; then - AC_MSG_ERROR( + AC_MSG_ERROR( [$tape_id_t is not a valid choice for TAPE_ID_TYPE] ) fi @@ -474,24 +480,29 @@ AM_CONDITIONAL(CppAD_PKG_CONFIG, test "$have_pkg_config" = "yes") dnl check if we can build libraries -AM_PROG_AR() -AM_CONDITIONAL(CppAD_HAVE_AR, test "$AR" = "ar") -if test "$AR" != "ar"; then +AM_CONDITIONAL(CppAD_HAVE_AR, test "$have_ar" = 'yes' ) +if test "$have_ar" = 'no'; then AC_MSG_WARN( [cannot build any libraries because ar is missing; e.g,, speed/* not built] ) fi +dnl test_one.sh.in settings for cppad_cxx_flags +AC_SUBST(cppad_cxx_flags, "-g -O0") -dnl auto-tools version does not support ColPack coloring +dnl auto-tools version does not colpack AC_SUBST(cppad_has_colpack, 0) +dnl auto-tools version will assumes mkstemp is available. +AC_SUBST(cppad_has_mkstemp, 1) + dnl auto-tools version cannot use c++11 compiler dnl so supress corresponding features AC_SUBST(cppad_has_nullptr, 0) AC_SUBST(cppad_has_rvalue, 0) AC_SUBST(cppad_has_cstdint_8_to_64, 0) -AC_SUBST(cppad_compiler_has_erf, 0) +AC_SUBST(cppad_use_cplusplus_2011, 0) +AC_SUBST(cppad_has_high_resolution_clock, 0) dnl Determine if size_t has same size as unsigned int AC_CHECK_SIZEOF([size_t]) @@ -537,8 +548,8 @@ -dnl Have configure check source directory to see if cppad/CppAD.h is there -AC_CONFIG_SRCDIR(cppad/CppAD.h) +dnl Have configure check source directory to see if cppad/cppad.hpp is there +AC_CONFIG_SRCDIR(cppad/cppad.hpp) dnl AC_PROG_CP outputs CPP as command to run C preprocessor AC_PROG_CPP @@ -751,9 +762,9 @@ cppad_pkgconfig_libs_value="$cppad_pkgconfig_libs_value -lcppad_ipopt" cppad_pkgconfig_requires_value="ipopt" fi -AC_SUBST(cppad_cflags, "$cppad_pkgconfig_cflags_value") -AC_SUBST(cppad_libs, "$cppad_pkgconfig_libs_value") -AC_SUBST(cppad_requires, "$cppad_pkgconfig_requires_value") +AC_SUBST(cppad_pkgconfig_cflags, "$cppad_pkgconfig_cflags_value") +AC_SUBST(cppad_pkgconfig_libs, "$cppad_pkgconfig_libs_value") +AC_SUBST(cppad_pkgconfig_requires, "$cppad_pkgconfig_requires_value") dnl dnl names set here so cppad.pc-uninstalled works both with cmake and autoconf AC_SUBST(cppad_SOURCE_DIR, ${ABS_TOP_SRCDIR} ) diff -Nru cppad-2015.00.00.9/cppad/base_require.hpp cppad-2016.00.00.1/cppad/base_require.hpp --- cppad-2015.00.00.9/cppad/base_require.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/base_require.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: base_require.hpp 3495 2014-12-24 01:16:15Z bradbell $ -# ifndef CPPAD_BASE_REQUIRE_INCLUDED -# define CPPAD_BASE_REQUIRE_INCLUDED +// $Id: base_require.hpp 3768 2015-12-28 18:58:35Z bradbell $ +# ifndef CPPAD_BASE_REQUIRE_HPP +# define CPPAD_BASE_REQUIRE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,6 +16,7 @@ /* $begin base_require$$ $spell + azmul ostream alloc eps @@ -27,11 +28,6 @@ Gt cppad.hpp namespace - acos - asin - atan - cos - sqrt optimizations bool const @@ -40,7 +36,7 @@ Lt Le Eq - Ge + Ge Gt inline Op @@ -48,28 +44,27 @@ CondExp $$ -$index Base, require$$ -$index require, Base type$$ -$index type, Base require$$ - -$section AD Requirements for Base Type$$ +$section AD Requirements for a CppAD Base Type$$ $head Syntax$$ -$code include $$ - -$head Warning$$ -This is a preliminary version of these specifications -and it is subject to change in future versions of CppAD. +$code # include $$ $head Purpose$$ -This section lists the requirements that the type +This section lists the requirements for the type $icode Base$$ so that the type $codei%AD<%Base%>%$$ can be used. -$subhead Standard Base Types$$ -In the case where $icode Base$$ is -$code float$$, +$head API Warning$$ +Defining a CppAD $icode Base$$ type is an advanced use of CppAD. +This part of the CppAD API changes with time. The most common change +is adding more requirements. +Search for $code base_require$$ in the +current $cref whats_new$$ section for these changes. + +$head Standard Base Types$$ +In the case where $icode Base$$ is +$code float$$, $code double$$, -$code std::complex$$, +$code std::complex$$, $code std::complex$$, or $codei%AD<%Other%>%$$, these requirements are provided by including the file @@ -78,30 +73,24 @@ $head Include Order$$ If you are linking a non-standard base type to CppAD, you must first include the file $code cppad/base_require.hpp$$, -then provide the specifications below, +then provide the specifications below, and then include the file $code cppad/cppad.hpp$$. $head Numeric Type$$ -The type $icode Base$$ must support all the operations for a +The type $icode Base$$ must support all the operations for a $cref NumericType$$. $head Output Operator$$ -$index output, base operator$$ -$index base, output operator$$ -$index operator, base output$$ The type $icode Base$$ must support the syntax $codei% %os% << %x% %$$ where $icode os$$ is an $code std::ostream&$$ and $icode x$$ is a $code const base_alloc&$$. -For example, see +For example, see $cref/base_alloc/base_alloc.hpp/Output Operator/$$. $head Integer$$ -$index Integer, base require$$ -$index base, Integer require$$ -$index require, base Integer$$ The type $icode Base$$ must support the syntax $codei% %i% = CppAD::Integer(%x%) @@ -129,20 +118,46 @@ $cref/base_float/base_float.hpp/Integer/$$ and $cref/base_alloc/base_alloc.hpp/Integer/$$. +$head Absolute Zero, azmul$$ +The type $icode Base$$ must support the syntax +$codei% + %z% = azmul(%x%, %y%) +%$$ +see; $cref azmul$$. +The following preprocessor macro invocation suffices +(for most $icode Base$$ types): +$codei% +namespace CppAD { + CPPAD_AZMUL(%Base%) +} +%$$ +where the macro is defined by +$codep */ +# define CPPAD_AZMUL(Base) \ + inline Base azmul(const Base& x, const Base& y) \ + { Base zero(0.0); \ + if( x == zero ) \ + return zero; \ + return x * y; \ + } +/* $$ + $childtable% - omh/base_member.omh% + omh/base_require/base_member.omh% cppad/local/base_cond_exp.hpp% - omh/base_identical.omh% - omh/base_ordered.omh% + omh/base_require/base_identical.omh% + omh/base_require/base_ordered.omh% cppad/local/base_std_math.hpp% - omh/base_example.omh + cppad/local/base_limits.hpp% + cppad/local/base_to_string.hpp% + omh/base_require/base_example.omh %$$ $end */ // definitions that must come before base implementations -# include +# include # include # include # include @@ -150,9 +165,11 @@ // grouping documentation by feature # include # include +# include +# include // must define template class numeric_limits before the base cases -# include +# include # include // deprecated // base cases that come with CppAD @@ -160,4 +177,7 @@ # include # include +// deprecated base type +# include + # endif diff -Nru cppad-2015.00.00.9/cppad/CheckNumericType.h cppad-2016.00.00.1/cppad/CheckNumericType.h --- cppad-2015.00.00.9/cppad/CheckNumericType.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/CheckNumericType.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: CheckNumericType.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/check_numeric_type.hpp" diff -Nru cppad-2015.00.00.9/cppad/check_numeric_type.hpp cppad-2016.00.00.1/cppad/check_numeric_type.hpp --- cppad-2015.00.00.9/cppad/check_numeric_type.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/check_numeric_type.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ -/* $Id: check_numeric_type.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_CHECK_NUMERIC_TYPE_INCLUDED -# define CPPAD_CHECK_NUMERIC_TYPE_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin CheckNumericType$$ -$spell - alloc - cppad.hpp - CppAD -$$ - -$section Check NumericType Class Concept$$ - -$index numeric, check$$ -$index check, numeric$$ -$index concept, check numeric$$ - -$head Syntax$$ -$code # include $$ -$pre -$$ -$codei%CheckNumericType<%NumericType%>()%$$ - - -$head Purpose$$ -The syntax -$codei% - CheckNumericType<%NumericType%>() -%$$ -preforms compile and run time checks that the type specified -by $icode NumericType$$ satisfies all the requirements for -a $cref NumericType$$ class. -If a requirement is not satisfied, -a an error message makes it clear what condition is not satisfied. - -$head Include$$ -The file $code cppad/check_numeric_type.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest -if the CppAD include files. - -$head Parallel Mode$$ -$index parallel, CheckNumericType$$ -$index CheckNumericType, parallel$$ -The routine $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ -must be called before it -can be used in $cref/parallel/ta_in_parallel/$$ mode. - -$head Example$$ -$children% - example/check_numeric_type.cpp -%$$ -The file $cref check_numeric_type.cpp$$ -contains an example and test of this function. -It returns true, if it succeeds an false otherwise. -The comments in this example suggest a way to change the example -so an error message occurs. - -$end ---------------------------------------------------------------------------- -*/ - -# include -# include - -namespace CppAD { - -# ifdef NDEBUG - template - void CheckNumericType(void) - { } -# else - template - NumericType CheckNumericType(void) - { // Section 3.6.2 of ISO/IEC 14882:1998(E) states: "The storage for - // objects with static storage duration (3.7.1) shall be zero- - // initialized (8.5) before any other initialization takes place." - static size_t count[CPPAD_MAX_NUM_THREADS]; - size_t thread = thread_alloc::thread_num(); - if( count[thread] > 0 ) - return NumericType(0); - count[thread]++; - /* - contructors - */ - NumericType check_NumericType_default_constructor; - NumericType check_NumericType_constructor_from_int(1); - - const NumericType x(1); - - NumericType check_NumericType_copy_constructor(x); - - // assignment - NumericType check_NumericType_assignment; - check_NumericType_assignment = x; - - /* - unary operators - */ - const NumericType check_NumericType_unary_plus(1); - NumericType check_NumericType_unary_plus_result = - + check_NumericType_unary_plus; - - const NumericType check_NumericType_unary_minus(1); - NumericType check_NumericType_unary_minus_result = - - check_NumericType_unary_minus; - - /* - binary operators - */ - const NumericType check_NumericType_binary_addition(1); - NumericType check_NumericType_binary_addition_result = - check_NumericType_binary_addition + x; - - const NumericType check_NumericType_binary_subtraction(1); - NumericType check_NumericType_binary_subtraction_result = - check_NumericType_binary_subtraction - x; - - const NumericType check_NumericType_binary_multiplication(1); - NumericType check_NumericType_binary_multiplication_result = - check_NumericType_binary_multiplication * x; - - const NumericType check_NumericType_binary_division(1); - NumericType check_NumericType_binary_division_result = - check_NumericType_binary_division / x; - - /* - computed assignment operators - */ - NumericType - check_NumericType_computed_assignment_addition(1); - check_NumericType_computed_assignment_addition += x; - - NumericType - check_NumericType_computed_assignment_subtraction(1); - check_NumericType_computed_assignment_subtraction -= x; - - NumericType - check_NumericType_computed_assignment_multiplication(1); - check_NumericType_computed_assignment_multiplication *= x; - - NumericType - check_NumericType_computed_assignment_division(1); - check_NumericType_computed_assignment_division /= x; - - /* - use all values so as to avoid warnings - */ - check_NumericType_default_constructor = x; - return - + check_NumericType_default_constructor - + check_NumericType_constructor_from_int - + check_NumericType_copy_constructor - + check_NumericType_assignment - + check_NumericType_unary_plus_result - + check_NumericType_unary_minus_result - + check_NumericType_binary_addition_result - + check_NumericType_binary_subtraction_result - + check_NumericType_binary_multiplication_result - + check_NumericType_binary_division_result - + check_NumericType_computed_assignment_addition - + check_NumericType_computed_assignment_subtraction - + check_NumericType_computed_assignment_multiplication - + check_NumericType_computed_assignment_division - ; - } -# endif - -} // end namespace CppAD - -# endif diff -Nru cppad-2015.00.00.9/cppad/CheckSimpleVector.h cppad-2016.00.00.1/cppad/CheckSimpleVector.h --- cppad-2015.00.00.9/cppad/CheckSimpleVector.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/CheckSimpleVector.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: CheckSimpleVector.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/check_simple_vector.hpp" diff -Nru cppad-2015.00.00.9/cppad/check_simple_vector.hpp cppad-2016.00.00.1/cppad/check_simple_vector.hpp --- cppad-2015.00.00.9/cppad/check_simple_vector.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/check_simple_vector.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,207 +0,0 @@ -/* $Id: check_simple_vector.hpp 2870 2013-07-28 17:00:59Z bradbell $ */ -# ifndef CPPAD_CHECK_SIMPLE_VECTOR_INCLUDED -# define CPPAD_CHECK_SIMPLE_VECTOR_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin CheckSimpleVector$$ -$spell - alloc - const - cppad.hpp - CppAD -$$ - -$section Check Simple Vector Concept$$ - -$index simple, vector check$$ -$index vector, simple check$$ -$index check, simple vector$$ -$index concept, check simple vector$$ - -$head Syntax$$ -$code # include $$ -$pre -$$ -$codei%CheckSimpleVector<%Scalar%, %Vector%>()%$$ -$pre -$$ -$codei%CheckSimpleVector<%Scalar%, %Vector%>(%x%, %y%)%$$ - - -$head Purpose$$ -Preforms compile and run time checks that the type specified -by $icode Vector$$ satisfies all the requirements for -a $cref SimpleVector$$ class with -$cref/elements of type/SimpleVector/Elements of Specified Type/$$ -$icode Scalar$$. -If a requirement is not satisfied, -a an error message makes it clear what condition is not satisfied. - -$head x, y$$ -If the arguments $icode x$$ and $icode y$$ are present, -they have prototype -$codei% - const %Scalar%& %x% - const %Scalar%& %y% -%$$ -In addition, the check -$codei% - %x% == %x% -%$$ -will return the boolean value $code true$$, and -$codei% - %x% == %y% -%$$ -will return $code false$$. - -$head Restrictions$$ -If the arguments $icode x$$ and $icode y$$ are not present, -the following extra assumption is made by $code CheckSimpleVector$$: -If $icode x$$ is a $icode Scalar$$ object -$codei% - %x% = 0 - %y% = 1 -%$$ -assigns values to the objects $icode x$$ and $icode y$$. -In addition, -$icode%x% == %x%$$ would return the boolean value $code true$$ and -$icode%x% == %y%$$ would return $code false$$. - -$head Include$$ -The file $code cppad/check_simple_vector.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest -if the CppAD include files. - -$head Parallel Mode$$ -$index parallel, CheckSimpleVector$$ -$index CheckSimpleVector, parallel$$ -The routine $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ -must be called before it -can be used in $cref/parallel/ta_in_parallel/$$ mode. - -$head Example$$ -$children% - example/check_simple_vector.cpp -%$$ -The file $cref check_simple_vector.cpp$$ -contains an example and test of this function where $icode S$$ -is the same as $icode T$$. -It returns true, if it succeeds an false otherwise. -The comments in this example suggest a way to change the example -so $icode S$$ is not the same as $icode T$$. - -$end ---------------------------------------------------------------------------- -*/ - -# include -# include -# include -# include - -namespace CppAD { - -# ifdef NDEBUG - template - inline void CheckSimpleVector(const Scalar& x, const Scalar& y) - { } - template - inline void CheckSimpleVector(void) - { } -# else - template - struct ok_if_S_same_as_T { }; - - template - struct ok_if_S_same_as_T { T value; }; - - template - void CheckSimpleVector(const Scalar& x, const Scalar& y) - { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL - static size_t count; - if( count > 0 ) - return; - count++; - - // value_type must be type of elements of Vector - typedef typename Vector::value_type value_type; - - // check that elements of Vector have type Scalar - struct ok_if_S_same_as_T x_copy; - x_copy.value = x; - - // check default constructor - Vector d; - - // size member function - CPPAD_ASSERT_KNOWN( - d.size() == 0, - "default construtor result does not have size zero" - ); - - // resize to same size as other vectors in test - d.resize(1); - - // check sizing constructor - Vector s(1); - - // check element assignment - s[0] = y; - CPPAD_ASSERT_KNOWN( - s[0] == y, - "element assignment failed" - ); - - // check copy constructor - s[0] = x_copy.value; - const Vector c(s); - s[0] = y; - CPPAD_ASSERT_KNOWN( - c[0] == x, - "copy constructor is shallow" - ); - - // vector assignment operator - d[0] = x; - s = d; - s[0] = y; - CPPAD_ASSERT_KNOWN( - d[0] == x, - "assignment operator is shallow" - ); - - // element access, right side const - // element assignment, left side not const - d[0] = c[0]; - CPPAD_ASSERT_KNOWN( - d[0] == x, - "element assignment from const failed" - ); - } - template - void CheckSimpleVector(void) - { Scalar x; - Scalar y; - - // use assignment and not constructor - x = 0; - y = 1; - - CheckSimpleVector(x, y); - } - -# endif - -} // end namespace CppAD - -# endif diff -Nru cppad-2015.00.00.9/cppad/CMakeLists.txt cppad-2016.00.00.1/cppad/CMakeLists.txt --- cppad-2015.00.00.9/cppad/CMakeLists.txt 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/CMakeLists.txt 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: CMakeLists.txt 3532 2014-12-30 19:49:53Z bradbell $ +# $Id: CMakeLists.txt 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -12,7 +12,7 @@ # Build the cppad/configure.hpp file. # Inherit environment from ../CMakeLists.txt # ----------------------------------------------------------------------------- -MACRO(check_match match_variable match_constant output_variable) +MACRO(check_match match_variable match_constant output_variable) STRING(COMPARE EQUAL ${${match_variable}} ${match_constant} match_flag ) IF( match_flag ) SET(${output_variable} 1) @@ -24,7 +24,7 @@ # ----------------------------------------------------------------------------- # command line arguments # -# cppad_testvector +# cppad_testvector command_line_arg(cppad_testvector cppad STRING "Namespace of vector used for testing, one of: boost, cppad, eigen, std" ) @@ -34,7 +34,7 @@ "maximum number of threads that CppAD can use use" ) # cppad_sparse_list -command_line_arg(cppad_sparse_list YES BOOL +command_line_arg(cppad_sparse_list YES BOOL "use sparse list for internal sparse set representation" ) # @@ -48,17 +48,17 @@ "type used to identify variables on one tape, size must be <= sizeof(size_t)" ) # -# cppad_implicit_ctor_from_any_type -command_line_arg(cppad_implicit_ctor_from_any_type NO BOOL +# cppad_deprecated +command_line_arg(cppad_deprecated NO BOOL "implicit (instead of explicit) conversion from any type to AD" ) # ----------------------------------------------------------------------------- -# cppad_explicit_ctor -IF( cppad_implicit_ctor_from_any_type ) - SET(cppad_implicit_ctor_from_any_type 1) -ELSE( cppad_implicit_ctor_from_any_type ) - SET(cppad_implicit_ctor_from_any_type 0) -ENDIF( cppad_implicit_ctor_from_any_type ) +# cppad_deprecated +IF( cppad_deprecated ) + SET(cppad_deprecated 1) +ELSE( cppad_deprecated ) + SET(cppad_deprecated 0) +ENDIF( cppad_deprecated ) # ----------------------------------------------------------------------------- # cppad_internal_sparse_set # @@ -80,8 +80,8 @@ IF( NOT cppad_cppadvector ) IF( NOT cppad_eigenvector ) IF( NOT cppad_stdvector ) -MESSAGE(FATAL_ERROR -"cppad_testvector not one of following: boost, cppad, eigen, std." +MESSAGE(FATAL_ERROR +"cppad_testvector not one of following: boost, cppad, eigen, std." ) ENDIF( NOT cppad_stdvector ) ENDIF( NOT cppad_eigenvector ) @@ -91,7 +91,7 @@ IF( cppad_boostvector ) # FIND_PACKAGE(Boost) done by ../CMakeLists.txt IF( NOT Boost_FOUND ) - MESSAGE(FATAL_ERROR + MESSAGE(FATAL_ERROR "cppad_testvector == boost but cannot find boost include files" ) ENDIF( NOT Boost_FOUND ) @@ -99,12 +99,29 @@ # IF( cppad_eigenvector ) IF( NOT eigen_prefix ) - MESSAGE(FATAL_ERROR + MESSAGE(FATAL_ERROR "cppad_testvector == eigen but eigen_prefix is not specified" ) ENDIF( NOT eigen_prefix ) ENDIF( cppad_eigenvector ) +# ============================================================================= +# Begin C++11 features +# +SET(cppad_cplusplus_201100_ok 1) +# ----------------------------------------------------------------------------- +# cppad_has_signed_long_long +# +SET(source " +int main(void) +{ signed long long value = 0; + return int(value); +}" +) +check_source_runs("${source}" cppad_has_signed_long_long ) +IF( NOT cppad_has_signed_long_long ) + SET(cppad_cplusplus_201100_ok 0) +ENDIF( NOT cppad_has_signed_long_long ) # ----------------------------------------------------------------------------- # cppad_has_rvalue # @@ -114,9 +131,12 @@ if( value != 3 ) return 1; return 0; -}" +}" ) check_source_runs("${source}" cppad_has_rvalue) +IF( NOT cppad_has_rvalue ) + SET(cppad_cplusplus_201100_ok 0) +ENDIF( NOT cppad_has_rvalue ) # ----------------------------------------------------------------------------- # cppad_has_nullptr # @@ -127,59 +147,100 @@ }" ) check_source_runs("${source}" cppad_has_nullptr) +IF( NOT cppad_has_nullptr ) + SET(cppad_cplusplus_201100_ok 0) +ENDIF( NOT cppad_has_nullptr ) # ----------------------------------------------------------------------------- -# cppad_has_gettimeofday +# cppad_has_cstdint_8_to_64 # SET(source " -# include +# include +template inline bool is_pod(void) { return false; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } int main(void) -{ struct timeval time; - gettimeofday(&time, 0); +{ return 0; } +" +) +check_source_runs("${source}" cppad_has_cstdint_8_to_64) +IF( NOT cppad_has_cstdint_8_to_64 ) + SET(cppad_cplusplus_201100_ok 0) +ENDIF( NOT cppad_has_cstdint_8_to_64 ) +# ----------------------------------------------------------------------------- +# cppad_compiler_has_erf +# cppad_compiler_has_asinh +# cppad_compiler_has_acosh +# cppad_compiler_has_atanh +# cppad_compiler_has_expm1 +# +SET(source_template " +# include +int main(void) +{ std::c11_function(0.0); return 0; -}" +} +" ) -check_source_runs("${source}" cppad_has_gettimeofday) +FOREACH(c11_function erf asinh acosh atanh expm1 log1p) + STRING(REPLACE "c11_function" ${c11_function} source "${source_template}" ) + # really only checking if program compiles + check_source_runs("${source}" cppad_compiler_has_${c11_function} ) + IF( NOT cppad_compiler_has_${c11_function} ) + SET(cppad_cplusplus_201100_ok 0) + ENDIF( NOT cppad_compiler_has_${c11_function} ) +ENDFOREACH(c11_function) # ----------------------------------------------------------------------------- -# cppad_size_t_not_unsigned_int +# cppad_has_high_resolution_clock # SET(source " -# include -template inline bool is_pod(void) { return false; } -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } +# include int main(void) -{ return 0; } +{ std::chrono::time_point start, end; + start = std::chrono::high_resolution_clock::now(); + end = std::chrono::high_resolution_clock::now(); + std::chrono::duration difference = end - start; + double elapsed_seconds = difference.count(); + if( elapsed_seconds > 0.0 ) + return 0; + return 1; +} " ) -check_source_runs("${source}" cppad_size_t_not_unsigned_int) +check_source_runs("${source}" cppad_has_high_resolution_clock) +IF( NOT cppad_has_high_resolution_clock ) + SET(cppad_cplusplus_201100_ok 0) +ENDIF( NOT cppad_has_high_resolution_clock ) +# ============================================================================= +# End C++11 features +# +MESSAGE(STATUS "cppad_cplusplus_201100_ok = ${cppad_cplusplus_201100_ok}") # ----------------------------------------------------------------------------- -# cppad_has_cstdint_8_to_64 +# cppad_has_gettimeofday # SET(source " -# include -template inline bool is_pod(void) { return false; } -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } +# include int main(void) -{ return 0; } -" +{ struct timeval time; + gettimeofday(&time, 0); + return 0; +}" ) -check_source_runs("${source}" cppad_has_cstdint_8_to_64) +check_source_runs("${source}" cppad_has_gettimeofday) # ----------------------------------------------------------------------------- -# cppad_compiler_has_erf +# cppad_size_t_not_unsigned_int # SET(source " -# include +# include +template inline bool is_pod(void) { return false; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } int main(void) -{ if( std::erf(0.0) == 0.0 ) - return 0; - return 1; -} +{ return 0; } " ) -check_source_runs("${source}" cppad_compiler_has_erf) +check_source_runs("${source}" cppad_size_t_not_unsigned_int) # ----------------------------------------------------------------------------- # cppad_tape_addr_type, cppad_tape_id_type # @@ -187,20 +248,20 @@ SET(source " # include int main(void) -{ bool is_signed = std::numeric_limits<${${cmake_var}}>::is_signed; - return int(! is_signed); +{ bool is_unsigned = ! std::numeric_limits<${${cmake_var}}>::is_signed; + return int(! is_unsigned); } " ) - check_source_runs("${source}" ${cmake_var}_is_signed) - IF( ${cmake_var}_is_signed STREQUAL 1 ) - MESSAGE(STATUS -"Warning: using a signed ${cmake_var} (for CppAD developers not users)" + check_source_runs("${source}" ${cmake_var}_is_unsigned) + IF( ${cmake_var}_is_unsigned STREQUAL 0 ) + MESSAGE(STATUS +"Warning: using a signed ${cmake_var} is for CppAD developers only !" ) - ENDIF( ${cmake_var}_is_signed STREQUAL 1 ) + ENDIF( ${cmake_var}_is_unsigned STREQUAL 0 ) ENDFOREACH( cmake_var ) # ----------------------------------------------------------------------------- -# cppad_max_num_threads +# check that cppad_max_num_threads is >= 4 # SET(CMAKE_REQUIRED_INCLUDES "") SET(CMAKE_REQUIRED_LIBRARIES "") @@ -224,17 +285,44 @@ return 0; } " ) +# Using CHECK_CXX_SOURCE_RUNS directly (instead of check_source_runs). CHECK_CXX_SOURCE_RUNS("${source}" cppad_max_num_threads_is_integer_ge_4) IF( NOT cppad_max_num_threads_is_integer_ge_4 ) - MESSAGE(FATAL_ERROR + MESSAGE(FATAL_ERROR "cppad_max_num_threads is not an integer greater than or equal 4" ) ENDIF( NOT cppad_max_num_threads_is_integer_ge_4 ) - +# ----------------------------------------------------------------------------- +# cppad_has_mkstemp +# +SET(source " +# include +# include +int main(void) +{ + char pattern[] = \"/tmp/fileXXXXXX\"; + int fd = mkstemp(pattern); + return 0; +} +" ) +check_source_runs("${source}" cppad_has_mkstemp ) +# ----------------------------------------------------------------------------- +# cppad_has_tmpname_s +# +SET(source " +# include +int main(void) +{ char filename[L_tmpnam_s ]; + if( tmpnam_s(filename, L_tmpnam_s ) != 0 ) + return 1; + return 0; +} +" ) +check_source_runs("${source}" cppad_has_tmpnam_s ) # ----------------------------------------------------------------------------- # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp ) diff -Nru cppad-2015.00.00.9/cppad/configure.hpp.in cppad-2016.00.00.1/cppad/configure.hpp.in --- cppad-2015.00.00.9/cppad/configure.hpp.in 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/configure.hpp.in 2016-02-09 08:31:49.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: configure.hpp.in 3495 2014-12-24 01:16:15Z bradbell $ -# ifndef CPPAD_CONFIGURE_INCLUDED -# define CPPAD_CONFIGURE_INCLUDED +// $Id: configure.hpp.in 3760 2015-12-01 04:12:28Z bradbell $ +# ifndef CPPAD_CONFIGURE_HPP +# define CPPAD_CONFIGURE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,13 +19,9 @@ CppAD $$ -$section Preprocessor Definitions Used by CppAD$$ -$index configure, symbol$$ -$index symbol, configure$$ +$section Configuration Preprocessor Symbols Used by CppAD$$ $head Preprocessor Symbols$$ -$index preprocessor, symbol$$ -$index symbol, processor$$ All of the preprocessor symbols used by CppAD begin with $code CPPAD_$$ (there are some deprecated symbols that begin with $code CppAD$$). @@ -35,14 +31,41 @@ /*! \file configure.hpp -Replacement for config.h so that all preprocessor symbols begin with CPPAD_ +Replacement for config.h so that all preprocessor symbols begin with CPPAD_ */ /*! -\def CPPAD_HAS_RVALUE -Does this compiler cupport c++11 rvalues; i.e., values with move semantics +\def CPPAD_DISABLE_SOME_MICROSOFT_COMPILER_WARNINGS +This macro is only used to document the pragmas that disables the +follow warnings: + +\li C4100 +unreferenced formal parameter. +\li C4127 +conditional expression is constant. */ -# define CPPAD_HAS_RVALUE @cppad_has_rvalue@ +# define CPPAD_DISABLE_SOME_MICROSOFT_COMPILER_WARNINGS 1 +# if _MSC_VER +# pragma warning( disable : 4100 ) +# pragma warning( disable : 4127 ) +# endif +# undef CPPAD_DISABLE_SOME_MICROSOFT_COMPILER_WARNINGS + +/*! +\def CPPAD_USE_CPLUSPLUS_2011 +Should CppAD use C++11 features. This will be true if the current +compiler flags request C++11 features and the install procedure +determined that all the necessary features are avaiable. +*/ +# if _MSC_VER +# define CPPAD_USE_CPLUSPLUS_2011 @cppad_cplusplus_201100_ok@ +# else // +# if __cplusplus >= 201100 +# define CPPAD_USE_CPLUSPLUS_2011 @cppad_cplusplus_201100_ok@ +# else // +# define CPPAD_USE_CPLUSPLUS_2011 0 +# endif // +# endif // /*! \def CPPAD_PACKAGE_STRING @@ -57,13 +80,6 @@ # define CPPAD_HAS_COLPACK @cppad_has_colpack@ /*! -def CPPAD_HAS_NULLPTR -Does this compiler support the a c++11 null-pointer constant nullptr -(true = 1, false = 0). -*/ -# define CPPAD_HAS_NULLPTR @cppad_has_nullptr@ - - /*! def CPPAD_INTERNAL_SPARSE_SET is the internal representation used for sparse vectors of std::set either sparse_set or sparse_list). @@ -71,45 +87,45 @@ # define CPPAD_INTERNAL_SPARSE_SET @cppad_internal_sparse_set@ /*! -\def CPPAD_IMPLICIT_CTOR_FROM_ANY_TYPE -If this symbol is one, an implicit constor of AD is defined +\def CPPAD_DEPRECATED +If this symbol is one, an implicit constor of AD is defined where the argument has any type. Otherwise this constructor is explicit. */ -# define CPPAD_IMPLICIT_CTOR_FROM_ANY_TYPE @cppad_implicit_ctor_from_any_type@ +# define CPPAD_DEPRECATED @cppad_deprecated@ /*! \def CPPAD_BOOSTVECTOR If this symbol is one, and _MSC_VER is not defined, we are using boost vector for CPPAD_TESTVECTOR. -It this symbol is zero, +It this symbol is zero, we are not using boost vector for CPPAD_TESTVECTOR. */ # define CPPAD_BOOSTVECTOR @cppad_boostvector@ /*! \def CPPAD_CPPADVECTOR -If this symbol is one, +If this symbol is one, we are using CppAD vector for CPPAD_TESTVECTOR. -It this symbol is zero, +It this symbol is zero, we are not using CppAD vector for CPPAD_TESTVECTOR. */ # define CPPAD_CPPADVECTOR @cppad_cppadvector@ /*! \def CPPAD_STDVECTOR -If this symbol is one, +If this symbol is one, we are using standard vector for CPPAD_TESTVECTOR. -It this symbol is zero, +It this symbol is zero, we are not using standard vector for CPPAD_TESTVECTOR. */ # define CPPAD_STDVECTOR @cppad_stdvector@ /*! \def CPPAD_EIGENVECTOR -If this symbol is one, +If this symbol is one, we are using Eigen vector for CPPAD_TESTVECTOR. -If this symbol is zero, +If this symbol is zero, we are not using Eigen vector for CPPAD_TESTVECTOR. */ # define CPPAD_EIGENVECTOR @cppad_eigenvector@ @@ -123,29 +139,15 @@ # define CPPAD_HAS_GETTIMEOFDAY @cppad_has_gettimeofday@ /*! -\def CPPAD_SIZE_T_NOT_UNSIGNED_INT +\def CPPAD_SIZE_T_NOT_UNSIGNED_INT If this symbol is zero, the type size_t is the same as the type unsigned int, otherwise this symbol is one. */ # define CPPAD_SIZE_T_NOT_UNSIGNED_INT @cppad_size_t_not_unsigned_int@ /*! -\def CPPAD_HAS_CSTDINT_8_TO_64 -If this symbol is one, the types uint_8, uint_16, uint_32, and uint_64 -are defined. otherwise this symbol is zero. -*/ -# define CPPAD_HAS_CSTDINT_8_TO_64 @cppad_has_cstdint_8_to_64@ - -/*! -\def CPPAD_COMPILER_HAS_ERF -If this symbol is one, the function std::erf(double) is defined by the -C++ compiler, otherwise the symbol is zero. -*/ -# define CPPAD_COMPILER_HAS_ERF @cppad_compiler_has_erf@ - -/*! \def CPPAD_TAPE_ADDR_TYPE -Is the type used to store address on the tape. If not size_t, then +Is the type used to store address on the tape. If not size_t, then sizeof(CPPAD_TAPE_ADDR_TYPE) <= sizeof( size_t ) to conserve memory. This type must support \c std::numeric_limits, @@ -159,7 +161,7 @@ /*! \def CPPAD_TAPE_ID_TYPE -Is the type used to store tape identifiers. If not size_t, then +Is the type used to store tape identifiers. If not size_t, then sizeof(CPPAD_TAPE_ID_TYPE) <= sizeof( size_t ) to conserve memory. This type must support \c std::numeric_limits, @@ -170,7 +172,7 @@ This type is later defined as \c tape_id_t in the CppAD namespace. */ # define CPPAD_TAPE_ID_TYPE @cppad_tape_id_type@ - + /*! \def CPPAD_MAX_NUM_THREADS Specifies the maximum number of threads that CppAD can support @@ -183,4 +185,34 @@ # define CPPAD_MAX_NUM_THREADS @cppad_max_num_threads@ # endif +/*! +\def CPPAD_HAS_MKSTEMP +It true, mkstemp works in C++ on this system. +*/ +# define CPPAD_HAS_MKSTEMP @cppad_has_mkstemp@ + +/*! +\def CPPAD_HAS_TMPNAM_S +It true, tmpnam_s works in C++ on this system. +*/ +# define CPPAD_HAS_TMPNAM_S @cppad_has_tmpnam_s@ + +// --------------------------------------------------------------------------- +// defines that only depend on values above +// --------------------------------------------------------------------------- +/*! +\def CPPAD_NULL +This preprocessor symbol is used for a null pointer. + +If it is not yet defined, +it is defined when cppad/local/define.hpp is included. +*/ +# ifndef CPPAD_NULL +# if CPPAD_USE_CPLUSPLUS_2011 +# define CPPAD_NULL nullptr +# else +# define CPPAD_NULL 0 +# endif +# endif + # endif diff -Nru cppad-2015.00.00.9/cppad/COPYING cppad-2016.00.00.1/cppad/COPYING --- cppad-2015.00.00.9/cppad/COPYING 2012-10-24 19:36:49.000000000 +0000 +++ cppad-2016.00.00.1/cppad/COPYING 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - Eclipse Public License Version 1.0. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -Eclipse Public License Version 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC -LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM -CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - - a) in the case of the initial Contributor, the initial code and -documentation distributed under this Agreement, and - - b) in the case of each subsequent Contributor: - - i) changes to the Program, and - - ii) additions to the Program; - - where such changes and/or additions to the Program originate from and are -distributed by that particular Contributor. A Contribution 'originates' from a -Contributor if it was added to the Program by such Contributor itself or anyone -acting on such Contributor's behalf. Contributions do not include additions to -the Program which: (i) are separate modules of software distributed in -conjunction with the Program under their own license agreement, and (ii) are not -derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor which are -necessarily infringed by the use or sale of its Contribution alone or when -combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, -including all Contributors. - -2. GRANT OF RIGHTS - - a) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free copyright license to -reproduce, prepare derivative works of, publicly display, publicly perform, -distribute and sublicense the Contribution of such Contributor, if any, and such -derivative works, in source code and object code form. - - b) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed -Patents to make, use, sell, offer to sell, import and otherwise transfer the -Contribution of such Contributor, if any, in source code and object code form. -This patent license shall apply to the combination of the Contribution and the -Program if, at the time the Contribution is added by the Contributor, such -addition of the Contribution causes such combination to be covered by the -Licensed Patents. The patent license shall not apply to any other combinations -which include the Contribution. No hardware per se is licensed hereunder. - - c) Recipient understands that although each Contributor grants the licenses -to its Contributions set forth herein, no assurances are provided by any -Contributor that the Program does not infringe the patent or other intellectual -property rights of any other entity. Each Contributor disclaims any liability to -Recipient for claims brought by any other entity based on infringement of -intellectual property rights or otherwise. As a condition to exercising the -rights and licenses granted hereunder, each Recipient hereby assumes sole -responsibility to secure any other intellectual property rights needed, if any. -For example, if a third party patent license is required to allow Recipient to -distribute the Program, it is Recipient's responsibility to acquire that license -before distributing the Program. - - d) Each Contributor represents that to its knowledge it has sufficient -copyright rights in its Contribution, if any, to grant the copyright license set -forth in this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its -own license agreement, provided that: - - a) it complies with the terms and conditions of this Agreement; and - - b) its license agreement: - - i) effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title and -non-infringement, and implied warranties or conditions of merchantability and -fitness for a particular purpose; - - ii) effectively excludes on behalf of all Contributors all liability for -damages, including direct, indirect, special, incidental and consequential -damages, such as lost profits; - - iii) states that any provisions which differ from this Agreement are offered -by that Contributor alone and not by any other party; and - - iv) states that source code for the Program is available from such -Contributor, and informs licensees how to obtain it in a reasonable manner on or -through a medium customarily used for software exchange. - -When the Program is made available in source code form: - - a) it must be made available under this Agreement; and - - b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the -Program. - -Each Contributor must identify itself as the originator of its Contribution, if -any, in a manner that reasonably allows subsequent Recipients to identify the -originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with -respect to end users, business partners and the like. While this license is -intended to facilitate the commercial use of the Program, the Contributor who -includes the Program in a commercial product offering should do so in a manner -which does not create potential liability for other Contributors. Therefore, if -a Contributor includes the Program in a commercial product offering, such -Contributor ("Commercial Contributor") hereby agrees to defend and indemnify -every other Contributor ("Indemnified Contributor") against any losses, damages -and costs (collectively "Losses") arising from claims, lawsuits and other legal -actions brought by a third party against the Indemnified Contributor to the -extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor to -control, and cooperate with the Commercial Contributor in, the defense and any -related settlement negotiations. The Indemnified Contributor may participate in -any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product -offering, Product X. That Contributor is then a Commercial Contributor. If that -Commercial Contributor then makes performance claims, or offers warranties -related to Product X, those performance claims and warranties are such -Commercial Contributor's responsibility alone. Under this section, the -Commercial Contributor would have to defend claims against the other -Contributors related to those performance claims and warranties, and if a court -requires any other Contributor to pay any damages as a result, the Commercial -Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR -IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each -Recipient is solely responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its exercise of -rights under this Agreement, including but not limited to the risks and costs of -program errors, compliance with applicable laws, damage to or loss of data, -programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY -CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST -PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS -GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable -law, it shall not affect the validity or enforceability of the remainder of the -terms of this Agreement, and without further action by the parties hereto, such -provision shall be reformed to the minimum extent necessary to make such -provision valid and enforceable. - -If Recipient institutes patent litigation against a Contributor with respect to -a patent applicable to software (including a cross-claim or counterclaim in a -lawsuit), then any patent licenses granted by that Contributor to such Recipient -under this Agreement shall terminate as of the date such litigation is filed. In -addition, if Recipient institutes patent litigation against any entity -(including a cross-claim or counterclaim in a lawsuit) alleging that the Program -itself (excluding combinations of the Program with other software or hardware) -infringes such Recipient's patent(s), then such Recipient's rights granted under -Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it fails to -comply with any of the material terms or conditions of this Agreement and does -not cure such failure in a reasonable period of time after becoming aware of -such noncompliance. If all Recipient's rights under this Agreement terminate, -Recipient agrees to cease use and distribution of the Program as soon as -reasonably practicable. However, Recipient's obligations under this Agreement -and any licenses granted by Recipient relating to the Program shall continue and -survive. - -Everyone is permitted to copy and distribute copies of this Agreement, but in -order to avoid inconsistency the Agreement is copyrighted and may only be -modified in the following manner. The Agreement Steward reserves the right to -publish new versions (including revisions) of this Agreement from time to time. -No one other than the Agreement Steward has the right to modify this Agreement. -IBM is the initial Agreement Steward. IBM may assign the responsibility to serve -as the Agreement Steward to a suitable separate entity. Each new version of the -Agreement will be given a distinguishing version number. The Program (including -Contributions) may always be distributed subject to the version of the Agreement -under which it was received. In addition, after a new version of the Agreement -is published, Contributor may elect to distribute the Program (including its -Contributions) under the new version. Except as expressly stated in Sections -2(a) and 2(b) above, Recipient receives no rights or licenses to the -intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and the -intellectual property laws of the United States of America. No party to this -Agreement will bring a legal action under this Agreement more than one year -after the cause of action arose. Each party waives its rights to a jury trial in -any resulting litigation. diff -Nru cppad-2015.00.00.9/cppad/CppAD.h cppad-2016.00.00.1/cppad/CppAD.h --- cppad-2015.00.00.9/cppad/CppAD.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/CppAD.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: CppAD.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/cppad.hpp" diff -Nru cppad-2015.00.00.9/cppad/cppad.hpp cppad-2016.00.00.1/cppad/cppad.hpp --- cppad-2015.00.00.9/cppad/cppad.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/cppad.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -1,8 +1,8 @@ -/* $Id: cppad.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_CPPAD_INCLUDED -# define CPPAD_CPPAD_INCLUDED +// $Id: cppad.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_CPPAD_HPP +# define CPPAD_CPPAD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -22,32 +22,9 @@ # include // all base type requirements // --------------------------------------------------------------------------- // CppAD general purpose library routines (can be included separately) - -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include - +# include // -------------------------------------------------------------------------- -// System routines that can be used by rest of CppAD with out including +// System routines that can be used by rest of CppAD with out including # include # include @@ -92,6 +69,6 @@ # include // undo definitions in Define.h -# include +# include # endif diff -Nru cppad-2015.00.00.9/cppad/CppAD_vector.h cppad-2016.00.00.1/cppad/CppAD_vector.h --- cppad-2015.00.00.9/cppad/CppAD_vector.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/CppAD_vector.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: CppAD_vector.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/vector.hpp" diff -Nru cppad-2015.00.00.9/cppad/deprecated/CheckNumericType.h cppad-2016.00.00.1/cppad/deprecated/CheckNumericType.h --- cppad-2015.00.00.9/cppad/deprecated/CheckNumericType.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/CheckNumericType.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/check_numeric_type.hpp cppad-2016.00.00.1/cppad/deprecated/check_numeric_type.hpp --- cppad-2015.00.00.9/cppad/deprecated/check_numeric_type.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/check_numeric_type.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/CheckSimpleVector.h cppad-2016.00.00.1/cppad/deprecated/CheckSimpleVector.h --- cppad-2015.00.00.9/cppad/deprecated/CheckSimpleVector.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/CheckSimpleVector.h 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/check_simple_vector.hpp cppad-2016.00.00.1/cppad/deprecated/check_simple_vector.hpp --- cppad-2015.00.00.9/cppad/deprecated/check_simple_vector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/check_simple_vector.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/CppAD.h cppad-2016.00.00.1/cppad/deprecated/CppAD.h --- cppad-2015.00.00.9/cppad/deprecated/CppAD.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/CppAD.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/CppAD_vector.h cppad-2016.00.00.1/cppad/deprecated/CppAD_vector.h --- cppad-2015.00.00.9/cppad/deprecated/CppAD_vector.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/CppAD_vector.h 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/elapsed_seconds.hpp cppad-2016.00.00.1/cppad/deprecated/elapsed_seconds.hpp --- cppad-2015.00.00.9/cppad/deprecated/elapsed_seconds.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/elapsed_seconds.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/ErrorHandler.h cppad-2016.00.00.1/cppad/deprecated/ErrorHandler.h --- cppad-2015.00.00.9/cppad/deprecated/ErrorHandler.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/ErrorHandler.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/error_handler.hpp cppad-2016.00.00.1/cppad/deprecated/error_handler.hpp --- cppad-2015.00.00.9/cppad/deprecated/error_handler.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/error_handler.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/index_sort.hpp cppad-2016.00.00.1/cppad/deprecated/index_sort.hpp --- cppad-2015.00.00.9/cppad/deprecated/index_sort.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/index_sort.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/LuFactor.h cppad-2016.00.00.1/cppad/deprecated/LuFactor.h --- cppad-2015.00.00.9/cppad/deprecated/LuFactor.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/LuFactor.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/lu_factor.hpp cppad-2016.00.00.1/cppad/deprecated/lu_factor.hpp --- cppad-2015.00.00.9/cppad/deprecated/lu_factor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/lu_factor.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/LuInvert.h cppad-2016.00.00.1/cppad/deprecated/LuInvert.h --- cppad-2015.00.00.9/cppad/deprecated/LuInvert.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/LuInvert.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/lu_invert.hpp cppad-2016.00.00.1/cppad/deprecated/lu_invert.hpp --- cppad-2015.00.00.9/cppad/deprecated/lu_invert.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/lu_invert.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/LuSolve.h cppad-2016.00.00.1/cppad/deprecated/LuSolve.h --- cppad-2015.00.00.9/cppad/deprecated/LuSolve.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/LuSolve.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/lu_solve.hpp cppad-2016.00.00.1/cppad/deprecated/lu_solve.hpp --- cppad-2015.00.00.9/cppad/deprecated/lu_solve.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/lu_solve.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/memory_leak.hpp cppad-2016.00.00.1/cppad/deprecated/memory_leak.hpp --- cppad-2015.00.00.9/cppad/deprecated/memory_leak.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/memory_leak.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/nan.hpp cppad-2016.00.00.1/cppad/deprecated/nan.hpp --- cppad-2015.00.00.9/cppad/deprecated/nan.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/nan.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/NearEqual.h cppad-2016.00.00.1/cppad/deprecated/NearEqual.h --- cppad-2015.00.00.9/cppad/deprecated/NearEqual.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/NearEqual.h 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/near_equal.hpp cppad-2016.00.00.1/cppad/deprecated/near_equal.hpp --- cppad-2015.00.00.9/cppad/deprecated/near_equal.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/near_equal.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/OdeErrControl.h cppad-2016.00.00.1/cppad/deprecated/OdeErrControl.h --- cppad-2015.00.00.9/cppad/deprecated/OdeErrControl.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/OdeErrControl.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/ode_err_control.hpp cppad-2016.00.00.1/cppad/deprecated/ode_err_control.hpp --- cppad-2015.00.00.9/cppad/deprecated/ode_err_control.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/ode_err_control.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/OdeGearControl.h cppad-2016.00.00.1/cppad/deprecated/OdeGearControl.h --- cppad-2015.00.00.9/cppad/deprecated/OdeGearControl.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/OdeGearControl.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/ode_gear_control.hpp cppad-2016.00.00.1/cppad/deprecated/ode_gear_control.hpp --- cppad-2015.00.00.9/cppad/deprecated/ode_gear_control.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/ode_gear_control.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/OdeGear.h cppad-2016.00.00.1/cppad/deprecated/OdeGear.h --- cppad-2015.00.00.9/cppad/deprecated/OdeGear.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/OdeGear.h 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/ode_gear.hpp cppad-2016.00.00.1/cppad/deprecated/ode_gear.hpp --- cppad-2015.00.00.9/cppad/deprecated/ode_gear.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/ode_gear.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/omp_alloc.hpp cppad-2016.00.00.1/cppad/deprecated/omp_alloc.hpp --- cppad-2015.00.00.9/cppad/deprecated/omp_alloc.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/omp_alloc.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/Poly.h cppad-2016.00.00.1/cppad/deprecated/Poly.h --- cppad-2015.00.00.9/cppad/deprecated/Poly.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/Poly.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/poly.hpp cppad-2016.00.00.1/cppad/deprecated/poly.hpp --- cppad-2015.00.00.9/cppad/deprecated/poly.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/poly.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/PowInt.h cppad-2016.00.00.1/cppad/deprecated/PowInt.h --- cppad-2015.00.00.9/cppad/deprecated/PowInt.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/PowInt.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/pow_int.hpp cppad-2016.00.00.1/cppad/deprecated/pow_int.hpp --- cppad-2015.00.00.9/cppad/deprecated/pow_int.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/pow_int.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/RombergMul.h cppad-2016.00.00.1/cppad/deprecated/RombergMul.h --- cppad-2015.00.00.9/cppad/deprecated/RombergMul.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/RombergMul.h 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/romberg_mul.hpp cppad-2016.00.00.1/cppad/deprecated/romberg_mul.hpp --- cppad-2015.00.00.9/cppad/deprecated/romberg_mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/romberg_mul.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/RombergOne.h cppad-2016.00.00.1/cppad/deprecated/RombergOne.h --- cppad-2015.00.00.9/cppad/deprecated/RombergOne.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/RombergOne.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/romberg_one.hpp cppad-2016.00.00.1/cppad/deprecated/romberg_one.hpp --- cppad-2015.00.00.9/cppad/deprecated/romberg_one.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/romberg_one.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/Rosen34.h cppad-2016.00.00.1/cppad/deprecated/Rosen34.h --- cppad-2015.00.00.9/cppad/deprecated/Rosen34.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/Rosen34.h 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/rosen_34.hpp cppad-2016.00.00.1/cppad/deprecated/rosen_34.hpp --- cppad-2015.00.00.9/cppad/deprecated/rosen_34.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/rosen_34.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/Runge45.h cppad-2016.00.00.1/cppad/deprecated/Runge45.h --- cppad-2015.00.00.9/cppad/deprecated/Runge45.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/Runge45.h 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/runge_45.hpp cppad-2016.00.00.1/cppad/deprecated/runge_45.hpp --- cppad-2015.00.00.9/cppad/deprecated/runge_45.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/runge_45.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/SpeedTest.h cppad-2016.00.00.1/cppad/deprecated/SpeedTest.h --- cppad-2015.00.00.9/cppad/deprecated/SpeedTest.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/SpeedTest.h 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/speed_test.hpp cppad-2016.00.00.1/cppad/deprecated/speed_test.hpp --- cppad-2015.00.00.9/cppad/deprecated/speed_test.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/speed_test.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/thread_alloc.hpp cppad-2016.00.00.1/cppad/deprecated/thread_alloc.hpp --- cppad-2015.00.00.9/cppad/deprecated/thread_alloc.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/thread_alloc.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/time_test.hpp cppad-2016.00.00.1/cppad/deprecated/time_test.hpp --- cppad-2015.00.00.9/cppad/deprecated/time_test.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/time_test.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/TrackNewDel.h cppad-2016.00.00.1/cppad/deprecated/TrackNewDel.h --- cppad-2015.00.00.9/cppad/deprecated/TrackNewDel.h 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/TrackNewDel.h 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/track_new_del.hpp cppad-2016.00.00.1/cppad/deprecated/track_new_del.hpp --- cppad-2015.00.00.9/cppad/deprecated/track_new_del.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/track_new_del.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/deprecated/vector.hpp cppad-2016.00.00.1/cppad/deprecated/vector.hpp --- cppad-2015.00.00.9/cppad/deprecated/vector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/deprecated/vector.hpp 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1 @@ +# include diff -Nru cppad-2015.00.00.9/cppad/elapsed_seconds.hpp cppad-2016.00.00.1/cppad/elapsed_seconds.hpp --- cppad-2015.00.00.9/cppad/elapsed_seconds.hpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/cppad/elapsed_seconds.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -/* $Id: elapsed_seconds.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_ELAPSED_SECONDS_INCLUDED -# define CPPAD_ELAPSED_SECONDS_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin elapsed_seconds$$ -$spell - Microsoft - gettimeofday - std -$$ - -$section Returns Elapsed Number of Seconds$$ -$index elapsed_seconds$$ -$index seconds, time$$ -$index time, seconds$$ - - -$head Syntax$$ -$icode%s% = elapsed_seconds()%$$ - -$head Purpose$$ -This routine is accurate to within .02 seconds -(see $cref elapsed_seconds.cpp$$). -It does not necessary work for time intervals that are greater than a day. -$list number$$ -If running under the Microsoft compiler, it uses -$code ::GetSystemTime$$ for timing. -$lnext -Otherwise, if $code gettimeofday$$ is available, it is used. -$lnext -Otherwise, $code std::clock()$$ is used. -$lend - -$head s$$ -is a $code double$$ equal to the -number of seconds since the first call to $code elapsed_seconds$$. - -$head Microsoft Systems$$ -It you are using the Microsoft C++ compiler, -you will need to link in the external routine -called $cref microsoft_timer$$. - -$children% - speed/example/elapsed_seconds.cpp -%$$ -$head Example$$ -The routine $cref elapsed_seconds.cpp$$ is -an example and test of this routine. - - -$end ------------------------------------------------------------------------ -*/ - -// For some unknown reason under Fedora (which needs to be understood), -// if you move this include for cppad_assert.hpp below include for define.hpp, -// cd work/speed/example -// make test.sh -// fails with the error message 'gettimeofday' not defined. -# include - -# ifdef _MSC_VER -extern double microsoft_timer(void); -# elif CPPAD_HAS_GETTIMEOFDAY -# include -# else -# include -# endif - -// define CPPAD_NULL -# include - -// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include -namespace CppAD { // BEGIN_CPPAD_NAMESPACE -/*! -\file elapsed_seconds.hpp -\brief Function that returns the elapsed seconds from first call. -*/ - -/*! -Returns the elapsed number since the first call to this function. - -This routine tries is accurate to within .02 seconds. -It does not necessary work for time intervals that are less than a day. -\li -If running under the Microsoft system, it uses \c ::%GetSystemTime for timing. -\li -Otherwise, if \c gettimeofday is available, it is used. -\li -Otherwise, \c std::clock() is used. - -\return -The number of seconds since the first call to \c elapsed_seconds. -*/ -inline double elapsed_seconds(void) -# ifdef _MSC_VER -{ return microsoft_timer(); } - -# elif CPPAD_HAS_GETTIMEOFDAY -{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; - static bool first_ = true; - static struct timeval tv_; - struct timeval tv; - if( first_ ) - { gettimeofday(&tv_, CPPAD_NULL); - first_ = false; - return 0.; - } - gettimeofday(&tv, CPPAD_NULL); - assert( tv.tv_sec >= tv_.tv_sec ); - - double sec = double(tv.tv_sec - tv_.tv_sec); - double usec = double(tv.tv_usec) - double(tv_.tv_usec); - double diff = sec + 1e-6*usec; - - return diff; -} -# else -{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; - static bool first_ = true; - static double tic_; - double tic; - if( first_ ) - { tic_ = double(std::clock()); - first_ = false; - return 0.; - } - tic = double( std::clock() ); - - double diff = (tic - tic_) / double(CLOCKS_PER_SEC); - - return diff; -} -# endif - -} // END_CPPAD_NAMESPACE -# endif diff -Nru cppad-2015.00.00.9/cppad/ErrorHandler.h cppad-2016.00.00.1/cppad/ErrorHandler.h --- cppad-2015.00.00.9/cppad/ErrorHandler.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/ErrorHandler.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: ErrorHandler.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/error_handler.hpp" diff -Nru cppad-2015.00.00.9/cppad/error_handler.hpp cppad-2016.00.00.1/cppad/error_handler.hpp --- cppad-2015.00.00.9/cppad/error_handler.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/error_handler.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,238 +0,0 @@ -/* $Id: error_handler.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ERROR_HANDLER_INCLUDED -# define CPPAD_ERROR_HANDLER_INCLUDED -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin ErrorHandler$$ -$spell - cppad.hpp - CppAD - exp - bool - const -$$ - -$section Replacing the CppAD Error Handler$$ -$index error, handler$$ -$index handler, error$$ -$index replace, error handler$$ -$index assert, error handler$$ -$index exception, error handler$$ - -$head Syntax$$ -$codei%ErrorHandler %info%(%handler%) -%$$ -$codei%ErrorHandler::Call(%known%, %line%, %file%, %exp%, %msg%) -%$$ - -$head Constructor$$ -When you construct a $code ErrorHandler$$ object, -the current CppAD error handler is replaced by $icode handler$$. -When the object is destructed, the previous CppAD error handler is restored. - -$subhead Parallel Mode$$ -$index parallel, ErrorHandler$$ -$index ErrorHandler, parallel$$ -The $code ErrorHandler$$ constructor and destructor cannot be called in -$cref/parallel/ta_in_parallel/$$ execution mode. -Furthermore, this rule is not abided by, a raw C++ $code assert$$, -instead of one that uses this error handler, will be generated. - -$head Call$$ -When $code ErrorHandler::Call$$ is called, -the current CppAD error handler is used to report an error. -This starts out as a default error handler and can be replaced -using the $code ErrorHandler$$ constructor. - -$head info$$ -The object $icode info$$ is used to store information -that is necessary to restore the previous CppAD error handler. -This is done when the destructor for $icode info$$ is called. - - -$head handler$$ -The argument $icode handler$$ has prototype -$codei% - void (*%handler%) - (bool, int, const char *, const char *, const char *); -%$$ -When an error is detected, -it is called with the syntax -$codei% - %handler% (%known%, %line%, %file%, %exp%, %msg%) -%$$ -This routine should not return; i.e., upon detection of the error, -the routine calling $icode handler$$ does not know how to proceed. - -$head known$$ -The $icode handler$$ argument $icode known$$ has prototype -$codei% - bool %known% -%$$ -If it is true, the error being reported is from a know problem. - -$head line$$ -The $icode handler$$ argument $icode line$$ has prototype -$codei% - int %line% -%$$ -It reports the source code line number where the error is detected. - -$head file$$ -The $icode handler$$ argument $icode file$$ has prototype -$codei% - const char *%file% -%$$ -and is a $code '\0'$$ terminated character vector. -It reports the source code file where the error is detected. - -$head exp$$ -The $icode handler$$ argument $icode exp$$ has prototype -$codei% - const char *%exp% -%$$ -and is a $code '\0'$$ terminated character vector. -It is a source code boolean expression that should have been true, -but is false, -and thereby causes this call to $icode handler$$. - -$head msg$$ -The $icode handler$$ argument $icode msg$$ has prototype -$codei% - const char *%msg% -%$$ -and is a $code '\0'$$ terminated character vector. -It reports the meaning of the error from the C++ programmers point of view. - -$children% - example/error_handler.cpp% - cppad/local/cppad_assert.hpp -%$$ -$head Example$$ -The file -$cref error_handler.cpp$$ -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -$end ---------------------------------------------------------------------------- -*/ - -# include - -# ifdef _OPENMP -# include -# endif - -# include -# include -# include -# include - -// Cannot use the CPPAD_ASSERT_* macros here because they inturn use the -// error handler. So this code generates a raw assert. -# ifdef _OPENMP -# include -# define CPPAD_ASSERT_NOT_PARALLEL \ - assert( ! omp_in_parallel() ); -# else -# define CPPAD_ASSERT_NOT_PARALLEL -# endif - -namespace CppAD { // BEGIN CppAD namespace - -class ErrorHandler { - template - friend void parallel_ad(void); -public: - typedef void (*Handler) - (bool, int, const char *, const char *, const char *); - - - // construct an handler - ErrorHandler(Handler handler) : previous( Current() ) - { CPPAD_ASSERT_NOT_PARALLEL; - Current() = handler; - } - - // destructor for an error handler - ~ErrorHandler(void) - { CPPAD_ASSERT_NOT_PARALLEL; - Current() = previous; - } - - // report an error - static void Call( - bool known, - int line , - const char *file , - const char *exp , - const char *msg ) - { Handler handler = Current(); - handler(known, line, file, exp, msg); - } - -private: - const Handler previous; - - // The default error handler - static void Default( - bool known, - int line , - const char *file , - const char *exp , - const char *msg ) - { using std::cerr; - using std::endl; - - cerr << CPPAD_PACKAGE_STRING; - if( known ) - cerr << " error from a known source:" << endl; - else cerr << " error from unknown source" << endl; - if( msg[0] != '\0' ) - cerr << msg << endl; - cerr << "Error detected by false result for" << endl; - cerr << " " << exp << endl; - cerr << "at line " << line << " in the file " << endl; - cerr << " " << file << endl; - - // terminate program execution - assert(false); - - // termination when NDEBUG is defined - std::exit(1); - } - - // current error handler - static Handler &Current(void) - { -# ifndef NDEBUG -# ifdef _OPENMP - // This assert would be a CppAD error (not user error) - static bool first_call = true; - if( first_call ) - { assert( ! omp_in_parallel() ); - first_call = false; - } -# endif -# endif - static Handler current = Default; - return current; - } -}; - -} // END CppAD namespace - - - -# endif diff -Nru cppad-2015.00.00.9/cppad/example/base_adolc.hpp cppad-2016.00.00.1/cppad/example/base_adolc.hpp --- cppad-2015.00.00.9/cppad/example/base_adolc.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/example/base_adolc.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: base_adolc.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_BASE_ADOLC_INCLUDED -# define CPPAD_BASE_ADOLC_INCLUDED +// $Id: base_adolc.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_BASE_ADOLC_HPP +# define CPPAD_BASE_ADOLC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,6 +14,11 @@ /* $begin base_adolc.hpp$$ $spell + azmul + expm1 + atanh + acosh + asinh erf ifndef define @@ -53,9 +58,6 @@ sqrt $$ -$index Adolc, adouble as Base$$ -$index Base, Adolc's adouble$$ -$index adouble, as Base$$ $section Enable use of AD where Base is Adolc's adouble Type$$ @@ -95,7 +97,7 @@ %$$ This enables one to include conditionals in the recording of $code adouble$$ operations and later evaluation for different -values of the independent variables +values of the independent variables (in the same spirit as the CppAD $cref CondExp$$ function). $codep */ namespace CppAD { @@ -141,9 +143,17 @@ } /* $$ +$head CondExpRel$$ +The $cref/CPPAD_COND_EXP_REL/base_cond_exp/CondExpRel/$$ macro invocation +$codep */ +namespace CppAD { + CPPAD_COND_EXP_REL(adouble) +} +/* $$ + $head EqualOpSeq$$ -The Adolc user interface does not specify a way to determine if -two $code adouble$$ variables correspond to the same operations sequence. +The Adolc user interface does not specify a way to determine if +two $code adouble$$ variables correspond to the same operations sequence. Make $code EqualOpSeq$$ an error if it gets used: $codep */ namespace CppAD { @@ -159,8 +169,8 @@ /* $$ $head Identical$$ -The Adolc user interface does not specify a way to determine if an -$code adouble$$ depends on the independent variables. +The Adolc user interface does not specify a way to determine if an +$code adouble$$ depends on the independent variables. To be safe (but slow) return $code false$$ in all the cases below. $codep */ namespace CppAD { @@ -181,6 +191,13 @@ { return static_cast( x.getValue() ); } /* $$ +$head azmul$$ +$codep */ +namespace CppAD { + CPPAD_AZMUL( adouble ) +} +/* $$ + $head Ordered$$ $codep */ namespace CppAD { @@ -198,7 +215,7 @@ /* $$ $head Unary Standard Math$$ -The following $cref/required/base_require/$$ functions +The following $cref/required/base_require/$$ functions are defined by the Adolc package for the $code adouble$$ base case: $pre $$ @@ -215,29 +232,40 @@ $code sqrt$$, $code tan$$. -$head erf$$ -If the error function is supported by the compiler, -it must also be supported by a $icode Base$$ type; -see $cref/erf/base_std_math/erf/$$. -The adolc package does not support this function: +$head erf, asinh, acosh, atanh, expm1, log1p$$ +If the +$cref/erf, asinh, acosh, atanh, expm1, log1p + /base_std_math + /erf, asinh, acosh, atanh, expm1, log1p +/$$, +functions are supported by the compiler, +they must also be supported by a $icode Base$$ type; +The adolc package does not support these functions so make +their use an error: $codep */ namespace CppAD { -# if CPPAD_COMPILER_HAS_ERF - inline adouble erf(const adouble& x) - { CPPAD_ASSERT_KNOWN( - false, - "erf: adolc does not support the error function" - ); - return 0; - } +# define CPPAD_BASE_ADOLC_NO_SUPPORT(fun) \ + inline adouble fun(const adouble& x) \ + { CPPAD_ASSERT_KNOWN( \ + false, \ + #fun ": adolc does not support this function" \ + ); \ + return 0.0; \ + } +# if CPPAD_USE_CPLUSPLUS_2011 + CPPAD_BASE_ADOLC_NO_SUPPORT(erf) + CPPAD_BASE_ADOLC_NO_SUPPORT(asinh) + CPPAD_BASE_ADOLC_NO_SUPPORT(acosh) + CPPAD_BASE_ADOLC_NO_SUPPORT(atanh) + CPPAD_BASE_ADOLC_NO_SUPPORT(expm1) + CPPAD_BASE_ADOLC_NO_SUPPORT(log1p) # endif +# undef CPPAD_BASE_ADOLC_NO_SUPPORT } -/* $$ - - +/* $$ $head sign$$ -This $cref/required/base_require/$$ function is defined using the +This $cref/required/base_require/$$ function is defined using the $code codassign$$ function so that its $code adouble$$ operation sequence does not depend on the value of $icode x$$. $codep */ @@ -255,7 +283,7 @@ /* $$ $head abs$$ -This $cref/required/base_require/$$ function uses the adolc $code fabs$$ +This $cref/required/base_require/$$ function uses the adolc $code fabs$$ function: $codep */ namespace CppAD { @@ -265,32 +293,15 @@ /* $$ $head pow$$ -This $cref/required/base_require/$$ function +This $cref/required/base_require/$$ function is defined by the Adolc package for the $code adouble$$ base case. -$head limits$$ -The following defines the numeric limits functions -$code epsilon$$, $code min$$, and $code max$$ for the type -$code adouble$$. -It also defines the deprecated $code epsilon$$ function: +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code adouble$$: $codep */ namespace CppAD { - template <> - class numeric_limits { - public: - // machine epsilon - static adouble epsilon(void) - { return adouble( std::numeric_limits::epsilon() ); } - // minimum positive normalized value - static adouble min(void) - { return adouble( std::numeric_limits::min() ); } - // maximum finite value - static adouble max(void) - { return adouble( std::numeric_limits::max() ); } - }; - // deprecated machine epsilon - template <> inline adouble epsilon(void) - { return numeric_limits::epsilon(); } + CPPAD_NUMERIC_LIMITS(double, adouble) } /* $$ $end diff -Nru cppad-2015.00.00.9/cppad/example/cppad_eigen.hpp cppad-2016.00.00.1/cppad/example/cppad_eigen.hpp --- cppad-2015.00.00.9/cppad/example/cppad_eigen.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/example/cppad_eigen.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: cppad_eigen.hpp 3065 2013-12-29 14:03:45Z bradbell $ */ -# ifndef CPPAD_CPPAD_EIGEN_INCLUDED -# define CPPAD_CPPAD_EIGEN_INCLUDED +// $Id: cppad_eigen.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_CPPAD_EIGEN_HPP +# define CPPAD_CPPAD_EIGEN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -51,22 +51,22 @@ %$$ $head Purpose$$ -Enables the use of the +Enables the use of the $href%http://eigen.tuxfamily.org%eigen%$$ linear algebra package with the type $icode%AD<%Base%>%$$. $head Example$$ -The files $cref eigen_array.cpp$$ and $cref eigen_det.cpp$$ +The files $cref eigen_array.cpp$$ and $cref eigen_det.cpp$$ contain an example and test of this include file. It returns true if it succeeds and false otherwise. $head Include Files$$ The file $code cppad_eigen.hpp$$ includes both -$code $$ and $code $$. +$code $$ and $code $$. In addition, -The file $cref eigen_plugin.hpp$$ +The file $cref eigen_plugin.hpp$$ is used to define $code value_type$$ -in the Eigen matrix class definition so its vectors are +in the Eigen matrix class definition so its vectors are $cref/simple vectors/SimpleVector/$$. $codep */ # define EIGEN_MATRIXBASE_PLUGIN @@ -109,8 +109,8 @@ // relaxed version of machine epsilon for comparison of different // operations that should result in the same value static CppAD::AD dummy_precision(void) - { return 100. * - CppAD::numeric_limits< CppAD::AD >::epsilon(); + { return 100. * + CppAD::numeric_limits< CppAD::AD >::epsilon(); } // minimum normalized positive value @@ -142,23 +142,23 @@ { return x * x; } } -namespace Eigen { +namespace Eigen { namespace internal { - template + template struct significant_decimals_default_impl< CppAD::AD, false> { typedef CppAD::AD Scalar; - typedef typename NumTraits::Real RealScalar; - static inline int run() - { Scalar neg_log_eps = - log( + typedef typename NumTraits::Real RealScalar; + static inline int run() + { Scalar neg_log_eps = - log( NumTraits::epsilon() ); int ceil_neg_log_eps = Integer( neg_log_eps ); if( Scalar(ceil_neg_log_eps) < neg_log_eps ) ceil_neg_log_eps++; return ceil_neg_log_eps; - } + } }; } } diff -Nru cppad-2015.00.00.9/cppad/example/eigen_plugin.hpp cppad-2016.00.00.1/cppad/example/eigen_plugin.hpp --- cppad-2015.00.00.9/cppad/example/eigen_plugin.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/example/eigen_plugin.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: eigen_plugin.hpp 2572 2012-11-15 19:43:06Z bradbell $ */ -# ifndef CPPAD_EIGEN_PLUGIN_INCLUDED -# define CPPAD_EIGEN_PLUGIN_INCLUDED +// $Id: eigen_plugin.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_EIGEN_PLUGIN_HPP +# define CPPAD_EIGEN_PLUGIN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/cppad/example/matrix_mul.hpp cppad-2016.00.00.1/cppad/example/matrix_mul.hpp --- cppad-2015.00.00.9/cppad/example/matrix_mul.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/example/matrix_mul.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: matrix_mul.hpp 3543 2014-12-31 18:38:00Z bradbell $ -# ifndef CPPAD_MATRIX_MUL_INCLUDED -# define CPPAD_MATRIX_MUL_INCLUDED +// $Id: matrix_mul.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_MATRIX_MUL_HPP +# define CPPAD_MATRIX_MUL_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $$ $section Matrix Multiply as an Atomic Operation$$ -$index multiply, matrix atomic operation$$ -$index atomic, matrix multiply operation$$ -$index matrix, multiply atomic operation$$ $nospell @@ -46,7 +43,7 @@ result.swap(temp); } // -// matrix result = left * right +// matrix result = left * right class matrix_mul : public CppAD::atomic_base { /* $$ $head Constructor$$ @@ -72,9 +69,9 @@ nr_result_(nr_result) , n_middle_(n_middle) , nc_result_(nc_result) , - n_( nr_result * n_middle + n_middle * nc_result ) + n_( nr_result * n_middle + n_middle * nc_result ) # ifndef NDEBUG - , m_( n_middle * nc_result ) + , m_( n_middle * nc_result ) # endif { } private: @@ -86,7 +83,7 @@ size_t i , // left matrix row index size_t j , // left matrix column index size_t k , // Taylor coeffocient order - size_t nk ) // number of Taylor coefficients in tx + size_t nk ) // number of Taylor coefficients in tx { assert( i < nr_result_ ); assert( j < n_middle_ ); return (i * n_middle_ + j) * nk + k; @@ -99,11 +96,11 @@ size_t i , // right matrix row index size_t j , // right matrix column index size_t k , // Taylor coeffocient order - size_t nk ) // number of Taylor coefficients in tx + size_t nk ) // number of Taylor coefficients in tx { assert( i < n_middle_ ); assert( j < nc_result_ ); size_t offset = nr_result_ * n_middle_; - return (offset + i * nc_result_ + j) * nk + k; + return (offset + i * nc_result_ + j) * nk + k; } /* $$ $head Result Element Index$$ @@ -127,7 +124,7 @@ size_t k_left , // order for left coefficients size_t k_right , // order for right coefficients const vector& tx , // domain space Taylor coefficients - vector& ty ) // range space Taylor coefficients + vector& ty ) // range space Taylor coefficients { size_t nk = tx.size() / n_; assert( nk == ty.size() / m_ ); // @@ -156,9 +153,9 @@ size_t k_left , // order for left coefficients size_t k_right , // order for right coefficients const vector& tx , // domain space Taylor coefficients - const vector& ty , // range space Taylor coefficients + const vector& ty , // range space Taylor coefficients vector& px , // partials w.r.t. tx - const vector& py ) // partials w.r.t. ty + const vector& py ) // partials w.r.t. ty { size_t nk = tx.size() / n_; assert( nk == ty.size() / m_ ); assert( tx.size() == px.size() ); @@ -214,7 +211,7 @@ bool nz_right = vx[i_right]|(tx[i_right] != 0.); // if not multiplying by the constant zero if( nz_left & nz_right ) - var |= vx[i_left] | vx[i_right]; + var |= bool(vx[i_left]) | bool(vx[i_right]); } size_t i_result = result(i, j, k, nk); vy[i_result] = var; @@ -290,13 +287,14 @@ { for(size_t j = 0; j < nc_result_; j++) { size_t i_result = result(i, j, k, nk); for(p = 0; p < q; p++) - s[i_result * q + p] = false; + s[i_result * q + p] = false; for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); for(p = 0; p < q; p++) - { s[i_result * q + p] |= r[i_left * q + p ]; - s[i_result * q + p] |= r[i_right * q + p ]; + { // cast avoids Microsoft warning (should not be needed) + s[i_result * q + p] |= bool( r[i_left * q + p ] ); + s[i_result * q + p] |= bool( r[i_right * q + p ] ); } } } @@ -356,8 +354,8 @@ { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); for(p = 0; p < q; p++) - { st[i_left * q + p] |= rt[i_result * q + p]; - st[i_right* q + p] |= rt[i_result * q + p]; + { st[i_left * q + p] |= bool( rt[i_result * q + p] ); + st[i_right* q + p] |= bool( rt[i_result * q + p] ); } } } @@ -405,7 +403,7 @@ const vector< std::set >& r , const vector< std::set >& u , vector< std::set >& v ) - { size_t n = vx.size(); + { size_t n = vx.size(); assert( t.size() == n ); assert( r.size() == n ); assert( v.size() == n ); @@ -431,10 +429,10 @@ // // Compute sparsity for T(x) = S(x) * f'(x). // We need not use vx with f'(x) back propagation. - t[i_left] |= s[i_result]; - t[i_right] |= s[i_result]; + t[i_left] |= bool( s[i_result] ); + t[i_right] |= bool( s[i_result] ); - // V(x) = f'(x)^T * U(x) + S(x) * f''(x) * R + // V(x) = f'(x)^T * U(x) + S(x) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) @@ -489,26 +487,26 @@ // // Compute sparsity for T(x) = S(x) * f'(x). // We so not need to use vx with f'(x) propagation. - t[i_left] |= s[i_result]; - t[i_right] |= s[i_result]; + t[i_left] |= bool( s[i_result] ); + t[i_right] |= bool( s[i_result] ); - // V(x) = f'(x)^T * U(x) + S(x) * f''(x) * R + // V(x) = f'(x)^T * U(x) + S(x) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) // back propagate f'(x)^T * U(x) // (no need to use vx with f'(x) propogation) for(p = 0; p < q; p++) - { v[ i_left * q + p] |= u[ i_result * q + p]; - v[ i_right * q + p] |= u[ i_result * q + p]; + { v[ i_left * q + p] |= bool( u[ i_result * q + p] ); + v[ i_right * q + p] |= bool( u[ i_result * q + p] ); } // back propagate S(x) * f''(x) * R // (here is where we must check for cross terms) if( s[i_result] & vx[i_left] & vx[i_right] ) { for(p = 0; p < q; p++) - { v[i_left * q + p] |= r[i_right * q + p]; - v[i_right * q + p] |= r[i_left * q + p]; + { v[i_left * q + p] |= bool( r[i_right * q + p] ); + v[i_right * q + p] |= bool( r[i_left * q + p] ); } } } diff -Nru cppad-2015.00.00.9/cppad/index_sort.hpp cppad-2016.00.00.1/cppad/index_sort.hpp --- cppad-2015.00.00.9/cppad/index_sort.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/index_sort.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -/* $Id: index_sort.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_INDEX_SORT_INCLUDED -# define CPPAD_INDEX_SORT_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin index_sort$$ -$spell - cppad.hpp - ind - const -$$ - -$section Returns Indices that Sort a Vector$$ - -$index index_sort$$ -$index sort, index$$ - -$head Syntax$$ -$codei%# include -index_sort(%keys%, %ind%)%$$ - -$head keys$$ -The argument $icode keys$$ has prototype -$codei% - const %VectorKey%& %keys% -%$$ -where $icode VectorKey$$ is -a $cref SimpleVector$$ class with elements that support the $code <$$ -operation. - -$head ind$$ -The argument $icode ind$$ has prototype -$codei% - const %VectorSize%& %ind% -%$$ -where $icode VectorSize$$ is -a $cref SimpleVector$$ class with elements of type $code size_t$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. -The size of $icode ind$$ must be the same as the size of $icode keys$$ -and the value of its input elements does not matter. -$pre - -$$ -Upon return, $icode ind$$ is a permutation of the set of indices -that yields increasing order for $icode keys$$. -In other words, for all $icode%i% != %j%$$, -$codei% - %ind%[%i%] != %ind%[%j%] -%$$ -and for $icode%i% = 0 , %...% , %size%-2%$$, -$codei% - ( %keys%[ %ind%[%i%+1] ] < %keys%[ %ind%[%i%] ] ) == false -%$$ - - -$head Example$$ -$children% - example/index_sort.cpp -%$$ -The file $cref index_sort.cpp$$ contains an example -and test of this routine. -It return true if it succeeds and false otherwise. - -$end -*/ -# include -# include -# include -# include - -namespace CppAD { // BEGIN_CPPAD_NAMESPACE -/*! -\file index_sort.hpp -File used to implement the CppAD index sort utility -*/ - -/*! -Helper class used by index_sort -*/ -template -class index_sort_element { -private: - /// key used to determine position of this element - Compare key_; - /// index vlaue corresponding to this key - size_t index_; -public: - /// operator requried by std::sort - bool operator<(const index_sort_element& other) const - { return key_ < other.key_; } - /// set the key for this element - void set_key(const Compare& value) - { key_ = value; } - /// set the index for this element - void set_index(const size_t& index) - { index_ = index; } - /// get the key for this element - Compare get_key(void) const - { return key_; } - /// get the index for this element - size_t get_index(void) const - { return index_; } -}; - -/*! -Compute the indices that sort a vector of keys - -\tparam VectorKey -Simple vector type that deterimene the sorting order by \c < operator -on its elements. - -\tparam VectorSize -Simple vector type with elements of \c size_t -that is used to return index values. - -\param keys [in] -values that determine the sorting order. - -\param ind [out] -must have the same size as \c keys. -The input value of its elements does not matter. -The output value of its elements satisfy -\code -( keys[ ind[i] ] < keys[ ind[i+1] ] ) == false -\endcode -*/ -template -void index_sort(const VectorKey& keys, VectorSize& ind) -{ typedef typename VectorKey::value_type Compare; - CheckSimpleVector(); - - typedef index_sort_element element; - - CPPAD_ASSERT_KNOWN( - size_t(keys.size()) == size_t(ind.size()), - "index_sort: vector sizes do not match" - ); - - size_t size_work = size_t(keys.size()); - size_t size_out; - element* work = - thread_alloc::create_array(size_work, size_out); - - // copy initial order into work - size_t i; - for(i = 0; i < size_work; i++) - { work[i].set_key( keys[i] ); - work[i].set_index( i ); - } - - // sort the work array - std::sort(work, work+size_work); - - // copy the indices to the output vector - for(i = 0; i < size_work; i++) - ind[i] = work[i].get_index(); - - // we are done with this work array - thread_alloc::delete_array(work); - - return; -} - -} // END_CPPAD_NAMESPACE - -# endif diff -Nru cppad-2015.00.00.9/cppad/ipopt/solve_callback.hpp cppad-2016.00.00.1/cppad/ipopt/solve_callback.hpp --- cppad-2015.00.00.9/cppad/ipopt/solve_callback.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/ipopt/solve_callback.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: solve_callback.hpp 3275 2014-05-20 17:35:11Z bradbell $ */ -# ifndef CPPAD_SOLVE_CALLBACK_INCLUDED -# define CPPAD_SOLVE_CALLBACK_INCLUDED +// $Id: solve_callback.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SOLVE_CALLBACK_HPP +# define CPPAD_SOLVE_CALLBACK_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -33,7 +33,7 @@ \verbatim { eval_f, eval_grad_f, eval_g, eval_jac_g, eval_h } \endverbatim -Note that the bool return flag for the evaluations methods +Note that the bool return flag for the evaluations methods does not appear in the Ipopt documentation. Looking at the code, it seems to be a flag telling Ipopt to abort when the flag is false. @@ -43,19 +43,19 @@ { private: // ------------------------------------------------------------------ - // Types used by this class + // Types used by this class // ------------------------------------------------------------------ /// A Scalar value used by Ipopt typedef Ipopt::Number Number; - /// An index value used by Ipopt + /// An index value used by Ipopt typedef Ipopt::Index Index; - /// Indexing style used in Ipopt sparsity structure + /// Indexing style used in Ipopt sparsity structure typedef Ipopt::TNLP::IndexStyleEnum IndexStyleEnum; // ------------------------------------------------------------------ - // Values directly passed in to constuctor + // Values directly passed in to constuctor // ------------------------------------------------------------------ /// dimension of the range space for f(x). - /// The objective is sum_i f_i (x). + /// The objective is sum_i f_i (x). /// Note that, at this point, there is no advantage having nf_ > 1. const size_t nf_; /// dimension of the domain space for f(x) and g(x) @@ -64,9 +64,9 @@ const size_t ng_; /// initial value for x const Dvector& xi_; - /// lower limit for x + /// lower limit for x const Dvector& xl_; - /// upper limit for x + /// upper limit for x const Dvector& xu_; /// lower limit for g(x) const Dvector& gl_; @@ -77,15 +77,15 @@ /// should operation sequence be retaped for each new x. bool retape_; /// Should sparse methods be used to compute Jacobians and Hessians - /// with forward mode used for Jacobian. + /// with forward mode used for Jacobian. bool sparse_forward_; /// Should sparse methods be used to compute Jacobians and Hessians - /// with reverse mode used for Jacobian. + /// with reverse mode used for Jacobian. bool sparse_reverse_; /// final results are returned to this structure solve_result& solution_; // ------------------------------------------------------------------ - // Values that are initilaized by the constructor + // Values that are initilaized by the constructor // ------------------------------------------------------------------ /// AD function object that evaluates x -> [ f(x) , g(x) ] /// If retape is false, this object is initialzed by constructor @@ -101,7 +101,7 @@ /// Sparsity pattern for Jacobian of [f(x), g(x) ]. /// If sparse is true, this pattern set by constructor and does not change. /// Otherwise this vector has size zero. - CppAD::vector< std::set > pattern_jac_; + CppAD::vectorBool pattern_jac_; /// Row indices of [f(x), g(x)] for Jacobian of g(x) in row order. /// (Set by constructor and not changed.) CppAD::vector row_jac_; @@ -120,7 +120,7 @@ /// \f[ L(x) = \sigma \sum_i f_i (x) + \sum_i \lambda_i g_i (x) \f] /// If sparse is true, this pattern set by constructor and does not change. /// Otherwise this vector has size zero. - CppAD::vector< std::set > pattern_hes_; + CppAD::vectorBool pattern_hes_; /// Row indices of Hessian lower left triangle in row order. /// (Set by constructor and not changed.) CppAD::vector row_hes_; @@ -130,7 +130,7 @@ /// Work vector used by SparseJacobian, stored here to avoid recalculation. CppAD::sparse_hessian_work work_hes_; // ------------------------------------------------------------------ - // Private member functions + // Private member functions // ------------------------------------------------------------------ /*! Cache information for a new value of x. @@ -149,7 +149,7 @@ is changes to correspond to the argument x. If retape is false, the operation sequence is not changed. The zero order Taylor coefficients for this function are set - so they correspond to the argument x. + so they correspond to the argument x. */ void cache_new_x(const Number* x) { size_t i; @@ -173,30 +173,30 @@ } public: // ---------------------------------------------------------------------- - /*! + /*! Constructor for the interface between ipopt::solve and Ipopt - + \param nf dimension of the range space for f(x) - + \param nx dimension of the domain space for f(x) and g(x). - + \param ng dimension of the range space for g(x) - + \param xi initial value of x during the optimization procedure (size nx). - + \param xl lower limit for x (size nx). - + \param xu upper limit for x (size nx). - + \param gl lower limit for g(x) (size ng). - + \param gu upper limit for g(x) (size ng). @@ -214,13 +214,13 @@ should sparse matrix computations be used for Jacobians and Hessians with reverse mode for Jacobian. (sparse_forward and sparse_reverse cannot both be true). - + \param solution object where final results are stored. */ solve_callback( size_t nf , - size_t nx , + size_t nx , size_t ng , const Dvector& xi , const Dvector& xl , @@ -231,7 +231,7 @@ bool retape , bool sparse_forward , bool sparse_reverse , - solve_result& solution ) : + solve_result& solution ) : nf_ ( nf ), nx_ ( nx ), ng_ ( ng ), @@ -269,67 +269,145 @@ // optimize because we will make repeated use of this tape adfun_.optimize(); } - if( sparse_forward_ | sparse_reverse_ ) - { CPPAD_ASSERT_UNKNOWN( ! retape ); + if( sparse_forward_ | sparse_reverse_ ) + { CPPAD_ASSERT_UNKNOWN( ! retape ); + size_t m = nf_ + ng_; + // // ----------------------------------------------------------- // Jacobian - pattern_jac_.resize(nf_ + ng_); - if( nx_ <= nf_ + ng_ ) + pattern_jac_.resize( m * nx_ ); + if( nx_ <= m ) { // use forward mode to compute sparsity - CppAD::vector< std::set > r(nx_); - for(i = 0; i < nx_; i++) - { CPPAD_ASSERT_UNKNOWN( r[i].empty() ); - r[i].insert(i); + + // number of bits that are packed into one unit in vectorBool + size_t n_column = vectorBool::bit_per_unit(); + + // sparsity patterns for current columns + vectorBool r(nx_ * n_column), s(m * n_column); + + // compute the sparsity pattern n_column columns at a time + size_t n_loop = (nx_ - 1) / n_column + 1; + for(size_t i_loop = 0; i_loop < n_loop; i_loop++) + { // starting column index for this iteration + size_t i_column = i_loop * n_column; + + // pattern that picks out the appropriate columns + for(i = 0; i < nx_; i++) + { for(j = 0; j < n_column; j++) + r[i * n_column + j] = (i == i_column + j); + } + s = adfun_.ForSparseJac(n_column, r); + + // fill in the corresponding columns of total_sparsity + for(i = 0; i < m; i++) + { for(j = 0; j < n_column; j++) + { if( i_column + j < nx_ ) + pattern_jac_[i * nx_ + i_column + j] = + s[i * n_column + j]; + } + } } - pattern_jac_ = adfun_.ForSparseJac(nx_, r); } else { // use reverse mode to compute sparsity - size_t m = nf_ + ng_; - CppAD::vector< std::set > s(m); + + // number of bits that are packed into one unit in vectorBool + size_t n_row = vectorBool::bit_per_unit(); + + // sparsity patterns for current rows + vectorBool r(n_row * m), s(n_row * nx_); + + // compute the sparsity pattern n_row row at a time + size_t n_loop = (m - 1) / n_row + 1; + for(size_t i_loop = 0; i_loop < n_loop; i_loop++) + { // starting row index for this iteration + size_t i_row = i_loop * n_row; + + // pattern that picks out the appropriate rows + for(i = 0; i < n_row; i++) + { for(j = 0; j < m; j++) + r[i * m + j] = (i_row + i == j); + } + s = adfun_.RevSparseJac(n_row, r); + + // fill in correspoding rows of total sparsity + for(i = 0; i < n_row; i++) + { for(j = 0; j < nx_; j++) + if( i_row + i < m ) + pattern_jac_[ (i_row + i) * nx_ + j ] = + s[ i * nx_ + j]; + } + } + } + /* + { // use reverse mode to compute sparsity + CppAD::vectorBool s(m * m); for(i = 0; i < m; i++) - { CPPAD_ASSERT_UNKNOWN( s[i].empty() ); - s[i].insert(i); + { for(j = 0; j < m; j++) + s[i * m + j] = (i == j); } pattern_jac_ = adfun_.RevSparseJac(m, s); } + */ // Set row and column indices in Jacoian of [f(x), g(x)] // for Jacobian of g(x). These indices are in row major order. - std::set:: const_iterator itr, end; for(i = nf_; i < nfg; i++) - { itr = pattern_jac_[i].begin(); - end = pattern_jac_[i].end(); - while( itr != end ) - { j = *itr++; - row_jac_.push_back(i); - col_jac_.push_back(j); + { for(j = 0; j < nx_; j++) + { if( pattern_jac_[ i * nx_ + j ] ) + { row_jac_.push_back(i); + col_jac_.push_back(j); + } } } + // Set row and column indices in Jacoian of [f(x), g(x)] + // for Jacobian of g(x). These indices are in row major order. // ----------------------------------------------------------- // Hessian - pattern_hes_.resize(nx_); - CppAD::vector< std::set > r(nx_); - for(i = 0; i < nx_; i++) - { CPPAD_ASSERT_UNKNOWN( r[i].empty() ); - r[i].insert(i); - } - // forward Jacobian sparsity for fg - adfun_.ForSparseJac(nx_, r); + pattern_hes_.resize(nx_ * nx_); - // The Lagragian can use any of the components of f(x), g(x) - CppAD::vector< std::set > s(1); - CPPAD_ASSERT_UNKNOWN( s[0].empty() ); - for(i = 0; i < nf_ + ng_; i++) - s[0].insert(i); - pattern_hes_ = adfun_.RevSparseHes(nx_, s); + // number of bits that are packed into one unit in vectorBool + size_t n_column = vectorBool::bit_per_unit(); - // Set row and column indices for Lower triangle of Hessian + // sparsity patterns for current columns + vectorBool r(nx_ * n_column), h(nx_ * n_column); + + // sparsity pattern for range space of function + vectorBool s(m); + for(i = 0; i < m; i++) + s[i] = true; + + // compute the sparsity pattern n_column columns at a time + size_t n_loop = (nx_ - 1) / n_column + 1; + for(size_t i_loop = 0; i_loop < n_loop; i_loop++) + { // starting column index for this iteration + size_t i_column = i_loop * n_column; + + // pattern that picks out the appropriate columns + for(i = 0; i < nx_; i++) + { for(j = 0; j < n_column; j++) + r[i * n_column + j] = (i == i_column + j); + } + adfun_.ForSparseJac(n_column, r); + + // sparsity pattern corresponding to paritls w.r.t. (theta, u) + // of partial w.r.t. the selected columns + bool transpose = true; + h = adfun_.RevSparseHes(n_column, s, transpose); + + // fill in the corresponding columns of total_sparsity + for(i = 0; i < nx_; i++) + { for(j = 0; j < n_column; j++) + { if( i_column + j < nx_ ) + pattern_hes_[i * nx_ + i_column + j] = + h[i * n_column + j]; + } + } + } + // Set row and column indices for Lower triangle of Hessian // of Lagragian. These indices are in row major order. for(i = 0; i < nx_; i++) - { itr = pattern_hes_[i].begin(); - end = pattern_hes_[i].end(); - while( itr != end ) - { j = *itr++; + { for(j = 0; j < nx_; j++) + { if( pattern_hes_[ i * nx_ + j ] ) if( j <= i ) { row_hes_.push_back(i); col_hes_.push_back(j); @@ -343,7 +421,7 @@ for(i = nf_; i < nfg; i++) { for(j = 0; j < nx_; j++) { row_jac_.push_back(i); - col_jac_.push_back(j); + col_jac_.push_back(j); } } // Set row and column indices for lower triangle of Hessian. @@ -363,35 +441,35 @@ // ----------------------------------------------------------------------- /*! Return dimension information about optimization problem. - + \param[out] n is set to the value nx_. - + \param[out] m is set to the value ng_. - + \param[out] nnz_jac_g - is set to ng_ * nx_ (sparsity not yet implemented) - + is set to ng_ * nx_ (sparsity not yet implemented) + \param[out] nnz_h_lag is set to nx_*(nx_+1)/2 (sparsity not yet implemented) - + \param[out] index_style is set to C_STYLE; i.e., zeoro based indexing is used in the information passed to Ipopt. */ virtual bool get_nlp_info( - Index& n , - Index& m , + Index& n , + Index& m , Index& nnz_jac_g , - Index& nnz_h_lag , + Index& nnz_h_lag , IndexStyleEnum& index_style ) { n = static_cast(nx_); m = static_cast(ng_); nnz_jac_g = static_cast(row_jac_.size()); nnz_h_lag = static_cast(row_hes_.size()); - + # ifndef NDEBUG if( ! (sparse_forward_ | sparse_reverse_) ) { size_t nnz = static_cast(nnz_jac_g); @@ -402,57 +480,57 @@ } # endif - // use the fortran index style for row/col entries + // use the fortran index style for row/col entries index_style = C_STYLE; - + return true; } // ----------------------------------------------------------------------- /*! Return bound information about optimization problem. - + \param[in] n is the dimension of the domain space for f(x) and g(x); i.e., it must be equal to nx_. - + \param[out] x_l is a vector of size nx_. The input value of its elements does not matter. On output, it is a copy of the lower bound for \f$ x \f$; i.e., xl_. - + \param[out] x_u is a vector of size nx_. The input value of its elements does not matter. On output, it is a copy of the upper bound for \f$ x \f$; i.e., xu_. - + \param[in] m is the dimension of the range space for g(x). i.e., it must be equal to ng_. - + \param[out] g_l is a vector of size ng_. The input value of its elements does not matter. On output, it is a copy of the lower bound for \f$ g(x) \f$; i.e., gl_. - + \param[out] g_u is a vector of size ng_. The input value of its elements does not matter. On output, it is a copy of the upper bound for \f$ g(x) \f$; i.e, gu_. */ virtual bool get_bounds_info( - Index n , - Number* x_l , + Index n , + Number* x_l , Number* x_u , - Index m , - Number* g_l , + Index m , + Number* g_l , Number* g_u ) { size_t i; - // here, the n and m we gave IPOPT in get_nlp_info are passed back + // here, the n and m we gave IPOPT in get_nlp_info are passed back CPPAD_ASSERT_UNKNOWN(static_cast(n) == nx_); CPPAD_ASSERT_UNKNOWN(static_cast(m) == ng_); - + // pass back bounds for(i = 0; i < nx_; i++) { x_l[i] = xl_[i]; @@ -462,92 +540,92 @@ { g_l[i] = gl_[i]; g_u[i] = gu_[i]; } - + return true; } // ----------------------------------------------------------------------- /*! Return initial x value where optimiation is started. - + \param[in] n must be equal to the domain dimension for f(x) and g(x); i.e., it must be equal to nx_. - + \param[in] init_x must be equal to true. - + \param[out] x is a vector of size nx_. The input value of its elements does not matter. On output, it is a copy of the initial value for \f$ x \f$; i.e. xi_. - + \param[in] init_z must be equal to false. - + \param z_L is not used. - + \param z_U is not used. - + \param[in] m must be equal to the domain dimension for f(x) and g(x); i.e., it must be equal to ng_. - + \param init_lambda must be equal to false. - + \param lambda is not used. */ virtual bool get_starting_point( - Index n , - bool init_x , + Index n , + bool init_x , Number* x , - bool init_z , - Number* z_L , + bool init_z , + Number* z_L , Number* z_U , - Index m , + Index m , bool init_lambda , Number* lambda ) { size_t j; - + CPPAD_ASSERT_UNKNOWN(static_cast(n) == nx_ ); CPPAD_ASSERT_UNKNOWN(static_cast(m) == ng_ ); CPPAD_ASSERT_UNKNOWN(init_x == true); CPPAD_ASSERT_UNKNOWN(init_z == false); CPPAD_ASSERT_UNKNOWN(init_lambda == false); - + for(j = 0; j < nx_; j++) x[j] = xi_[j]; - + return true; } // ----------------------------------------------------------------------- /*! Evaluate the objective fucntion f(x). - + \param[in] n is the dimension of the argument space for f(x); i.e., must be equal nx_. - + \param[in] x is a vector of size nx_ containing the point at which to evaluate the function sum_i f_i (x). - + \param[in] new_x - is false if the previous call to any one of the + is false if the previous call to any one of the \ref Evaluation_Methods used the same value for x. - + \param[out] obj_value is the value of the objective sum_i f_i (x) at this value of x. - + \return The return value is always true; see \ref Evaluation_Methods. */ virtual bool eval_f( - Index n , - const Number* x , - bool new_x , + Index n , + const Number* x , + bool new_x , Number& obj_value ) { size_t i; if( new_x ) @@ -562,31 +640,31 @@ // ----------------------------------------------------------------------- /*! Evaluate the gradient of f(x). - + \param[in] n is the dimension of the argument space for f(x); i.e., must be equal nx_. - + \param[in] x has a vector of size nx_ containing the point at which to evaluate the gradient of f(x). - + \param[in] new_x - is false if the previous call to any one of the + is false if the previous call to any one of the \ref Evaluation_Methods used the same value for x. - + \param[out] grad_f is a vector of size nx_. The input value of its elements does not matter. - The output value of its elements is the gradient of f(x) + The output value of its elements is the gradient of f(x) at this value of. - + \return The return value is always true; see \ref Evaluation_Methods. */ virtual bool eval_grad_f( - Index n , - const Number* x , - bool new_x , + Index n , + const Number* x , + bool new_x , Number* grad_f ) { size_t i; if( new_x ) @@ -605,35 +683,35 @@ // ----------------------------------------------------------------------- /*! Evaluate the function g(x). - + \param[in] n is the dimension of the argument space for g(x); i.e., must be equal nx_. - + \param[in] x has a vector of size n containing the point at which to evaluate the gradient of g(x). - + \param[in] new_x - is false if the previous call to any one of the + is false if the previous call to any one of the \ref Evaluation_Methods used the same value for x. - + \param[in] m is the dimension of the range space for g(x); i.e., must be equal to ng_. - + \param[out] g is a vector of size ng_. The input value of its elements does not matter. - The output value of its elements is + The output value of its elements is the value of the function g(x) at this value of x. - + \return The return value is always true; see \ref Evaluation_Methods. */ virtual bool eval_g( - Index n , - const Number* x , - bool new_x , - Index m , + Index n , + const Number* x , + bool new_x , + Index m , Number* g ) { size_t i; if( new_x ) @@ -646,70 +724,70 @@ // ----------------------------------------------------------------------- /*! Evaluate the Jacobian of g(x). - + \param[in] n - is the dimension of the argument space for g(x); + is the dimension of the argument space for g(x); i.e., must be equal nx_. - + \param x If values is not NULL, x is a vector of size nx_ containing the point at which to evaluate the gradient of g(x). - + \param[in] new_x - is false if the previous call to any one of the + is false if the previous call to any one of the \ref Evaluation_Methods used the same value for x. - + \param[in] m - is the dimension of the range space for g(x); + is the dimension of the range space for g(x); i.e., must be equal to ng_. - + \param[in] nele_jac is the number of possibly non-zero elements in the Jacobian of g(x); i.e., must be equal to ng_ * nx_. - + \param iRow if values is not NULL, iRow is not defined. if values is NULL, iRow is a vector with size nele_jac. The input value of its elements does not matter. - On output, - For k = 0 , ... , nele_jac-1, iRow[k] is the - base zero row index for the + On output, + For k = 0 , ... , nele_jac-1, iRow[k] is the + base zero row index for the k-th possibly non-zero entry in the Jacobian of g(x). - + \param jCol if values is not NULL, jCol is not defined. if values is NULL, jCol is a vector with size nele_jac. The input value of its elements does not matter. - On output, - For k = 0 , ... , nele_jac-1, jCol[k] is the - base zero column index for the + On output, + For k = 0 , ... , nele_jac-1, jCol[k] is the + base zero column index for the k-th possibly non-zero entry in the Jacobian of g(x). - + \param values if \c values is not \c NULL, \c values is a vector with size \c nele_jac. The input value of its elements does not matter. - On output, - For k = 0 , ... , nele_jac-1, values[k] is the - value for the + On output, + For k = 0 , ... , nele_jac-1, values[k] is the + value for the k-th possibly non-zero entry in the Jacobian of g(x). - + \return The return value is always true; see \ref Evaluation_Methods. */ virtual bool eval_jac_g( - Index n, - const Number* x, + Index n, + const Number* x, bool new_x, - - Index m, - Index nele_jac, - Index* iRow, + + Index m, + Index nele_jac, + Index* iRow, Index *jCol, - + Number* values) { size_t i, j, k, ell; CPPAD_ASSERT_UNKNOWN(static_cast(m) == ng_ ); @@ -776,7 +854,7 @@ } } else - { // user reverse mode + { // user reverse mode size_t nfg = nf_ + ng_; // user reverse mode Dvector w(nfg), dw(nx_); @@ -802,101 +880,101 @@ // ----------------------------------------------------------------------- /*! Evaluate the Hessian of the Lagragian - + \section The_Hessian_of_the_Lagragian The Hessian of the Lagragian The Hessian of the Lagragian is defined as \f[ - H(x, \sigma, \lambda ) + H(x, \sigma, \lambda ) = \sigma \nabla^2 f(x) + \sum_{i=0}^{m-1} \lambda_i \nabla^2 g(x)_i \f] - + \param[in] n - is the dimension of the argument space for g(x); + is the dimension of the argument space for g(x); i.e., must be equal nx_. - + \param x if values is not NULL, x is a vector of size nx_ containing the point at which to evaluate the Hessian of the Lagragian. - + \param[in] new_x - is false if the previous call to any one of the + is false if the previous call to any one of the \ref Evaluation_Methods used the same value for x. - + \param[in] obj_factor the value \f$ \sigma \f$ multiplying the Hessian of f(x) in the expression for \ref The_Hessian_of_the_Lagragian. - + \param[in] m - is the dimension of the range space for g(x); + is the dimension of the range space for g(x); i.e., must be equal to ng_. - + \param[in] lambda if values is not NULL, lambda is a vector of size ng_ specifing the value of \f$ \lambda \f$ in the expression for \ref The_Hessian_of_the_Lagragian. - + \param[in] new_lambda is true if the previous call to eval_h had the same value for lambda and false otherwise. (Not currently used.) - + \param[in] nele_hess - is the number of possibly non-zero elements in the + is the number of possibly non-zero elements in the Hessian of the Lagragian; i.e., must be equal to nx_*(nx_+1)/2. - + \param iRow if values is not NULL, iRow is not defined. if values is NULL, iRow is a vector with size nele_hess. The input value of its elements does not matter. - On output, - For k = 0 , ... , nele_hess-1, iRow[k] is the - base zero row index for the + On output, + For k = 0 , ... , nele_hess-1, iRow[k] is the + base zero row index for the k-th possibly non-zero entry in the Hessian fo the Lagragian. - + \param jCol if values is not NULL, jCol is not defined. if values is NULL, jCol is a vector with size nele_hess. The input value of its elements does not matter. - On output, - For k = 0 , ... , nele_hess-1, jCol[k] is the - base zero column index for the + On output, + For k = 0 , ... , nele_hess-1, jCol[k] is the + base zero column index for the k-th possibly non-zero entry in the Hessian of the Lagragian. - + \param values if values is not NULL, it is a vector with size nele_hess. The input value of its elements does not matter. - On output, - For k = 0 , ... , nele_hess-1, values[k] is the - value for the + On output, + For k = 0 , ... , nele_hess-1, values[k] is the + value for the k-th possibly non-zero entry in the Hessian of the Lagragian. - + \return The return value is always true; see \ref Evaluation_Methods. */ virtual bool eval_h( Index n , - const Number* x , + const Number* x , bool new_x , - Number obj_factor , + Number obj_factor , Index m , const Number* lambda , - bool new_lambda , - Index nele_hess , + bool new_lambda , + Index nele_hess , Index* iRow , - Index* jCol , + Index* jCol , Number* values ) { size_t i, j, k; CPPAD_ASSERT_UNKNOWN(static_cast(m) == ng_ ); CPPAD_ASSERT_UNKNOWN(static_cast(n) == nx_ ); // size_t nk = row_hes_.size(); - CPPAD_ASSERT_UNKNOWN( static_cast(nele_hess) == nk ); + CPPAD_ASSERT_UNKNOWN( static_cast(nele_hess) == nk ); // if( new_x ) cache_new_x(x); @@ -943,67 +1021,67 @@ // ---------------------------------------------------------------------- /*! Pass solution information from Ipopt to users solution structure. - + \param[in] status is value that the Ipopt solution status - which gets mapped to a correponding value for + which gets mapped to a correponding value for \n solution_.status - + \param[in] n is the dimension of the domain space for f(x) and g(x); i.e., it must be equal to nx_. - + \param[in] x is a vector with size nx_ specifing the final solution. This is the output value for \n - solution_.x - + solution_.x + \param[in] z_L is a vector with size nx_ specifing the Lagragian multipliers for the constraint \f$ x^l \leq x \f$. This is the output value for \n solution_.zl - + \param[in] z_U is a vector with size nx_ specifing the Lagragian multipliers for the constraint \f$ x \leq x^u \f$. This is the output value for \n - solution_.zu - + solution_.zu + \param[in] m is the dimension of the range space for g(x). i.e., it must be equal to ng_. - + \param[in] g is a vector with size ng_ containing the value of the constraint function g(x) at the final solution x. This is the output value for \n - solution_.g - + solution_.g + \param[in] lambda is a vector with size ng_ specifing the Lagragian multipliers for the constraints \f$ g^l \leq g(x) \leq g^u \f$. This is the output value for \n - solution_.lambda - + solution_.lambda + \param[in] obj_value is the value of the objective function f(x) at the final solution x. This is the output value for \n solution_.obj_value - + \param[in] ip_data is unspecified (by Ipopt) and hence not used. - + \param[in] ip_cq is unspecified (by Ipopt) and hence not used. - + \par solution_[out] this is a reference to the solution argument in the constructor for solve_callback. @@ -1012,83 +1090,83 @@ */ virtual void finalize_solution( Ipopt::SolverReturn status , - Index n , - const Number* x , - const Number* z_L , + Index n , + const Number* x , + const Number* z_L , const Number* z_U , - Index m , - const Number* g , + Index m , + const Number* g , const Number* lambda , Number obj_value , const Ipopt::IpoptData* ip_data , Ipopt::IpoptCalculatedQuantities* ip_cq ) { size_t i, j; - + CPPAD_ASSERT_UNKNOWN(static_cast(n) == nx_ ); CPPAD_ASSERT_UNKNOWN(static_cast(m) == ng_ ); - + switch(status) { // convert status from Ipopt enum to solve_result enum case Ipopt::SUCCESS: solution_.status = solve_result::success; break; - + case Ipopt::MAXITER_EXCEEDED: - solution_.status = + solution_.status = solve_result::maxiter_exceeded; break; - + case Ipopt::STOP_AT_TINY_STEP: - solution_.status = + solution_.status = solve_result::stop_at_tiny_step; break; - + case Ipopt::STOP_AT_ACCEPTABLE_POINT: - solution_.status = + solution_.status = solve_result::stop_at_acceptable_point; break; - + case Ipopt::LOCAL_INFEASIBILITY: - solution_.status = + solution_.status = solve_result::local_infeasibility; break; - + case Ipopt::USER_REQUESTED_STOP: - solution_.status = + solution_.status = solve_result::user_requested_stop; break; - + case Ipopt::DIVERGING_ITERATES: - solution_.status = + solution_.status = solve_result::diverging_iterates; break; - + case Ipopt::RESTORATION_FAILURE: - solution_.status = + solution_.status = solve_result::restoration_failure; break; - + case Ipopt::ERROR_IN_STEP_COMPUTATION: - solution_.status = + solution_.status = solve_result::error_in_step_computation; break; - + case Ipopt::INVALID_NUMBER_DETECTED: - solution_.status = + solution_.status = solve_result::invalid_number_detected; break; - + case Ipopt::INTERNAL_ERROR: - solution_.status = + solution_.status = solve_result::internal_error; break; - + default: - solution_.status = + solution_.status = solve_result::unknown; } - + solution_.x.resize(nx_); solution_.zl.resize(nx_); solution_.zu.resize(nx_); diff -Nru cppad-2015.00.00.9/cppad/ipopt/solve.hpp cppad-2016.00.00.1/cppad/ipopt/solve.hpp --- cppad-2015.00.00.9/cppad/ipopt/solve.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/ipopt/solve.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: solve.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_SOLVE_INCLUDED -# define CPPAD_SOLVE_INCLUDED +// $Id: solve.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SOLVE_HPP +# define CPPAD_SOLVE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -61,29 +61,29 @@ problems of the form $latex \[ \begin{array}{rll} -{\rm minimize} & f (x) +{\rm minimize} & f (x) \\ {\rm subject \; to} & gl \leq g(x) \leq gu \\ & xl \leq x \leq xu \end{array} \] $$ -This is done using +This is done using $href% http://www.coin-or.org/projects/Ipopt.xml% Ipopt %$$ -optimizer and CppAD for the derivative and sparsity calculations. +optimizer and CppAD for the derivative and sparsity calculations. $head Include File$$ -Currently, this routine +Currently, this routine $cref/ipopt::solve/ipopt_solve/$$ is not included by the command $codei% # include %$$ (Doing so would require the ipopt library to link the corresponding program (even if $code ipopt::solve$$) was not used.) -For this reason, +For this reason, if you are using $code ipopt::solve$$ you should use $codei% # include @@ -92,12 +92,12 @@ $head Bvector$$ The type $icode Bvector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ $code bool$$. $head Dvector$$ The type $icode DVector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ $code double$$. $head options$$ @@ -106,7 +106,7 @@ const std::string %options% %$$ It contains a list of options. -Each option, including the last option, +Each option, including the last option, is terminated by the $code '\n'$$ character. Each line consists of two or three tokens separated by one or more spaces. @@ -120,7 +120,7 @@ new value of $icode x$$. If the value is $code false$$, $code ipopt::solve$$ will tape the operation sequence at the value -of $icode xi$$ and use that sequence for the entire optimization process. +of $icode xi$$ and use that sequence for the entire optimization process. The default value is $code false$$. $subhead Sparse$$ @@ -130,7 +130,7 @@ %$$ If the value is $code true$$, $code ipopt::solve$$ will use a sparse matrix representation for the computation of Jacobians and Hessians. -Otherwise, it will use a full matrix representation for +Otherwise, it will use a full matrix representation for these calculations. The default for $icode value$$ is $code false$$. If sparse is true, retape must be false. @@ -139,23 +139,23 @@ $$ It is unclear if $cref sparse_jacobian$$ would be faster user forward or reverse mode so you are able to choose the direction. -If +If $codei% %value% == true && %direction% == forward %$$ -the Jacobians will be calculated using $code SparseJacobianForward$$. -If +the Jacobians will be calculated using $code SparseJacobianForward$$. +If $codei% %value% == true && %direction% == reverse %$$ -the Jacobians will be calculated using $code SparseJacobianReverse$$. +the Jacobians will be calculated using $code SparseJacobianReverse$$. $subhead String$$ You can set any Ipopt string option using a line with the following syntax: $codei% String %name% %value% %$$ -Here $icode name$$ is any valid Ipopt string option +Here $icode name$$ is any valid Ipopt string option and $icode value$$ is its setting. $subhead Numeric$$ @@ -163,7 +163,7 @@ $codei% Numeric %name% %value% %$$ -Here $icode name$$ is any valid Ipopt numeric option +Here $icode name$$ is any valid Ipopt numeric option and $icode value$$ is its setting. $subhead Integer$$ @@ -171,7 +171,7 @@ $codei% Integer %name% %value% %$$ -Here $icode name$$ is any valid Ipopt integer option +Here $icode name$$ is any valid Ipopt integer option and $icode value$$ is its setting. $head xi$$ @@ -230,7 +230,7 @@ $subhead ADvector$$ The type $icode%FG_eval%::ADvector%$$ must be a $cref SimpleVector$$ class with -$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ $code AD$$. $subhead x$$ @@ -268,7 +268,7 @@ $codei% ipopt::solve_result<%Dvector%>::status_type %solution%.status %$$ -It is the final Ipopt status for the optimizer. +It is the final Ipopt status for the optimizer. Here is a list of the possible values for the status: $table @@ -282,7 +282,7 @@ documentation for $code finalize_solution$$. $rnext success $cnext -Algorithm terminated successfully at a point satisfying the convergence +Algorithm terminated successfully at a point satisfying the convergence tolerances (see Ipopt options). $rnext maxiter_exceeded $cnext @@ -292,8 +292,8 @@ Algorithm terminated because progress was very slow. $rnext stop_at_acceptable_point $cnext -Algorithm stopped at a point that was converged, -not to the 'desired' tolerances, but to 'acceptable' tolerances +Algorithm stopped at a point that was converged, +not to the 'desired' tolerances, but to 'acceptable' tolerances (see Ipopt options). $rnext local_infeasibility $cnext @@ -310,11 +310,11 @@ Restoration phase failed, algorithm doesn't know how to proceed. $rnext error_in_step_computation $cnext -An unrecoverable error occurred while Ipopt tried to +An unrecoverable error occurred while Ipopt tried to compute the search direction. $rnext invalid_number_detected $cnext -Algorithm received an invalid number (such as $code nan$$ or $code inf$$) +Algorithm received an invalid number (such as $code nan$$ or $code inf$$) from the users function $icode%fg_info%.eval%$$ or from the CppAD evaluations of its derivatives (see the Ipopt option $code check_derivatives_for_naninf$$). @@ -338,7 +338,7 @@ %Vector% %solution%.zl %$$ and its size is equal to $icode nx$$. -It is the final Lagrange multipliers for the +It is the final Lagrange multipliers for the lower bounds on $latex x$$. $subhead zu$$ @@ -347,7 +347,7 @@ %Vector% %solution%.zu %$$ and its size is equal to $icode nx$$. -It is the final Lagrange multipliers for the +It is the final Lagrange multipliers for the upper bounds on $latex x$$. $subhead g$$ @@ -364,7 +364,7 @@ %Vector%> %solution%.lambda %$$ and its size is equal to $icode ng$$. -It is the final value for the +It is the final value for the Lagrange multipliers corresponding to the constraint function. $subhead obj_value$$ @@ -398,7 +398,7 @@ The file $cref%example/ipopt_solve/ode_inverse.cpp%ipopt_solve_ode_inverse.cpp%$$ demonstrates using Ipopt to solve for parameters in an ODE model. - + $end ------------------------------------------------------------------------------- */ @@ -408,7 +408,7 @@ namespace ipopt { /*! \file solve.hpp -\brief Implement the ipopt::solve Nonlinear Programming Solver +\brief Implement the ipopt::solve Nonlinear Programming Solver */ /*! @@ -429,7 +429,7 @@ to dentify the type used for the arguments to fg_eval. \param options -list of options, one for each line. +list of options, one for each line. Ipopt options (are optional) and have one of the following forms \code String name value @@ -469,14 +469,14 @@ template void solve( const std::string& options , - const Dvector& xi , + const Dvector& xi , const Dvector& xl , - const Dvector& xu , - const Dvector& gl , - const Dvector& gu , - FG_eval& fg_eval , + const Dvector& xu , + const Dvector& gl , + const Dvector& gu , + FG_eval& fg_eval , ipopt::solve_result& solution ) -{ bool ok = true; +{ bool ok = true; typedef typename FG_eval::ADvector ADvector; @@ -502,7 +502,7 @@ bool sparse_forward = false; bool sparse_reverse = false; while( begin_1 < options.size() ) - { // split this line into tokens + { // split this line into tokens while( options[begin_1] == ' ') begin_1++; end_1 = options.find_first_of(" \n", begin_1); @@ -516,13 +516,13 @@ end_3 = options.find_first_of(" \n", begin_3); // check for errors - CPPAD_ASSERT_KNOWN( - (end_1 != std::string::npos) & - (end_2 != std::string::npos) & + CPPAD_ASSERT_KNOWN( + (end_1 != std::string::npos) & + (end_2 != std::string::npos) & (end_3 != std::string::npos) , "ipopt::solve: missing '\\n' at end of an option line" ); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( (end_1 > begin_1) & (end_2 > begin_2) , "ipopt::solve: an option line does not have two tokens" ); @@ -538,8 +538,8 @@ three_tok |= tok_1 == "String"; three_tok |= tok_1 == "Numeric"; three_tok |= tok_1 == "Integer"; - if( three_tok ) - { CPPAD_ASSERT_KNOWN( + if( three_tok ) + { CPPAD_ASSERT_KNOWN( (end_3 > begin_3) , "ipopt::solve: a Sparse, String, Numeric, or Integer\n" "option line does not have three tokens." @@ -576,11 +576,11 @@ else if ( tok_1 == "String" ) app->Options()->SetStringValue(tok_2.c_str(), tok_3.c_str()); else if ( tok_1 == "Numeric" ) - { Ipopt::Number value = std::atof( tok_3.c_str() ); + { Ipopt::Number value = std::atof( tok_3.c_str() ); app->Options()->SetNumericValue(tok_2.c_str(), value); } else if ( tok_1 == "Integer" ) - { Ipopt::Index value = std::atoi( tok_3.c_str() ); + { Ipopt::Index value = std::atoi( tok_3.c_str() ); app->Options()->SetIntegerValue(tok_2.c_str(), value); } else CPPAD_ASSERT_KNOWN( @@ -599,7 +599,7 @@ ); begin_1++; } - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( ! ( retape & (sparse_forward | sparse_reverse) ) , "ipopt::solve: retape and sparse both true is not supported." ); @@ -608,27 +608,27 @@ Ipopt::ApplicationReturnStatus status = app->Initialize(); ok &= status == Ipopt::Solve_Succeeded; if( ! ok ) - { solution.status = solve_result::unknown; + { solution.status = solve_result::unknown; return; } // Create an interface from Ipopt to this specific problem. // Note the assumption here that ADvector is same as cppd_ipopt::ADvector size_t nf = 1; - Ipopt::SmartPtr cppad_nlp = + Ipopt::SmartPtr cppad_nlp = new CppAD::ipopt::solve_callback( - nf, - nx, - ng, - xi, - xl, - xu, - gl, - gu, - fg_eval, - retape, - sparse_forward, - sparse_reverse, + nf, + nx, + ng, + xi, + xl, + xu, + gl, + gu, + fg_eval, + retape, + sparse_forward, + sparse_reverse, solution ); diff -Nru cppad-2015.00.00.9/cppad/ipopt/solve_result.hpp cppad-2016.00.00.1/cppad/ipopt/solve_result.hpp --- cppad-2015.00.00.9/cppad/ipopt/solve_result.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/ipopt/solve_result.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: solve_result.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_SOLVE_RESULT_INCLUDED -# define CPPAD_SOLVE_RESULT_INCLUDED +// $Id: solve_result.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SOLVE_RESULT_HPP +# define CPPAD_SOLVE_RESULT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,8 +26,8 @@ a simple vector with elements of type double */ template -class solve_result -{ +class solve_result +{ public: /// possible values for the result status enum status_type { diff -Nru cppad-2015.00.00.9/cppad/local/abort_recording.hpp cppad-2016.00.00.1/cppad/local/abort_recording.hpp --- cppad-2015.00.00.9/cppad/local/abort_recording.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/abort_recording.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: abort_recording.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ABORT_RECORDING_INCLUDED -# define CPPAD_ABORT_RECORDING_INCLUDED +// $Id: abort_recording.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ABORT_RECORDING_HPP +# define CPPAD_ABORT_RECORDING_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,16 +14,12 @@ -------------------------------------------------------------------------- */ /* $begin abort_recording$$ -$spell +$spell $$ $section Abort Recording of an Operation Sequence$$ +$mindex tape$$ -$index abort, operation sequence$$ -$index operation, sequence abort$$ -$index sequence, operation abort$$ -$index recording, abort$$ -$index tape, abort recording$$ $head Syntax$$ $codei%AD<%Base%>::abort_recording()%$$ @@ -44,7 +40,7 @@ %$$ $head Example$$ The file -$cref abort_recording.cpp$$ +$cref abort_recording.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. diff -Nru cppad-2015.00.00.9/cppad/local/abs.hpp cppad-2016.00.00.1/cppad/local/abs.hpp --- cppad-2015.00.00.9/cppad/local/abs.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/abs.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: abs.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ABS_INCLUDED -# define CPPAD_ABS_INCLUDED +// $Id: abs.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ABS_HPP +# define CPPAD_ABS_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,46 +28,25 @@ abs $$ -$index abs, AD$$ -$index fabs, AD$$ -$index absolute, AD value$$ -$index value, AD absolute$$ - -$section AD Absolute Value Function$$ +$section AD Absolute Value Functions: abs, fabs$$ $head Syntax$$ $icode%y% = abs(%x%) %$$ $icode%y% = fabs(%x%)%$$ - -$head Purpose$$ -Evaluates the absolute value function. - -$head x$$ -The argument $icode x$$ has one of the following prototypes -$codei% - const AD<%Base%> &%x% - const VecAD<%Base%>::reference &%x% -%$$ - -$head y$$ -The result $icode y$$ has prototype -$codei% - AD<%Base%> %y% -%$$ - - -$head Operation Sequence$$ -This is an AD of $icode Base$$ -$cref/atomic operation/glossary/Operation/Atomic/$$ -and hence is part of the current -AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$. +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +In the case where $icode x$$ is an AD type, +this is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Complex Types$$ -The function $code abs$$ is not defined for the AD type sequences -above $code std::complex$$ or $code std::complex$$ +The functions $code abs$$ and $icode fabs$$ +are not defined for the base types +$code std::complex$$ or $code std::complex$$ because the complex $code abs$$ function is not complex differentiable (see $cref/complex types faq/Faq/Complex Types/$$). @@ -75,15 +54,14 @@ CppAD defines the derivative of the $code abs$$ function is the $cref sign$$ function; i.e., $latex \[ -{\rm abs}^{(1)} ( x ) = {\rm sign} (x ) = +{\rm abs}^{(1)} ( x ) = {\rm sign} (x ) = \left\{ \begin{array}{rl} +1 & {\rm if} \; x > 0 \\ 0 & {\rm if} \; x = 0 \\ -1 & {\rm if} \; x < 0 \end{array} \right. \] $$ -This used to be different; -see $cref/old derivative/abs/Old Derivative/$$ below. +The result for $icode%x% == 0%$$ used to be a directional derivative. $head Example$$ $children% @@ -91,52 +69,9 @@ %$$ The file $cref abs.cpp$$ -contains an example and test of this function. +contains an example and test of this function. It returns true if it succeeds and false otherwise. -$head Old Derivative$$ -The derivative of the absolute value function is one for -$latex x > 0$$ and minus one for $latex x < 0$$. -CppAD used to compute its directional derivative -what $latex x = 0$$. -$pre - -$$ -The function corresponding to the argument $icode x$$ -and the result $icode y$$ are represented -by their Taylor coefficients; i.e., -$latex \[ -\begin{array}{rcl} - X(t) & = & x^{(0)} (t) + x^{(1)} t + \cdots + x^{(p)} t^p - \\ - Y(t) & = & y^{(0)} (t) + y^{(1)} t + \cdots + y^{(p)} t^p -\end{array} -\] $$ -Note that $latex x^{(0)} = X(0)$$ is the value of $icode x$$ and -$latex y^{(0)} = Y(0)$$ is the value of $icode y$$. -In the equations above, the order $latex p$$ is specified -by a call to $cref Forward$$ or $cref Reverse$$ as follows: -$codei% - %f%.Forward(%p%, %dx%) - %f%.Reverse(%p%+1, %w%) -%$$ -If all of the Taylor coefficients of $latex X(t)$$ are zero, -we define $latex k = p$$. -Otherwise, we define $latex k$$ to be the minimal index such that -$latex x^{(k)} \neq 0$$. -Note that if $latex x \neq 0$$, $latex k = 0$$. -The Taylor coefficient representation of $latex Y(t)$$ -(and hence it's derivatives) are computed as -$latex \[ -y^{(\ell)} -= -\left\{ \begin{array}{ll} - x^{(\ell)} & {\rm if} \; x^{(k)} > 0 \\ - 0 & {\rm if} \; x^{(k)} = 0 \\ - - x^{(\ell)} & {\rm if} \; x^{(k)} < 0 -\end{array} \right. -\] $$ - $end ------------------------------------------------------------------------------- */ @@ -146,12 +81,12 @@ template AD AD::Abs (void) const -{ +{ AD result; result.value_ = abs(value_); CPPAD_ASSERT_UNKNOWN( Parameter(result) ); - if( Variable(*this) ) + if( Variable(*this) ) { // add this operation to the tape CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 ); @@ -177,4 +112,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/abs_op.hpp cppad-2016.00.00.1/cppad/local/abs_op.hpp --- cppad-2015.00.00.9/cppad/local/abs_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/abs_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: abs_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_ABS_OP_INCLUDED -# define CPPAD_ABS_OP_INCLUDED +// $Id: abs_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ABS_OP_HPP +# define CPPAD_ABS_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,7 +36,7 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -69,7 +69,7 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -102,7 +102,7 @@ inline void forward_abs_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { @@ -133,11 +133,11 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) -{ size_t j; +{ size_t j; // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 ); @@ -152,6 +152,7 @@ // Taylor coefficients and partials corresponding to result Base* pz = partial + i_z * nc_partial; + // do not need azmul becasue sign is either +1, -1, or zero for(j = 0; j <= d; j++) px[j] += sign(x[0]) * pz[j]; } diff -Nru cppad-2015.00.00.9/cppad/local/acosh.hpp cppad-2016.00.00.1/cppad/local/acosh.hpp --- cppad-2015.00.00.9/cppad/local/acosh.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/acosh.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,96 @@ +// $Id$ +# ifndef CPPAD_ACOSH_HPP +# define CPPAD_ACOSH_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin acosh$$ +$spell + acosh + const + Vec + std + cmath + CppAD +$$ +$section The Inverse Hyperbolic Cosine Function: acosh$$ + +$head Syntax$$ +$icode%y% = acosh(%x%)%$$ + +$head Description$$ +The inverse hyperbolic cosine function is defined by +$icode%x% == cosh(%y%)%$$. + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head CPPAD_USE_CPLUSPLUS_2011$$ + +$subhead true$$ +If this preprocessor symbol is true ($code 1$$), +and $icode x$$ is an AD type, +this is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$subhead false$$ +If this preprocessor symbol is false ($code 0$$), +CppAD uses the representation +$latex \[ +\R{acosh} (x) = \log \left( x + \sqrt{ x^2 - 1 } \right) +\] $$ +to compute this function. + +$head Example$$ +$children% + example/acosh.cpp +%$$ +The file +$cref acosh.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +*/ +# include +# if ! CPPAD_USE_CPLUSPLUS_2011 + +// BEGIN CppAD namespace +namespace CppAD { + +template +Type acosh_template(const Type &x) +{ return CppAD::log( x + CppAD::sqrt( x * x - Type(1) ) ); +} + +inline float acosh(const float &x) +{ return acosh_template(x); } + +inline double acosh(const double &x) +{ return acosh_template(x); } + +template +inline AD acosh(const AD &x) +{ return acosh_template(x); } + +template +inline AD acosh(const VecAD_reference &x) +{ return acosh_template( x.ADBase() ); } + + +} // END CppAD namespace + +# endif // CPPAD_USE_CPLUSPLUS_2011 +# endif // CPPAD_ACOSH_INCLUDED diff -Nru cppad-2015.00.00.9/cppad/local/acosh_op.hpp cppad-2016.00.00.1/cppad/local/acosh_op.hpp --- cppad-2015.00.00.9/cppad/local/acosh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/acosh_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -0,0 +1,266 @@ +// $Id$ +# ifndef CPPAD_ACOSH_OP_HPP +# define CPPAD_ACOSH_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file acosh_op.hpp +Forward and reverse mode calculations for z = acosh(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = AcoshOp. + +The C++ source code corresponding to this operation is +\verbatim + z = acosh(x) +\endverbatim +The auxillary result is +\verbatim + y = sqrt(x * x - 1) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails forward_unary2_op +*/ +template +inline void forward_acosh_op( + size_t p , + size_t q , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AcoshOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AcoshOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + Base* b = z - cap_order; // called y in documentation + + size_t k; + Base uj; + if( p == 0 ) + { z[0] = acosh( x[0] ); + uj = x[0] * x[0] - Base(1); + b[0] = sqrt( uj ); + p++; + } + for(size_t j = p; j <= q; j++) + { uj = Base(0); + for(k = 0; k <= j; k++) + uj += x[k] * x[j-k]; + b[j] = Base(0); + z[j] = Base(0); + for(k = 1; k < j; k++) + { b[j] -= Base(k) * b[k] * b[j-k]; + z[j] -= Base(k) * z[k] * b[j-k]; + } + b[j] /= Base(j); + z[j] /= Base(j); + // + b[j] += uj / Base(2); + z[j] += x[j]; + // + b[j] /= b[0]; + z[j] /= b[0]; + } +} +/*! +Multiple directions forward mode Taylor coefficient for op = AcoshOp. + +The C++ source code corresponding to this operation is +\verbatim + z = acosh(x) +\endverbatim +The auxillary result is +\verbatim + y = sqrt(x * x - 1) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails forward_unary2_op_dir +*/ +template +inline void forward_acosh_op_dir( + size_t q , + size_t r , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AcoshOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AcoshOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + + // Taylor coefficients corresponding to argument and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + i_x * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + Base* b = z - num_taylor_per_var; // called y in documentation + + size_t k, ell; + size_t m = (q-1) * r + 1; + for(ell = 0; ell < r; ell ++) + { Base uq = 2.0 * x[m + ell] * x[0]; + for(k = 1; k < q; k++) + uq += x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; + b[m+ell] = Base(0); + z[m+ell] = Base(0); + for(k = 1; k < q; k++) + { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + b[m+ell] = ( uq / Base(2) - b[m+ell] / Base(q) ) / b[0]; + z[m+ell] = ( x[m+ell] - z[m+ell] / Base(q) ) / b[0]; + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = AcoshOp. + +The C++ source code corresponding to this operation is +\verbatim + z = acosh(x) +\endverbatim +The auxillary result is +\verbatim + y = sqrt( x * x - 1 ) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails forward_unary2_op_0 +*/ +template +inline void forward_acosh_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AcoshOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AcoshOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + Base* b = z - cap_order; // called y in documentation + + z[0] = acosh( x[0] ); + b[0] = sqrt( x[0] * x[0] - Base(1) ); +} +/*! +Compute reverse mode partial derivatives for result of op = AcoshOp. + +The C++ source code corresponding to this operation is +\verbatim + z = acosh(x) +\endverbatim +The auxillary result is +\verbatim + y = sqrt( x * x - 1 ) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails reverse_unary2_op +*/ + +template +inline void reverse_acosh_op( + size_t d , + size_t i_z , + size_t i_x , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AcoshOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AcoshOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Taylor coefficients and partials corresponding to argument + const Base* x = taylor + i_x * cap_order; + Base* px = partial + i_x * nc_partial; + + // Taylor coefficients and partials corresponding to first result + const Base* z = taylor + i_z * cap_order; + Base* pz = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + const Base* b = z - cap_order; // called y in documentation + Base* pb = pz - nc_partial; + + Base inv_b0 = Base(1) / b[0]; + + // number of indices to access + size_t j = d; + size_t k; + while(j) + { + // scale partials w.r.t b[j] by 1 / b[0] + pb[j] = azmul(pb[j], inv_b0); + + // scale partials w.r.t z[j] by 1 / b[0] + pz[j] = azmul(pz[j], inv_b0); + + // update partials w.r.t b^0 + pb[0] -= azmul(pz[j], z[j]) + azmul(pb[j], b[j]); + + // update partial w.r.t. x^0 + px[0] += azmul(pb[j], x[j]); + + // update partial w.r.t. x^j + px[j] += pz[j] + azmul(pb[j], x[0]); + + // further scale partial w.r.t. z[j] by 1 / j + pz[j] /= Base(j); + + for(k = 1; k < j; k++) + { // update partials w.r.t b^(j-k) + pb[j-k] -= Base(k) * azmul(pz[j], z[k]) + azmul(pb[j], b[k]); + + // update partials w.r.t. x^k + px[k] += azmul(pb[j], x[j-k]); + + // update partials w.r.t. z^k + pz[k] -= Base(k) * azmul(pz[j], b[j-k]); + } + --j; + } + + // j == 0 case + px[0] += azmul(pz[0] + azmul(pb[0], x[0]), inv_b0); +} + +} // END_CPPAD_NAMESPACE +# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/acos_op.hpp cppad-2016.00.00.1/cppad/local/acos_op.hpp --- cppad-2015.00.00.9/cppad/local/acos_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/acos_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: acos_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_ACOS_OP_INCLUDED -# define CPPAD_ACOS_OP_INCLUDED +// $Id: acos_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ACOS_OP_HPP +# define CPPAD_ACOS_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,9 +43,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AcosOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AcosOp) == 2 ); @@ -107,9 +107,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AcosOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AcosOp) == 2 ); @@ -127,12 +127,12 @@ for(ell = 0; ell < r; ell ++) { Base uq = - 2.0 * x[m + ell] * x[0]; for(k = 1; k < q; k++) - uq -= x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; + uq -= x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; b[m+ell] = Base(0); z[m+ell] = Base(0); for(k = 1; k < q; k++) - { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; - z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; } b[m+ell] = ( uq / Base(2) - b[m+ell] / Base(q) ) / b[0]; z[m+ell] = -( x[m+ell] + z[m+ell] / Base(q) ) / b[0]; @@ -158,7 +158,7 @@ inline void forward_acos_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -195,7 +195,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -218,44 +218,46 @@ const Base* b = z - cap_order; // called y in documentation Base* pb = pz - nc_partial; + Base inv_b0 = Base(1) / b[0]; + // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t b[j] by 1 / b[0] - pb[j] /= b[0]; + pb[j] = azmul(pb[j], inv_b0); // scale partials w.r.t z[j] by 1 / b[0] - pz[j] /= b[0]; + pz[j] = azmul(pz[j], inv_b0); - // update partials w.r.t b^0 - pb[0] -= pz[j] * z[j] + pb[j] * b[j]; + // update partials w.r.t b^0 + pb[0] -= azmul(pz[j], z[j]) + azmul(pb[j], b[j]); // update partial w.r.t. x^0 - px[0] -= pb[j] * x[j]; + px[0] -= azmul(pb[j], x[j]); // update partial w.r.t. x^j - px[j] -= pz[j] + pb[j] * x[0]; + px[j] -= pz[j] + azmul(pb[j], x[0]); // further scale partial w.r.t. z[j] by 1 / j pz[j] /= Base(j); for(k = 1; k < j; k++) { // update partials w.r.t b^(j-k) - pb[j-k] -= Base(k) * pz[j] * z[k] + pb[j] * b[k]; + pb[j-k] -= Base(k) * azmul(pz[j], z[k]) + azmul(pb[j], b[k]); - // update partials w.r.t. x^k - px[k] -= pb[j] * x[j-k]; + // update partials w.r.t. x^k + px[k] -= azmul(pb[j], x[j-k]); // update partials w.r.t. z^k - pz[k] -= pz[j] * Base(k) * b[j-k]; + pz[k] -= Base(k) * azmul(pz[j], b[j-k]); } --j; } // j == 0 case - px[0] -= ( pz[0] + pb[0] * x[0]) / b[0]; + px[0] -= azmul( pz[0] + azmul(pb[0], x[0]), inv_b0); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/ad_assign.hpp cppad-2016.00.00.1/cppad/local/ad_assign.hpp --- cppad-2015.00.00.9/cppad/local/ad_assign.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad_assign.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ad_assign.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_AD_ASSIGN_INCLUDED -# define CPPAD_AD_ASSIGN_INCLUDED +// $Id: ad_assign.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_AD_ASSIGN_HPP +# define CPPAD_AD_ASSIGN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,31 +22,27 @@ const $$ -$index assignment, AD$$ -$index AD, assignment$$ -$index assign, to AD$$ -$index Base, assign to AD$$ -$index VecAD, assign to AD$$ $section AD Assignment Operator$$ +$mindex assign Base VecAD$$ $head Syntax$$ $icode%y% = %x%$$ $head Purpose$$ Assigns the value in $icode x$$ to the object $icode y$$. -In either case, +In either case, $head x$$ The argument $icode x$$ has prototype $codei% const %Type% &%x% -%$$ +%$$ where $icode Type$$ is $codei%VecAD<%Base%>::reference%$$, $codei%AD<%Base%>%$$, -$icode Base$$, -or any type that has a constructor of the form +$icode Base$$, +or any type that has an implicit constructor of the form $icode%Base%(%x%)%$$. $head y$$ diff -Nru cppad-2015.00.00.9/cppad/local/ad_binary.hpp cppad-2016.00.00.1/cppad/local/ad_binary.hpp --- cppad-2015.00.00.9/cppad/local/ad_binary.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad_binary.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ad_binary.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_AD_BINARY_INCLUDED -# define CPPAD_AD_BINARY_INCLUDED +// $Id: ad_binary.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_AD_BINARY_HPP +# define CPPAD_AD_BINARY_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,24 +23,12 @@ $$ $section AD Binary Arithmetic Operators$$ +$mindex + add plus - subtract minus * multiply times / divide$$ + + -$index binary, operator$$ -$index operator, binary$$ -$index +, binary operator$$ -$index add, binary operator$$ -$index plus, binary operator$$ - -$index -, binary operator$$ -$index subtract, binary operator$$ -$index minus, binary operator$$ - -$index *, binary operator$$ -$index multiply, binary operator$$ -$index times, binary operator$$ -$index /, binary operator$$ -$index divide, binary operator$$ $head Syntax$$ @@ -48,9 +36,9 @@ $head Purpose$$ Performs arithmetic operations where either $icode x$$ or $icode y$$ -has type +has type $codei%AD<%Base%>%$$ or -$cref%VecAD::reference%VecAD%VecAD::reference%$$. +$cref%VecAD::reference%VecAD%VecAD::reference%$$. $head Op$$ The operator $icode Op$$ is one of the following @@ -59,7 +47,7 @@ $code +$$ $cnext $icode z$$ is $icode x$$ plus $icode y$$ $rnext $code -$$ $cnext $icode z$$ is $icode x$$ minus $icode y$$ $rnext $code *$$ $cnext $icode z$$ is $icode x$$ times $icode y$$ $rnext -$code /$$ $cnext $icode z$$ is $icode x$$ divided by $icode y$$ +$code /$$ $cnext $icode z$$ is $icode x$$ divided by $icode y$$ $tend $head Base$$ @@ -101,7 +89,7 @@ This is an $cref/atomic/glossary/Operation/Atomic/$$ $cref/AD of Base/glossary/AD of Base/$$ operation and hence it is part of the current -AD of $icode Base$$ +AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. $children% @@ -122,7 +110,7 @@ $tend $head Derivative$$ -If $latex f$$ and $latex g$$ are +If $latex f$$ and $latex g$$ are $cref/Base functions/glossary/Base Function/$$ $subhead Addition$$ @@ -142,11 +130,11 @@ $subhead Division$$ $latex \[ - \D{[ f(x) / g(x) ]}{x} = + \D{[ f(x) / g(x) ]}{x} = [1/g(x)] * \D{f(x)}{x} - [f(x)/g(x)^2] * \D{g(x)}{x} \] $$ -$end +$end ----------------------------------------------------------------------------- */ # include diff -Nru cppad-2015.00.00.9/cppad/local/ad_ctor.hpp cppad-2016.00.00.1/cppad/local/ad_ctor.hpp --- cppad-2015.00.00.9/cppad/local/ad_ctor.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad_ctor.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ad_ctor.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_AD_CTOR_INCLUDED -# define CPPAD_AD_CTOR_INCLUDED +// $Id: ad_ctor.hpp 3760 2015-12-01 04:12:28Z bradbell $ +# ifndef CPPAD_AD_CTOR_HPP +# define CPPAD_AD_CTOR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,23 +25,18 @@ const $$ -$index AD, constructor$$ -$index constructor, AD$$ -$index convert, to AD$$ -$index Base, convert to AD$$ -$index VecAD, convert to AD$$ $section AD Constructors $$ +$mindex convert Base VecAD$$ $head Syntax$$ $codei%AD<%Base%> %y%() %$$ $codei%AD<%Base%> %y%(%x%) %$$ -$codei%AD<%Base%> %y% = %x%$$ $head Purpose$$ -creates a new $codei%AD<%Base%>%$$ object $icode y$$ +creates a new $codei%AD<%Base%>%$$ object $icode y$$ and initializes its value as equal to $icode x$$. $head x$$ @@ -52,29 +47,23 @@ $codei% const %Base%& %x% const VecAD<%Base%>& %x% -%$$ +%$$ $subhead explicit$$ There is an explicit constructor where $icode x$$ has prototype $codei% const %Type%& %x% -%$$ +%$$ for any type that has an explicit constructor of the form $icode%Base%(%x%)%$$. -$subhead deprecated$$ -$index deprecated, constructor$$ -$index constructor, deprecated$$ -If you set -$cref/cppad_implicit_ctor_from_any_type - /cmake - /cppad_implicit_ctor_from_any_type -/$$ +$subhead Deprecated 2013-12-31$$ +If you set $cref/cppad_deprecated/cmake/cppad_deprecated/$$ to be $code YES$$ during the install procedure, you will get an implicit constructor with prototype $codei% const %Type%& %x% -%$$ +%$$ for any type that has an explicit constructor of the form $icode%Base%(%x%)%$$. @@ -104,11 +93,11 @@ /*! \page AD_default_ctor -Use default copy constructor +Use default copy constructor because they may be optimized better than the code below: \code template -inline AD::AD(const AD &x) +inline AD::AD(const AD &x) { value_ = x.value_; tape_id_ = x.tape_id_; @@ -126,7 +115,7 @@ Base type for this AD object. */ template -inline AD::AD(void) +inline AD::AD(void) : value_() , tape_id_(0) , taddr_(0) @@ -145,13 +134,13 @@ so this object is initially a parameter. */ template -inline AD::AD(const Base &b) +inline AD::AD(const Base &b) : value_(b) , tape_id_(0) , taddr_(0) { // check that this is a parameter CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); -} +} /*! Constructor from an ADVec element drops the vector information. @@ -179,7 +168,7 @@ */ template template -inline AD::AD(const T &t) +inline AD::AD(const T &t) : value_(Base(t)) , tape_id_(0) , taddr_(0) diff -Nru cppad-2015.00.00.9/cppad/local/add_eq.hpp cppad-2016.00.00.1/cppad/local/add_eq.hpp --- cppad-2015.00.00.9/cppad/local/add_eq.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/add_eq.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: add_eq.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ADD_EQ_INCLUDED -# define CPPAD_ADD_EQ_INCLUDED +// $Id: add_eq.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ADD_EQ_HPP +# define CPPAD_ADD_EQ_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,7 +19,7 @@ template AD& AD::operator += (const AD &right) { - // compute the Base part + // compute the Base part Base left; left = value_; value_ += right.value_; @@ -89,4 +89,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/add.hpp cppad-2016.00.00.1/cppad/local/add.hpp --- cppad-2015.00.00.9/cppad/local/add.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/add.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: add.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ADD_INCLUDED -# define CPPAD_ADD_INCLUDED +// $Id: add.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ADD_HPP +# define CPPAD_ADD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -94,4 +94,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/add_op.hpp cppad-2016.00.00.1/cppad/local/add_op.hpp --- cppad-2015.00.00.9/cppad/local/add_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/add_op.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: add_op.hpp 3321 2014-09-12 09:50:39Z bradbell $ */ -# ifndef CPPAD_ADD_OP_INCLUDED -# define CPPAD_ADD_OP_INCLUDED +// $Id: add_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ADD_OP_HPP +# define CPPAD_ADD_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,8 +36,8 @@ template inline void forward_addvv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -74,8 +74,8 @@ template inline void forward_addvv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -149,7 +149,7 @@ template inline void reverse_addvv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -193,8 +193,8 @@ */ template inline void forward_addpv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -234,8 +234,8 @@ */ template inline void forward_addpv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -307,7 +307,7 @@ template inline void reverse_addpv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , diff -Nru cppad-2015.00.00.9/cppad/local/ad_fun.hpp cppad-2016.00.00.1/cppad/local/ad_fun.hpp --- cppad-2015.00.00.9/cppad/local/ad_fun.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad_fun.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ad_fun.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_AD_FUN_INCLUDED -# define CPPAD_AD_FUN_INCLUDED +// $Id: ad_fun.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_AD_FUN_HPP +# define CPPAD_AD_FUN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,7 +14,7 @@ -------------------------------------------------------------------------- */ /* $begin ADFun$$ -$spell +$spell xk Ind bool @@ -31,8 +31,6 @@ $section ADFun Objects$$ -$index ADFun, object$$ -$index object, ADFun$$ $head Purpose$$ An AD of $icode Base$$ @@ -51,7 +49,7 @@ cppad/local/drivers.hpp% cppad/local/fun_check.hpp% cppad/local/optimize.hpp% - omh/check_for_nan.omh + cppad/local/check_for_nan.hpp %$$ $end @@ -76,11 +74,25 @@ // ------------------------------------------------------------ // Private member variables private: + /// Has this ADFun object been optmized + bool has_been_optimized_; + /// Check for nan's and report message to user (default value is true). bool check_for_nan_; - /// debug checking number of comparision operations that changed - size_t compare_change_; + /// If zero, ignoring comparison operators. Otherwise is the + /// compare change count at which to store the operator index. + size_t compare_change_count_; + + /// If compare_change_count_ is zero, compare_change_number_ is also zero. + /// Otherwise, it is set to the number of comparison operations that had a + /// different result during the subsequent zero order forward. + size_t compare_change_number_; + + /// If compare_change_count is zero, compare_change_op_index_ is also + /// zero. Otherwise it is the operator index for the comparison operator + //// that corresponded to the number changing from count-1 to count. + size_t compare_change_op_index_; /// number of orders stored in taylor_ size_t num_order_taylor_; @@ -140,8 +152,9 @@ void ForSparseJacCase( bool set_type , bool transpose , + bool dependency, size_t q , - const VectorSet& r , + const VectorSet& r , VectorSet& s ); // vector of std::set version of ForSparseJac @@ -150,8 +163,9 @@ void ForSparseJacCase( const std::set& set_type , bool transpose , + bool dependency, size_t q , - const VectorSet& r , + const VectorSet& r , VectorSet& s ); // ------------------------------------------------------------ @@ -161,9 +175,9 @@ void RevSparseJacCase( bool set_type , bool transpose , - bool nz_compare, + bool dependency, size_t p , - const VectorSet& s , + const VectorSet& s , VectorSet& r ); // vector of std::set version of RevSparseJac @@ -172,9 +186,9 @@ void RevSparseJacCase( const std::set& set_type , bool transpose , - bool nz_compare, + bool dependency, size_t p , - const VectorSet& s , + const VectorSet& s , VectorSet& r ); // ------------------------------------------------------------ @@ -185,7 +199,7 @@ bool set_type , bool transpose , size_t q , - const VectorSet& s , + const VectorSet& s , VectorSet& h ); // vector of std::set version of RevSparseHes @@ -195,7 +209,7 @@ const std::set& set_type , bool transpose , size_t q , - const VectorSet& s , + const VectorSet& s , VectorSet& h ); // ------------------------------------------------------------ @@ -222,7 +236,7 @@ sparse_jacobian_work& work ); // ------------------------------------------------------------ - // combined sparse_set, sparse_list and sparse_pack version of + // combined sparse_set, sparse_list and sparse_pack version of // SparseHessian (see doxygen in sparse_hessian.hpp) template size_t SparseHessianCompute( @@ -237,7 +251,7 @@ // ------------------------------------------------------------ public: /// copy constructor - ADFun(const ADFun& g) + ADFun(const ADFun& g) : num_var_tape_(0) { CppAD::ErrorHandler::Call( true, @@ -251,7 +265,7 @@ } /// default constructor - ADFun(void); + ADFun(void); // assignment operator // (see doxygen in fun_construct.hpp) @@ -281,7 +295,7 @@ /// forward mode user API, multiple directions one order. template - VectorBase Forward(size_t q, + VectorBase Forward(size_t q, const VectorBase& x, std::ostream& s = std::cout ); @@ -289,50 +303,77 @@ template VectorBase Reverse(size_t p, const VectorBase &v); - // forward mode Jacobian sparsity + // forward mode Jacobian sparsity // (see doxygen documentation in for_sparse_jac.hpp) template VectorSet ForSparseJac( - size_t q, const VectorSet &r, bool transpose = false + size_t q, const VectorSet &r, bool transpose = false, + bool dependency = false ); - // reverse mode Jacobian sparsity + // reverse mode Jacobian sparsity // (see doxygen documentation in rev_sparse_jac.hpp) template VectorSet RevSparseJac( size_t q, const VectorSet &s, bool transpose = false, - bool nz_compare = false + bool dependency = false ); - // reverse mode Hessian sparsity + // reverse mode Hessian sparsity // (see doxygen documentation in rev_sparse_hes.hpp) template VectorSet RevSparseHes( size_t q, const VectorSet &s, bool transpose = false ); + // internal set sparsity version of RevSparseHes + // (used by checkpoint functions only) + void RevSparseHesCheckpoint( + size_t q , + vector& s , + bool transpose , + CPPAD_INTERNAL_SPARSE_SET& h + ); + // internal set sparsity version of RevSparseJac + // (used by checkpoint functions only) + void RevSparseJacCheckpoint( + size_t q , + CPPAD_INTERNAL_SPARSE_SET& r , + bool transpose , + bool dependency , + CPPAD_INTERNAL_SPARSE_SET& s + ); + // internal set sparsity version of RevSparseJac + // (used by checkpoint functions only) + void ForSparseJacCheckpoint( + size_t q , + CPPAD_INTERNAL_SPARSE_SET& r , + bool transpose , + bool dependency , + CPPAD_INTERNAL_SPARSE_SET& s + ); - /// amount of memeory used for Jacobain sparsity pattern + /// amount of memory used for Jacobain sparsity pattern size_t size_forward_bool(void) const { return for_jac_sparse_pack_.memory(); } - /// free memeory used for Jacobain sparsity pattern - void size_forward_bool(size_t zero) + /// free memory used for Jacobain sparsity pattern + void size_forward_bool(size_t zero) { CPPAD_ASSERT_KNOWN( zero == 0, "size_forward_bool: argument not equal to zero" ); - for_jac_sparse_pack_.resize(0, 0); + for_jac_sparse_pack_.resize(0, 0); } /// total number of elements used for Jacobian sparsity pattern size_t size_forward_set(void) const { return for_jac_sparse_set_.number_elements(); } - /// free memeory used for Jacobain sparsity pattern + /// free memory used for Jacobain sparsity pattern void size_forward_set(size_t zero) { CPPAD_ASSERT_KNOWN( zero == 0, "size_forward_bool: argument not equal to zero" ); - for_jac_sparse_set_.resize(0, 0); + for_jac_sparse_set_.resize(0, 0); } /// number of operators in the operation sequence @@ -351,13 +392,13 @@ size_t size_par(void) const { return play_.num_par_rec(); } - /// number taylor coefficient orders calculated + /// number taylor coefficient orders calculated size_t size_order(void) const - { return num_order_taylor_; } + { return num_order_taylor_; } - /// number taylor coefficient directions calculated + /// number taylor coefficient directions calculated size_t size_direction(void) const - { return num_direction_taylor_; } + { return num_direction_taylor_; } /// number of characters in the operation sequence size_t size_text(void) const @@ -375,10 +416,10 @@ void capacity_order(size_t c); /// set number of orders and directions currently allocated - void capacity_order(size_t c, size_t r); + void capacity_order(size_t c, size_t r); /// number of variables in conditional expressions that can be skipped - size_t number_skip(void); + size_t number_skip(void); /// number of independent variables size_t Domain(void) const @@ -394,24 +435,41 @@ i < dep_taddr_.size(), "Argument to Parameter is >= dimension of range space" ); - return dep_parameter_[i]; + return dep_parameter_[i]; } -# ifndef NDEBUG - /// in not NDEBUG case, number of comparison operations that change + /// Deprecated: number of comparison operations that changed + /// for the previous zero order forward (than when function was recorded) size_t CompareChange(void) const - { return compare_change_; } -# endif + { return compare_change_number_; } + + /// count as which to store operator index + void compare_change_count(size_t count) + { compare_change_count_ = count; + compare_change_number_ = 0; + compare_change_op_index_ = 0; + } + + /// number of comparison operations that changed + size_t compare_change_number(void) const + { return compare_change_number_; } + + /// operator index for the count-th comparison change + size_t compare_change_op_index(void) const + { if( has_been_optimized_ ) + return 0; + return compare_change_op_index_; + } /// calculate entire Jacobian template - VectorBase Jacobian(const VectorBase &x); + VectorBase Jacobian(const VectorBase &x); /// calculate Hessian for one component of f template - VectorBase Hessian(const VectorBase &x, const VectorBase &w); + VectorBase Hessian(const VectorBase &x, const VectorBase &w); template - VectorBase Hessian(const VectorBase &x, size_t i); + VectorBase Hessian(const VectorBase &x, size_t i); /// forward mode calculation of partial w.r.t one domain component template @@ -439,16 +497,16 @@ const VectorSize_t &I , const VectorSize_t &J ); - /// calculate sparse Jacobians + /// calculate sparse Jacobians template VectorBase SparseJacobian( const VectorBase &x - ); + ); template VectorBase SparseJacobian( - const VectorBase &x , + const VectorBase &x , const VectorSet &p - ); + ); template size_t SparseJacobianForward( const VectorBase& x , @@ -468,18 +526,18 @@ sparse_jacobian_work& work ); - /// calculate sparse Hessians + /// calculate sparse Hessians template VectorBase SparseHessian( - const VectorBase& x , + const VectorBase& x , const VectorBase& w - ); + ); template VectorBase SparseHessian( const VectorBase& x , const VectorBase& w , const VectorBool& p - ); + ); template size_t SparseHessian( const VectorBase& x , @@ -489,11 +547,11 @@ const VectorSize& c , VectorBase& hes , sparse_hessian_work& work - ); + ); // Optimize the tape // (see doxygen documentation in optimize.hpp) - void optimize(void); + void optimize(const std::string& options = ""); // ------------------- Deprecated ----------------------------- /// deprecated: assign a new operation sequence @@ -504,12 +562,12 @@ size_t Size(void) const { return num_var_tape_; } - /// Deprecated: # taylor_ coefficients currently stored + /// Deprecated: # taylor_ coefficients currently stored /// (per variable,direction) size_t Order(void) const { return num_order_taylor_ - 1; } - /// Deprecated: amount of memory for this object + /// Deprecated: amount of memory for this object /// Note that an approximation is used for the std::set memory size_t Memory(void) const { size_t pervar = cap_order_taylor_ * sizeof(Base) @@ -519,24 +577,24 @@ return total; } - /// Deprecated: # taylor_ coefficient orderss stored + /// Deprecated: # taylor_ coefficient orderss stored /// (per variable,direction) size_t taylor_size(void) const - { return num_order_taylor_; } + { return num_order_taylor_; } - /// Deprecated: Does this AD operation sequence use + /// Deprecated: Does this AD operation sequence use /// VecAD::reference operands bool use_VecAD(void) const { return play_.num_vec_ind_rec() > 0; } - /// Deprecated: # taylor_ coefficient orders calculated + /// Deprecated: # taylor_ coefficient orders calculated /// (per variable,direction) size_t size_taylor(void) const - { return num_order_taylor_; } + { return num_order_taylor_; } - /// Deprecated: set number of orders currently allocated + /// Deprecated: set number of orders currently allocated /// (per variable,direction) - void capacity_taylor(size_t per_var); + void capacity_taylor(size_t per_var); }; // --------------------------------------------------------------------------- @@ -561,6 +619,6 @@ # include # include # include -# include +# include # endif diff -Nru cppad-2015.00.00.9/cppad/local/ad.hpp cppad-2016.00.00.1/cppad/local/ad.hpp --- cppad-2015.00.00.9/cppad/local/ad.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ad.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_AD_INCLUDED -# define CPPAD_AD_INCLUDED +// $Id: ad.hpp 3760 2015-12-01 04:12:28Z bradbell $ +# ifndef CPPAD_AD_HPP +# define CPPAD_AD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,8 +26,8 @@ namespace CppAD { // BEGIN_CPPAD_NAMESPACE typedef enum { - tape_manage_new, - tape_manage_delete, + tape_manage_new, + tape_manage_delete, tape_manage_clear } tape_manage_job; @@ -39,18 +39,18 @@ // template friend functions where template parameter is not bound template - friend void Independent(VectorAD &x); + friend void Independent(VectorAD &x, size_t abort_op_index); // one argument functions - friend bool Parameter + friend bool Parameter (const AD &u); friend bool Parameter (const VecAD &u); - friend bool Variable + friend bool Variable (const AD &u); - friend bool Variable + friend bool Variable (const VecAD &u); - friend int Integer + friend int Integer (const AD &u); friend AD Var2Par (const AD &u); @@ -59,6 +59,10 @@ friend AD pow (const AD &x, const AD &y); + // azmul function + friend AD azmul + (const AD &x, const AD &y); + // order determining functions, see ordered.hpp friend bool GreaterThanZero (const AD &x); friend bool GreaterThanOrZero (const AD &x); @@ -71,11 +75,11 @@ friend bool IdenticalPar (const AD &x); friend bool IdenticalZero (const AD &x); friend bool IdenticalOne (const AD &x); - friend bool IdenticalEqualPar + friend bool IdenticalEqualPar (const AD &x, const AD &y); // EqualOpSeq function - friend bool EqualOpSeq + friend bool EqualOpSeq (const AD &u, const AD &v); // NearEqual function @@ -91,10 +95,10 @@ // CondExp function friend AD CondExpOp ( enum CompareOp cop , - const AD &left , - const AD &right , - const AD &trueCase , - const AD &falseCase + const AD &left , + const AD &right , + const AD &trueCase , + const AD &falseCase ); // classes @@ -139,7 +143,7 @@ friend void PrintFor ( const AD& flag , const char* before , - const AD& var , + const AD& var , const char* after ); public: @@ -155,13 +159,13 @@ // implicit construction and assingment from base type inline AD(const Base &b); - inline AD& operator=(const Base &b); + inline AD& operator=(const Base &b); // implicit contructor and assignment from VecAD::reference inline AD(const VecAD_reference &x); inline AD& operator=(const VecAD_reference &x); -# if CPPAD_IMPLICIT_CTOR_FROM_ANY_TYPE +# if CPPAD_DEPRECATED // implicit construction from some other type (depricated) template inline AD(const T &t); # else @@ -205,15 +209,20 @@ inline AD sqrt(void) const; inline AD tan(void) const; inline AD tanh(void) const; -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 inline AD erf(void) const; + inline AD asinh(void) const; + inline AD acosh(void) const; + inline AD atanh(void) const; + inline AD expm1(void) const; + inline AD log1p(void) const; # endif // ---------------------------------------------------------- // static public member functions - + // abort current AD recording - static void abort_recording(void); + static void abort_recording(void); // set the maximum number of OpenMP threads (deprecated) static void omp_max_thread(size_t number); @@ -238,7 +247,7 @@ // Tape identifier corresponding to taddr tape_id_t tape_id_; - // taddr_ in tape for this variable + // taddr_ in tape for this variable addr_t taddr_; // // Make this variable a parameter @@ -248,7 +257,7 @@ tape_id_ = 0; } // - // Make this parameter a new variable + // Make this parameter a new variable // void make_variable(size_t id, size_t taddr) { CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); // currently a par @@ -259,18 +268,18 @@ } // --------------------------------------------------------------- // tape linking functions - // + // // not static inline ADTape* tape_this(void) const; // - // static + // static inline static tape_id_t** tape_id_handle(size_t thread); inline static tape_id_t* tape_id_ptr(size_t thread); inline static ADTape** tape_handle(size_t thread); static ADTape* tape_manage(tape_manage_job job); inline static ADTape* tape_ptr(void); inline static ADTape* tape_ptr(tape_id_t tape_id); -}; +}; // --------------------------------------------------------------------------- } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/ad_io.hpp cppad-2016.00.00.1/cppad/local/ad_io.hpp --- cppad-2015.00.00.9/cppad/local/ad_io.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad_io.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ad_io.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_AD_IO_INCLUDED -# define CPPAD_AD_IO_INCLUDED +// $Id: ad_io.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_AD_IO_HPP +# define CPPAD_AD_IO_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,13 +22,9 @@ const $$ -$index >>, AD input$$ -$index AD, stream input$$ -$index input, AD$$ -$index stream, AD input$$ -$index write, AD$$ -$section AD Output Stream Operator$$ +$section AD Output Stream Operator$$ +$mindex >> input write$$ $head Syntax$$ $icode%is% >> %x%$$ @@ -67,7 +63,7 @@ %is% >> %x% >> %y% %$$ will first read the $icode Base$$ value of $icode x$$ from $icode is$$, -and then read the $icode Base$$ value to $icode y$$. +and then read the $icode Base$$ value to $icode y$$. $head Operation Sequence$$ The result of this operation is not an @@ -95,13 +91,9 @@ const $$ -$index <<, AD output$$ -$index AD, stream output$$ -$index output, AD$$ -$index stream, AD output$$ -$index write, AD$$ -$section AD Output Stream Operator$$ +$section AD Output Stream Operator$$ +$mindex <<$$ $head Syntax$$ $icode%os% << %x%$$ @@ -142,7 +134,7 @@ %os% << %x% << %y% %$$ will output the value corresponding to $icode x$$ -followed by the value corresponding to $icode y$$. +followed by the value corresponding to $icode y$$. $head Operation Sequence$$ The result of this operation is not an @@ -179,7 +171,7 @@ Is the input stream from which that value is read. \param x [out] -is the object that is being set to a value. +is the object that is being set to a value. Upone return, x.value_ is read from the input stream and x.tape_is_ is zero; i.e., x is a parameter. */ @@ -189,7 +181,7 @@ { // like assignment to a base type value x.tape_id_ = 0; CPPAD_ASSERT_UNKNOWN( Parameter(x) ); - return (is >> x.value_); + return (is >> x.value_); } // --------------------------------------------------------------------------- /*! @@ -203,12 +195,12 @@ \param x is the object that is being written to the output stream. -This is equivalent to writing x.value_ to the output stream. +This is equivalent to writing x.value_ to the output stream. */ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION std::ostream& operator << (std::ostream &os, const AD &x) -{ return (os << x.value_); } +{ return (os << x.value_); } // --------------------------------------------------------------------------- /*! Write a VecAD_reference object to an output stream. @@ -221,12 +213,12 @@ \param x is the element of the VecAD object that is being written to the output stream. -This is equivalent to writing the corresponing Base value to the stream. +This is equivalent to writing the corresponing Base value to the stream. */ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION std::ostream& operator << (std::ostream &os, const VecAD_reference &x) -{ return (os << x.ADBase()); } +{ return (os << x.ADBase()); } } // END_CPPAD_NAMESPACE # endif diff -Nru cppad-2015.00.00.9/cppad/local/ad_tape.hpp cppad-2016.00.00.1/cppad/local/ad_tape.hpp --- cppad-2015.00.00.9/cppad/local/ad_tape.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad_tape.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ad_tape.hpp 3153 2014-03-04 19:49:06Z bradbell $ */ -# ifndef CPPAD_AD_TAPE_INCLUDED -# define CPPAD_AD_TAPE_INCLUDED +// $Id: ad_tape.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_AD_TAPE_HPP +# define CPPAD_AD_TAPE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -40,25 +40,28 @@ friend void PrintFor ( const AD& flag , const char* before , - const AD& var , + const AD& var , const char* after ); // CondExpOp friend AD CondExpOp ( enum CompareOp cop , - const AD &left , - const AD &right , - const AD &trueCase , - const AD &falseCase + const AD &left , + const AD &right , + const AD &trueCase , + const AD &falseCase ); // pow friend AD pow (const AD &x, const AD &y); + // azmul + friend AD azmul + (const AD &x, const AD &y); // Parameter - friend bool Parameter + friend bool Parameter (const AD &u); // Variable - friend bool Variable + friend bool Variable (const AD &u); // operators ----------------------------------------------------------- // arithematic binary operators @@ -91,9 +94,9 @@ // ---------------------------------------------------------------------- // private data /*! - Unique identifier for this tape. It is always greater than - CPPAD_MAX_NUM_THREADS, and different for every tape (even ones that have - been deleted). In addition, id_ % CPPAD_MAX_NUM_THREADS is the thread + Unique identifier for this tape. It is always greater than + CPPAD_MAX_NUM_THREADS, and different for every tape (even ones that have + been deleted). In addition, id_ % CPPAD_MAX_NUM_THREADS is the thread number for this tape. Set by Independent and effectively const */ tape_id_t id_; @@ -107,7 +110,7 @@ // // add a parameter to the tape size_t RecordParOp(const Base &x); - + // see CondExp.h void RecordCondExp( enum CompareOp cop , @@ -118,14 +121,6 @@ const AD &falseCase ); - // see Compare.h - void RecordCompare( - enum CompareOp cop , - bool result , - const AD &left , - const AD &right - ); - // place a VecAD object in the tape size_t AddVec( size_t length, @@ -138,6 +133,8 @@ // public function only used by CppAD::Independent template void Independent(VectorADBase &u); + template + void Independent(VectorADBase &u, size_t abort_op_index); }; // --------------------------------------------------------------------------- @@ -153,7 +150,7 @@ \param z value of the parameter that we are placing in the tape. -\return +\return variable index (for this recording) correpsonding to the parameter. \par 2DO @@ -192,7 +189,7 @@ There are \c length indices following for this vector. The values for these vector indices are the corresponding parameter indices in the tape for the initial value of the corresponding -vec_ad element. +vec_ad element. \par 2DO All these operates are preformed in \c Rec_, so we should @@ -207,13 +204,13 @@ // store the length in VecInd size_t start = Rec_.PutVecInd(length); - // store indices of the values in VecInd + // store indices of the values in VecInd for(i = 0; i < length; i++) { value_index = Rec_.PutPar( data[i] ); Rec_.PutVecInd( value_index ); } - + // return the taddr of the length (where the vector starts) return start; } diff -Nru cppad-2015.00.00.9/cppad/local/ad_to_string.hpp cppad-2016.00.00.1/cppad/local/ad_to_string.hpp --- cppad-2015.00.00.9/cppad/local/ad_to_string.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad_to_string.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,71 @@ +// $Id$ +# ifndef CPPAD_AD_TO_STRING_HPP +# define CPPAD_AD_TO_STRING_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin ad_to_string$$ +$spell + const + std +$$ + +$section Convert An AD or Base Type to String$$ + +$head Syntax$$ +$icode%s% = to_string(%value%)%$$. + +$head See Also$$ +$cref to_string$$, $cref base_to_string$$ + +$head value$$ +The argument $icode value$$ has prototype +$codei% + const AD<%Base%>& %value% + const %Base%& %value% +%$$ +where $icode Base$$ is a type that supports the +$cref base_to_string$$ type requirement. + +$head s$$ +The return value has prototype +$codei% + std::string %s% +%$$ +and contains a representation of the specified $icode value$$. +If $icode value$$ is an AD type, +the result has the same precision as for the $icode Base$$ type. + +$head Example$$ +The file $cref to_string.cpp$$ +includes an example and test of $code to_string$$ with AD types. +It returns true if it succeeds and false otherwise. + +$end +*/ +# include +# include + +namespace CppAD { + + // Template definition is in cppad/utility/to_string.hpp. + // Partial specialzation for AD types + template + struct to_string_struct< CppAD::AD > + { std::string operator()(const CppAD::AD& value) + { to_string_struct ts; + return ts( Value( Var2Par( value ) ) ); } + }; + +} + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/ad_valued.hpp cppad-2016.00.00.1/cppad/local/ad_valued.hpp --- cppad-2015.00.00.9/cppad/local/ad_valued.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ad_valued.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ad_valued.hpp 2859 2013-05-28 06:03:21Z bradbell $ */ -# ifndef CPPAD_AD_VALUED_INCLUDED -# define CPPAD_AD_VALUED_INCLUDED +// $Id: ad_valued.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_AD_VALUED_HPP +# define CPPAD_AD_VALUED_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,31 +18,29 @@ $spell $$ -$index operation, AD valued$$ -$index function, AD valued$$ $section AD Valued Operations and Functions$$ $comment atomic.omh includes atomic_base.omh which atomic_base.hpp$$ $childtable% cppad/local/arithmetic.hpp% - cppad/local/std_math_ad.hpp% - cppad/local/math_other.hpp% + cppad/local/standard_math.hpp% cppad/local/cond_exp.hpp% cppad/local/discrete.hpp% + cppad/local/numeric_limits.hpp% omh/atomic.omh %$$ $end */ -// include MathOther.h after CondExp.h because some MathOther.h routines use +// include MathOther.h after CondExp.h because some MathOther.h routines use // CondExp.h and CondExp.h is not sufficently declared in Declare.h # include -# include +# include +# include # include -# include # include # include # include diff -Nru cppad-2015.00.00.9/cppad/local/arithmetic.hpp cppad-2016.00.00.1/cppad/local/arithmetic.hpp --- cppad-2015.00.00.9/cppad/local/arithmetic.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/arithmetic.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: arithmetic.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ARITHMETIC_INCLUDED -# define CPPAD_ARITHMETIC_INCLUDED +// $Id: arithmetic.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ARITHMETIC_HPP +# define CPPAD_ARITHMETIC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,13 +21,7 @@ const $$ -$index operator, AD arithmetic$$ -$index AD, arithmetic operator$$ -$index arithmetic, AD operator$$ - -$index computed, AD assignment$$ -$index assignment, AD computed$$ -$index AD, computed assignment$$ + $section AD Arithmetic Operators and Computed Assignments$$ diff -Nru cppad-2015.00.00.9/cppad/local/asinh.hpp cppad-2016.00.00.1/cppad/local/asinh.hpp --- cppad-2015.00.00.9/cppad/local/asinh.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/asinh.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,97 @@ +// $Id$ +# ifndef CPPAD_ASINH_HPP +# define CPPAD_ASINH_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- + +$begin asinh$$ +$spell + asinh + const + Vec + std + cmath + CppAD +$$ +$section The Inverse Hyperbolic Sine Function: asinh$$ + +$head Syntax$$ +$icode%y% = asinh(%x%)%$$ + +$head Description$$ +The inverse hyperbolic sine function is defined by +$icode%x% == sinh(%y%)%$$. + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head CPPAD_USE_CPLUSPLUS_2011$$ + +$subhead true$$ +If this preprocessor symbol is true ($code 1$$), +and $icode x$$ is an AD type, +this is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$subhead false$$ +If this preprocessor symbol is false ($code 0$$), +CppAD uses the representation +$latex \[ +\R{asinh} (x) = \log \left( x + \sqrt{ 1 + x^2 } \right) +\] $$ +to compute this function. + +$head Example$$ +$children% + example/asinh.cpp +%$$ +The file +$cref asinh.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +*/ +# include +# if ! CPPAD_USE_CPLUSPLUS_2011 + +// BEGIN CppAD namespace +namespace CppAD { + +template +Type asinh_template(const Type &x) +{ return CppAD::log( x + CppAD::sqrt( Type(1) + x * x ) ); +} + +inline float asinh(const float &x) +{ return asinh_template(x); } + +inline double asinh(const double &x) +{ return asinh_template(x); } + +template +inline AD asinh(const AD &x) +{ return asinh_template(x); } + +template +inline AD asinh(const VecAD_reference &x) +{ return asinh_template( x.ADBase() ); } + + +} // END CppAD namespace + +# endif // CPPAD_USE_CPLUSPLUS_2011 +# endif // CPPAD_ASINH_INCLUDED diff -Nru cppad-2015.00.00.9/cppad/local/asinh_op.hpp cppad-2016.00.00.1/cppad/local/asinh_op.hpp --- cppad-2015.00.00.9/cppad/local/asinh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/asinh_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -0,0 +1,266 @@ +// $Id$ +# ifndef CPPAD_ASINH_OP_HPP +# define CPPAD_ASINH_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file asinh_op.hpp +Forward and reverse mode calculations for z = asinh(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = AsinhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = asinh(x) +\endverbatim +The auxillary result is +\verbatim + y = sqrt(1 + x * x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails forward_unary2_op +*/ +template +inline void forward_asinh_op( + size_t p , + size_t q , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + Base* b = z - cap_order; // called y in documentation + + size_t k; + Base uj; + if( p == 0 ) + { z[0] = asinh( x[0] ); + uj = Base(1) + x[0] * x[0]; + b[0] = sqrt( uj ); + p++; + } + for(size_t j = p; j <= q; j++) + { uj = Base(0); + for(k = 0; k <= j; k++) + uj += x[k] * x[j-k]; + b[j] = Base(0); + z[j] = Base(0); + for(k = 1; k < j; k++) + { b[j] -= Base(k) * b[k] * b[j-k]; + z[j] -= Base(k) * z[k] * b[j-k]; + } + b[j] /= Base(j); + z[j] /= Base(j); + // + b[j] += uj / Base(2); + z[j] += x[j]; + // + b[j] /= b[0]; + z[j] /= b[0]; + } +} +/*! +Multiple directions forward mode Taylor coefficient for op = AsinhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = asinh(x) +\endverbatim +The auxillary result is +\verbatim + y = sqrt(1 + x * x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails forward_unary2_op_dir +*/ +template +inline void forward_asinh_op_dir( + size_t q , + size_t r , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AcosOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AcosOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + + // Taylor coefficients corresponding to argument and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + i_x * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + Base* b = z - num_taylor_per_var; // called y in documentation + + size_t k, ell; + size_t m = (q-1) * r + 1; + for(ell = 0; ell < r; ell ++) + { Base uq = 2.0 * x[m + ell] * x[0]; + for(k = 1; k < q; k++) + uq += x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; + b[m+ell] = Base(0); + z[m+ell] = Base(0); + for(k = 1; k < q; k++) + { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + b[m+ell] = ( uq / Base(2) - b[m+ell] / Base(q) ) / b[0]; + z[m+ell] = ( x[m+ell] - z[m+ell] / Base(q) ) / b[0]; + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = AsinhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = asinh(x) +\endverbatim +The auxillary result is +\verbatim + y = sqrt( 1 + x * x ) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails forward_unary2_op_0 +*/ +template +inline void forward_asinh_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + Base* b = z - cap_order; // called y in documentation + + z[0] = asinh( x[0] ); + b[0] = sqrt( Base(1) + x[0] * x[0] ); +} +/*! +Compute reverse mode partial derivatives for result of op = AsinhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = asinh(x) +\endverbatim +The auxillary result is +\verbatim + y = sqrt( 1 + x * x ) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails reverse_unary2_op +*/ + +template +inline void reverse_asinh_op( + size_t d , + size_t i_z , + size_t i_x , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Taylor coefficients and partials corresponding to argument + const Base* x = taylor + i_x * cap_order; + Base* px = partial + i_x * nc_partial; + + // Taylor coefficients and partials corresponding to first result + const Base* z = taylor + i_z * cap_order; + Base* pz = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + const Base* b = z - cap_order; // called y in documentation + Base* pb = pz - nc_partial; + + Base inv_b0 = Base(1) / b[0]; + + // number of indices to access + size_t j = d; + size_t k; + while(j) + { + // scale partials w.r.t b[j] by 1 / b[0] + pb[j] = azmul(pb[j], inv_b0); + + // scale partials w.r.t z[j] by 1 / b[0] + pz[j] = azmul(pz[j], inv_b0); + + // update partials w.r.t b^0 + pb[0] -= azmul(pz[j], z[j]) + azmul(pb[j], b[j]); + + // update partial w.r.t. x^0 + px[0] += azmul(pb[j], x[j]); + + // update partial w.r.t. x^j + px[j] += pz[j] + azmul(pb[j], x[0]); + + // further scale partial w.r.t. z[j] by 1 / j + pz[j] /= Base(j); + + for(k = 1; k < j; k++) + { // update partials w.r.t b^(j-k) + pb[j-k] -= Base(k) * azmul(pz[j], z[k]) + azmul(pb[j], b[k]); + + // update partials w.r.t. x^k + px[k] += azmul(pb[j], x[j-k]); + + // update partials w.r.t. z^k + pz[k] -= Base(k) * azmul(pz[j], b[j-k]); + } + --j; + } + + // j == 0 case + px[0] += azmul(pz[0] + azmul(pb[0], x[0]), inv_b0); +} + +} // END_CPPAD_NAMESPACE +# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/asin_op.hpp cppad-2016.00.00.1/cppad/local/asin_op.hpp --- cppad-2015.00.00.9/cppad/local/asin_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/asin_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: asin_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_ASIN_OP_INCLUDED -# define CPPAD_ASIN_OP_INCLUDED +// $Id: asin_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ASIN_OP_HPP +# define CPPAD_ASIN_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,9 +43,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AsinOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 2 ); @@ -107,9 +107,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AcosOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AcosOp) == 2 ); @@ -127,12 +127,12 @@ for(ell = 0; ell < r; ell ++) { Base uq = - 2.0 * x[m + ell] * x[0]; for(k = 1; k < q; k++) - uq -= x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; + uq -= x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; b[m+ell] = Base(0); z[m+ell] = Base(0); for(k = 1; k < q; k++) - { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; - z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; } b[m+ell] = ( uq / Base(2) - b[m+ell] / Base(q) ) / b[0]; z[m+ell] = ( x[m+ell] - z[m+ell] / Base(q) ) / b[0]; @@ -158,7 +158,7 @@ inline void forward_asin_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -195,7 +195,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -218,44 +218,46 @@ const Base* b = z - cap_order; // called y in documentation Base* pb = pz - nc_partial; + Base inv_b0 = Base(1) / b[0]; + // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t b[j] by 1 / b[0] - pb[j] /= b[0]; + pb[j] = azmul(pb[j], inv_b0); // scale partials w.r.t z[j] by 1 / b[0] - pz[j] /= b[0]; + pz[j] = azmul(pz[j], inv_b0); - // update partials w.r.t b^0 - pb[0] -= pz[j] * z[j] + pb[j] * b[j]; + // update partials w.r.t b^0 + pb[0] -= azmul(pz[j], z[j]) + azmul(pb[j], b[j]); // update partial w.r.t. x^0 - px[0] -= pb[j] * x[j]; + px[0] -= azmul(pb[j], x[j]); // update partial w.r.t. x^j - px[j] += pz[j] - pb[j] * x[0]; + px[j] += pz[j] - azmul(pb[j], x[0]); // further scale partial w.r.t. z[j] by 1 / j pz[j] /= Base(j); for(k = 1; k < j; k++) { // update partials w.r.t b^(j-k) - pb[j-k] -= Base(k) * pz[j] * z[k] + pb[j] * b[k]; + pb[j-k] -= Base(k) * azmul(pz[j], z[k]) + azmul(pb[j], b[k]); - // update partials w.r.t. x^k - px[k] -= pb[j] * x[j-k]; + // update partials w.r.t. x^k + px[k] -= azmul(pb[j], x[j-k]); // update partials w.r.t. z^k - pz[k] -= pz[j] * Base(k) * b[j-k]; + pz[k] -= Base(k) * azmul(pz[j], b[j-k]); } --j; } // j == 0 case - px[0] += ( pz[0] - pb[0] * x[0]) / b[0]; + px[0] += azmul(pz[0] - azmul(pb[0], x[0]), inv_b0); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/atan2.hpp cppad-2016.00.00.1/cppad/local/atan2.hpp --- cppad-2015.00.00.9/cppad/local/atan2.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/atan2.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: atan2.hpp 3083 2014-01-10 18:35:07Z bradbell $ */ -# ifndef CPPAD_ATAN2_INCLUDED -# define CPPAD_ATAN2_INCLUDED +// $Id: atan2.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ATAN2_HPP +# define CPPAD_ATAN2_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,11 +25,9 @@ const $$ -$index tan, AD inverse$$ -$index inverse, AD tan$$ -$index atan2, AD$$ $section AD Two Argument Inverse Tangent Function$$ +$mindex tan atan2$$ $head Syntax$$ $icode%theta% = atan2(%y%, %x%)%$$ @@ -37,7 +35,7 @@ $head Purpose$$ Determines an angle $latex \theta \in [ - \pi , + \pi ]$$ -such that +such that $latex \[ \begin{array}{rcl} \sin ( \theta ) & = & y / \sqrt{ x^2 + y^2 } \\ @@ -50,14 +48,14 @@ $codei% const AD<%Base%> &%y% const VecAD<%Base%>::reference &%y% -%$$ +%$$ $head x$$ The argument $icode x$$ has one of the following prototypes $codei% const AD<%Base%> &%x% const VecAD<%Base%>::reference &%x% -%$$ +%$$ $head theta$$ The result $icode theta$$ has prototype @@ -77,7 +75,7 @@ %$$ The file $cref atan2.cpp$$ -contains an example and test of this function. +contains an example and test of this function. It returns true if it succeeds and false otherwise. $end @@ -108,23 +106,23 @@ AD ay = abs(y); // if( ax > ay ) - // theta = atan(ay / ax); + // theta = atan(ay / ax); // else theta = pi2 - atan(ax / ay); alpha = atan(ay / ax); beta = pi2 - atan(ax / ay); theta = CondExpGt(ax, ay, alpha, beta); // use of CondExp // if( x <= 0 ) - // theta = pi - theta; + // theta = pi - theta; theta = CondExpLe(x, zero, pi - theta, theta); // use of CondExp - + // if( y <= 0 ) - // theta = - theta; + // theta = - theta; theta = CondExpLe(y, zero, -theta, theta); // use of CondExp return theta; } -// END CondExp +// END CondExp template inline AD atan2 (const VecAD_reference &y, const AD &x) @@ -135,10 +133,10 @@ { return atan2( y , x.ADBase() ); } template -inline AD atan2 +inline AD atan2 (const VecAD_reference &y, const VecAD_reference &x) { return atan2( y.ADBase() , x.ADBase() ); } } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/atanh.hpp cppad-2016.00.00.1/cppad/local/atanh.hpp --- cppad-2015.00.00.9/cppad/local/atanh.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/atanh.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -0,0 +1,97 @@ +// $Id$ +# ifndef CPPAD_ATANH_HPP +# define CPPAD_ATANH_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin atanh$$ +$spell + atanh + const + Vec + std + cmath + CppAD + tanh +$$ +$section The Inverse Hyperbolic Tangent Function: atanh$$ + +$head Syntax$$ +$icode%y% = atanh(%x%)%$$ + +$head Description$$ +The inverse hyperbolic tangent function is defined by +$icode%x% == tanh(%y%)%$$. + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head CPPAD_USE_CPLUSPLUS_2011$$ + +$subhead true$$ +If this preprocessor symbol is true ($code 1$$), +and $icode x$$ is an AD type, +this is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$subhead false$$ +If this preprocessor symbol is false ($code 0$$), +CppAD uses the representation +$latex \[ +\R{atanh} (x) = \frac{1}{2} \log \left( \frac{1 + x}{1 - x} \right) +\] $$ +to compute this function. + +$head Example$$ +$children% + example/atanh.cpp +%$$ +The file +$cref atanh.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +*/ +# include +# if ! CPPAD_USE_CPLUSPLUS_2011 + +// BEGIN CppAD namespace +namespace CppAD { + +template +Type atanh_template(const Type &x) +{ return CppAD::log( (1 + x) / (1 - x) ) / 2.0; +} + +inline float atanh(const float &x) +{ return atanh_template(x); } + +inline double atanh(const double &x) +{ return atanh_template(x); } + +template +inline AD atanh(const AD &x) +{ return atanh_template(x); } + +template +inline AD atanh(const VecAD_reference &x) +{ return atanh_template( x.ADBase() ); } + + +} // END CppAD namespace + +# endif // CPPAD_USE_CPLUSPLUS_2011 +# endif // CPPAD_ATANH_INCLUDED diff -Nru cppad-2015.00.00.9/cppad/local/atanh_op.hpp cppad-2016.00.00.1/cppad/local/atanh_op.hpp --- cppad-2015.00.00.9/cppad/local/atanh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/atanh_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,238 @@ +// $Id$ +# ifndef CPPAD_ATANH_OP_HPP +# define CPPAD_ATANH_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atanh_op.hpp +Forward and reverse mode calculations for z = atanh(x). +*/ + + +/*! +Forward mode Taylor coefficient for result of op = AtanhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = atanh(x) +\endverbatim +The auxillary result is +\verbatim + y = 1 - x * x +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails forward_unary2_op +*/ +template +inline void forward_atanh_op( + size_t p , + size_t q , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + Base* b = z - cap_order; // called y in documentation + + size_t k; + if( p == 0 ) + { z[0] = atanh( x[0] ); + b[0] = Base(1) - x[0] * x[0]; + p++; + } + for(size_t j = p; j <= q; j++) + { + b[j] = - Base(2) * x[0] * x[j]; + z[j] = Base(0); + for(k = 1; k < j; k++) + { b[j] -= x[k] * x[j-k]; + z[j] -= Base(k) * z[k] * b[j-k]; + } + z[j] /= Base(j); + z[j] += x[j]; + z[j] /= b[0]; + } +} + +/*! +Multiple direction Taylor coefficient for op = AtanhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = atanh(x) +\endverbatim +The auxillary result is +\verbatim + y = 1 - x * x +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails forward_unary2_op_dir +*/ +template +inline void forward_atanh_op_dir( + size_t q , + size_t r , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + + // Taylor coefficients corresponding to argument and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + i_x * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + Base* b = z - num_taylor_per_var; // called y in documentation + + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { b[m+ell] = - Base(2) * x[m+ell] * x[0]; + z[m+ell] = Base(q) * x[m+ell]; + for(size_t k = 1; k < q; k++) + { b[m+ell] -= x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; + z[m+ell] -= Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + z[m+ell] /= ( Base(q) * b[0] ); + } +} + +/*! +Zero order forward mode Taylor coefficient for result of op = AtanhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = atanh(x) +\endverbatim +The auxillary result is +\verbatim + y = 1 - x * x +\endverbatim +The value of y is computed along with the value of z. + +\copydetails forward_unary2_op_0 +*/ +template +inline void forward_atanh_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + Base* b = z - cap_order; // called y in documentation + + z[0] = atanh( x[0] ); + b[0] = Base(1) - x[0] * x[0]; +} +/*! +Reverse mode partial derivatives for result of op = AtanhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = atanh(x) +\endverbatim +The auxillary result is +\verbatim + y = 1 - x * x +\endverbatim +The value of y is computed along with the value of z. + +\copydetails reverse_unary2_op +*/ + +template +inline void reverse_atanh_op( + size_t d , + size_t i_z , + size_t i_x , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Taylor coefficients and partials corresponding to argument + const Base* x = taylor + i_x * cap_order; + Base* px = partial + i_x * nc_partial; + + // Taylor coefficients and partials corresponding to first result + const Base* z = taylor + i_z * cap_order; + Base* pz = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + const Base* b = z - cap_order; // called y in documentation + Base* pb = pz - nc_partial; + + Base inv_b0 = Base(1) / b[0]; + + // number of indices to access + size_t j = d; + size_t k; + while(j) + { // scale partials w.r.t z[j] and b[j] + pz[j] = azmul(pz[j], inv_b0); + pb[j] *= Base(2); + + pb[0] -= azmul(pz[j], z[j]); + px[j] += pz[j] - azmul(pb[j], x[0]); + px[0] -= azmul(pb[j], x[j]); + + // more scaling of partials w.r.t z[j] + pz[j] /= Base(j); + + for(k = 1; k < j; k++) + { pb[j-k] -= Base(k) * azmul(pz[j], z[k]); + pz[k] -= Base(k) * azmul(pz[j], b[j-k]); + px[k] -= azmul(pb[j], x[j-k]); + } + --j; + } + px[0] += azmul(pz[0], inv_b0) - Base(2) * azmul(pb[0], x[0]); +} + +} // END_CPPAD_NAMESPACE +# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/atan_op.hpp cppad-2016.00.00.1/cppad/local/atan_op.hpp --- cppad-2015.00.00.9/cppad/local/atan_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/atan_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: atan_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_ATAN_OP_INCLUDED -# define CPPAD_ATAN_OP_INCLUDED +// $Id: atan_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ATAN_OP_HPP +# define CPPAD_ATAN_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,9 +43,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AtanOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AtanOp) == 2 ); @@ -99,9 +99,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AtanOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AtanOp) == 2 ); @@ -145,7 +145,7 @@ inline void forward_atan_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -182,7 +182,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -205,29 +205,31 @@ const Base* b = z - cap_order; // called y in documentation Base* pb = pz - nc_partial; + Base inv_b0 = Base(1) / b[0]; + // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t z[j] and b[j] - pz[j] /= b[0]; + pz[j] = azmul(pz[j], inv_b0); pb[j] *= Base(2); - pb[0] -= pz[j] * z[j]; - px[j] += pz[j] + pb[j] * x[0]; - px[0] += pb[j] * x[j]; + pb[0] -= azmul(pz[j], z[j]); + px[j] += pz[j] + azmul(pb[j], x[0]); + px[0] += azmul(pb[j], x[j]); // more scaling of partials w.r.t z[j] pz[j] /= Base(j); for(k = 1; k < j; k++) - { pb[j-k] -= pz[j] * Base(k) * z[k]; - pz[k] -= pz[j] * Base(k) * b[j-k]; - px[k] += pb[j] * x[j-k]; + { pb[j-k] -= Base(k) * azmul(pz[j], z[k]); + pz[k] -= Base(k) * azmul(pz[j], b[j-k]); + px[k] += azmul(pb[j], x[j-k]); } --j; } - px[0] += pz[0] / b[0] + pb[0] * Base(2) * x[0]; + px[0] += azmul(pz[0], inv_b0) + Base(2) * azmul(pb[0], x[0]); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/atomic_base.hpp cppad-2016.00.00.1/cppad/local/atomic_base.hpp --- cppad-2015.00.00.9/cppad/local/atomic_base.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/atomic_base.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: atomic_base.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_ATOMIC_BASE_INCLUDED -# define CPPAD_ATOMIC_BASE_INCLUDED +// $Id: atomic_base.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ATOMIC_BASE_HPP +# define CPPAD_ATOMIC_BASE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,7 +16,7 @@ # include # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -28,7 +28,11 @@ class atomic_base { // =================================================================== public: - enum option_enum { bool_sparsity_enum, set_sparsity_enum}; + enum option_enum { + pack_sparsity_enum , + bool_sparsity_enum , + set_sparsity_enum + }; private: // ------------------------------------------------------ // constants @@ -43,7 +47,7 @@ /// (set by constructor and option member functions) option_enum sparsity_; - /// temporary work space used afun, declared here to avoid memory + /// temporary work space used afun, declared here to avoid memory /// allocation/deallocation for each call to afun vector afun_vx_[CPPAD_MAX_NUM_THREADS]; vector afun_vy_[CPPAD_MAX_NUM_THREADS]; @@ -80,6 +84,7 @@ /* $begin atomic_ctor$$ $spell + enum sq std afun @@ -92,14 +97,11 @@ $$ $section Atomic Function Constructor$$ -$index constructor, atomic function$$ -$index atomic, function constructor$$ -$index function, atomic constructor$$ $head Syntax$$ $icode%atomic_user afun%(%ctor_arg_list%) %$$ -$codei%atomic_base<%Base%>(%name%) +$codei%atomic_base<%Base%>(%name%, %sparsity%) %$$ $head atomic_user$$ @@ -110,26 +112,26 @@ $subhead afun$$ The object $icode afun$$ must stay in scope for as long as the corresponding atomic function is used. -This includes use by any $cref/ADFun/ADFun/$$ that -has this $icode atomic_user$$ operation in its +This includes use by any $cref/ADFun/ADFun/$$ that +has this $icode atomic_user$$ operation in its $cref/operation sequence/glossary/Operation/Sequence/$$. $subhead Implementation$$ -The user defined $icode atomic_user$$ class is a publicly derived class of +The user defined $icode atomic_user$$ class is a publicly derived class of $codei%atomic_base<%Base%>%$$. It should be declared as follows: $codei% class %atomic_user% : public CppAD::atomic_base<%Base%> { public: - %atomic_user%(%ctor_arg_list%) : atomic_base<%Base%>(%name%) + %atomic_user%(%ctor_arg_list%) : atomic_base<%Base%>(%name%, %sparsity%) %...% }; %$$ -where $icode ...$$ +where $icode ...$$ denotes the rest of the implementation of the derived class. This includes completing the constructor and -all the virtual functions that have their -$code atomic_base$$ implementations replaced by +all the virtual functions that have their +$code atomic_base$$ implementations replaced by $icode atomic_user$$ implementations. $head atomic_base$$ @@ -143,16 +145,36 @@ $icode Base$$ type for this $codei%AD<%Base%>%$$ atomic operation. $subhead name$$ -This $icode atomic_base$$ constructor argument has either of the -following prototypes +This $code atomic_base$$ constructor argument has the following prototype $codei% - const char* %name% const std::string& %name% %$$ It is the name for this atomic function and is used for error reporting. The suggested value for $icode name$$ is $icode afun$$ or $icode atomic_user$$, i.e., the name of the corresponding atomic object or class. +$subhead sparsity$$ +This $code atomic_base$$ constructor argument has prototype +$codei% + atomic_base<%Base%>::option_enum %sparsity% +%$$ +The current $icode sparsity$$ for an $code atomic_base$$ object +determines which type of sparsity patterns it uses +and its value is one of the following: +$table +$icode sparsity$$ $cnext sparsity patterns $rnext +$codei%atomic_base<%Base%>::pack_sparsity_enum%$$ $pre $$ $cnext + $cref/vectorBool/CppAD_vector/vectorBool/$$ +$rnext +$codei%atomic_base<%Base%>::bool_sparsity_enum%$$ $pre $$ $cnext + $cref/vector/CppAD_vector/$$$code $$ +$rnext +$codei%atomic_base<%Base%>::set_sparsity_enum%$$ $pre $$ $cnext + $cref/vector/CppAD_vector/$$$code >$$ +$tend +There is a default value for $icode sparsity$$ if it is not +included in the constructor (which may be either the bool or set option). + $head Examples$$ $subhead Define Constructor$$ @@ -191,10 +213,18 @@ \param name name used for error reporting + +\param sparsity [in] +what type of sparsity patterns are computed by this function, +bool_sparsity_enum or set_sparsity_enum. Default value is +bool sparsity patterns. */ -atomic_base( const std::string& name) : +atomic_base( + const std::string& name, + option_enum sparsity = bool_sparsity_enum +) : index_( class_object().size() ) , -sparsity_( set_sparsity_enum ) +sparsity_( sparsity ) { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "atomic_base: constructor cannot be called in parallel mode." @@ -233,57 +263,61 @@ $$ $section Set Atomic Function Options$$ -$index atomic, options$$ -$index options, atomic$$ $head Syntax$$ $icode%afun%.option(%option_value%)%$$ +These settings do not apply to individual $icode afun$$ calls, +but rather all subsequent uses of the corresponding atomic operation +in an $cref ADFun$$ object. $head atomic_sparsity$$ -$index atomic_sparsity$$ -$index sparsity, atomic$$ -You can used this option to set to type used for -$icode afun$$ sparsity patterns. -This does not apply individual calls to $icode afun$$, -but rather all its uses between when the sparsity pattern is set and when -it is changed. -If neither the $code set_sparsity_enum$$ or -$code bool_sparsity_enum$$ option is set, -the type for $icode atomic_sparsity$$ is one of the two choices below -(and otherwise unspecified). +Note that, if you use $cref optimize$$, these sparsity patterns are used +to determine the $cref/dependency/dependency.cpp/$$ relationship between +argument and result variables. + +$subhead pack_sparsity_enum$$ +If $icode option_value$$ is $codei%atomic_base<%Base%>::pack_sparsity_enum%$$, +then the type used by $icode afun$$ for +$cref/sparsity patterns/glossary/Sparsity Pattern/$$, +(after the option is set) will be +$codei% + typedef CppAD::vectorBool %atomic_sparsity% +%$$ +If $icode r$$ is a sparsity pattern +for a matrix $latex R \in B^{p \times q}$$: +$icode%r%.size() == %p% * %q%$$. $subhead bool_sparsity_enum$$ -$index bool_sparsity_enum$$ -If $icode option_value$$ is $codei%atomic_base<%Base%>::bool_sparsity_enum%$$, +If $icode option_value$$ is $codei%atomic_base<%Base%>::bool_sparsity_enum%$$, then the type used by $icode afun$$ for $cref/sparsity patterns/glossary/Sparsity Pattern/$$, (after the option is set) will be $codei% typedef CppAD::vector %atomic_sparsity% %$$ -If $icode r$$ is a sparsity pattern +If $icode r$$ is a sparsity pattern for a matrix $latex R \in B^{p \times q}$$: $icode%r%.size() == %p% * %q%$$. $subhead set_sparsity_enum$$ -$index set_sparsity_enum$$ -If $icode option_value$$ is $icode%atomic_base<%Base%>::set_sparsity_enum%$$, +If $icode option_value$$ is $icode%atomic_base<%Base%>::set_sparsity_enum%$$, then the type used by $icode afun$$ for $cref/sparsity patterns/glossary/Sparsity Pattern/$$, (after the option is set) will be $codei% typedef CppAD::vector< std::set > %atomic_sparsity% %$$ -If $icode r$$ is a sparsity pattern +If $icode r$$ is a sparsity pattern for a matrix $latex R \in B^{p \times q}$$: $icode%r%.size() == %p%$$, and for $latex i = 0 , \ldots , p-1$$, -the elements of $icode%r%[%i%]%$$ are between zero and $latex q-1$$ inclusive. +the elements of $icode%r%[%i%]%$$ are between zero and $latex q-1$$ inclusive. $end */ void option(enum option_enum option_value) { switch( option_value ) - { case bool_sparsity_enum: + { case pack_sparsity_enum: + case bool_sparsity_enum: case set_sparsity_enum: sparsity_ = option_value; break; @@ -309,14 +343,13 @@ $$ $section Using AD Version of Atomic Function$$ -$index atomic, use function$$ $head Syntax$$ $icode%afun%(%ax%, %ay%)%$$ $head Purpose$$ Given $icode ax$$, -this call computes the corresponding value of $icode ay$$. +this call computes the corresponding value of $icode ay$$. If $codei%AD<%Base%>%$$ operations are being recorded, it enters the computation as an atomic operation in the recording; see $cref/start recording/Independent/Start Recording/$$. @@ -327,9 +360,9 @@ $codei%AD<%Base%>%$$; see $cref/Base/atomic_ctor/atomic_base/Base/$$. $head afun$$ -is a $cref/atomic_user/atomic_ctor/atomic_user/$$ object +is a $cref/atomic_user/atomic_ctor/atomic_user/$$ object and this $icode afun$$ function call is implemented by the -$cref/atomic_base/atomic_ctor/atomic_base/$$ class. +$cref/atomic_base/atomic_ctor/atomic_base/$$ class. $head ax$$ This argument has prototype @@ -337,9 +370,9 @@ const %ADVector%& %ax% %$$ and size must be equal to $icode n$$. -It specifies vector $latex x \in B^n$$ -at which an $codei%AD<%Base%>%$$ version of -$latex y = f(x)$$ is to be evaluated; see +It specifies vector $latex x \in B^n$$ +at which an $codei%AD<%Base%>%$$ version of +$latex y = f(x)$$ is to be evaluated; see $cref/Base/atomic_ctor/atomic_base/Base/$$. $head ay$$ @@ -348,13 +381,13 @@ %ADVector%& %ay% %$$ and size must be equal to $icode m$$. -The input values of its elements +The input values of its elements are not specified (must not matter). -Upon return, it is an $codei%AD<%Base%>%$$ version of +Upon return, it is an $codei%AD<%Base%>%$$ version of $latex y = f(x)$$. $head Examples$$ -The following files contain example uses of +The following files contain example uses of the AD version of atomic functions during recording: $cref%get_started.cpp%atomic_get_started.cpp%Use Atomic Function%Recording%$$, $cref%norm_sq.cpp%atomic_norm_sq.cpp%Use Atomic Function%Recording%$$, @@ -416,7 +449,7 @@ { vy.resize(m); ty.resize(m); } - // + // // Determine tape corresponding to variables in ax tape_id_t tape_id = 0; ADTape* tape = CPPAD_NULL; @@ -432,7 +465,7 @@ } # ifndef NDEBUG if( tape_id != ax[j].tape_id_ ) - { msg += afun_name() + + { msg += afun_name() + ": ax contains variables from different threads."; CPPAD_ASSERT_KNOWN(false, msg.c_str()); } @@ -443,9 +476,9 @@ size_t p = 0, q = 0; set_id(id); # ifdef NDEBUG - forward(p, q, vx, vy, tx, ty); + forward(p, q, vx, vy, tx, ty); # else - ok = forward(p, q, vx, vy, tx, ty); + ok = forward(p, q, vx, vy, tx, ty); if( ! ok ) { msg += afun_name() + ": ok is false for " "zero order forward mode calculation."; @@ -468,7 +501,7 @@ } # ifndef NDEBUG if( record_operation & (tape == CPPAD_NULL) ) - { msg += + { msg += "all elements of vx are false but vy contains a true element"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } @@ -482,7 +515,7 @@ tape->Rec_.PutArg(index_, id, n, m); tape->Rec_.PutOp(UserOp); - // Now put n operators, one for each element of arugment vector + // Now put n operators, one for each element of argument vector CPPAD_ASSERT_UNKNOWN( NumRes(UsravOp) == 0 ); CPPAD_ASSERT_UNKNOWN( NumRes(UsrapOp) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg(UsravOp) == 1 ); @@ -494,7 +527,7 @@ tape->Rec_.PutOp(UsravOp); } else - { // information for an arugment that is parameter + { // information for an argument that is parameter addr_t par = tape->Rec_.PutPar(ax[j].value_); tape->Rec_.PutArg(par); tape->Rec_.PutOp(UsrapOp); @@ -521,7 +554,7 @@ // Put a duplicate UserOp at end of UserOp sequence tape->Rec_.PutArg(index_, id, n, m); tape->Rec_.PutOp(UserOp); - } + } return; } /* @@ -542,9 +575,7 @@ $$ $section Atomic Forward Mode$$ -$index atomic, forward callback$$ -$index forward, atomic callback$$ -$index forward, atomic virtual$$ +$mindex callback virtual$$ $head Syntax$$ @@ -559,7 +590,7 @@ $head Implementation$$ This virtual function must be defined by the $cref/atomic_user/atomic_ctor/atomic_user/$$ class. -It can just return $icode%ok% == false%$$ +It can just return $icode%ok% == false%$$ (and not compute anything) for values of $icode%q% > 0%$$ that are greater than those used by your $cref/forward/Forward/$$ mode calculations. @@ -569,7 +600,7 @@ $codei% size_t %p% %$$ -It specifies the lowest order Taylor coefficient that we are evaluating. +It specifies the lowest order Taylor coefficient that we are evaluating. During calls to $cref atomic_afun$$, $icode%p% == 0%$$. $head q$$ @@ -577,7 +608,7 @@ $codei% size_t %q% %$$ -It specifies the highest order Taylor coefficient that we are evaluating. +It specifies the highest order Taylor coefficient that we are evaluating. During calls to $cref atomic_afun$$, $icode%q% == 0%$$. $head vx$$ @@ -585,19 +616,19 @@ $codei% const CppAD::vector& %vx% %$$ -The case $icode%vx%.size() > 0%$$ only occurs while evaluating a call to +The case $icode%vx%.size() > 0%$$ only occurs while evaluating a call to $cref atomic_afun$$. In this case, -$icode%p% == %q% == 0%$$, +$icode%p% == %q% == 0%$$, $icode%vx%.size() == %n%$$, and for $latex j = 0 , \ldots , n-1$$, $icode%vx%[%j%]%$$ is true if and only if -$icode%ax%[%j%]%$$ is a $cref/variable/glossary/Variable/$$ -in the corresponding call to +$icode%ax%[%j%]%$$ is a $cref/variable/glossary/Variable/$$ +in the corresponding call to $codei% %afun%(%ax%, %ay%, %id%) %$$ -If $icode%vx%.size() == 0%$$, +If $icode%vx%.size() == 0%$$, then $icode%vy%.size() == 0%$$ and neither of these vectors should be used. @@ -607,9 +638,9 @@ CppAD::vector& %vy% %$$ If $icode%vy%.size() == 0%$$, it should not be used. -Otherwise, +Otherwise, $icode%q% == 0%$$ and $icode%vy%.size() == %m%$$. -The input values of the elements of $icode vy$$ +The input values of the elements of $icode vy$$ are not specified (must not matter). Upon return, for $latex j = 0 , \ldots , m-1$$, $icode%vy%[%i%]%$$ is true if and only if @@ -664,7 +695,7 @@ $latex \[ y_j^k = \frac{1}{ k ! } Y_j^{(k)} (0) \] $$ -If $latex p > 0$$, +If $latex p > 0$$, for $latex i = 0 , \ldots , m-1$$ and $latex k = 0 , \ldots , p-1$$, the input of $icode ty$$ satisfies $latex \[ @@ -684,24 +715,24 @@ Then you can compute $icode ty$$ using the following formulas: $latex \[ \begin{array}{rcl} -y_i^0 & = & Y(0) +y_i^0 & = & Y(0) = f_i ( x^0 ) \\ -y_i^1 & = & Y^{(1)} ( 0 ) - = f_i^{(1)} ( x^0 ) X^{(1)} ( 0 ) - = f_i^{(1)} ( x^0 ) x^1 +y_i^1 & = & Y^{(1)} ( 0 ) + = f_i^{(1)} ( x^0 ) X^{(1)} ( 0 ) + = f_i^{(1)} ( x^0 ) x^1 \\ -y_i^2 +y_i^2 & = & \frac{1}{2 !} Y^{(2)} (0) \\ & = & \frac{1}{2} X^{(1)} (0)^\R{T} f_i^{(2)} ( x^0 ) X^{(1)} ( 0 ) + \frac{1}{2} f_i^{(1)} ( x^0 ) X^{(2)} ( 0 ) \\ -& = & \frac{1}{2} (x^1)^\R{T} f_i^{(2)} ( x^0 ) x^1 +& = & \frac{1}{2} (x^1)^\R{T} f_i^{(2)} ( x^0 ) x^1 + f_i^{(1)} ( x^0 ) x^2 \end{array} \] $$ -For $latex i = 0 , \ldots , m-1$$, and $latex k = 0 , 1 , 2$$, +For $latex i = 0 , \ldots , m-1$$, and $latex k = 0 , 1 , 2$$, $latex \[ ty [ i * (q + 1) + k ] = y_i^k \] $$ @@ -724,12 +755,12 @@ $cref%tangent.cpp%atomic_tangent.cpp%Use Atomic Function%forward%$$, $cref%mat_mul.cpp%atomic_mat_mul.cpp%Use Atomic Function%forward%$$. - + $end ----------------------------------------------------------------------------- */ /*! -Link from atomic_base to forward mode +Link from atomic_base to forward mode \param p [in] lowerest order for this forward mode calculation. @@ -749,7 +780,7 @@ \param ty [out] Taylor coefficient corresponding to \c y for this calculation -See the forward mode in user's documentation for base_atomic +See the forward mode in user's documentation for base_atomic */ virtual bool forward( size_t p , @@ -775,9 +806,6 @@ $$ $section Atomic Reverse Mode$$ -$index atomic, reverse callback$$ -$index reverse, atomic callback$$ -$index reverse, atomic virtual$$ $spell bool $$ @@ -786,7 +814,7 @@ $icode%ok% = %afun%.reverse(%q%, %tx%, %ty%, %px%, %py%)%$$ $head Purpose$$ -This function is used by $cref/reverse/Reverse/$$ +This function is used by $cref/reverse/Reverse/$$ to compute derivatives. $head Implementation$$ @@ -794,7 +822,7 @@ $cref/reverse/Reverse/$$ mode, this virtual function must be defined by the $cref/atomic_user/atomic_ctor/atomic_user/$$ class. -It can just return $icode%ok% == false%$$ +It can just return $icode%ok% == false%$$ (and not compute anything) for values of $icode q$$ that are greater than those used by your $cref/reverse/Reverse/$$ mode calculations. @@ -858,14 +886,14 @@ $head F, G, H$$ -We use the notation $latex \{ x_j^k \} \in B^{n \times (q+1)}$$ for +We use the notation $latex \{ x_j^k \} \in B^{n \times (q+1)}$$ for $latex \[ \{ x_j^k \W{:} j = 0 , \ldots , n-1, k = 0 , \ldots , q \} -\]$$ -We use the notation $latex \{ y_i^k \} \in B^{m \times (q+1)}$$ for +\]$$ +We use the notation $latex \{ y_i^k \} \in B^{m \times (q+1)}$$ for $latex \[ \{ y_i^k \W{:} i = 0 , \ldots , m-1, k = 0 , \ldots , q \} -\]$$ +\]$$ We define the function $latex F : B^{n \times (q+1)} \rightarrow B^{m \times (q+1)}$$ by $latex \[ @@ -896,7 +924,7 @@ CppAD::vector<%Base%>& %px% %$$ and $icode%px%.size() == n * (%q%+1)%$$. -The input values of the elements of $icode px$$ +The input values of the elements of $icode px$$ are not specified (must not matter). Upon return, for $latex j = 0 , \ldots , n-1$$ and $latex \ell = 0 , \ldots , q$$, @@ -904,15 +932,15 @@ \begin{array}{rcl} px [ j * (q + 1) + \ell ] & = & \partial H / \partial x_j^\ell \\ -& = & -( \partial G / \partial \{ y_i^k \} ) +& = & +( \partial G / \partial \{ y_i^k \} ) ( \partial \{ y_i^k \} / \partial x_j^\ell ) \\ -& = & +& = & \sum_{i=0}^{m-1} \sum_{k=0}^q ( \partial G / \partial y_i^k ) ( \partial y_i^k / \partial x_j^\ell ) \\ -& = & +& = & \sum_{i=0}^{m-1} \sum_{k=\ell}^q py[ i * (q + 1 ) + k ] ( \partial F_i^k / \partial x_j^\ell ) \end{array} @@ -965,7 +993,7 @@ \param py [in] Partials w.r.t. the \c y Taylor coefficients. -See atomic_reverse mode use documentation +See atomic_reverse mode use documentation */ virtual bool reverse( size_t q , @@ -991,9 +1019,6 @@ $$ $section Atomic Forward Jacobian Sparsity Patterns$$ -$index atomic, for_sparse_jac callback$$ -$index for_sparse_jac, atomic callback$$ -$index for_sparse_jac, atomic virtual$$ $head Syntax$$ $icode%ok% = %afun%.for_sparse_jac(%q%, %r%, %s%)%$$ @@ -1019,16 +1044,16 @@ $codei% size_t %q% %$$ -It specifies the number of columns in -$latex R \in B^{n \times q}$$ and the Jacobian -$latex S(x) \in B^{m \times q}$$. +It specifies the number of columns in +$latex R \in B^{n \times q}$$ and the Jacobian +$latex S(x) \in B^{m \times q}$$. $subhead r$$ This argument has prototype $codei% const %atomic_sparsity%& %r% %$$ -and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for +and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex R \in B^{n \times q}$$. $subhead s$$ @@ -1036,10 +1061,10 @@ $codei% %atomic_sparsity%& %s% %$$ -The input values of its elements +The input values of its elements are not specified (must not matter). -Upon return, $icode s$$ is a -$cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for +Upon return, $icode s$$ is a +$cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex S(x) \in B^{m \times q}$$. $head ok$$ @@ -1093,6 +1118,11 @@ const vector& r , vector& s ) { return false; } +virtual bool for_sparse_jac( + size_t q , + const vectorBool& r , + vectorBool& s ) +{ return false; } /* -------------------------------------- --------------------------------------- $begin atomic_rev_sparse_jac$$ @@ -1111,9 +1141,6 @@ $$ $section Atomic Reverse Jacobian Sparsity Patterns$$ -$index atomic, rev_sparse_jac callback$$ -$index rev_sparse_jac, atomic callback$$ -$index rev_sparse_jac, atomic virtual$$ $head Syntax$$ $icode%ok% = %afun%.rev_sparse_jac(%q%, %rt%, %st%)%$$ @@ -1139,16 +1166,16 @@ $codei% size_t %q% %$$ -It specifies the number of rows in -$latex R \in B^{q \times m}$$ and the Jacobian -$latex S(x) \in B^{q \times n}$$. +It specifies the number of rows in +$latex R \in B^{q \times m}$$ and the Jacobian +$latex S(x) \in B^{q \times n}$$. $subhead rt$$ This argument has prototype $codei% const %atomic_sparsity%& %rt% %$$ -and is a +and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex R^\R{T} \in B^{m \times q}$$. @@ -1157,11 +1184,11 @@ $codei% %atomic_sparsity%& %st% %$$ -The input value of its elements +The input value of its elements are not specified (must not matter). -Upon return, $icode s$$ is a +Upon return, $icode s$$ is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for -$latex S(x)^\R{T} \in B^{n \times q}$$. +$latex S(x)^\R{T} \in B^{n \times q}$$. $head ok$$ The return value $icode ok$$ has prototype @@ -1214,6 +1241,11 @@ const vector& rt , vector& st ) { return false; } +virtual bool rev_sparse_jac( + size_t q , + const vectorBool& rt , + vectorBool& st ) +{ return false; } /* -------------------------------------- --------------------------------------- $begin atomic_rev_sparse_hes$$ @@ -1232,9 +1264,6 @@ $$ $section Atomic Reverse Hessian Sparsity Patterns$$ -$index atomic, rev_sparse_hes callback$$ -$index rev_sparse_hes, atomic callback$$ -$index rev_sparse_hes, atomic virtual$$ $head Syntax$$ $icode%ok% = %afun%.rev_sparse_hes(%vx%, %s%, %t%, %q%, %r%, %u%, %v%)%$$ @@ -1242,9 +1271,9 @@ $head Purpose$$ This function is used by $cref RevSparseHes$$ to compute Hessian sparsity patterns. -There is an unspecified scalar valued function +There is an unspecified scalar valued function $latex g : B^m \rightarrow B$$. -Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for +Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R \in B^{n \times q}$$, and information about the function $latex z = g(y)$$, this routine computes the sparsity pattern for @@ -1265,8 +1294,8 @@ $icode%vx%.size() == %n%$$, and for $latex j = 0 , \ldots , n-1$$, $icode%vx%[%j%]%$$ is true if and only if -$icode%ax%[%j%]%$$ is a $cref/variable/glossary/Variable/$$ -in the corresponding call to +$icode%ax%[%j%]%$$ is a $cref/variable/glossary/Variable/$$ +in the corresponding call to $codei% %afun%(%ax%, %ay%, %id%) %$$ @@ -1276,8 +1305,8 @@ $codei% const CppAD:vector& %s% %$$ -and its size is $icode m$$. -It is a sparsity pattern for +and its size is $icode m$$. +It is a sparsity pattern for $latex S(x) = g^{(1)} (y) \in B^{1 \times m}$$. $subhead t$$ @@ -1286,10 +1315,10 @@ CppAD:vector& %t% %$$ and its size is $icode m$$. -The input values of its elements +The input values of its elements are not specified (must not matter). -Upon return, $icode t$$ is a -sparsity pattern for +Upon return, $icode t$$ is a +sparsity pattern for $latex T(x) \in B^{1 \times n}$$ where $latex \[ T(x) = (g \circ f)^{(1)} (x) = S(x) * f^{(1)} (x) @@ -1300,17 +1329,17 @@ $codei% size_t %q% %$$ -It specifies the number of columns in +It specifies the number of columns in $latex R \in B^{n \times q}$$, $latex U(x) \in B^{m \times q}$$, and -$latex V(x) \in B^{n \times q}$$. +$latex V(x) \in B^{n \times q}$$. $subhead r$$ This argument has prototype $codei% const %atomic_sparsity%& %r% %$$ -and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for +and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex R \in B^{n \times q}$$. $head u$$ @@ -1318,15 +1347,15 @@ $codei% const %atomic_sparsity%& %u% %$$ -and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for +and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex U(x) \in B^{m \times q}$$ which is defined by $latex \[ \begin{array}{rcl} U(x) -& = & +& = & \partial_u \{ \partial_y g[ y + f^{(1)} (x) R u ] \}_{u=0} \\ -& = & +& = & \partial_u \{ g^{(1)} [ y + f^{(1)} (x) R u ] \}_{u=0} \\ & = & @@ -1339,15 +1368,15 @@ $codei% %atomic_sparsity%& %v% %$$ -The input value of its elements +The input value of its elements are not specified (must not matter). -Upon return, $icode v$$ is a -$cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for +Upon return, $icode v$$ is a +$cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex V(x) \in B^{n \times q}$$ which is defined by $latex \[ \begin{array}{rcl} -V(x) -& = & +V(x) +& = & \partial_u [ \partial_x (g \circ f) ( x + R u ) ]_{u=0} \\ & = & @@ -1431,6 +1460,15 @@ const vector& u , vector& v ) { return false; } +virtual bool rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vectorBool& r , + const vectorBool& u , + vectorBool& v ) +{ return false; } /* ------------------------------------------------------------------------------ $begin atomic_base_clear$$ @@ -1440,10 +1478,7 @@ $$ $section Free Static Variables$$ -$index free, atomic static$$ -$index atomic, free static$$ -$index static, free atomic$$ -$index clear, atomic static$$ +$mindex clear$$ $head Syntax$$ $codei%atomic_base<%Base%>::clear()%$$ @@ -1454,11 +1489,11 @@ (until it is deleted). If an the $code atomic_base$$ object is global or static because, the it does not get deleted. -This is a problem when using -$code thread_alloc$$ $cref/free_all/ta_free_all/$$ -to check that all allocated memory has been freed. +This is a problem when using +$code thread_alloc$$ $cref/free_all/ta_free_all/$$ +to check that all allocated memory has been freed. Calling this $code clear$$ function will free all the -memory currently being held onto by the +memory currently being held onto by the $codei%atomic_base<%Base%>%$$ class. $head Future Use$$ @@ -1506,7 +1541,7 @@ This function is called just before calling any of the virtual funcitons and has the corresponding id of the corresponding virtual call. */ -virtual void set_id(size_t id) +virtual void set_id(size_t id) { } // --------------------------------------------------------------------------- }; diff -Nru cppad-2015.00.00.9/cppad/local/azmul.hpp cppad-2016.00.00.1/cppad/local/azmul.hpp --- cppad-2015.00.00.9/cppad/local/azmul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/azmul.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,214 @@ +// $Id$ +# ifndef CPPAD_AZMUL_HPP +# define CPPAD_AZMUL_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin azmul$$ +$spell + azmul + const + namespace + Vec +$$ + +$section Absolute Zero Multiplication$$ + +$head Syntax$$ +$icode%z% = azmul(%x%, %y%)%$$ + +$head Purpose$$ +Evaluates multiplication with an absolute zero +for any of the possible types listed below. +The result is given by +$latex \[ +z = \left\{ \begin{array}{ll} + 0 & {\rm if} \; x = 0 \\ + x \cdot y & {\rm otherwise} +\end{array} \right. +\] $$ +Note if $icode x$$ is zero and $icode y$$ is infinity, +ieee multiplication would result in not a number whereas +$icode z$$ would be zero. + +$head Base$$ +If $icode Base$$ satisfies the +$cref/base type requirements/base_require/$$ +and arguments $icode x$$, $icode y$$ have prototypes +$codei% + const %Base%& %x% + const %Base%& %y% +%$$ +then the result $icode z$$ has prototype +$codei% + %Base% %z% +%$$ + +$head AD$$ +If the arguments $icode x$$, $icode y$$ have prototype +$codei% + const AD<%Base%>& %x% + const AD<%Base%>& %y% +%$$ +then the result $icode z$$ has prototype +$codei% + AD<%Base%> %z% +%$$ + +$head VecAD$$ +If the arguments $icode x$$, $icode y$$ have prototype +$codei% + const VecAD<%Base%>::reference& %x% + const VecAD<%Base%>::reference& %y% +%$$ +then the result $icode z$$ has prototype +$codei% + AD<%Base%> %z% +%$$ + +$head Example$$ +$children% + example/azmul.cpp +%$$ +The file +$cref azmul.cpp$$ +is an examples and tests of this function. +It returns true if it succeeds and false otherwise. + +$end +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +// ========================================================================== + +// case where x and y are AD ------------------------------------------- +template AD +azmul(const AD& x, const AD& y) +{ + // compute the Base part + AD result; + result.value_ = azmul(x.value_, y.value_); + + // check if there is a recording in progress + ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + tape_id_t tape_id = tape->id_; + + // tape_id cannot match the default value for tape_id_; i.e., 0 + CPPAD_ASSERT_UNKNOWN( tape_id > 0 ); + bool var_x = x.tape_id_ == tape_id; + bool var_y = y.tape_id_ == tape_id; + + if( var_x ) + { if( var_y ) + { // result = azmul(variable, variable) + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(x.taddr_, y.taddr_); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(ZmulvvOp); + + // make result a variable + result.tape_id_ = tape_id; + } + else if( IdenticalZero( y.value_ ) ) + { // result = variable * 0 + } + else if( IdenticalOne( y.value_ ) ) + { // result = variable * 1 + result.make_variable(x.tape_id_, x.taddr_); + } + else + { // result = zmul(variable, parameter) + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); + + // put operand addresses in tape + addr_t p = tape->Rec_.PutPar(y.value_); + tape->Rec_.PutArg(x.taddr_, p); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(ZmulvpOp); + + // make result a variable + result.tape_id_ = tape_id; + } + } + else if( var_y ) + { if( IdenticalZero(x.value_) ) + { // result = 0 * variable + } + else if( IdenticalOne( x.value_ ) ) + { // result = 1 * variable + result.make_variable(y.tape_id_, y.taddr_); + } + else + { // result = zmul(parameter, variable) + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = tape->Rec_.PutPar(x.value_); + tape->Rec_.PutArg(p, y.taddr_); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(ZmulpvOp); + + // make result a variable + result.tape_id_ = tape_id; + } + } + return result; +} +// ========================================================================= +// Fold operations into case above +// ------------------------------------------------------------------------- +// Operations with VecAD_reference and AD only + +template AD +azmul(const AD& x, const VecAD_reference& y) +{ return azmul(x, y.ADBase()); } + +template AD +azmul(const VecAD_reference& x, const VecAD_reference& y) +{ return azmul(x.ADBase(), y.ADBase()); } + +template AD +azmul(const VecAD_reference& x, const AD& y) +{ return azmul(x.ADBase(), y); } +// ------------------------------------------------------------------------- +// Operations with Base + +template AD +azmul(const Base& x, const AD& y) +{ return azmul(AD(x), y); } + +template AD +azmul(const Base& x, const VecAD_reference& y) +{ return azmul(AD(x), y.ADBase()); } + +template AD +azmul(const AD& x, const Base& y) +{ return azmul(x, AD(y)); } + +template AD +azmul(const VecAD_reference& x, const Base& y) +{ return azmul(x.ADBase(), AD(y)); } + +// ========================================================================== +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/base_complex.hpp cppad-2016.00.00.1/cppad/local/base_complex.hpp --- cppad-2015.00.00.9/cppad/local/base_complex.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/base_complex.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,8 +1,8 @@ -/* $Id: base_complex.hpp 3526 2014-12-29 21:56:45Z bradbell $ */ -# ifndef CPPAD_BASE_COMPLEX_INCLUDED -# define CPPAD_BASE_COMPLEX_INCLUDED +// $Id: base_complex.hpp 3768 2015-12-28 18:58:35Z bradbell $ +# ifndef CPPAD_BASE_COMPLEX_HPP +# define CPPAD_BASE_COMPLEX_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -16,11 +16,16 @@ # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include +# include /* $begin base_complex.hpp$$ $spell + azmul + expm1 + atanh + acosh + asinh endif eps abs_geq @@ -49,9 +54,6 @@ bool $$ -$index complex, double Base$$ -$index Base, double complex$$ -$index double, complex Base$$ $section Enable use of AD where Base is std::complex$$ @@ -111,20 +113,20 @@ $code Lt$$, $code Le$$, $code Eq$$, $code Ge$$, and $code Gt$$. $head EqualOpSeq$$ -Complex numbers do not carry operation sequence information. -Thus they are equal in this sense if and only if there values are equal. +Complex numbers do not carry operation sequence information. +Thus they are equal in this sense if and only if there values are equal. $codep */ namespace CppAD { inline bool EqualOpSeq( - const std::complex &x , + const std::complex &x , const std::complex &y ) - { return x == y; + { return x == y; } } /* $$ $head Identical$$ -Complex numbers do not carry operation sequence information. +Complex numbers do not carry operation sequence information. Thus they are all parameters so the identical functions just check values. $codep */ namespace CppAD { @@ -141,7 +143,7 @@ /* $$ $head Ordered$$ -Complex types do not support comparison operators, +Complex types do not support comparison operators, $codep */ # undef CPPAD_USER_MACRO # define CPPAD_USER_MACRO(Fun) \ @@ -159,24 +161,12 @@ CPPAD_USER_MACRO(GreaterThanOrZero) CPPAD_USER_MACRO(GreaterThanZero) inline bool abs_geq( - const std::complex& x , + const std::complex& x , const std::complex& y ) { return std::abs(x) >= std::abs(y); } } /* $$ -$head erf$$ -Complex types do not support the error function -(use CPPAD_USER_MACRO define above). -$codep */ -# if CPPAD_COMPILER_HAS_ERF -namespace CppAD { - CPPAD_USER_MACRO(erf) -} -# endif -/* $$ - - $head Integer$$ The implementation of this function must agree with the CppAD user specifications for complex arguments to the @@ -188,6 +178,13 @@ } /* $$ +$head azmul$$ +$codep */ +namespace CppAD { + CPPAD_AZMUL( std::complex ) +} +/* $$ + $head isnan$$ The gcc 4.1.1 complier defines the function $codei% @@ -207,7 +204,7 @@ /* $$ $head Valid Unary Math$$ -The following macro invocations define the standard unary +The following macro invocations define the standard unary math functions that are valid with complex arguments and are required to use $code AD< std::complex >$$. $codep */ @@ -223,7 +220,7 @@ /* $$ $head Invalid Unary Math$$ -The following macro definition and invocations define the standard unary +The following macro definition and invocations define the standard unary math functions that are invalid with complex arguments and are required to use $code AD< std::complex >$$. $codep */ @@ -243,6 +240,14 @@ CPPAD_USER_MACRO(asin) CPPAD_USER_MACRO(atan) CPPAD_USER_MACRO(sign) +# if CPPAD_USE_CPLUSPLUS_2011 + CPPAD_USER_MACRO(erf) + CPPAD_USER_MACRO(asinh) + CPPAD_USER_MACRO(acosh) + CPPAD_USER_MACRO(atanh) + CPPAD_USER_MACRO(expm1) + CPPAD_USER_MACRO(log1p) +# endif } /* $$ @@ -252,42 +257,27 @@ $codep */ namespace CppAD { inline std::complex pow( - const std::complex &x , + const std::complex &x , const std::complex &y ) { return std::pow(x, y); } } /*$$ -$head limits$$ -The following defines the numeric limits functions -$code epsilon$$, $code min$$, and $code max$$ for the type -$code std::complex$$. -It also defines the deprecated $code epsilon$$ function: -$codep */ -namespace CppAD { - template <> - class numeric_limits< std::complex > { - public: - // machine epsilon - static std::complex epsilon(void) - { double eps = std::numeric_limits::epsilon(); - return std::complex(eps, 0.0); - } - // minimum positive normalized value - static std::complex min(void) - { double min = std::numeric_limits::min(); - return std::complex(min, 0.0); - } - // maximum finite value - static std::complex max(void) - { double max = std::numeric_limits::max(); - return std::complex(max, 0.0); - } - }; - // deprecated machine epsilon - template <> - inline std::complex epsilon< std::complex > (void) - { return numeric_limits< std::complex >::epsilon(); } +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code std::complex$$: +$codep */ +namespace CppAD { + CPPAD_NUMERIC_LIMITS(double, std::complex) +} +/*$$ + +$head to_string$$ +The following defines the function CppAD $cref to_string$$ +for the type $code std::complex$$: +$codep */ +namespace CppAD { + CPPAD_TO_STRING(std::complex) } /* $$ $end @@ -331,9 +321,9 @@ CPPAD_COND_EXP_REL( std::complex ) // EqualOpSeq ----------------------------------------------------- inline bool EqualOpSeq( - const std::complex &x , + const std::complex &x , const std::complex &y ) - { return x == y; + { return x == y; } // Identical ------------------------------------------------------ inline bool IdenticalPar(const std::complex &x) @@ -351,7 +341,7 @@ CPPAD_USER_MACRO_ONE(GreaterThanOrZero) CPPAD_USER_MACRO_ONE(GreaterThanZero) inline bool abs_geq( - const std::complex& x , + const std::complex& x , const std::complex& y ) { return std::abs(x) >= std::abs(y); } // Integer ------------------------------------------------------ @@ -377,32 +367,13 @@ CPPAD_USER_MACRO_TWO(sign) // The pow function inline std::complex pow( - const std::complex &x , + const std::complex &x , const std::complex &y ) { return std::pow(x, y); } // numeric_limits ------------------------------------------------- - template <> - class numeric_limits< std::complex > { - public: - /// machine epsilon - static std::complex epsilon(void) - { float eps = std::numeric_limits::epsilon(); - return std::complex(eps, 0.0); - } - /// minimum positive normalized value - static std::complex min(void) - { float min = std::numeric_limits::min(); - return std::complex(min, 0.0); - } - /// maximum finite value - static std::complex max(void) - { float max = std::numeric_limits::max(); - return std::complex(max, 0.0); - } - }; - template <> - inline std::complex epsilon< std::complex >(void) - { return numeric_limits< std::complex >::epsilon(); } + CPPAD_NUMERIC_LIMITS(float, std::complex) + // to_string ------------------------------------------------- + CPPAD_TO_STRING(std::complex) } // undefine macros only used by this file diff -Nru cppad-2015.00.00.9/cppad/local/base_cond_exp.hpp cppad-2016.00.00.1/cppad/local/base_cond_exp.hpp --- cppad-2015.00.00.9/cppad/local/base_cond_exp.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/base_cond_exp.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,19 +1,19 @@ -/* $Id: base_cond_exp.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_BASE_COND_EXP_INCLUDED -# define CPPAD_BASE_COND_EXP_INCLUDED +// $Id: base_cond_exp.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_BASE_COND_EXP_HPP +# define CPPAD_BASE_COND_EXP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -/* +/* $begin base_cond_exp$$ $spell alloc @@ -37,12 +37,10 @@ $$ $section Base Type Requirements for Conditional Expressions$$ -$index CondExp, base require$$ -$index base, CondExp require$$ -$index require, base CondExp$$ +$mindex CondExp require CPPAD_COND_EXP_REL$$ $head Purpose$$ -These definitions are required by the user's code to support the +These definitions are required by the user's code to support the $codei%AD<%Base%>%$$ type for $cref CondExp$$ operations: $head CompareOp$$ @@ -50,7 +48,7 @@ $codep namespace CppAD { // The conditional expression operator enum type - enum CompareOp + enum CompareOp { CompareLt, // less than CompareLe, // less than or equal CompareEq, // equal @@ -68,7 +66,7 @@ %cop%, %left%, %right%, %exp_if_true%, %exp_if_false% ) %$$ -which computes implements the corresponding $cref CondExp$$ +which computes implements the corresponding $cref CondExp$$ function when the result has prototype $codei% %Base% %result% @@ -76,13 +74,13 @@ The argument $icode cop$$ has prototype $codei% enum CppAD::CompareOp %cop% -%$$ +%$$ The other arguments have the prototype $codei% - const %Base%& %left% - const %Base%& %right% + const %Base%& %left% + const %Base%& %right% const %Base%& %exp_if_true% - const %Base%& %exp_if_false% + const %Base%& %exp_if_false% %$$ $subhead Ordered Type$$ @@ -103,12 +101,12 @@ } } %$$ -For example, see +For example, see $cref/double CondExpOp/base_alloc.hpp/CondExpOp/$$. For an example of and implementation of $code CondExpOp$$ with a more involved $icode Base$$ type see $cref/adolc CondExpOp/base_adolc.hpp/CondExpOp/$$. - + $subhead Not Ordered$$ If the type $icode Base$$ does not support ordering, @@ -130,9 +128,8 @@ %$$ For example, see $cref/complex CondExpOp/base_complex.hpp/CondExpOp/$$. - + $head CondExpRel$$ -$index CPPAD_COND_EXP_REL$$ The macro invocation $codei% CPPAD_COND_EXP_REL(%Base%) @@ -234,11 +231,11 @@ see \c exp_if_true and \c exp_if_false above. */ template -ResultType CondExpTemplate( +ResultType CondExpTemplate( enum CompareOp cop , const CompareType& left , - const CompareType& right , - const ResultType& exp_if_true , + const CompareType& right , + const ResultType& exp_if_true , const ResultType& exp_if_false ) { ResultType returnValue; switch( cop ) diff -Nru cppad-2015.00.00.9/cppad/local/base_double.hpp cppad-2016.00.00.1/cppad/local/base_double.hpp --- cppad-2015.00.00.9/cppad/local/base_double.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/base_double.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,8 +1,8 @@ -/* $Id: base_double.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_BASE_DOUBLE_INCLUDED -# define CPPAD_BASE_DOUBLE_INCLUDED +// $Id: base_double.hpp 3769 2015-12-29 16:13:16Z bradbell $ +# ifndef CPPAD_BASE_DOUBLE_HPP +# define CPPAD_BASE_DOUBLE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -17,6 +17,13 @@ /* $begin base_double.hpp$$ $spell + cppad + hpp + azmul + expm1 + atanh + acosh + asinh erf endif abs_geq @@ -41,9 +48,6 @@ const $$ -$index double, Base$$ -$index Base, double$$ -$index double, Base$$ $section Enable use of AD where Base is double$$ @@ -54,11 +58,11 @@ Hence its $code CondExpOp$$ function is defined by $codep */ namespace CppAD { - inline double CondExpOp( + inline double CondExpOp( enum CompareOp cop , const double& left , - const double& right , - const double& exp_if_true , + const double& right , + const double& exp_if_true , const double& exp_if_false ) { return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false); } @@ -109,6 +113,13 @@ } /* $$ +$head azmul$$ +$codep */ +namespace CppAD { + CPPAD_AZMUL( double ) +} +/* $$ + $head Ordered$$ The $code double$$ type supports ordered comparisons $codep */ @@ -145,12 +156,17 @@ CPPAD_STANDARD_MATH_UNARY(double, sqrt) CPPAD_STANDARD_MATH_UNARY(double, tan) CPPAD_STANDARD_MATH_UNARY(double, tanh) -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 CPPAD_STANDARD_MATH_UNARY(double, erf) + CPPAD_STANDARD_MATH_UNARY(double, asinh) + CPPAD_STANDARD_MATH_UNARY(double, acosh) + CPPAD_STANDARD_MATH_UNARY(double, atanh) + CPPAD_STANDARD_MATH_UNARY(double, expm1) + CPPAD_STANDARD_MATH_UNARY(double, log1p) # endif } /* $$ -The absolute value function is special because its $code std$$ name is +The absolute value function is special because its $code std$$ name is $code fabs$$ $codep */ namespace CppAD { @@ -184,32 +200,22 @@ } /*$$ -$head limits$$ -The following defines the numeric limits functions -$code epsilon$$, $code min$$, and $code max$$ for the type -$code double$$. -It also defines the deprecated $code epsilon$$ function: -$codep */ -namespace CppAD { - template <> - class numeric_limits { - public: - // machine epsilon - static double epsilon(void) - { return std::numeric_limits::epsilon(); } - // minimum positive normalized value - static double min(void) - { return std::numeric_limits::min(); } - // maximum finite value - static double max(void) - { return std::numeric_limits::max(); } - }; - // deprecated machine epsilon - template <> - inline double epsilon(void) - { return numeric_limits::epsilon(); } +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code double$$: +$codep */ +namespace CppAD { + CPPAD_NUMERIC_LIMITS(double, double) } -/* $$ +/*$$ + +$head to_string$$ +There is no need to define $code to_string$$ for $code double$$ +because it is defined by including $code cppad/utility/to_string.hpp$$; +see $cref to_string$$. +See $cref/base_complex.hpp/base_complex.hpp/to_string/$$ for an example where +it is necessary to define $code to_string$$ for a $icode Base$$ type. + $end */ diff -Nru cppad-2015.00.00.9/cppad/local/base_float.hpp cppad-2016.00.00.1/cppad/local/base_float.hpp --- cppad-2015.00.00.9/cppad/local/base_float.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/base_float.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,8 +1,8 @@ -/* $Id: base_float.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_BASE_FLOAT_INCLUDED -# define CPPAD_BASE_FLOAT_INCLUDED +// $Id: base_float.hpp 3769 2015-12-29 16:13:16Z bradbell $ +# ifndef CPPAD_BASE_FLOAT_HPP +# define CPPAD_BASE_FLOAT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -17,6 +17,13 @@ /* $begin base_float.hpp$$ $spell + cppad + hpp + azmul + expm1 + atanh + acosh + asinh erf endif abs_geq @@ -41,9 +48,6 @@ const $$ -$index float, Base$$ -$index Base, float$$ -$index float, Base$$ $section Enable use of AD where Base is float$$ @@ -54,11 +58,11 @@ Hence its $code CondExpOp$$ function is defined by $codep */ namespace CppAD { - inline float CondExpOp( + inline float CondExpOp( enum CompareOp cop , const float& left , - const float& right , - const float& exp_if_true , + const float& right , + const float& exp_if_true , const float& exp_if_false ) { return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false); } @@ -109,6 +113,13 @@ } /* $$ +$head azmul$$ +$codep */ +namespace CppAD { + CPPAD_AZMUL( float ) +} +/* $$ + $head Ordered$$ The $code float$$ type supports ordered comparisons $codep */ @@ -146,12 +157,17 @@ CPPAD_STANDARD_MATH_UNARY(float, sqrt) CPPAD_STANDARD_MATH_UNARY(float, tan) CPPAD_STANDARD_MATH_UNARY(float, tanh) -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 CPPAD_STANDARD_MATH_UNARY(float, erf) + CPPAD_STANDARD_MATH_UNARY(float, asinh) + CPPAD_STANDARD_MATH_UNARY(float, acosh) + CPPAD_STANDARD_MATH_UNARY(float, atanh) + CPPAD_STANDARD_MATH_UNARY(float, expm1) + CPPAD_STANDARD_MATH_UNARY(float, log1p) # endif } /* $$ -The absolute value function is special because its $code std$$ name is +The absolute value function is special because its $code std$$ name is $code fabs$$ $codep */ namespace CppAD { @@ -174,7 +190,7 @@ } } /* $$ - + $head pow $$ The following defines a $code CppAD::pow$$ function that is required to use $code AD$$: @@ -185,31 +201,22 @@ } /*$$ -$head limits$$ -The following defines the numeric limits functions -$code epsilon$$, $code min$$, and $code max$$ for the type -$code float$$: -$codep */ -namespace CppAD { - template <> - class numeric_limits { - public: - // machine epsilon - static float epsilon(void) - { return std::numeric_limits::epsilon(); } - // minimum positive normalized value - static float min(void) - { return std::numeric_limits::min(); } - // maximum finite value - static float max(void) - { return std::numeric_limits::max(); } - }; - // deprecated machine epsilon - template <> - inline float epsilon(void) - { return numeric_limits::epsilon(); } +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code float$$: +$codep */ +namespace CppAD { + CPPAD_NUMERIC_LIMITS(float, float) } -/* $$ +/*$$ + +$head to_string$$ +There is no need to define $code to_string$$ for $code float$$ +because it is defined by including $code cppad/utility/to_string.hpp$$; +see $cref to_string$$. +See $cref/base_complex.hpp/base_complex.hpp/to_string/$$ for an example where +it is necessary to define $code to_string$$ for a $icode Base$$ type. + $end */ diff -Nru cppad-2015.00.00.9/cppad/local/base_limits.hpp cppad-2016.00.00.1/cppad/local/base_limits.hpp --- cppad-2015.00.00.9/cppad/local/base_limits.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/base_limits.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,67 @@ +// $Id$ +# ifndef CPPAD_BASE_LIMITS_HPP +# define CPPAD_BASE_LIMITS_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin base_limits$$ +$spell + std + namespace + CppAD +$$ + +$section Base Type Requirements for Numeric Limits$$ + +$head CppAD::numeric_limits$$ +A specialization for +$cref/CppAD::numeric_limits/numeric_limits/$$ +must be defined in order to use the type $codei%AD<%Base%>%$$. +CppAD does not use a specialization of +$codei%std::numeric_limits<%Base%>%$$. +Since C++11, using a specialization of +$codei%std::numeric_limits<%Base%>%$$ +would require that $icode Base$$ be a literal type. + +$head CPPAD_NUMERIC_LIMITS$$ +In most cases, this macro can be used to define the specialization where +the numeric limits for the type $icode Base$$ +are the same as the standard numeric limits for the type $icode Other$$. +For most $icode Base$$ types, +there is a choice of $icode Other$$, +for which the following preprocessor macro invocation suffices: +$codei% + namespace CppAD { + CPPAD_NUMERIC_LIMITS(%Other%, %Base%) + } +%$$ +where the macro is defined by +$codep */ +# define CPPAD_NUMERIC_LIMITS(Other, Base) \ +template <> class numeric_limits\ +{\ + public:\ + static Base min(void) \ + { return static_cast( std::numeric_limits::min() ); }\ + static Base max(void) \ + { return static_cast( std::numeric_limits::max() ); }\ + static Base epsilon(void) \ + { return static_cast( std::numeric_limits::epsilon() ); }\ + static Base quiet_NaN(void) \ + { return static_cast( std::numeric_limits::quiet_NaN() ); }\ +}; +/* $$ +$end +*/ + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/base_std_math.hpp cppad-2016.00.00.1/cppad/local/base_std_math.hpp --- cppad-2015.00.00.9/cppad/local/base_std_math.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/base_std_math.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,21 +1,25 @@ -/* $Id: base_std_math.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_BASE_STD_MATH_INCLUDED -# define CPPAD_BASE_STD_MATH_INCLUDED +// $Id: base_std_math.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_BASE_STD_MATH_HPP +# define CPPAD_BASE_STD_MATH_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -/* +/* $begin base_std_math$$ $spell + expm1 + atanh + acosh + asinh inline fabs isnan @@ -34,22 +38,16 @@ $$ $section Base Type Requirements for Standard Math Functions$$ -$index math, base require$$ -$index base, math require$$ -$index require, base math$$ $head Purpose$$ These definitions are required for the user's code to use the type $codei%AD<%Base%>%$$: -$head Unary Standard Math$$ -$index math, base unary$$ -$index base, unary math$$ -$index unary, base math$$ +$head Unary Standard Math$$ The type $icode Base$$ must support the following functions unary standard math functions (in the CppAD namespace): $table -$bold Syntax$$ $cnext $bold Result$$ +$bold Syntax$$ $cnext $bold Result$$ $rnext $icode%y% = abs(%x%)%$$ $cnext absolute value $rnext $icode%y% = acos(%x%)%$$ $cnext inverse cosine $rnext @@ -63,7 +61,7 @@ $icode%y% = sin(%x%)%$$ $cnext sine $rnext $icode%y% = sinh(%x%)%$$ $cnext hyperbolic sine $rnext $icode%y% = sqrt(%x%)%$$ $cnext square root $rnext -$icode%y% = tan(%x%)%$$ $cnext tangent +$icode%y% = tan(%x%)%$$ $cnext tangent $tend where the arguments and return value have the prototypes $codei% @@ -75,7 +73,6 @@ $head CPPAD_STANDARD_MATH_UNARY$$ -$index CPPAD_STANDARD_MATH_UNARY$$ The macro invocation, within the CppAD namespace, $codei% CPPAD_STANDARD_MATH_UNARY(%Base%, %Fun%) @@ -86,28 +83,32 @@ %$$ This macro uses the functions $codei%std::%Fun%$$ which must be defined and have the same prototype as $codei%CppAD::%Fun%$$. -For example, +For example, $cref/float/base_float.hpp/Unary Standard Math/$$. -$head erf$$ -$index erf, base require$$ -$index base, erf require$$ -$index require, base erf$$ -If the error function is supported by the compiler, -$cref/CPPAD_COMPILER_HAS_ERF/erf/Method/CPPAD_COMPILER_HAS_ERF/$$ -is one, -the type $icode Base$$ must support the syntax +$head erf, asinh, acosh, atanh, expm1, log1p$$ +If this preprocessor symbol +$code CPPAD_USE_CPLUSPLUS_2011$$ is true ($code 1$$), +when compiling for c++11, the type +$code double$$ is supported for the functions listed below. +In this case, the type $icode Base$$ must also support these functions: +$table +$bold Syntax$$ $cnext $bold Result$$ +$rnext +$icode%y% = erf(%x%)%$$ $cnext error function $rnext +$icode%y% = asinh(%x%)%$$ $cnext inverse hyperbolic sin $rnext +$icode%y% = acosh(%x%)%$$ $cnext inverse hyperbolic cosine $rnext +$icode%y% = atanh(%x%)%$$ $cnext inverse hyperbolic tangent $rnext +$icode%y% = expm1(%x%)%$$ $cnext exponential of x minus one $rnext +$icode%y% = log1p(%x%)%$$ $cnext logarithm of one plus x +$tend +where the arguments and return value have the prototypes $codei% - %y% = CppAD::erf(%x%) + const %Base%& %x% + %Base% %y% %$$ -where $icode x$$ and $icode y$$ have the same prototype as above. -For example, see -$cref/base_alloc/base_alloc.hpp/erf/$$. $head sign$$ -$index sign, base require$$ -$index base, sign require$$ -$index require, base sign$$ The type $icode Base$$ must support the syntax $codei% %y% = CppAD::sign(%x%) @@ -128,9 +129,6 @@ $cref/complex invalid unary math/base_complex.hpp/Invalid Unary Math/$$. $head pow$$ -$index pow, base require$$ -$index base, pow require$$ -$index require, base pow$$ The type $icode Base$$ must support the syntax $codei% %z% = CppAD::pow(%x%, %y%) @@ -150,8 +148,6 @@ $head isnan$$ -$index isnan, base type$$ -$index base, isnan$$ If $icode Base$$ defines the $code isnan$$ function, you may also have to provide a definition in the CppAD namespace (to avoid a function ambiguity). @@ -159,30 +155,6 @@ $cref/base_complex/base_complex.hpp/isnan/$$. -$head limits$$ -$index numeric, limits Base$$ -$index limits, numeric Base$$ -$index Base, numeric_limits$$ -The $cref/numeric_limits/limits/$$ functions -$codei% - %Base% CppAD::numeric_limits<%Base%>::epsilon() - %Base% CppAD::numeric_limits<%Base%>::min() - %Base% CppAD::numeric_limits<%Base%>::max() -%$$ -must return machine epsilon, -minimum positive normalize value, -and maximum finite value for the type $icode Base$$. - -$subhead epsilon$$ -The deprecated function $cref epsilon$$ function -must also be included. It can be implemented using -$codei% -namespace CppAD { - template <> inline %Base% epsilon<%Base%>(void) - { return numeric_limits<%Base%>::epsilon(); } -} -%$$ - $end ------------------------------------------------------------------------------- */ diff -Nru cppad-2015.00.00.9/cppad/local/base_to_string.hpp cppad-2016.00.00.1/cppad/local/base_to_string.hpp --- cppad-2015.00.00.9/cppad/local/base_to_string.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/base_to_string.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -0,0 +1,68 @@ +// $Id$ +# ifndef CPPAD_BASE_TO_STRING_HPP +# define CPPAD_BASE_TO_STRING_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin base_to_string$$ +$spell + std + namespace + CppAD + struct + const + stringstream + setprecision + str +$$ + +$section Extending to_string To Another Floating Point Type$$ + +$head Base Requirement$$ +If the function $cref to_string$$ is used by an +$cref/AD type above Base/glossary/AD Type Above Base/$$, +A specialization for the template structure +$code CppAD::to_string_struct$$ must be defined. + +$head CPPAD_TO_STRING$$ +For most $icode Base$$ types, +the following can be used to define the specialization: +$codei% + namespace CppAD { + CPPAD_TO_STRING(%Base%) + } +%$$ +Note that the $code CPPAD_TO_STRING$$ macro assumes that the +$cref base_limits$$ and $cref base_std_math$$ have already been defined +for this type. +This macro is defined as follows: +$codep */ +# define CPPAD_TO_STRING(Base) \ +template <> struct to_string_struct\ +{ std::string operator()(const Base& value) \ + { std::stringstream os;\ + Base epsilon = CppAD::numeric_limits::epsilon();\ + Base log10 = CppAD::log( epsilon ) / CppAD::log(Base(10.));\ + size_t n_digits = 1 - Integer( log10 );\ + os << std::setprecision(n_digits);\ + os << value;\ + return os.str();\ + }\ +}; +/* $$ +$end +------------------------------------------------------------------------------ +*/ +// make sure to_string has been included +# include + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/bender_quad.hpp cppad-2016.00.00.1/cppad/local/bender_quad.hpp --- cppad-2015.00.00.9/cppad/local/bender_quad.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/bender_quad.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: bender_quad.hpp 2859 2013-05-28 06:03:21Z bradbell $ */ -# ifndef CPPAD_BENDER_QUAD_INCLUDED -# define CPPAD_BENDER_QUAD_INCLUDED +// $Id: bender_quad.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_BENDER_QUAD_HPP +# define CPPAD_BENDER_QUAD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,23 +30,21 @@ $$ -$index Hessian, Bender$$ -$index Jacobian, Bender$$ -$index BenderQuad$$ $section Computing Jacobian and Hessian of Bender's Reduced Objective$$ +$mindex BenderQuad$$ $head Syntax$$ $codei% # include -BenderQuad(%x%, %y%, %fun%, %g%, %gx%, %gxx%)%$$ +BenderQuad(%x%, %y%, %fun%, %g%, %gx%, %gxx%)%$$ $head See Also$$ $cref opt_val_hes$$ $head Problem$$ The type $cref/ADvector/BenderQuad/ADvector/$$ cannot be determined -form the arguments above -(currently the type $icode ADvector$$ must be +form the arguments above +(currently the type $icode ADvector$$ must be $codei%CPPAD_TESTVECTOR(%Base%)%$$.) This will be corrected in the future by requiring $icode Fun$$ to define $icode%Fun%::vector_type%$$ which will specify the @@ -61,7 +59,7 @@ \] $$ that is convex with respect to $latex y$$. In addition, we are given a set of equations $latex H(x, y)$$ -such that +such that $latex \[ H[ x , Y(x) ] = 0 \;\; \Rightarrow \;\; F_y [ x , Y(x) ] = 0 \] $$ @@ -70,7 +68,7 @@ $latex \[ dy = - [ \partial_y H(x, y)]^{-1} H(x, y) \] $$ -The purpose of this routine is to compute the +The purpose of this routine is to compute the value, Jacobian, and Hessian of the reduced objective function $latex \[ G(x) = F[ x , Y(x) ] @@ -79,7 +77,7 @@ computed more quickly using the relations $latex \[ G^{(1)} (x) = \partial_x F [x, Y(x) ] -\] $$ +\] $$ $head x$$ The $code BenderQuad$$ argument $icode x$$ has prototype @@ -88,7 +86,7 @@ %$$ (see $cref/BAvector/BenderQuad/BAvector/$$ below) and its size must be equal to $icode n$$. -It specifies the point at which we evaluating +It specifies the point at which we evaluating the reduced objective function and its derivatives. @@ -98,7 +96,7 @@ const %BAvector% &%y% %$$ and its size must be equal to $icode m$$. -It must be equal to $latex Y(x)$$; i.e., +It must be equal to $latex Y(x)$$; i.e., it must solve the problem in $latex y$$ for this given value of $latex x$$ $latex \[ \begin{array}{rcl} @@ -107,12 +105,12 @@ \] $$ $head fun$$ -The $code BenderQuad$$ object $icode fun$$ +The $code BenderQuad$$ object $icode fun$$ must support the member functions listed below. The $codei%AD<%Base%>%$$ arguments will be variables for a tape created by a call to $cref Independent$$ from $code BenderQuad$$ -(hence they can not be combined with variables corresponding to a -different tape). +(hence they can not be combined with variables corresponding to a +different tape). $subhead fun.f$$ The $code BenderQuad$$ argument $icode fun$$ supports the syntax @@ -177,7 +175,7 @@ const %BAvector% &%x% %$$ and its size must be equal to $icode n$$. -Its value will be exactly equal to the $code BenderQuad$$ argument +Its value will be exactly equal to the $code BenderQuad$$ argument $icode x$$ and values depending on it can be stored as private objects in $icode f$$ and need not be recalculated. $codei% @@ -189,7 +187,7 @@ const %BAvector% &%y% %$$ and its size must be equal to $icode m$$. -Its value will be exactly equal to the $code BenderQuad$$ argument +Its value will be exactly equal to the $code BenderQuad$$ argument $icode y$$ and values depending on it can be stored as private objects in $icode f$$ and need not be recalculated. $codei% @@ -217,9 +215,9 @@ Note that if $icode h$$ is equal to $latex H(x, y)$$, $latex dy$$ is the Newton step for finding a zero of $latex H(x, y)$$ with respect to $latex y$$; -i.e., +i.e., $latex y + dy$$ is an approximate solution for the equation -$latex H (x, y + dy) = 0$$. +$latex H (x, y + dy) = 0$$. $head g$$ The argument $icode g$$ has prototype @@ -243,7 +241,7 @@ The input values of its elements do not matter. On output, it contains the Jacobian of $latex G (x)$$; i.e., -for $latex j = 0 , \ldots , n-1$$, +for $latex j = 0 , \ldots , n-1$$, $latex \[ gx[ j ] = G^{(1)} (x)_j \] $$ @@ -258,23 +256,23 @@ On output, it contains the Hessian of $latex G (x)$$; i.e., for $latex i = 0 , \ldots , n-1$$, and -$latex j = 0 , \ldots , n-1$$, +$latex j = 0 , \ldots , n-1$$, $latex \[ gxx[ i * n + j ] = G^{(2)} (x)_{i,j} \] $$ $head BAvector$$ -The type $icode BAvector$$ must be a -$cref SimpleVector$$ class. -We use $icode Base$$ to refer to the type of the elements of +The type $icode BAvector$$ must be a +$cref SimpleVector$$ class. +We use $icode Base$$ to refer to the type of the elements of $icode BAvector$$; i.e., $codei% %BAvector%::value_type %$$ $head ADvector$$ -The type $icode ADvector$$ must be a -$cref SimpleVector$$ class with elements of type +The type $icode ADvector$$ must be a +$cref SimpleVector$$ class with elements of type $codei%AD<%Base%>%$$; i.e., $codei% %ADvector%::value_type @@ -291,7 +289,7 @@ %$$ The file $cref bender_quad.cpp$$ -contains an example and test of this operation. +contains an example and test of this operation. It returns true if it succeeds and false otherwise. @@ -303,9 +301,9 @@ template void BenderQuad( - const BAvector &x , - const BAvector &y , - Fun fun , + const BAvector &x , + const BAvector &y , + Fun fun , BAvector &g , BAvector &gx , BAvector &gxx ) @@ -343,11 +341,11 @@ ADvector vx(n); for(j = 0; j < n; j++) vx[j] = x[j]; - + // declare the independent variables Independent(vx); - // evaluate h = H(x, y) + // evaluate h = H(x, y) ADvector h(m); h = fun.h(vx, y); @@ -360,14 +358,14 @@ for(j = 0; j < m; j++) vy[j] = y[j] + dy[j]; - // evaluate G~ (x) = F [ x , y + dy(x) ] + // evaluate G~ (x) = F [ x , y + dy(x) ] ADvector gtilde(1); gtilde = fun.f(vx, vy); // AD function object that corresponds to G~ (x) // We will make heavy use of this tape, so optimize it ADFun Gtilde; - Gtilde.Dependent(vx, gtilde); + Gtilde.Dependent(vx, gtilde); Gtilde.optimize(); // value of G(x) @@ -401,7 +399,7 @@ return; } - + } // END CppAD namespace # endif diff -Nru cppad-2015.00.00.9/cppad/local/bool_fun.hpp cppad-2016.00.00.1/cppad/local/bool_fun.hpp --- cppad-2015.00.00.9/cppad/local/bool_fun.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/bool_fun.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: bool_fun.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_BOOL_FUN_INCLUDED -# define CPPAD_BOOL_FUN_INCLUDED +// $Id: bool_fun.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_BOOL_FUN_HPP +# define CPPAD_BOOL_FUN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,12 +22,9 @@ const $$ -$index bool, AD function$$ -$index function, AD bool$$ -$index unary, AD bool$$ -$index binary, AD bool$$ $section AD Boolean Functions$$ +$mindex bool CPPAD_BOOL_UNARY CPPAD_BOOL_BINARY$$ $head Syntax$$ $codei%CPPAD_BOOL_UNARY(%Base%, %unary_name%) @@ -61,7 +58,7 @@ %$$ It is the value at which the user provided version of $icode unary_name$$ is to be evaluated. -It is also used for the first argument to the +It is also used for the first argument to the user provided version of $icode binary_name$$. $head x$$ @@ -71,7 +68,7 @@ %$$ It is the value at which the CppAD provided version of $icode unary_name$$ is to be evaluated. -It is also used for the first argument to the +It is also used for the first argument to the CppAD provided version of $icode binary_name$$. $head b$$ @@ -81,14 +78,13 @@ %$$ $head Create Unary$$ -$index CPPAD_BOOL_UNARY$$ The preprocessor macro invocation $codei% CPPAD_BOOL_UNARY(%Base%, %unary_name%) %$$ defines the version of $icode unary_name$$ with a $codei%AD<%Base%>%$$ argument. -This can with in a namespace +This can with in a namespace (not the $code CppAD$$ namespace) but must be outside of any routine. @@ -117,14 +113,13 @@ the CppAD provided version of $icode binary_name$$. $head Create Binary$$ -$index CPPAD_BOOL_BINARY$$ The preprocessor macro invocation $codei% CPPAD_BOOL_BINARY(%Base%, %binary_name%) %$$ defines the version of $icode binary_name$$ with $codei%AD<%Base%>%$$ arguments. -This can with in a namespace +This can with in a namespace (not the $code CppAD$$ namespace) but must be outside of any routine. @@ -145,8 +140,8 @@ contains an example and test of these operations. It returns true if it succeeds and false otherwise. -$head Deprecated$$ -The preprocessor symbols $code CppADCreateUnaryBool$$ +$head Deprecated 2007-07-31$$ +The preprocessor symbols $code CppADCreateUnaryBool$$ and $code CppADCreateBinaryBool$$ are defined to be the same as $code CPPAD_BOOL_UNARY$$ and $code CPPAD_BOOL_BINARY$$ respectively (but their use is deprecated). @@ -161,7 +156,7 @@ */ /*! -Macro that defines a unary function bool F(AD x) +Macro that defines a unary function bool F(AD x) using bool F(Base x). \param Base @@ -195,13 +190,13 @@ inline bool AD::UnaryBool( bool FunName(const Base &x), const AD &x -) +) { return FunName(x.value_); } /*! -Macro that defines a binary function bool F(AD x, AD y) +Macro that defines a binary function bool F(AD x, AD y) using bool F(Base x, Base y). \param Base @@ -240,7 +235,7 @@ inline bool AD::BinaryBool( bool FunName(const Base &x, const Base &y), const AD &x, const AD &y -) +) { return FunName(x.value_, y.value_); } diff -Nru cppad-2015.00.00.9/cppad/local/bool_valued.hpp cppad-2016.00.00.1/cppad/local/bool_valued.hpp --- cppad-2015.00.00.9/cppad/local/bool_valued.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/bool_valued.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: bool_valued.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_BOOL_VALUED_INCLUDED -# define CPPAD_BOOL_VALUED_INCLUDED +// $Id: bool_valued.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_BOOL_VALUED_HPP +# define CPPAD_BOOL_VALUED_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,8 +19,6 @@ Bool $$ -$index operation, AD Bool valued$$ -$index function, AD Bool valued$$ $section Bool Valued Operations and Functions with AD Arguments$$ @@ -38,7 +36,7 @@ $rref ParVar$$ $rref EqualOpSeq$$ $tend - + $end */ diff -Nru cppad-2015.00.00.9/cppad/local/capacity_order.hpp cppad-2016.00.00.1/cppad/local/capacity_order.hpp --- cppad-2015.00.00.9/cppad/local/capacity_order.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/capacity_order.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: capacity_order.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_CAPACITY_ORDER_INCLUDED -# define CPPAD_CAPACITY_ORDER_INCLUDED +// $Id: capacity_order.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_CAPACITY_ORDER_HPP +# define CPPAD_CAPACITY_ORDER_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,13 +22,9 @@ yq $$ -$index Forward, capacity$$ -$index capacity_order$$ -$index capacity, Forward$$ -$index control, memory$$ -$index memory, control$$ $section Controlling Taylor Coefficients Memory Allocation$$ +$mindex Forward capacity_order control$$ $head Syntax$$ $icode%f%.capacity_order(%c%)%$$ @@ -38,18 +34,18 @@ $head Purpose$$ The Taylor coefficients calculated by $cref Forward$$ mode calculations -are retained in an $cref ADFun$$ object for subsequent use during +are retained in an $cref ADFun$$ object for subsequent use during $cref Reverse$$ mode and higher order Forward mode calculations. For example, a call to $cref/Forward/forward_order/$$ with the syntax $codei% %yq% = %f%.Forward(%q%, %xq%) %$$ where $icode%q% > 0%$$ and $code%xq%.size() == %f%.Domain()%$$, -uses the lower order Taylor coefficients and +uses the lower order Taylor coefficients and computes the $th q$$ order Taylor coefficients for all the variables in the operation sequence corresponding to $icode f$$. -The $code capacity_order$$ operation allows you to control that -amount of memory that is retained by an AD function object +The $code capacity_order$$ operation allows you to control that +amount of memory that is retained by an AD function object (to hold $code Forward$$ results for subsequent calculations). $head f$$ @@ -63,11 +59,11 @@ $codei% size_t %c% %$$ -It specifies the number of Taylor coefficient orders that are allocated +It specifies the number of Taylor coefficient orders that are allocated in the AD operation sequence corresponding to $icode f$$. $subhead Pre-Allocating Memory$$ -If you plan to make calls to $code Forward$$ with the maximum value of +If you plan to make calls to $code Forward$$ with the maximum value of $icode q$$ equal to $icode Q$$, it should be faster to pre-allocate memory for these calls using $codei% @@ -80,28 +76,28 @@ $$ Note that each call to $cref Dependent$$ frees the old memory -connected to the function object and sets the corresponding +connected to the function object and sets the corresponding taylor capacity to zero. $subhead Freeing Memory$$ If you no longer need the Taylor coefficients of order $icode q$$ -and higher (that are stored in $icode f$$), +and higher (that are stored in $icode f$$), you can reduce the memory allocated to $icode f$$ using $codei% %f%.capacity_order(%c%) %$$ with $icode c$$ equal to $icode q$$. -Note that, if $cref ta_hold_memory$$ is true, this memory is not actually -returned to the system, but rather held for future use by the same thread. +Note that, if $cref ta_hold_memory$$ is true, this memory is not actually +returned to the system, but rather held for future use by the same thread. $head Original State$$ If $icode f$$ is $cref/constructed/FunConstruct/$$ with the syntax $codei% ADFun<%Base%> %f%(%x%, %y%) %$$, -there is an implicit call to $cref forward_zero$$ with $icode xq$$ equal to +there is an implicit call to $cref forward_zero$$ with $icode xq$$ equal to the value of the -$cref/independent variables/glossary/Tape/Independent Variable/$$ +$cref/independent variables/glossary/Tape/Independent Variable/$$ when the AD operation sequence was recorded. This corresponds to $icode%c% == 1%$$. @@ -109,7 +105,7 @@ example/capacity_order.cpp %$$ $head Example$$ -The file +The file $cref capacity_order.cpp$$ contains an example and test of these operations. It returns true if it succeeds and false otherwise. @@ -142,7 +138,7 @@ \param r is the number of directions to allocate memory for. If c == 1 then \c r must also be one. -In all cases, it must hold that +In all cases, it must hold that r == num_direction_taylor_ || num_order_taylor <= 1 @@ -162,7 +158,7 @@ { // temporary indices size_t i, k, ell; - if( (c == cap_order_taylor_) & (r == num_direction_taylor_) ) + if( (c == cap_order_taylor_) & (r == num_direction_taylor_) ) return; if( c == 0 ) @@ -174,8 +170,8 @@ return; } CPPAD_ASSERT_UNKNOWN(r==num_direction_taylor_ || num_order_taylor_<=1); - - // Allocate new taylor with requested number of orders and directions + + // Allocate new taylor with requested number of orders and directions size_t new_len = ( (c-1)*r + 1 ) * num_var_tape_; pod_vector new_taylor; new_taylor.extend(new_len); @@ -227,7 +223,7 @@ \param c is the number of orders to allocate memory for. -If c == 0, +If c == 0, num_order_taylor_, cap_order_taylor_, and num_direction_taylor_ are all set to zero. In addition, taylor_.free() is called. @@ -259,6 +255,6 @@ } } // END CppAD namespace - + # endif diff -Nru cppad-2015.00.00.9/cppad/local/check_for_nan.hpp cppad-2016.00.00.1/cppad/local/check_for_nan.hpp --- cppad-2015.00.00.9/cppad/local/check_for_nan.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/check_for_nan.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -0,0 +1,199 @@ +// $Id$ +# ifndef CPPAD_CHECK_FOR_NAN_HPP +# define CPPAD_CHECK_FOR_NAN_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin check_for_nan$$ +$spell + std + vec + Cpp + const + bool + newline +$$ +$section Check an ADFun Object For Nan Results$$ + +$head Syntax$$ +$icode%f%.check_for_nan(%b%) +%$$ +$icode%b% = %f%.check_for_nan() +%$$ +$codei%get_check_for_nan(%vec%, %file%) +%$$ + +$head Debugging$$ +If $code NDEBUG$$ is not defined, and +the result of a $cref/forward/forward_order/$$ or $cref/reverse/reverse_any/$$ +calculation contains a $cref nan$$, +CppAD can halt with an error message. + +$head f$$ +For the syntax where $icode b$$ is an argument, +$icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +(see $codei%ADFun<%Base%>%$$ $cref/constructor/FunConstruct/$$). +For the syntax where $icode b$$ is the result, +$icode f$$ has prototype +$codei% + const ADFun<%Base%> %f% +%$$ + +$head b$$ +This argument or result has prototype +$codei% + bool %b% +%$$ +Future calls to $icode%f%.Forward%$$ will (will not) check for $code nan$$. +depending on if $icode b$$ is true (false). + +$head Default$$ +The value for this setting after construction of $icode f$$) is true. +The value of this setting is not affected by calling +$cref Dependent$$ for this function object. + +$head Error Message$$ +If this error is detected during zero order forward mode, +the values of the independent variables that resulted in the $code nan$$ +are written to a temporary binary file. +This is so that you can run the original source code with those values +to see what is causing the $code nan$$. + +$subhead vector_size$$ +The error message with contain the text +$codei%vector_size = %vector_size%$$ followed the newline character +$code '\n'$$. +The value of $icode vector_size$$ is the number of elements +in the independent vector. + +$subhead file_name$$ +The error message with contain the text +$codei%file_name = %file_name%$$ followed the newline character +$code '\n'$$. +The value of $icode file_name$$ is the name of the temporary file +that contains the dependent variable values. + +$subhead index$$ +The error message will contain the text +$codei%index = %index%$$ followed by the newline character $code '\n'$$. +The value of $icode index$$ is the lowest dependent variable index +that has the value $code nan$$. + +$head get_check_for_nan$$ +This routine can be used to get the independent variable +values that result in a $code nan$$. + +$subhead vec$$ +This argument has prototype +$codei% + CppAD::vector<%Base%>& %vec% +%$$ +It size must be equal to the corresponding value of +$cref/vector_size/check_for_nan/Error Message/vector_size/$$ +in the corresponding error message. +The input value of its elements does not matter. +Upon return, it will contain the values for the independent variables, +in the corresponding call to $cref Independent$$, +that resulted in the $code nan$$. +(Note that the call to $code Independent$$ uses an vector with elements +of type $codei%AD<%Base%>%$$ and $icode vec$$ has elements of type +$icode Base$$.) + +$subhead file$$ +This argument has prototype +$codei% + const std::string& %file% +%$$ +It must be the value of +$cref/file_name/check_for_nan/Error Message/file_name/$$ +in the corresponding error message. + +$head Example$$ +$children% + example/check_for_nan.cpp +%$$ +The file +$cref check_for_nan.cpp$$ +contains an example and test of these operations. +It returns true if it succeeds and false otherwise. + +$end +*/ + +# include +# include +# include + +# if CPPAD_HAS_MKSTEMP +# include +# include +# else +# if CPPAD_HAS_TMPNAM_S +# include +# else +# include +# endif +# endif + + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +void put_check_for_nan(const CppAD::vector& vec, std::string& file_name) +{ + size_t char_size = sizeof(Base) * vec.size(); + const char* char_ptr = reinterpret_cast( vec.data() ); +# if CPPAD_HAS_MKSTEMP + char pattern[] = "/tmp/fileXXXXXX"; + int fd = mkstemp(pattern); + file_name = pattern; + write(fd, char_ptr, char_size); + close(fd); +# else +# if CPPAD_HAS_TMPNAM_S + std::vector name(L_tmpnam_s); + if( tmpnam_s( name.data(), L_tmpnam_s ) != 0 ) + { CPPAD_ASSERT_KNOWN( + false, + "Cannot create a temporary file name" + ); + } + file_name = name.data(); +# else + file_name = tmpnam( CPPAD_NULL ); +# endif + std::fstream file_out(file_name.c_str(), std::ios::out|std::ios::binary ); + file_out.write(char_ptr, char_size); + file_out.close(); +# endif + return; +} + +template +void get_check_for_nan(CppAD::vector& vec, const std::string& file_name) +{ // + size_t n = vec.size(); + size_t char_size = sizeof(Base) * n; + char* char_ptr = reinterpret_cast( vec.data() ); + // + std::fstream file_in(file_name.c_str(), std::ios::in|std::ios::binary ); + file_in.read(char_ptr, char_size); + // + return; +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/checkpoint.hpp cppad-2016.00.00.1/cppad/local/checkpoint.hpp --- cppad-2015.00.00.9/cppad/local/checkpoint.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/checkpoint.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,17 +1,20 @@ -/* $Id: checkpoint.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_CHECKPOINT_INCLUDED -# define CPPAD_CHECKPOINT_INCLUDED +// $Id: checkpoint.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_CHECKPOINT_HPP +# define CPPAD_CHECKPOINT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ +# include +# include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -22,30 +25,43 @@ /* $begin checkpoint$$ $spell + sv + var cppad.hpp CppAD checkpoint checkpointing algo - afun + atom_fun const + enum + bool $$ $section Checkpointing Functions$$ -$index function, checkpoint$$ -$index checkpoint, function$$ $head Syntax$$ -$codei%checkpoint<%Base%> %afun%(%name%, %algo%, %ax%, %ay%) -%afun%.option(%option_value%) +$codei%checkpoint<%Base%> %atom_fun%(%name%, %algo%, %ax%, %ay%, %sparsity%) +%sv% = %atom_fun%.size_var() +%atom_fun%.option(%option_value%) %algo%(%ax%, %ay%) -%afun%(%ax%, %ay%) +%atom_fun%(%ax%, %ay%) checkpoint<%Base%>::clear()%$$ $head Purpose$$ -You can reduce the size of the tape and memory required for AD by + +$subhead Reduce Memory$$ +You can reduce the size of the tape and memory required for AD by checkpointing functions of the form $latex y = f(x)$$ where $latex f : B^n \rightarrow B^m$$. +The $cref/operation sequence/glossary/Operation/Sequence/$$ +representing $latex f(x)$$ cannot depend on the value of $latex x$$. + +$subhead Faster Recording$$ +It may also reduce the time to make a recording the same function +for different values of the independent variable. +Note that the operation sequence for a recording that uses $latex f(x)$$ +may depend on its independent variables. $head Method$$ The $code checkpoint$$ class is derived from $code atomic_base$$ @@ -54,20 +70,27 @@ $cref/virtual functions/atomic_base/Virtual Functions/$$ and hence its source code $code cppad/local/checkpoint.hpp$$ provides an example implementation of $cref atomic_base$$. -The difference is that $code checkpoint.hpp$$ uses AD +The difference is that $code checkpoint.hpp$$ uses AD instead of user provided derivatives. $head constructor$$ -The constructor +The syntax for the checkpoint constructor is $codei% - checkpoint<%Base%> %afun%(%name%, %algo%, %ax%, %ay%) + checkpoint<%Base%> %atom_fun%(%name%, %algo%, %ax%, %ay%) %$$ -cannot be called in $cref/parallel/ta_in_parallel/$$ mode. -In addition, you cannot currently be recording +$list number$$ +This constructor cannot be called in $cref/parallel/ta_in_parallel/$$ mode. +$lnext +You cannot currently be recording $codei%AD<%Base%>%$$ operations when the constructor is called. +$lnext +This object $icode atom_fun$$ must not be destructed for as long +as any $codei%ADFun<%Base%>%$$ object uses its atomic operation. +$lnext This class is implemented as a derived class of -$cref/atomic_base/atomic_ctor/atomic_base/$$ and hence +$cref/atomic_base/atomic_ctor/atomic_base/$$ and hence some of its error message will refer to $code atomic_base$$. +$lend $head Base$$ The type $icode Base$$ specifies the base type for AD operations. @@ -83,8 +106,8 @@ const char* %name% %$$ It is the name used for error reporting. -The suggested value for $icode name$$ is $icode afun$$; i.e., -the same name as used for the function. +The suggested value for $icode name$$ is $icode atom_fun$$; i.e., +the same name as used for the object being constructed. $head ax$$ This argument has prototype @@ -92,8 +115,8 @@ const %ADVector%& %ax% %$$ and size must be equal to $icode n$$. -It specifies vector $latex x \in B^n$$ -at which an $codei%AD<%Base%>%$$ version of +It specifies vector $latex x \in B^n$$ +at which an $codei%AD<%Base%>%$$ version of $latex y = f(x)$$ is to be evaluated. $head ay$$ @@ -103,12 +126,34 @@ %$$ Its input size must be equal to $icode m$$ and does not change. The input values of its elements do not matter. -Upon return, it is an $codei%AD<%Base%>%$$ version of +Upon return, it is an $codei%AD<%Base%>%$$ version of $latex y = f(x)$$. +$head sparsity$$ +This argument has prototype +$codei% + atomic_base<%Base%>::option_enum %sparsity% +%$$ +It specifies $cref/sparsity/atomic_ctor/atomic_base/sparsity/$$ +in the $code atomic_base$$ constructor and must be either +$codei%atomic_base<%Base%>::pack_sparsity_enum%$$, +$codei%atomic_base<%Base%>::bool_sparsity_enum%$$, or +$codei%atomic_base<%Base%>::set_sparsity_enum%$$. +This argument is optional and its default value is unspecified. + + +$head size_var$$ +This $code size_var$$ member function return value has prototype +$codei% + size_t %sv% +%$$ +It is the $cref/size_var/seq_property/size_var/$$ for the +$codei%ADFun<%Base%>%$$ object is used to store the operation sequence +corresponding to $icode algo$$. + $head option$$ The $code option$$ syntax can be used to set the type of sparsity -pattern used by $icode afun$$. +pattern used by $icode atom_fun$$. This is an $codei%atomic_base<%Base%>%$$ function and its documentation can be found at $cref atomic_option$$. @@ -117,21 +162,21 @@ the syntax $codei% %algo%(%ax%, %ay%) -%$$ +%$$ must evaluate the function $latex y = f(x)$$ using $codei%AD<%Base%>%$$ operations. -In addition, we assume that the +In addition, we assume that the $cref/operation sequence/glossary/Operation/Sequence/$$ does not depend on the value of $icode ax$$. -$head afun$$ +$head atom_fun$$ Given $icode ax$$ it computes the corresponding value of $icode ay$$ -using the operation sequence corresponding to $icode algo$$. +using the operation sequence corresponding to $icode algo$$. If $codei%AD<%Base%>%$$ operations are being recorded, it enters the computation as single operation in the recording see $cref/start recording/Independent/Start Recording/$$. -(Currently each use of $icode afun$$ actually corresponds to -$icode%m%+%n%+2%$$ operations and creates $icode m$$ new variables, +(Currently each use of $icode atom_fun$$ actually corresponds to +$icode%m%+%n%+2%$$ operations and creates $icode m$$ new variables, but this is not part of the CppAD specifications and my change.) $head clear$$ @@ -139,7 +184,7 @@ increase speed by avoiding system memory allocation calls. This call makes to work space $cref/available/ta_available/$$ to for other uses by the same thread. -This should be called when you are done using the +This should be called when you are done using the user atomic functions for a specific value of $icode Base$$. $subhead Restriction$$ @@ -158,11 +203,316 @@ */ template class checkpoint : public atomic_base { +// --------------------------------------------------------------------------- private: + /// same as option_enum in base class + typedef typename atomic_base::option_enum option_enum; + // + /// AD function corresponding to this checkpoint object ADFun f_; + // + /// sparsity for entire Jacobian f(x)^{(1)} does not change so can cache it + CPPAD_INTERNAL_SPARSE_SET jac_sparse_set_; + vectorBool jac_sparse_bool_; + // + /// sparsity for sum_i f_i(x)^{(2)} does not change so can cache it + CPPAD_INTERNAL_SPARSE_SET hes_sparse_set_; + vectorBool hes_sparse_bool_; + // ------------------------------------------------------------------------ + option_enum sparsity(void) + { return static_cast< atomic_base* >(this)->sparsity(); } + // ------------------------------------------------------------------------ + /// set jac_sparse_set_ + void set_jac_sparse_set(void) + { CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == 0 ); + bool transpose = false; + bool dependency = true; + size_t n = f_.Domain(); + size_t m = f_.Range(); + // Use the choice for forward / reverse that results in smaller + // size for the sparsity pattern of all variables in the tape. + if( n <= m ) + { CPPAD_INTERNAL_SPARSE_SET identity; + identity.resize(n, n); + for(size_t j = 0; j < n; j++) + identity.add_element(j, j); + f_.ForSparseJacCheckpoint( + n, identity, transpose, dependency, jac_sparse_set_ + ); + f_.size_forward_set(0); + } + else + { CPPAD_INTERNAL_SPARSE_SET identity; + identity.resize(m, m); + for(size_t i = 0; i < m; i++) + identity.add_element(i, i); + f_.RevSparseJacCheckpoint( + m, identity, transpose, dependency, jac_sparse_set_ + ); + } + CPPAD_ASSERT_UNKNOWN( f_.size_forward_set() == 0 ); + CPPAD_ASSERT_UNKNOWN( f_.size_forward_bool() == 0 ); + } + /// set jac_sparse_bool_ + void set_jac_sparse_bool(void) + { CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == 0 ); + bool transpose = false; + bool dependency = true; + size_t n = f_.Domain(); + size_t m = f_.Range(); + // Use the choice for forward / reverse that results in smaller + // size for the sparsity pattern of all variables in the tape. + if( n <= m ) + { vectorBool identity(n * n); + for(size_t j = 0; j < n; j++) + { for(size_t i = 0; i < n; i++) + identity[ i * n + j ] = (i == j); + } + jac_sparse_bool_ = f_.ForSparseJac( + n, identity, transpose, dependency + ); + f_.size_forward_bool(0); + } + else + { vectorBool identity(m * m); + for(size_t j = 0; j < m; j++) + { for(size_t i = 0; i < m; i++) + identity[ i * m + j ] = (i == j); + } + jac_sparse_bool_ = f_.RevSparseJac( + m, identity, transpose, dependency + ); + } + CPPAD_ASSERT_UNKNOWN( f_.size_forward_bool() == 0 ); + CPPAD_ASSERT_UNKNOWN( f_.size_forward_set() == 0 ); + } + // ------------------------------------------------------------------------ + /// set hes_sparse_set_ + void set_hes_sparse_set(void) + { CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.n_set() == 0 ); + size_t n = f_.Domain(); + size_t m = f_.Range(); + // + // set version of sparsity for vector of all ones + vector all_one(m); + for(size_t i = 0; i < m; i++) + all_one[i] = true; + + // set version of sparsity for n by n idendity matrix + CPPAD_INTERNAL_SPARSE_SET identity; + identity.resize(n, n); + for(size_t j = 0; j < n; j++) + identity.add_element(j, j); + + // compute sparsity pattern for H(x) = sum_i f_i(x)^{(2)} + bool transpose = false; + bool dependency = false; + f_.ForSparseJacCheckpoint( + n, identity, transpose, dependency, jac_sparse_set_ + ); + f_.RevSparseHesCheckpoint( + n, all_one, transpose, hes_sparse_set_ + ); + CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.n_set() == n ); + CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.end() == n ); + // + // drop the forward sparsity results from f_ + f_.size_forward_set(0); + } + /// set hes_sparse_bool_ + void set_hes_sparse_bool(void) + { CPPAD_ASSERT_UNKNOWN( hes_sparse_bool_.size() == 0 ); + size_t n = f_.Domain(); + size_t m = f_.Range(); + // + // set version of sparsity for vector of all ones + vectorBool all_one(m); + for(size_t i = 0; i < m; i++) + all_one[i] = true; + + // set version of sparsity for n by n idendity matrix + vectorBool identity(n * n); + for(size_t j = 0; j < n; j++) + { for(size_t i = 0; i < n; i++) + identity[ i * n + j ] = (i == j); + } + + // compute sparsity pattern for H(x) = sum_i f_i(x)^{(2)} + bool transpose = false; + bool dependency = false; + f_.ForSparseJac(n, identity, transpose, dependency); + hes_sparse_bool_ = f_.RevSparseHes(n, all_one, transpose); + CPPAD_ASSERT_UNKNOWN( hes_sparse_bool_.size() == n * n ); + // + // drop the forward sparsity results from f_ + f_.size_forward_bool(0); + CPPAD_ASSERT_UNKNOWN( f_.size_forward_bool() == 0 ); + CPPAD_ASSERT_UNKNOWN( f_.size_forward_set() == 0 ); + } + // ------------------------------------------------------------------------ + /*! + Link from user_atomic to forward sparse Jacobian pack and bool + + \copydetails atomic_base::for_sparse_jac + */ + template + bool for_sparse_jac( + size_t q , + const sparsity_type& r , + sparsity_type& s ) + { // during user sparsity calculations + size_t m = f_.Range(); + size_t n = f_.Domain(); + if( jac_sparse_bool_.size() == 0 ) + set_jac_sparse_bool(); + if( jac_sparse_set_.n_set() != 0 ) + jac_sparse_set_.resize(0, 0); + CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == m * n ); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == 0 ); + CPPAD_ASSERT_UNKNOWN( r.size() == n * q ); + CPPAD_ASSERT_UNKNOWN( s.size() == m * q ); + // + bool ok = true; + for(size_t i = 0; i < m; i++) + { for(size_t k = 0; k < q; k++) + s[i * q + k] = false; + } + // sparsity for s = jac_sparse_bool_ * r + for(size_t i = 0; i < m; i++) + { // compute row i of the return pattern + for(size_t j = 0; j < n; j++) + { if( jac_sparse_bool_[ i * n + j] ) + { for(size_t k = 0; k < q; k++) + // s[i * q + k] |= r[j * q + k ]; + s[i * q + k] = bool(s[i * q + k]) | bool(r[j * q + k]); + } + } + } + return ok; + } + // ------------------------------------------------------------------------ + /*! + Link from user_atomic to reverse sparse Jacobian pack and bool + + \copydetails atomic_base::rev_sparse_jac + */ + template + bool rev_sparse_jac( + size_t q , + const sparsity_type& rt , + sparsity_type& st ) + { // during user sparsity calculations + size_t m = f_.Range(); + size_t n = f_.Domain(); + if( jac_sparse_bool_.size() == 0 ) + set_jac_sparse_bool(); + if( jac_sparse_set_.n_set() != 0 ) + jac_sparse_set_.resize(0, 0); + CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == m * n ); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == 0 ); + CPPAD_ASSERT_UNKNOWN( rt.size() == m * q ); + CPPAD_ASSERT_UNKNOWN( st.size() == n * q ); + bool ok = true; + // + for(size_t j = 0; j < n; j++) + { for(size_t k = 0; k < q; k++) + st[j * q + k] = false; + } + // + // sparsity for s = r * jac_sparse_bool_ + // s^T = jac_sparse_bool_^T * r^T + for(size_t i = 0; i < m; i++) + { // i is the row index in r^T + for(size_t k = 0; k < q; k++) + { // k is column index in r^T + if( rt[i * q + k] ) + { // i is column index in jac_sparse_bool_^T + for(size_t j = 0; j < n; j++) + { if( jac_sparse_bool_[i * n + j] ) + st[j * q + k ] = true; + } + } + } + } + return ok; + } + /*! + Link from user_atomic to reverse sparse Hessian bools + + \copydetails atomic_base::rev_sparse_hes + */ + template + bool rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const sparsity_type& r , + const sparsity_type& u , + sparsity_type& v ) + { size_t n = f_.Domain(); + size_t m = f_.Range(); + CPPAD_ASSERT_UNKNOWN( vx.size() == n ); + CPPAD_ASSERT_UNKNOWN( s.size() == m ); + CPPAD_ASSERT_UNKNOWN( t.size() == n ); + CPPAD_ASSERT_UNKNOWN( r.size() == n * q ); + CPPAD_ASSERT_UNKNOWN( u.size() == m * q ); + CPPAD_ASSERT_UNKNOWN( v.size() == n * q ); + // + bool ok = true; + + // make sure hes_sparse_bool_ has been set + if( hes_sparse_bool_.size() == 0 ) + set_hes_sparse_bool(); + if( hes_sparse_set_.n_set() != 0 ) + hes_sparse_set_.resize(0, 0); + CPPAD_ASSERT_UNKNOWN( hes_sparse_bool_.size() == n * n ); + CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.n_set() == 0 ); + + + // compute sparsity pattern for T(x) = S(x) * f'(x) + t = f_.RevSparseJac(1, s); +# ifndef NDEBUG + for(size_t j = 0; j < n; j++) + CPPAD_ASSERT_UNKNOWN( vx[j] || ! t[j] ) +# endif + + // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R + // U(x) = g''(y) * f'(x) * R + // S(x) = g'(y) + + // compute sparsity pattern for A(x) = f'(x)^T * U(x) + bool transpose = true; + sparsity_type a(n * q); + a = f_.RevSparseJac(q, u, transpose); + + // Need sparsity pattern for H(x) = (S(x) * f(x))''(x) * R, + // but use less efficient sparsity for f(x)''(x) * R so that + // hes_sparse_set_ can be used every time this is needed. + for(size_t i = 0; i < n; i++) + { for(size_t k = 0; k < q; k++) + v[i * q + k] = false; + for(size_t j = 0; j < n; j++) + { if( hes_sparse_bool_[i * n + j] ) + { for(size_t k = 0; k < q; k++) + // v[i * q + k] |= r[ j * q + k ]; + v[i * q + k] = bool(v[i*q + k]) | bool(r[j*q + k]); + } + } + } + + // compute sparsity pattern for V(x) = A(x) + H(x) + for(size_t i = 0; i < n; i++) + { for(size_t k = 0; k < q; k++) + // v[ i * q + k ] |= a[ i * q + k]; + v[ i * q + k ] = bool(v[ i * q + k]) | bool(a[ i * q + k]); + } + return ok; + } public: + // ------------------------------------------------------------------------ /*! - Constructor of a checkpoint object + Constructor of a checkpoint object \param name [in] is the user's name for the AD version of this atomic operation. @@ -176,19 +526,29 @@ \param ay [out] function value at specified argument value. + + \param sparsity [in] + what type of sparsity patterns are computed by this function, + pack_sparsity_enum bool_sparsity_enum, or set_sparsity_enum. + The default value is unspecified. */ template - checkpoint(const char* name, - Algo& algo, const ADVector& ax, ADVector& ay) - : atomic_base(name) + checkpoint( + const char* name , + Algo& algo , + const ADVector& ax , + ADVector& ay , + option_enum sparsity = + atomic_base::pack_sparsity_enum + ) : atomic_base(name, sparsity) { CheckSimpleVector< CppAD::AD , ADVector>(); // make a copy of ax because Independent modifies AD information ADVector x_tmp(ax); // delcare x_tmp as the independent variables - Independent(x_tmp); + Independent(x_tmp); // record mapping from x_tmp to ay - algo(x_tmp, ay); + algo(x_tmp, ay); // create function f_ : x -> y f_.Dependent(ay); // suppress checking for nan in f_ results @@ -196,20 +556,30 @@ f_.check_for_nan(false); // now optimize (we expect to use this function many times). f_.optimize(); + // now disable checking of comparison opertaions + // 2DO: add a debugging mode that checks for changes and aborts + f_.compare_change_count(0); } + // ------------------------------------------------------------------------ + /*! + Implement the user call to atom_fun.size_var(). + */ + size_t size_var(void) + { return f_.size_var(); } + // ------------------------------------------------------------------------ /*! - Implement the user call to afun(ax, ay). - + Implement the user call to atom_fun(ax, ay). + \tparam ADVector A simple vector class with elements of type AD. - + \param id optional parameter which must be zero if present. - + \param ax is the argument vector for this call, ax.size() determines the number of arguments. - + \param ay is the result vector for this call, ay.size() determines the number of results. @@ -218,55 +588,83 @@ void operator()(const ADVector& ax, ADVector& ay, size_t id = 0) { CPPAD_ASSERT_KNOWN( id == 0, - "checkpoint: id is non-zero in afun(ax, ay, id)" + "checkpoint: id is non-zero in atom_fun(ax, ay, id)" ); this->atomic_base::operator()(ax, ay, id); } + // ------------------------------------------------------------------------ /*! - Link from user_atomic to forward mode + Link from user_atomic to forward mode \copydetails atomic_base::forward - */ + */ virtual bool forward( size_t p , size_t q , - const vector& vx , - vector& vy , + const vector& vx , + vector& vy , const vector& tx , vector& ty ) - { + { size_t n = f_.Domain(); + size_t m = f_.Range(); + // CPPAD_ASSERT_UNKNOWN( f_.size_var() > 0 ); CPPAD_ASSERT_UNKNOWN( tx.size() % (q+1) == 0 ); CPPAD_ASSERT_UNKNOWN( ty.size() % (q+1) == 0 ); - size_t n = tx.size() / (q+1); - size_t m = ty.size() / (q+1); - bool ok = true; - size_t i, j; - - // 2DO: test both forward and reverse vy information + CPPAD_ASSERT_UNKNOWN( n == tx.size() / (q+1) ); + CPPAD_ASSERT_UNKNOWN( m == ty.size() / (q+1) ); + bool ok = true; + // + if( vx.size() == 0 ) + { // during user forward mode + if( jac_sparse_set_.n_set() != 0 ) + jac_sparse_set_.resize(0,0); + if( jac_sparse_bool_.size() != 0 ) + jac_sparse_bool_.clear(); + // + if( hes_sparse_set_.n_set() != 0 ) + hes_sparse_set_.resize(0,0); + if( hes_sparse_bool_.size() != 0 ) + hes_sparse_bool_.clear(); + } if( vx.size() > 0 ) - { //Compute Jacobian sparsity pattern. - vector< std::set > s(m); - if( n <= m ) - { vector< std::set > r(n); - for(j = 0; j < n; j++) - r[j].insert(j); - s = f_.ForSparseJac(n, r); + { // need Jacobian sparsity pattern to determine variable relation + // during user recording using checkpoint functions + if( sparsity() == atomic_base::set_sparsity_enum ) + { if( jac_sparse_set_.n_set() == 0 ) + set_jac_sparse_set(); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == m ); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.end() == n ); + // + for(size_t i = 0; i < m; i++) + { vy[i] = false; + jac_sparse_set_.begin(i); + size_t j = jac_sparse_set_.next_element(); + while(j < n ) + { // y[i] depends on the value of x[j] + // cast avoid Microsoft warning (should not be needed) + vy[i] |= static_cast( vx[j] ); + j = jac_sparse_set_.next_element(); + } + } } else - { vector< std::set > r(m); - for(i = 0; i < m; i++) - r[i].insert(i); - s = f_.RevSparseJac(m, r); - } - std::set::const_iterator itr; - for(i = 0; i < m; i++) - { vy[i] = false; - for(itr = s[i].begin(); itr != s[i].end(); itr++) - { j = *itr; - assert( j < n ); - // y[i] depends on the value of x[j] - vy[i] |= vx[j]; + { if( jac_sparse_set_.n_set() != 0 ) + jac_sparse_set_.resize(0, 0); + if( jac_sparse_bool_.size() == 0 ) + set_jac_sparse_bool(); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == 0 ); + CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == m * n ); + // + for(size_t i = 0; i < m; i++) + { vy[i] = false; + for(size_t j = 0; j < n; j++) + { if( jac_sparse_bool_[ i * n + j ] ) + { // y[i] depends on the value of x[j] + // cast avoid Microsoft warning + vy[i] |= static_cast( vx[j] ); + } + } } } } @@ -274,34 +672,37 @@ // no longer need the Taylor coefficients in f_ // (have to reconstruct them every time) + // Hold onto sparsity pattern because it is always good. size_t c = 0; size_t r = 0; f_.capacity_order(c, r); return ok; } + // ------------------------------------------------------------------------ /*! - Link from user_atomic to reverse mode + Link from user_atomic to reverse mode \copydetails atomic_base::reverse - */ + */ virtual bool reverse( size_t q , const vector& tx , const vector& ty , vector& px , const vector& py ) - { + { size_t n = f_.Domain(); + size_t m = f_.Range(); + CPPAD_ASSERT_UNKNOWN( n == tx.size() / (q+1) ); + CPPAD_ASSERT_UNKNOWN( m == ty.size() / (q+1) ); CPPAD_ASSERT_UNKNOWN( f_.size_var() > 0 ); CPPAD_ASSERT_UNKNOWN( tx.size() % (q+1) == 0 ); CPPAD_ASSERT_UNKNOWN( ty.size() % (q+1) == 0 ); - bool ok = true; + bool ok = true; // put proper forward mode coefficients in f_ # ifdef NDEBUG f_.Forward(q, tx); # else - size_t n = tx.size() / (q+1); - size_t m = ty.size() / (q+1); CPPAD_ASSERT_UNKNOWN( px.size() == n * (q+1) ); CPPAD_ASSERT_UNKNOWN( py.size() == m * (q+1) ); size_t i, j, k; @@ -324,156 +725,169 @@ f_.capacity_order(c, r); return ok; } + // ------------------------------------------------------------------------ /*! - Link from user_atomic to forward sparse Jacobian + Link from user_atomic to forward sparse Jacobian pack \copydetails atomic_base::for_sparse_jac - */ + */ virtual bool for_sparse_jac( size_t q , - const vector< std::set >& r , - vector< std::set >& s ) - { - bool ok = true; - s = f_.ForSparseJac(q, r); - - // no longer need the forward mode sparsity pattern - // (have to reconstruct them every time) - f_.size_forward_set(0); - - return ok; + const vectorBool& r , + vectorBool& s ) + { return for_sparse_jac< vectorBool >(q, r, s); } /*! - Link from user_atomic to forward sparse Jacobian + Link from user_atomic to forward sparse Jacobian bool \copydetails atomic_base::for_sparse_jac - */ + */ virtual bool for_sparse_jac( size_t q , const vector& r , vector& s ) - { + { return for_sparse_jac< vector >(q, r, s); + } + /*! + Link from user_atomic to forward sparse Jacobian sets + + \copydetails atomic_base::for_sparse_jac + */ + virtual bool for_sparse_jac( + size_t q , + const vector< std::set >& r , + vector< std::set >& s ) + { // during user sparsity calculations + size_t m = f_.Range(); + size_t n = f_.Domain(); + if( jac_sparse_bool_.size() != 0 ) + jac_sparse_bool_.clear(); + if( jac_sparse_set_.n_set() == 0 ) + set_jac_sparse_set(); + CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == m ); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.end() == n ); + CPPAD_ASSERT_UNKNOWN( r.size() == n ); + CPPAD_ASSERT_UNKNOWN( s.size() == m ); + bool ok = true; - s = f_.ForSparseJac(q, r); + for(size_t i = 0; i < m; i++) + s[i].clear(); - // no longer need the forward mode sparsity pattern - // (have to reconstruct them every time) - f_.size_forward_bool(0); - - return ok; + // sparsity for s = jac_sparse_set_ * r + for(size_t i = 0; i < m; i++) + { // compute row i of the return pattern + jac_sparse_set_.begin(i); + size_t j = jac_sparse_set_.next_element(); + while(j < n ) + { std::set::const_iterator itr_j; + const std::set& r_j( r[j] ); + for(itr_j = r_j.begin(); itr_j != r_j.end(); itr_j++) + { size_t k = *itr_j; + CPPAD_ASSERT_UNKNOWN( k < q ); + s[i].insert(k); + } + j = jac_sparse_set_.next_element(); + } + } + + return ok; } + // ------------------------------------------------------------------------ /*! - Link from user_atomic to forward sparse Jacobian + Link from user_atomic to reverse sparse Jacobian pack \copydetails atomic_base::rev_sparse_jac - */ + */ virtual bool rev_sparse_jac( size_t q , - const vector< std::set >& rt , - vector< std::set >& st ) - { - bool ok = true; - - // compute rt - // 2DO: remove need for nz_compare all the time. It is only really - // necessary when optimizer calls this member function. - bool transpose = true; - bool nz_compare = true; - st = f_.RevSparseJac(q, rt, transpose, nz_compare); - - return ok; + const vectorBool& rt , + vectorBool& st ) + { return rev_sparse_jac< vectorBool >(q, rt, st); } /*! - Link from user_atomic to forward sparse Jacobian + Link from user_atomic to reverse sparse Jacobian bool \copydetails atomic_base::rev_sparse_jac - */ + */ virtual bool rev_sparse_jac( size_t q , const vector& rt , vector& st ) - { - bool ok = true; + { return rev_sparse_jac< vector >(q, rt, st); + } + /*! + Link from user_atomic to reverse Jacobian sets - // compute rt - bool transpose = true; - bool nz_compare = true; - // 2DO: remove need for nz_compare all the time. It is only really - // necessary when optimizer calls this member function. - st = f_.RevSparseJac(q, rt, transpose, nz_compare); + \copydetails atomic_base::rev_sparse_jac + */ + virtual bool rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st ) + { // during user sparsity calculations + size_t m = f_.Range(); + size_t n = f_.Domain(); + if( jac_sparse_bool_.size() != 0 ) + jac_sparse_bool_.clear(); + if( jac_sparse_set_.n_set() == 0 ) + set_jac_sparse_set(); + CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == m ); + CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.end() == n ); + CPPAD_ASSERT_UNKNOWN( rt.size() == m ); + CPPAD_ASSERT_UNKNOWN( st.size() == n ); + // + bool ok = true; + // + for(size_t j = 0; j < n; j++) + st[j].clear(); + // + // sparsity for s = r * jac_sparse_set_ + // s^T = jac_sparse_set_^T * r^T + for(size_t i = 0; i < m; i++) + { // i is the row index in r^T + std::set::const_iterator itr_i; + const std::set& r_i( rt[i] ); + for(itr_i = r_i.begin(); itr_i != r_i.end(); itr_i++) + { // k is the column index in r^T + size_t k = *itr_i; + CPPAD_ASSERT_UNKNOWN( k < q ); + // + // i is column index in jac_sparse_set^T + jac_sparse_set_.begin(i); + size_t j = jac_sparse_set_.next_element(); + while( j < n ) + { // j is row index in jac_sparse_set^T + st[j].insert(k); + j = jac_sparse_set_.next_element(); + } + } + } - return ok; + return ok; } + // ------------------------------------------------------------------------ /*! - Link from user_atomic to forward sparse Jacobian + Link from user_atomic to reverse sparse Hessian pack \copydetails atomic_base::rev_sparse_hes - */ + */ virtual bool rev_sparse_hes( const vector& vx , const vector& s , vector& t , size_t q , - const vector< std::set >& r , - const vector< std::set >& u , - vector< std::set >& v ) - { size_t n = v.size(); - size_t m = u.size(); - CPPAD_ASSERT_UNKNOWN( r.size() == v.size() ); - CPPAD_ASSERT_UNKNOWN( s.size() == m ); - CPPAD_ASSERT_UNKNOWN( t.size() == n ); - bool ok = true; - bool transpose = true; - std::set::const_iterator itr; - - // compute sparsity pattern for T(x) = S(x) * f'(x) - t = f_.RevSparseJac(1, s); -# ifndef NDEBUG - for(size_t j = 0; j < n; j++) - CPPAD_ASSERT_UNKNOWN( vx[j] || ! t[j] ) -# endif - - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R - // U(x) = g''(y) * f'(x) * R - // S(x) = g'(y) - - // compute sparsity pattern for A(x) = f'(x)^T * U(x) - vector< std::set > a(n); - a = f_.RevSparseJac(q, u, transpose); - - // set version of s - vector< std::set > set_s(1); - CPPAD_ASSERT_UNKNOWN( set_s[0].empty() ); - size_t i; - for(i = 0; i < m; i++) - if( s[i] ) - set_s[0].insert(i); - - // compute sparsity pattern for H(x) = (S(x) * F)''(x) * R - // (store it in v) - f_.ForSparseJac(q, r); - v = f_.RevSparseHes(q, set_s, transpose); - - // compute sparsity pattern for V(x) = A(x) + H(x) - for(i = 0; i < n; i++) - { for(itr = a[i].begin(); itr != a[i].end(); itr++) - { size_t j = *itr; - CPPAD_ASSERT_UNKNOWN( j < q ); - v[i].insert(j); - } - } - - // no longer need the forward mode sparsity pattern - // (have to reconstruct them every time) - f_.size_forward_set(0); - - return ok; + const vectorBool& r , + const vectorBool& u , + vectorBool& v ) + { return rev_sparse_hes< vectorBool >(vx, s, t, q, r, u, v); } /*! - Link from user_atomic to forward sparse Jacobian + Link from user_atomic to reverse sparse Hessian bool \copydetails atomic_base::rev_sparse_hes - */ + */ virtual bool rev_sparse_hes( const vector& vx , const vector& s , @@ -482,46 +896,85 @@ const vector& r , const vector& u , vector& v ) - { - CPPAD_ASSERT_UNKNOWN( r.size() == v.size() ); - CPPAD_ASSERT_UNKNOWN( s.size() == u.size() / q ); - CPPAD_ASSERT_UNKNOWN( t.size() == v.size() / q ); - size_t n = t.size(); + { return rev_sparse_hes< vector >(vx, s, t, q, r, u, v); + } + /*! + Link from user_atomic to reverse sparse Hessian sets + + \copydetails atomic_base::rev_sparse_hes + */ + virtual bool rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vector< std::set >& r , + const vector< std::set >& u , + vector< std::set >& v ) + { size_t n = f_.Domain(); + size_t m = f_.Range(); + CPPAD_ASSERT_UNKNOWN( vx.size() == n ); + CPPAD_ASSERT_UNKNOWN( s.size() == m ); + CPPAD_ASSERT_UNKNOWN( t.size() == n ); + CPPAD_ASSERT_UNKNOWN( r.size() == n ); + CPPAD_ASSERT_UNKNOWN( u.size() == m ); + CPPAD_ASSERT_UNKNOWN( v.size() == n ); + // bool ok = true; - bool transpose = true; - std::set::const_iterator itr; - size_t i, j; + + // make sure hes_sparse_set_ has been set + if( hes_sparse_bool_.size() != 0 ) + hes_sparse_bool_.clear(); + if( hes_sparse_set_.n_set() == 0 ) + set_hes_sparse_set(); + CPPAD_ASSERT_UNKNOWN( hes_sparse_bool_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.n_set() == n ); + CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.end() == n ); // compute sparsity pattern for T(x) = S(x) * f'(x) t = f_.RevSparseJac(1, s); # ifndef NDEBUG - for(j = 0; j < n; j++) + for(size_t j = 0; j < n; j++) CPPAD_ASSERT_UNKNOWN( vx[j] || ! t[j] ) # endif - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R + // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) // compute sparsity pattern for A(x) = f'(x)^T * U(x) - vector a(n * q); + // 2DO: change a to use INTERNAL_SPARSE_SET + bool transpose = true; + vector< std::set > a(n); a = f_.RevSparseJac(q, u, transpose); - // compute sparsity pattern for H(x) =(S(x) * F)''(x) * R - // (store it in v) - f_.ForSparseJac(q, r); - v = f_.RevSparseHes(q, s, transpose); - + // Need sparsity pattern for H(x) = (S(x) * f(x))''(x) * R, + // but use less efficient sparsity for f(x)''(x) * R so that + // hes_sparse_set_ can be used every time this is needed. + for(size_t i = 0; i < n; i++) + { v[i].clear(); + hes_sparse_set_.begin(i); + size_t j = hes_sparse_set_.next_element(); + while( j < n ) + { std::set::const_iterator itr_j; + const std::set& r_j( r[j] ); + for(itr_j = r_j.begin(); itr_j != r_j.end(); itr_j++) + { size_t k = *itr_j; + v[i].insert(k); + } + j = hes_sparse_set_.next_element(); + } + } // compute sparsity pattern for V(x) = A(x) + H(x) - for(i = 0; i < n; i++) - { for(j = 0; j < q; j++) - v[ i * q + j ] |= a[ i * q + j]; + std::set::const_iterator itr; + for(size_t i = 0; i < n; i++) + { for(itr = a[i].begin(); itr != a[i].end(); itr++) + { size_t j = *itr; + CPPAD_ASSERT_UNKNOWN( j < q ); + v[i].insert(j); + } } - // no longer need the forward mode sparsity pattern - // (have to reconstruct them every time) - f_.size_forward_set(0); - return ok; } }; diff -Nru cppad-2015.00.00.9/cppad/local/color_general.hpp cppad-2016.00.00.1/cppad/local/color_general.hpp --- cppad-2015.00.00.9/cppad/local/color_general.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/color_general.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: color_general.hpp 3239 2014-04-28 23:00:17Z bradbell $ */ -# ifndef CPPAD_COLOR_GENERAL_INCLUDED -# define CPPAD_COLOR_GENERAL_INCLUDED +// $Id: color_general.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_COLOR_GENERAL_HPP +# define CPPAD_COLOR_GENERAL_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,22 +21,22 @@ */ // -------------------------------------------------------------------------- /*! -Determine which rows of a general sparse matrix can be computed together; -i.e., do not have non-zero overlapping values. +Determine which rows of a general sparse matrix can be computed together; +i.e., do not have non-zero entries with the same column index. \tparam VectorSize -is a simple vector class with elements of type \c size_t. +is a simple vector class with elements of type size_t. \tparam VectorSet is an unspecified type with the exception that it must support the -operations under \c pattern and the following operations where -\c p is a \c VectorSet object: +operations under pattern and the following operations where +p is a VectorSet object: \n VectorSet p Constructs a new vector of sets object. \n p.resize(ns, ne) -resizes \p to \c ns sets with elements between zero \c ne. +resizes \c p to \c ns sets with elements between zero \c ne. All of the \c ns sets are initially empty. \n p.add_element(s, e) @@ -44,26 +44,26 @@ \param pattern [in] Is a representation of the sparsity pattern for the matrix. -Note that \c color_general does not change the values in \c pattern, -but it is not \c const because its iterator facility modifies some of its +Note that color_general does not change the values in pattern, +but it is not const because its iterator facility modifies some of its internal data. \n m = pattern.n_set() \n sets \c m to the number of rows in the sparse matrix. -All of the row indices are less than this value. +All of the row indices are less than this value. \n n = pattern.end() \n sets \c n to the number of columns in the sparse matrix. -All of the column indices are less than this value. +All of the column indices are less than this value. \n pattern.begin(i) instructs the iterator facility to start iterating over columns in the i-th row of the sparsity pattern. \n j = pattern.next_element() -Sets \c j to the next possibly non-zero column +Sets j to the next possibly non-zero column in the row specified by the previous call to pattern.begin. If there are no more such columns, the value pattern.end() is returned. @@ -72,34 +72,35 @@ is a vector specifying which row indices to compute. \param col [in] -is a vector, with the same size as \c row, +is a vector, with the same size as row, that specifies which column indices to compute. -For each valid index \c k, the index pair +For each valid index k, the index pair (row[k], col[k]) must be present in the sparsity pattern. It may be that some entries in the sparsity pattern do not need to be computed; i.e, do not appear in the set of (row[k], col[k]) entries. \param color [out] -is a vector with size \c m. +is a vector with size m. The input value of its elements does not matter. Upon return, it is a coloring for the rows of the sparse matrix. \n \n -If for come \c i, color[i] == m, then -the i-th row does not appear in the vector \c row. +If for some i, color[i] == m, then +the i-th row does not appear in the vector row. Otherwise, color[i] < m. \n \n Suppose two differen rows, i != r have the same color and -column index \c j is such that both of the pairs +column index j is such that both of the pairs (i, j) and (r, j) appear in the sparsity pattern. It follows that neither of these pairs appear in the set of (row[k], col[k]) entries. \n \n This routine tries to minimize, with respect to the choice of colors, -the maximum, with respct to \c k, of color[ row[k] ]. +the maximum, with respct to k, of color[ row[k] ] +(not counting the indices k for which row[k] == m). */ template void color_general_cppad( @@ -113,8 +114,8 @@ size_t m = pattern.n_set(); size_t n = pattern.end(); - CPPAD_ASSERT_UNKNOWN( col.size() == K ); - CPPAD_ASSERT_UNKNOWN( color.size() == m ); + CPPAD_ASSERT_UNKNOWN( size_t( col.size() ) == K ); + CPPAD_ASSERT_UNKNOWN( size_t( color.size() ) == m ); // We define the set of rows, columns, and pairs that appear // by the set ( row[k], col[k] ) for k = 0, ... , K-1. @@ -161,8 +162,8 @@ Graph Coloring in Optimization Revisited by Assefaw Gebremedhin, Fredrik Maane, Alex Pothen - The algorithm above was modified (by Brad Bell) to take advantage of the - fact that only the entries (subset of the sparsity pattern) specified by + The algorithm above was modified (by Brad Bell) to take advantage of the + fact that only the entries (subset of the sparsity pattern) specified by row and col need to be computed. */ CppAD::vector forbidden(m); @@ -181,11 +182,11 @@ pattern.begin(i); j = pattern.next_element(); while( j != pattern.end() ) - { // for each row that appears with this column + { // for each row that appears with this column c2r_appear.begin(j); r = c2r_appear.next_element(); while( r != c2r_appear.end() ) - { // if this is not the same row, forbid its color + { // if this is not the same row, forbid its color if( (r < i) & (color[r] < m) ) forbidden[ color[r] ] = true; r = c2r_appear.next_element(); @@ -197,7 +198,7 @@ // ----------------------------------------------------- // Forbid colors that destroy results needed for this row. // - // for each column that appears with this row + // for each column that appears with this row r2c_appear.begin(i); j = r2c_appear.next_element(); while( j != r2c_appear.end() ) @@ -206,7 +207,7 @@ not_appear.begin(j); r = not_appear.next_element(); while( r != not_appear.end() ) - { // if this is not the same row, forbid its color + { // if this is not the same row, forbid its color if( (r < i) & (color[r] < m) ) forbidden[ color[r] ] = true; r = not_appear.next_element(); @@ -227,7 +228,7 @@ # if CPPAD_HAS_COLPACK /*! -Colpack version of determining which rows of a sparse matrix +Colpack version of determining which rows of a sparse matrix can be computed together. \copydetails color_general @@ -238,7 +239,7 @@ const VectorSize& row , const VectorSize& col , CppAD::vector& color ) -{ size_t i, j, k; +{ size_t i, j, k; size_t m = pattern.n_set(); size_t n = pattern.end(); diff -Nru cppad-2015.00.00.9/cppad/local/color_symmetric.hpp cppad-2016.00.00.1/cppad/local/color_symmetric.hpp --- cppad-2015.00.00.9/cppad/local/color_symmetric.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/color_symmetric.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -0,0 +1,333 @@ +// $Id: color_symmetric.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_COLOR_SYMMETRIC_HPP +# define CPPAD_COLOR_SYMMETRIC_HPP + +# include + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/*! +\file color_symmetric.hpp +Coloring algorithm for a symmetric sparse matrix. +*/ +// -------------------------------------------------------------------------- +/*! +CppAD algorithm for determining which rows of a symmetric sparse matrix can be +computed together. + +\tparam VectorSize +is a simple vector class with elements of type size_t. + +\tparam VectorSet +is an unspecified type with the exception that it must support the +operations under pattern and the following operations where +p is a VectorSet object: +\n +VectorSet p +Constructs a new vector of sets object. +\n +p.resize(ns, ne) +resizes \c p to ns sets with elements between zero and \c ne. +All of the sets are initially empty. +\n +p.add_element(s, e) +add element \c e to set with index \c s. + +\param pattern [in] +Is a representation of the sparsity pattern for the matrix. +Note that color_symmetric does not change the values in pattern, +but it is not const because its iterator facility modifies some of its +internal data. +\n +m = pattern.n_set() +\n +sets m to the number of rows (and columns) in the sparse matrix. +All of the row indices are less than this value. +\n +n = pattern.end() +\n +sets n to the number of columns in the sparse matrix +(which must be equal to the number of rows). +All of the column indices are less than this value. +\n +pattern.begin(i) +instructs the iterator facility to start iterating over +columns in the i-th row of the sparsity pattern. +\n +j = pattern.next_element() +Sets j to the next possibly non-zero column +in the row specified by the previous call to pattern.begin. +If there are no more such columns, the value +pattern.end() is returned. + +\param row [in/out] +is a vector specifying which row indices to compute. + +\param col [in/out] +is a vector, with the same size as row, +that specifies which column indices to compute. +\n +\n +Input: +For each valid index \c k, the index pair +(row[k], col[k]) must be present in the sparsity pattern. +It may be that some entries in the sparsity pattern do not need to be computed; +i.e, do not appear in the set of +(row[k], col[k]) entries. +\n +\n +Output: +On output, some of row and column indices may have been swapped +\code + std::swap( row[k], col[k] ) +\endcode +So the the the color for row[k] can be used to compute entry +(row[k], col[k]). + +\param color [out] +is a vector with size m. +The input value of its elements does not matter. +Upon return, it is a coloring for the rows of the sparse matrix. +Note that if color[i] == m, then ther is no index k for which +row[k] == i (for the return value of row). +\n +\n +Fix any (i, j) in the sparsity pattern. +Suppose that there is a row index i1 with +i1 != i, color[i1] == color[i] and (i1, j) is in the sparsity pattern. +If follows that for all j1 with +j1 != j and color[j1] == color[j], +(j1, i ) is not in the sparsity pattern. +\n +\n +This routine tries to minimize, with respect to the choice of colors, +the maximum, with respect to k, of color[ row[k] ]. +*/ +template +void color_symmetric_cppad( + VectorSet& pattern , + CppAD::vector& row , + CppAD::vector& col , + CppAD::vector& color ) +{ size_t o1, o2, i1, i2, j1, j2, k1, c1, c2; + + size_t K = row.size(); + size_t m = pattern.n_set(); + CPPAD_ASSERT_UNKNOWN( m == pattern.end() ); + CPPAD_ASSERT_UNKNOWN( color.size() == m ); + CPPAD_ASSERT_UNKNOWN( col.size() == K ); + + // row, column pairs that appear in ( row[k], col[k] ) + CppAD::vector< std::set > pair_needed(m); + std::set::iterator itr1, itr2; + for(k1 = 0; k1 < K; k1++) + { CPPAD_ASSERT_UNKNOWN( pattern.is_element(row[k1], col[k1]) ); + pair_needed[ row[k1] ].insert( col[k1] ); + pair_needed[ col[k1] ].insert( row[k1] ); + } + + // order the rows decending by number of pairs needed + CppAD::vector key(m), order2row(m); + for(i1 = 0; i1 < m; i1++) + { CPPAD_ASSERT_UNKNOWN( pair_needed[i1].size() <= m ); + key[i1] = m - pair_needed[i1].size(); + } + CppAD::index_sort(key, order2row); + + // mapping from order index to row index + CppAD::vector row2order(m); + for(o1 = 0; o1 < m; o1++) + row2order[ order2row[o1] ] = o1; + + // initial coloring + color.resize(m); + c1 = 0; + for(o1 = 0; o1 < m; o1++) + { i1 = order2row[o1]; + if( pair_needed[i1].empty() ) + color[i1] = m; + else + color[i1] = c1++; + } + + // which colors are forbidden for this row + CppAD::vector forbidden(m); + + // must start with row zero so that we remove results computed for it + for(o1 = 0; o1 < m; o1++) // for each row that appears (in order) + if( color[ order2row[o1] ] < m ) + { i1 = order2row[o1]; + c1 = color[i1]; + + // initial all colors as ok for this row + // (value of forbidden for c > c1 does not matter) + for(c2 = 0; c2 <= c1; c2++) + forbidden[c2] = false; + + // ----------------------------------------------------- + // Forbid grouping with rows that would destroy results that are + // needed for this row. + itr1 = pair_needed[i1].begin(); + while( itr1 != pair_needed[i1].end() ) + { // entry (i1, j1) is needed for this row + j1 = *itr1; + + // Forbid rows i2 != i1 that have non-zero sparsity at (i2, j1). + // Note that this is the same as non-zero sparsity at (j1, i2) + pattern.begin(j1); + i2 = pattern.next_element(); + while( i2 != pattern.end() ) + { c2 = color[i2]; + if( c2 < c1 ) + forbidden[c2] = true; + i2 = pattern.next_element(); + } + itr1++; + } + // ----------------------------------------------------- + // Forbid grouping with rows that this row would destroy results for + for(o2 = 0; o2 < o1; o2++) + { i2 = order2row[o2]; + c2 = color[i2]; + itr2 = pair_needed[i2].begin(); + while( itr2 != pair_needed[i2].end() ) + { j2 = *itr2; + // row i2 needs pair (i2, j2). + // Forbid grouping with i1 if (i1, j2) has non-zero sparsity + if( pattern.is_element(i1, j2) ) + forbidden[c2] = true; + itr2++; + } + } + + // pick the color with smallest index + c2 = 0; + while( forbidden[c2] ) + { c2++; + CPPAD_ASSERT_UNKNOWN( c2 <= c1 ); + } + color[i1] = c2; + + // no longer need results that are computed by this row + itr1 = pair_needed[i1].begin(); + while( itr1 != pair_needed[i1].end() ) + { j1 = *itr1; + if( row2order[j1] > o1 ) + { itr2 = pair_needed[j1].find(i1); + if( itr2 != pair_needed[j1].end() ) + { pair_needed[j1].erase(itr2); + if( pair_needed[j1].empty() ) + color[j1] = m; + } + } + itr1++; + } + } + + // determine which sparsity entries need to be reflected + for(k1 = 0; k1 < row.size(); k1++) + { i1 = row[k1]; + j1 = col[k1]; + itr1 = pair_needed[i1].find(j1); + if( itr1 == pair_needed[i1].end() ) + { row[k1] = j1; + col[k1] = i1; +# ifndef NDEBUG + itr1 = pair_needed[j1].find(i1); + CPPAD_ASSERT_UNKNOWN( itr1 != pair_needed[j1].end() ); +# endif + } + } + return; +} + +// -------------------------------------------------------------------------- +/*! +Colpack algorithm for determining which rows of a symmetric sparse matrix +can be computed together. + +\copydetails color_symmetric_cppad +*/ +template +void color_symmetric_colpack( + VectorSet& pattern , + CppAD::vector& row , + CppAD::vector& col , + CppAD::vector& color ) +{ +# if ! CPPAD_HAS_COLPACK + CPPAD_ASSERT_UNKNOWN(false); + return; +# else + size_t i, j, k; + size_t m = pattern.n_set(); + CPPAD_ASSERT_UNKNOWN( m == pattern.end() ); + CPPAD_ASSERT_UNKNOWN( row.size() == col.size() ); + + // Determine number of non-zero entries in each row + CppAD::vector n_nonzero(m); + size_t n_nonzero_total = 0; + for(i = 0; i < m; i++) + { n_nonzero[i] = 0; + pattern.begin(i); + j = pattern.next_element(); + while( j != pattern.end() ) + { n_nonzero[i]++; + j = pattern.next_element(); + } + n_nonzero_total += n_nonzero[i]; + } + + // Allocate memory and fill in Adolc sparsity pattern + CppAD::vector adolc_pattern(m); + CppAD::vector adolc_memory(m + n_nonzero_total); + size_t i_memory = 0; + for(i = 0; i < m; i++) + { adolc_pattern[i] = adolc_memory.data() + i_memory; + adolc_pattern[i][0] = n_nonzero[i]; + pattern.begin(i); + j = pattern.next_element(); + k = 1; + while(j != pattern.end() ) + { adolc_pattern[i][k++] = j; + j = pattern.next_element(); + } + CPPAD_ASSERT_UNKNOWN( k == 1 + n_nonzero[i] ); + i_memory += k; + } + CPPAD_ASSERT_UNKNOWN( i_memory == m + n_nonzero_total ); + + // Must use an external routine for this part of the calculation because + // ColPack/ColPackHeaders.h has as 'using namespace std' at global level. + cppad_colpack_symmetric(color, m, adolc_pattern); + + // determine which sparsity entries need to be reflected + size_t i1, i2, j1, j2, k1, k2; + for(k1 = 0; k1 < row.size(); k1++) + { i1 = row[k1]; + j1 = col[k1]; + bool reflect = false; + for(i2 = 0; i2 < m; i2++) if( (i1 != i2) & (color[i1]==color[i2]) ) + { for(k2 = 1; k2 <= adolc_pattern[i2][0]; k2++) + { j2 = adolc_pattern[i2][k2]; + reflect |= (j1 == j2); + } + } + if( reflect ) + { row[k1] = j1; + col[k1] = i1; + } + } + return; +# endif // CPPAD_HAS_COLPACK +} + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/compare.hpp cppad-2016.00.00.1/cppad/local/compare.hpp --- cppad-2015.00.00.9/cppad/local/compare.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/compare.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: compare.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_COMPARE_INCLUDED -# define CPPAD_COMPARE_INCLUDED +// $Id: compare.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_COMPARE_HPP +# define CPPAD_COMPARE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,19 +23,10 @@ const $$ -$index binary, AD compare operator$$ -$index AD, binary compare operator$$ -$index compare, AD binary operator$$ -$index operator, AD binary compare$$ - -$index <, AD operator$$ -$index <=, AD operator$$ -$index >, AD operator$$ -$index >=, AD operator$$ -$index ==, AD operator$$ -$index !=, AD operator$$ + $section AD Binary Comparison Operators$$ +$mindex compare < <= > >= == !=$$ $head Syntax$$ @@ -46,7 +37,7 @@ $head Purpose$$ Compares two operands where one of the operands is an $codei%AD<%Base%>%$$ object. -The comparison has the same interpretation as for +The comparison has the same interpretation as for the $icode Base$$ type. @@ -61,7 +52,7 @@ $code ==$$ $cnext is $icode x$$ equal to $icode y$$ $rnext $code !=$$ $cnext is $icode x$$ not equal to $icode y$$ $tend - + $head x$$ The operand $icode x$$ has prototype $codei% @@ -91,7 +82,7 @@ $pre $$ -For example, suppose +For example, suppose $icode x$$ and $icode y$$ are $codei%AD<%Base%>%$$ objects, the tape corresponding to $codei%AD<%Base%>%$$ is recording, $icode b$$ is true, @@ -99,22 +90,22 @@ $codei% if( %b% ) %y% = cos(%x%); - else %y% = sin(%x%); + else %y% = sin(%x%); %$$ only the assignment $icode%y% = cos(%x%)%$$ is recorded on the tape -(if $icode x$$ is a $cref/parameter/glossary/Parameter/$$, +(if $icode x$$ is a $cref/parameter/glossary/Parameter/$$, nothing is recorded). The $cref CompareChange$$ function can yield some information about changes in comparison operation results. You can use $cref CondExp$$ to obtain comparison operations -that depends on the -$cref/independent variable/glossary/Tape/Independent Variable/$$ +that depends on the +$cref/independent variable/glossary/Tape/Independent Variable/$$ values with out re-taping the AD sequence of operations. $head Assumptions$$ If one of the $icode Op$$ operators listed above is used with an $codei%AD<%Base%>%$$ object, -it is assumed that the same operator is supported by the base type +it is assumed that the same operator is supported by the base type $icode Base$$. $head Example$$ @@ -132,249 +123,291 @@ // BEGIN CppAD namespace namespace CppAD { -template - -// -------------- RecordCompare(cop, result, left, right) -------------------- -/// All these operations are done in \c Rec_, so we should move this -/// routine to recorder. -void ADTape::RecordCompare( - enum CompareOp cop , - bool result , - const AD &left , - const AD &right ) -{ addr_t ind0, ind1, ind2, ind3; - - // ind[1] = base 2 representation of [result, Var(left), Var(right]) - ind1 = 0; - - // ind[2] = left address - if( Parameter(left) ) - ind2 = Rec_.PutPar(left.value_); - else - { ind1 += 2; - ind2 = left.taddr_; - } - - // ind[3] = right address - if( Parameter(right) ) - ind3 = Rec_.PutPar(right.value_); - else - { ind1 += 4; - ind3 = right.taddr_; - } - - // If both left and right are parameters, do not need to record - if( ind1 == 0 ) - return; - - // ind[1] & 1 = result - if( result ) - ind1+= 1; - - // ind[0] = cop - ind0 = size_t (cop); - - CPPAD_ASSERT_UNKNOWN( ind1 > 1 ); - CPPAD_ASSERT_UNKNOWN( NumArg(ComOp) == 4 ); - CPPAD_ASSERT_UNKNOWN( NumRes(ComOp) == 0 ); - - // put the operator in the tape - Rec_.PutOp(ComOp); - Rec_.PutArg(ind0, ind1, ind2, ind3); -} - -// -------------------------------- < ------------------------- -# ifdef NDEBUG - +// -------------------------------- < -------------------------- template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool operator < (const AD &left , const AD &right) -{ bool result = (left.value_ < right.value_); - return result; -} - -# else -template -CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool operator < (const AD &left , const AD &right) -{ bool result = (left.value_ < right.value_); +{ bool result = (left.value_ < right.value_); + bool var_left = Variable(left); + bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; - if( Variable(left) ) - tape = left.tape_this(); - else if ( Variable(right) ) - tape = right.tape_this(); - - if( tape != CPPAD_NULL ) - tape->RecordCompare(CompareLt, result, left, right); + if( var_left ) + { tape = left.tape_this(); + if( var_right ) + { if( result ) + { tape->Rec_.PutOp(LtvvOp); + tape->Rec_.PutArg(left.taddr_, right.taddr_); + } + else + { tape->Rec_.PutOp(LevvOp); + tape->Rec_.PutArg(right.taddr_, left.taddr_); + } + } + else + { addr_t arg1 = tape->Rec_.PutPar(right.value_); + if( result ) + { tape->Rec_.PutOp(LtvpOp); + tape->Rec_.PutArg(left.taddr_, arg1); + } + else + { tape->Rec_.PutOp(LepvOp); + tape->Rec_.PutArg(arg1, left.taddr_); + } + } + } + else if ( var_right ) + { tape = right.tape_this(); + addr_t arg0 = tape->Rec_.PutPar(left.value_); + if( result ) + { tape->Rec_.PutOp(LtpvOp); + tape->Rec_.PutArg(arg0, right.taddr_); + } + else + { tape->Rec_.PutOp(LevpOp); + tape->Rec_.PutArg(right.taddr_, arg0); + } + } return result; } -# endif - // convert other cases into the case above CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(<) // -------------------------------- <= ------------------------- -# ifdef NDEBUG - -template -CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool operator <= (const AD &left , const AD &right) -{ bool result = (left.value_ <= right.value_); - return result; -} - -# else template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool operator <= (const AD &left , const AD &right) -{ bool result = (left.value_ <= right.value_); +{ bool result = (left.value_ <= right.value_); + bool var_left = Variable(left); + bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; - if( Variable(left) ) - tape = left.tape_this(); - else if ( Variable(right) ) - tape = right.tape_this(); - - if( tape != CPPAD_NULL ) - tape->RecordCompare(CompareLe, result, left, right); + if( var_left ) + { tape = left.tape_this(); + if( var_right ) + { if( result ) + { tape->Rec_.PutOp(LevvOp); + tape->Rec_.PutArg(left.taddr_, right.taddr_); + } + else + { tape->Rec_.PutOp(LtvvOp); + tape->Rec_.PutArg(right.taddr_, left.taddr_); + } + } + else + { addr_t arg1 = tape->Rec_.PutPar(right.value_); + if( result ) + { tape->Rec_.PutOp(LevpOp); + tape->Rec_.PutArg(left.taddr_, arg1); + } + else + { tape->Rec_.PutOp(LtpvOp); + tape->Rec_.PutArg(arg1, left.taddr_); + } + } + } + else if ( var_right ) + { tape = right.tape_this(); + addr_t arg0 = tape->Rec_.PutPar(left.value_); + if( result ) + { tape->Rec_.PutOp(LepvOp); + tape->Rec_.PutArg(arg0, right.taddr_); + } + else + { tape->Rec_.PutOp(LtvpOp); + tape->Rec_.PutArg(right.taddr_, arg0); + } + } return result; } -# endif - // convert other cases into the case above CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(<=) - -// -------------------------------- > ------------------------- -# ifdef NDEBUG - +// -------------------------------- > -------------------------- template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool operator > (const AD &left , const AD &right) -{ bool result = (left.value_ > right.value_); - return result; -} - -# else -template -CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool operator > (const AD &left , const AD &right) -{ bool result = (left.value_ > right.value_); +{ bool result = (left.value_ > right.value_); + bool var_left = Variable(left); + bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; - if( Variable(left) ) - tape = left.tape_this(); - else if ( Variable(right) ) - tape = right.tape_this(); - - if( tape != CPPAD_NULL ) - tape->RecordCompare(CompareGt, result, left, right); - + if( var_left ) + { tape = left.tape_this(); + if( var_right ) + { if( result ) + { tape->Rec_.PutOp(LtvvOp); + tape->Rec_.PutArg(right.taddr_, left.taddr_); + } + else + { tape->Rec_.PutOp(LevvOp); + tape->Rec_.PutArg(left.taddr_, right.taddr_); + } + } + else + { addr_t arg1 = tape->Rec_.PutPar(right.value_); + if( result ) + { tape->Rec_.PutOp(LtpvOp); + tape->Rec_.PutArg(arg1, left.taddr_); + } + else + { tape->Rec_.PutOp(LevpOp); + tape->Rec_.PutArg(left.taddr_, arg1); + } + } + } + else if ( var_right ) + { tape = right.tape_this(); + addr_t arg0 = tape->Rec_.PutPar(left.value_); + if( result ) + { tape->Rec_.PutOp(LtvpOp); + tape->Rec_.PutArg(right.taddr_, arg0); + } + else + { tape->Rec_.PutOp(LepvOp); + tape->Rec_.PutArg(arg0, right.taddr_); + } + } return result; } -# endif - // convert other cases into the case above CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(>) // -------------------------------- >= ------------------------- -# ifdef NDEBUG - -template -CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool operator >= (const AD &left , const AD &right) -{ bool result = (left.value_ >= right.value_); - return result; -} - -# else template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool operator >= (const AD &left , const AD &right) -{ bool result = (left.value_ >= right.value_); +{ bool result = (left.value_ >= right.value_); + bool var_left = Variable(left); + bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; - if( Variable(left) ) - tape = left.tape_this(); - else if ( Variable(right) ) - tape = right.tape_this(); - - if( tape != CPPAD_NULL ) - tape->RecordCompare(CompareGe, result, left, right); + if( var_left ) + { tape = left.tape_this(); + if( var_right ) + { if( result ) + { tape->Rec_.PutOp(LevvOp); + tape->Rec_.PutArg(right.taddr_, left.taddr_); + } + else + { tape->Rec_.PutOp(LtvvOp); + tape->Rec_.PutArg(left.taddr_, right.taddr_); + } + } + else + { addr_t arg1 = tape->Rec_.PutPar(right.value_); + if( result ) + { tape->Rec_.PutOp(LepvOp); + tape->Rec_.PutArg(arg1, left.taddr_); + } + else + { tape->Rec_.PutOp(LtvpOp); + tape->Rec_.PutArg(left.taddr_, arg1); + } + } + } + else if ( var_right ) + { tape = right.tape_this(); + addr_t arg0 = tape->Rec_.PutPar(left.value_); + if( result ) + { tape->Rec_.PutOp(LevpOp); + tape->Rec_.PutArg(right.taddr_, arg0); + } + else + { tape->Rec_.PutOp(LtpvOp); + tape->Rec_.PutArg(arg0, right.taddr_); + } + } return result; } -# endif - // convert other cases into the case above CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(>=) - // -------------------------------- == ------------------------- -# ifdef NDEBUG - template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool operator == (const AD &left , const AD &right) -{ bool result = (left.value_ == right.value_); - return result; -} - -# else -template -CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool operator == (const AD &left , const AD &right) -{ bool result = (left.value_ == right.value_); +{ bool result = (left.value_ == right.value_); + bool var_left = Variable(left); + bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; - if( Variable(left) ) - tape = left.tape_this(); - else if ( Variable(right) ) - tape = right.tape_this(); - - if( tape != CPPAD_NULL ) - tape->RecordCompare(CompareEq, result, left, right); + if( var_left ) + { tape = left.tape_this(); + if( var_right ) + { tape->Rec_.PutArg(left.taddr_, right.taddr_); + if( result ) + tape->Rec_.PutOp(EqvvOp); + else + tape->Rec_.PutOp(NevvOp); + } + else + { addr_t arg1 = tape->Rec_.PutPar(right.value_); + tape->Rec_.PutArg(arg1, left.taddr_); + if( result ) + tape->Rec_.PutOp(EqpvOp); + else + tape->Rec_.PutOp(NepvOp); + } + } + else if ( var_right ) + { tape = right.tape_this(); + addr_t arg0 = tape->Rec_.PutPar(left.value_); + tape->Rec_.PutArg(arg0, right.taddr_); + if( result ) + tape->Rec_.PutOp(EqpvOp); + else + tape->Rec_.PutOp(NepvOp); + } return result; } -# endif - // convert other cases into the case above CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(==) // -------------------------------- != ------------------------- -# ifdef NDEBUG - -template -CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool operator != (const AD &left , const AD &right) -{ bool result = (left.value_ != right.value_); - return result; -} - -# else template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool operator != (const AD &left , const AD &right) -{ bool result = (left.value_ != right.value_); +{ bool result = (left.value_ != right.value_); + bool var_left = Variable(left); + bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; - if( Variable(left) ) - tape = left.tape_this(); - else if ( Variable(right) ) - tape = right.tape_this(); - - if( tape != CPPAD_NULL ) - tape->RecordCompare(CompareNe, result, left, right); + if( var_left ) + { tape = left.tape_this(); + if( var_right ) + { tape->Rec_.PutArg(left.taddr_, right.taddr_); + if( result ) + tape->Rec_.PutOp(NevvOp); + else + tape->Rec_.PutOp(EqvvOp); + } + else + { addr_t arg1 = tape->Rec_.PutPar(right.value_); + tape->Rec_.PutArg(arg1, left.taddr_); + if( result ) + tape->Rec_.PutOp(NepvOp); + else + tape->Rec_.PutOp(EqpvOp); + } + } + else if ( var_right ) + { tape = right.tape_this(); + addr_t arg0 = tape->Rec_.PutPar(left.value_); + tape->Rec_.PutArg(arg0, right.taddr_); + if( result ) + tape->Rec_.PutOp(NepvOp); + else + tape->Rec_.PutOp(EqpvOp); + } return result; } -# endif - // convert other cases into the case above CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(!=) diff -Nru cppad-2015.00.00.9/cppad/local/comp_op.hpp cppad-2016.00.00.1/cppad/local/comp_op.hpp --- cppad-2015.00.00.9/cppad/local/comp_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/comp_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: comp_op.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_COMP_OP_INCLUDED -# define CPPAD_COMP_OP_INCLUDED +// $Id: comp_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_COMP_OP_HPP +# define CPPAD_COMP_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,152 +20,286 @@ Zero order forward mode check how many comparisons changed. */ +// -------------------------------- <= ----------------------------------- /*! -Zero order forward mode execution of op = CompOp. +Zero order forward mode comparison check that left <= right -The C++ source code corresponding to this operation is -\verbatim - left Cop right -\endverbatim -where Cop is one of the following: -<, <=, == , >=, >, !=. - -\tparam Base -base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type -\a Base. +\param count +It the condition is not true, ths counter is incremented by one. + +\param arg +parameter[ arg[0] ] is the left operand and +taylor[ arg[1] * cap_order + 0 ] is the zero order Taylor coefficient +for the right operand. + +\param parameter +vector of parameter values. + +\param cap_order +number of Taylor coefficients allocated for each variable + +\param taylor +vector of taylor coefficients. +*/ +template +inline void forward_lepv_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LepvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LepvOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base x = parameter[ arg[0] ]; + Base* y = taylor + arg[1] * cap_order; + + count += GreaterThanZero(x - y[0]); +} +/*! +Zero order forward mode comparison check that left <= right + +\param count +It the condition is not true, ths counter is incremented by one. + +\param arg +taylor[ arg[0] * cap_order + 0 ] is the zero order Taylor coefficient +for the left operand and parameter[ arg[1] ] is the right operand + +\param parameter +vector of parameter values. + +\param cap_order +number of Taylor coefficients allocated for each variable + +\param taylor +vector of taylor coefficients. +*/ +template +inline void forward_levp_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LevpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LevpOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base y = parameter[ arg[1] ]; + + count += GreaterThanZero(x[0] - y); +} +/*! +Zero order forward mode comparison check that left <= right \param count -If the comparision has the same result as when t operation seqeunce was -recorded, \a count is not affected. -Otherwise it is incremented by one. +It the condition is not true, ths counter is incremented by one. \param arg -\n -\a arg[0] -is static cast to size_t from the enum type -\verbatim - enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, - CompareNe - } -\endverbatim -for this operation. -\n -\n -\a arg[1] & 1 -\n -If this expression is true, -the result of the comparison during taping it true. -Othwise the result if false. -\n -\n -\a arg[1] & 2 -\n -if this expression is true, left is a variable, otherwise it is a parameter. -\n -\n -\a arg[1] & 4 -\n -if this expression is true, right is a variable, otherwise it is a parameter. -\n - -\param num_par -is the lenght of the \a parameter vector. -This value is only used for checking assumptions mentioned below -(and is not used at all when NDEBUG is defined). +taylor[ arg[0] * cap_order + 0 ] is the zero order Taylor coefficient +for the left operand and +taylor[ arg[1] * cap_order + 0 ] is the zero order Taylor coefficient +for the right operand. \param parameter -Vector of parameters corresponding to the tape. -If left is a parameter, \a parameter[ arg[2] ] is its value. -If right is a parameter, \a parameter[ arg[3] ] is its value. +vector of parameter values. \param cap_order -number of columns in the matrix containing the Taylor coefficients. +number of Taylor coefficients allocated for each variable \param taylor -Matrix of Taylor coefficients. -If left is a variable, \a taylor[ arg[2] * cap_order + 0 ] is its value. -If right is a variable, \a taylor[ arg[3] * cap_order + 0 ] is its value. - - -\par Checked Assertions where op is a binary operator: -\li NumArg(ComOp) == 4 -\li NumRes(ComOp) == 0 -\li size_t(arg[0]) <= static_cast( CompareNe ) -\li arg[1] != 0 (either left or right is a variable) -\li if left is a parameter, \a arg[2] < \a num_par -\li if right is a parameter, \a arg[3] < \a num_par - -*/ -template -inline void forward_comp_op_0( - size_t& count , - const addr_t* arg , - size_t num_par , - const Base* parameter , - size_t cap_order , - Base* taylor ) -{ bool result; - Base left; - Base right; - - CPPAD_ASSERT_UNKNOWN( NumArg(ComOp) == 4 ); - CPPAD_ASSERT_UNKNOWN( NumRes(ComOp) == 0 ); - CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= static_cast (CompareNe) ); - CPPAD_ASSERT_UNKNOWN( arg[1] != 0 ); - - // result of comparision during recording - result = (arg[1] & 1) == 1; - - // value of left operand for this forward sweep - if( arg[1] & 2 ) - left = taylor[ arg[2] * cap_order + 0 ]; - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); - left = parameter[ arg[2] ]; - } - - // value of right operand for this forward sweep. - if( arg[1] & 4 ) - right = taylor[ arg[3] * cap_order + 0 ]; - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); - right = parameter[ arg[3] ]; - } - switch( CompareOp( arg[0] ) ) - { case CompareLt: - count += ( result != LessThanZero(left - right) ); - break; - - case CompareLe: - count += ( result != LessThanOrZero(left - right) ); - break; - - case CompareEq: - count += ( result != (left == right) ); - break; - - case CompareGe: - count += ( result != GreaterThanOrZero(left - right) ); - break; - - case CompareGt: - count += ( result != GreaterThanZero(left - right) ); - break; - - case CompareNe: - count += ( result != (left != right) ); - break; - - default: - CPPAD_ASSERT_UNKNOWN(0); - } - return; +vector of taylor coefficients. +*/ +template +inline void forward_levv_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LevvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LevvOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base* y = taylor + arg[1] * cap_order; + + count += GreaterThanZero(x[0] - y[0]); +} +// ------------------------------- < ------------------------------------- +/*! +Zero order forward mode comparison check that left < right + +\copydetails forward_lepv_op_0 +*/ +template +inline void forward_ltpv_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LtpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LtpvOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base x = parameter[ arg[0] ]; + Base* y = taylor + arg[1] * cap_order; + + count += GreaterThanOrZero(x - y[0]); } +/*! +Zero order forward mode comparison check that left < right + +\copydetails forward_levp_op_0 +*/ +template +inline void forward_ltvp_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LtvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LtvpOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base y = parameter[ arg[1] ]; + + count += GreaterThanOrZero(x[0] - y); +} +/*! +Zero order forward mode comparison check that left < right + +\copydetails forward_levv_op_0 +*/ +template +inline void forward_ltvv_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LtvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LtvvOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base* y = taylor + arg[1] * cap_order; + + count += GreaterThanOrZero(x[0] - y[0]); +} +// ------------------------------ == ------------------------------------- +/*! +Zero order forward mode comparison check that left == right + +\copydetails forward_lepv_op_0 +*/ +template +inline void forward_eqpv_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(EqpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(EqpvOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base x = parameter[ arg[0] ]; + Base* y = taylor + arg[1] * cap_order; + + count += (x != y[0]); +} +/*! +Zero order forward mode comparison check that left == right + +\copydetails forward_levv_op_0 +*/ +template +inline void forward_eqvv_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(EqvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(EqvvOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base* y = taylor + arg[1] * cap_order; + + count += (x[0] != y[0]); +} +// -------------------------------- != ----------------------------------- +/*! +Zero order forward mode comparison check that left != right + +\copydetails forward_lepv_op_0 +*/ +template +inline void forward_nepv_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(NepvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(NepvOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base x = parameter[ arg[0] ]; + Base* y = taylor + arg[1] * cap_order; + + count += (x == y[0]); +} +/*! +Zero order forward mode comparison check that left != right + +\copydetails forward_levv_op_0 +*/ +template +inline void forward_nevv_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(NevvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(NevvOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base* y = taylor + arg[1] * cap_order; + + count += (x[0] == y[0]); +} + + } // END_CPPAD_NAMESPACE # endif diff -Nru cppad-2015.00.00.9/cppad/local/compute_assign.hpp cppad-2016.00.00.1/cppad/local/compute_assign.hpp --- cppad-2015.00.00.9/cppad/local/compute_assign.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/compute_assign.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: compute_assign.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_COMPUTE_ASSIGN_INCLUDED -# define CPPAD_COMPUTE_ASSIGN_INCLUDED +// $Id: compute_assign.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_COMPUTE_ASSIGN_HPP +# define CPPAD_COMPUTE_ASSIGN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,31 +23,19 @@ $$ $section AD Computed Assignment Operators$$ +$mindex + add plus - subtract minus * multiply times / divide multiple$$ + + -$index assignment, operator$$ -$index operator, assignment$$ -$index +, computed assignment$$ -$index add, computed assignment$$ -$index plus, computed assignment$$ - -$index -, computed assignment$$ -$index subtract, computed assignment$$ -$index minus, computed assignment$$ - -$index *, computed assignment$$ -$index multiply, computed assignment$$ -$index times, computed assignment$$ -$index /, computed assignment$$ -$index divide, computed assignment$$ $head Syntax$$ $icode%x% %Op% %y%$$ $head Purpose$$ -Performs computed assignment operations -where either $icode x$$ has type +Performs computed assignment operations +where either $icode x$$ has type $codei%AD<%Base%>%$$. $head Op$$ @@ -57,7 +45,7 @@ $code +=$$ $cnext $icode x$$ is assigned $icode x$$ plus $icode y$$ $rnext $code -=$$ $cnext $icode x$$ is assigned $icode x$$ minus $icode y$$ $rnext $code *=$$ $cnext $icode x$$ is assigned $icode x$$ times $icode y$$ $rnext -$code /=$$ $cnext $icode x$$ is assigned $icode x$$ divided by $icode y$$ +$code /=$$ $cnext $icode x$$ is assigned $icode x$$ divided by $icode y$$ $tend $head Base$$ @@ -81,9 +69,7 @@ $code double$$. $head Result$$ -$index assignment, multiple$$ -$index multiple, assignment$$ -The result of this assignment +The result of this assignment can be used as a reference to $icode x$$. For example, if $icode z$$ has the following type $codei% @@ -94,14 +80,14 @@ %z% = %x% += %y% %$$ will compute $icode x$$ plus $icode y$$ -and then assign this value to both $icode x$$ and $icode z$$. +and then assign this value to both $icode x$$ and $icode z$$. $head Operation Sequence$$ This is an $cref/atomic/glossary/Operation/Atomic/$$ $cref/AD of Base/glossary/AD of Base/$$ operation and hence it is part of the current -AD of $icode Base$$ +AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. $children% @@ -122,7 +108,7 @@ $tend $head Derivative$$ -If $latex f$$ and $latex g$$ are +If $latex f$$ and $latex g$$ are $cref/Base functions/glossary/Base Function/$$ $subhead Addition$$ @@ -142,11 +128,11 @@ $subhead Division$$ $latex \[ - \D{[ f(x) / g(x) ]}{x} = + \D{[ f(x) / g(x) ]}{x} = [1/g(x)] * \D{f(x)}{x} - [f(x)/g(x)^2] * \D{g(x)}{x} \] $$ -$end +$end ----------------------------------------------------------------------------- */ # include diff -Nru cppad-2015.00.00.9/cppad/local/cond_exp.hpp cppad-2016.00.00.1/cppad/local/cond_exp.hpp --- cppad-2015.00.00.9/cppad/local/cond_exp.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/cond_exp.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: cond_exp.hpp 3170 2014-03-09 14:33:53Z bradbell $ */ -# ifndef CPPAD_COND_EXP_INCLUDED -# define CPPAD_COND_EXP_INCLUDED +// $Id: cond_exp.hpp 3768 2015-12-28 18:58:35Z bradbell $ +# ifndef CPPAD_COND_EXP_HPP +# define CPPAD_COND_EXP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -35,28 +35,26 @@ Gt $$ -$index conditional, expression$$ -$index expression, conditional$$ -$index assign, conditional$$ $section AD Conditional Expressions$$ +$mindex assign$$ $head Syntax$$ $icode%result% = CondExp%Rel%(%left%, %right%, %if_true%, %if_false%)%$$ $head Purpose$$ -Record, +Record, as part of an AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$, -the conditional result +the conditional result $codei% if( %left% %Cop% %right% ) %result% = %if_true% else %result% = %if_false% %$$ -The relational $icode Rel$$ and comparison operator $icode Cop$$ -above have the following correspondence: +The relational $icode Rel$$ and comparison operator $icode Cop$$ +above have the following correspondence: $codei% %Rel% Lt Le Eq Ge Gt %Cop% < <= == >= > @@ -66,14 +64,14 @@ the assignment choice for $icode result$$ in an AD conditional expression is made each time $cref/f.Forward/Forward/$$ is used to evaluate the zero order Taylor -coefficients with new values for the +coefficients with new values for the $cref/independent variables/glossary/Tape/Independent Variable/$$. This is in contrast to the $cref/AD comparison operators/Compare/$$ -which are boolean valued and not included in the AD operation sequence. +which are boolean valued and not included in the AD operation sequence. $head Rel$$ In the syntax above, the relation $icode Rel$$ represents one of the following -two characters: $code Lt$$, $code Le$$, $code Eq$$, $code Ge$$, $code Gt$$. +two characters: $code Lt$$, $code Le$$, $code Eq$$, $code Ge$$, $code Gt$$. As in the table above, $icode Rel$$ determines which comparison operator $icode Cop$$ is used when comparing $icode left$$ and $icode right$$. @@ -83,14 +81,14 @@ $icode Type$$ is $code float$$ , $code double$$, or any type of the form $codei%AD<%Base%>%$$. (Note that all four arguments must have the same type.) - + $head left$$ The argument $icode left$$ has prototype $codei% const %Type%& %left% %$$ It specifies the value for the left side of the comparison operator. - + $head right$$ The argument $icode right$$ has prototype $codei% @@ -122,21 +120,24 @@ The $cref optimize$$ method will optimize conditional expressions in the following way: During $cref/zero order forward mode/forward_zero/$$, -once the value of the $icode left$$ and $icode right$$ have been determined, +once the value of the $icode left$$ and $icode right$$ have been determined, it is known if the true or false case is required. From this point on, values corresponding to the case that is not required -are not computed. +are not computed. This optimization is done for the rest of zero order forward mode as well as forward and reverse derivatives calculations. There is one exception to this optimization; see -$cref/wish list/WishList/Conditional Expressions/$$. +$cref/optimizing nested conditional expressions + /wish_list + /Optimizing Nested Conditional Expressions +/$$. -$head Deprecated$$ -Previous versions of CppAD used +$head Deprecate 2005-08-07$$ +Previous versions of CppAD used $codei% CondExp(%flag%, %if_true%, %if_false%) %$$ -for the same meaning as +for the same meaning as $codei% CondExpGt(%flag%, %Type%(0), %if_true%, %if_false%) %$$ @@ -158,7 +159,7 @@ %$$ The file $cref cond_exp.cpp$$ -contains an example and test of this function. +contains an example and test of this function. It returns true if it succeeds and false otherwise. $head Atan2$$ @@ -180,9 +181,9 @@ CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION AD CondExpOp( enum CompareOp cop , - const AD &left , - const AD &right , - const AD &if_true , + const AD &left , + const AD &right , + const AD &if_true , const AD &if_false ) { AD returnValue; @@ -230,7 +231,7 @@ } // must use CondExp incase Base is an AD type and recording - returnValue.value_ = CondExpOp(cop, + returnValue.value_ = CondExpOp(cop, left.value_, right.value_, if_true.value_, if_false.value_); ADTape *tape = CPPAD_NULL; @@ -244,8 +245,8 @@ tape = if_false.tape_this(); // add this operation to the tape - if( tape != CPPAD_NULL ) - tape->RecordCondExp(cop, + if( tape != CPPAD_NULL ) + tape->RecordCondExp(cop, returnValue, left, right, if_true, if_false); return returnValue; @@ -287,7 +288,7 @@ ind2 = Rec_.PutPar(left.value_); else { ind1 += 1; - ind2 = left.taddr_; + ind2 = left.taddr_; } // ind[3] = right address @@ -295,7 +296,7 @@ ind3 = Rec_.PutPar(right.value_); else { ind1 += 2; - ind3 = right.taddr_; + ind3 = right.taddr_; } // ind[4] = if_true address @@ -303,7 +304,7 @@ ind4 = Rec_.PutPar(if_true.value_); else { ind1 += 4; - ind4 = if_true.taddr_; + ind4 = if_true.taddr_; } // ind[5] = if_false address @@ -311,7 +312,7 @@ ind5 = Rec_.PutPar(if_false.value_); else { ind1 += 8; - ind5 = if_false.taddr_; + ind5 = if_false.taddr_; } CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); @@ -346,14 +347,14 @@ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION AD CondExp( - const AD &flag , + const AD &flag , const AD &if_true , const AD &if_false ) -{ +{ return CondExpOp(CompareGt, flag, AD(0), if_true, if_false); } # undef CPPAD_COND_EXP } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/cond_op.hpp cppad-2016.00.00.1/cppad/local/cond_op.hpp --- cppad-2015.00.00.9/cppad/local/cond_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/cond_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: cond_op.hpp 3323 2014-09-12 12:10:54Z bradbell $ */ -# ifndef CPPAD_COND_OP_INCLUDED -# define CPPAD_COND_OP_INCLUDED +// $Id: cond_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_COND_OP_HPP +# define CPPAD_COND_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,11 +26,11 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param i_z @@ -42,11 +42,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -99,7 +99,7 @@ template inline void conditional_exp_op( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , const Base* parameter , size_t cap_order ) @@ -115,7 +115,7 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Vector_set is the type used for vectors of sets. It can be either @@ -130,11 +130,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -180,7 +180,7 @@ template inline void sparse_conditional_exp_op( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par ) { // This routine is only for documentation, it should never be used CPPAD_ASSERT_UNKNOWN( false ); @@ -194,11 +194,11 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param i_z @@ -210,11 +210,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -277,13 +277,13 @@ taylor [ arg[2+j] * cap_order + k ] is the k-th order Taylor coefficient corresponding to y_j. \n -\b Input: taylor [ i_z * cap_order + k ] +\b Input: taylor [ i_z * cap_order + k ] for k = 0 , ... , p-1, is the k-th order Taylor coefficient corresponding to z. \n \b Output: taylor [ i_z * cap_order + k ] -for k = p , ... , q, -is the k-th order Taylor coefficient corresponding to z. +for k = p , ... , q, +is the k-th order Taylor coefficient corresponding to z. */ template @@ -291,7 +291,7 @@ size_t p , size_t q , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , const Base* parameter , size_t cap_order , @@ -377,11 +377,11 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param i_z @@ -393,11 +393,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -467,23 +467,23 @@ taylor [ arg[2+j] * tpv + (k-1)*r+1+ell is its k-th order Taylor coefficient in the ell-th direction. \n -\b Input: +\b Input: For j = 0, 1, 2, 3, k = 1, ..., q-1, -taylor [ i_z * tpv + 0 ] +taylor [ i_z * tpv + 0 ] is the zero order Taylor coefficient corresponding to z and taylor [ i_z * tpv + (k-1)*r+1+ell is its k-th order Taylor coefficient in the ell-th direction. \n \b Output: taylor [ i_z * tpv + (q-1)*r+1+ell ] is the q-th order Taylor coefficient corresponding to z -in the ell-th direction. +in the ell-th direction. */ template inline void forward_cond_op_dir( size_t q , size_t r , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , const Base* parameter , size_t cap_order , @@ -547,11 +547,11 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param i_z @@ -563,11 +563,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -624,13 +624,13 @@ \a taylor [ \a arg[2+j] * cap_order + 0 ] is the zero order Taylor coefficient corresponding to y_j. \n -\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] -is the zero order Taylor coefficient corresponding to z. +\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. */ template inline void forward_cond_op_0( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , const Base* parameter , size_t cap_order , @@ -689,9 +689,9 @@ /*! Compute reverse mode Taylor coefficients for op = CExpOp. -This routine is given the partial derivatives of a function +This routine is given the partial derivatives of a function G( z , y , x , w , ... ) -and it uses them to compute the partial derivatives of +and it uses them to compute the partial derivatives of \verbatim H( y , x , w , u , ... ) = G[ z(y) , y , x , w , u , ... ] \endverbatim @@ -702,11 +702,11 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param i_z @@ -718,11 +718,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -782,7 +782,7 @@ \a taylor [ \a arg[2+j] * cap_order + k ] is the k-th order Taylor coefficient corresponding to y_j. \n -\a taylor [ \a i_z * \a cap_order + k ] +\a taylor [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to z. @@ -797,7 +797,7 @@ is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient corresponding to y_j. \n -\b Input: \a partial [ \a i_z * \a cap_order + k ] +\b Input: \a partial [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a d is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient corresponding to z. @@ -814,7 +814,7 @@ inline void reverse_cond_op( size_t d , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , const Base* parameter , size_t cap_order , @@ -888,7 +888,7 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Vector_set is the type used for vectors of sets. It can be either @@ -903,11 +903,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -950,6 +950,14 @@ \li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. +\param dependency +Are the derivatives with respect to left and right of the expression below +considered to be non-zero: +\code + CondExpRel(left, right, if_true, if_false) +\endcode +This is used by the optimizer to obtain the correct dependency relations. + \param sparsity \b Input: if y_2 is a variable, the set with index t is @@ -963,16 +971,17 @@ This identifies which of the independent variables the variable y_3 depends on. \n -\b Output: +\b Output: The set with index T is the sparsity pattern corresponding to z. This identifies which of the independent variables the variable z -depends on. +depends on. */ template inline void forward_sparse_jacobian_cond_op( + bool dependency , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , Vector_set& sparsity ) { @@ -980,43 +989,25 @@ CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); CPPAD_ASSERT_UNKNOWN( NumRes(CExpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( arg[1] != 0 ); - # ifndef NDEBUG - if( arg[1] & 1 ) - { - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); - } - if( arg[1] & 2 ) - { - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); + size_t k = 1; + for( size_t j = 0; j < 4; j++) + { if( ! ( arg[1] & k ) ) + CPPAD_ASSERT_UNKNOWN( size_t(arg[2+j]) < num_par ); + k *= 2; } # endif - if( arg[1] & 4 ) - { - if( arg[1] & 8 ) - { - sparsity.binary_union(i_z, arg[4], arg[5], sparsity); - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < num_par ); - sparsity.assignment(i_z, arg[4], sparsity); - } - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < num_par ); - if( arg[1] & 8 ) - { - sparsity.assignment(i_z, arg[5], sparsity); - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < num_par ); - sparsity.clear(i_z); - } + sparsity.clear(i_z); + if( dependency ) + { if( arg[1] & 1 ) + sparsity.binary_union(i_z, i_z, arg[2], sparsity); + if( arg[1] & 2 ) + sparsity.binary_union(i_z, i_z, arg[3], sparsity); } + if( arg[1] & 4 ) + sparsity.binary_union(i_z, i_z, arg[4], sparsity); + if( arg[1] & 8 ) + sparsity.binary_union(i_z, i_z, arg[5], sparsity); return; } @@ -1025,7 +1016,7 @@ This routine is given the sparsity patterns for a function G(z, y, x, ... ) -and it uses them to compute the sparsity patterns for +and it uses them to compute the sparsity patterns for \verbatim H( y, x, w , u , ... ) = G[ z(x,y) , y , x , w , u , ... ] \endverbatim @@ -1036,7 +1027,7 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Vector_set is the type used for vectors of sets. It can be either @@ -1051,11 +1042,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -1098,7 +1089,7 @@ \li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. -\param nz_compare +\param dependency Are the derivatives with respect to left and right of the expression below considered to be non-zero: \code @@ -1121,7 +1112,7 @@ On input, this pattern corresponds to the function G. On ouput, it corresponds to the function H. \n -\b Output: +\b Output: The set with index T is the sparsity pattern corresponding to z. This identifies which of the dependent variables depend on the variable z. @@ -1129,56 +1120,35 @@ */ template inline void reverse_sparse_jacobian_cond_op( - bool nz_compare , + bool dependency , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , Vector_set& sparsity ) -{ +{ CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < static_cast (CompareNe) ); CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); CPPAD_ASSERT_UNKNOWN( NumRes(CExpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( arg[1] != 0 ); - # ifndef NDEBUG - if( arg[1] & 1 ) - { - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); - } - if( arg[1] & 2 ) - { - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); - } - if( ! ( arg[1] & 4 ) ) - { CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < num_par ); - } - if( ! ( arg[1] & 8 ) ) - { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < num_par ); + size_t k = 1; + for( size_t j = 0; j < 4; j++) + { if( ! ( arg[1] & k ) ) + CPPAD_ASSERT_UNKNOWN( size_t(arg[2+j]) < num_par ); + k *= 2; } # endif - if( nz_compare ) + if( dependency ) { if( arg[1] & 1 ) - { sparsity.binary_union(arg[2], arg[2], i_z, sparsity); - } if( arg[1] & 2 ) - { sparsity.binary_union(arg[3], arg[3], i_z, sparsity); - } } // -------------------------------------------------------------------- if( arg[1] & 4 ) - { sparsity.binary_union(arg[4], arg[4], i_z, sparsity); - } if( arg[1] & 8 ) - { sparsity.binary_union(arg[5], arg[5], i_z, sparsity); - } return; } @@ -1187,7 +1157,7 @@ This routine is given the sparsity patterns for a function G(z, y, x, ... ) -and it uses them to compute the sparsity patterns for +and it uses them to compute the sparsity patterns for \verbatim H( y, x, w , u , ... ) = G[ z(x,y) , y , x , w , u , ... ] \endverbatim @@ -1198,7 +1168,7 @@ \verbatim z = CondExpRel(y_0, y_1, y_2, y_3) \endverbatim -where Rel is one of the following: Lt, Le, Eq, Ge, Gt. +where Rel is one of the following: Lt, Le, Eq, Ge, Gt. \tparam Vector_set is the type used for vectors of sets. It can be either @@ -1213,11 +1183,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -1262,45 +1232,45 @@ \param jac_reverse -\a jac_reverse[i_z] -is false (true) if the Jacobian of G with respect to z is always zero +\a jac_reverse[i_z] +is false (true) if the Jacobian of G with respect to z is always zero (may be non-zero). \n \n -\a jac_reverse[ arg[4] ] +\a jac_reverse[ arg[4] ] If y_2 is a variable, -\a jac_reverse[ arg[4] ] -is false (true) if the Jacobian with respect to y_2 is always zero +\a jac_reverse[ arg[4] ] +is false (true) if the Jacobian with respect to y_2 is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \n \n -\a jac_reverse[ arg[5] ] +\a jac_reverse[ arg[5] ] If y_3 is a variable, -\a jac_reverse[ arg[5] ] -is false (true) if the Jacobian with respect to y_3 is always zero +\a jac_reverse[ arg[5] ] +is false (true) if the Jacobian with respect to y_3 is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \param hes_sparsity -The set with index \a i_z in \a hes_sparsity +The set with index \a i_z in \a hes_sparsity is the Hessian sparsity pattern for the function G where one of the partials is with respect to z. \n \n If y_2 is a variable, -the set with index \a arg[4] in \a hes_sparsity -is the Hessian sparsity pattern +the set with index \a arg[4] in \a hes_sparsity +is the Hessian sparsity pattern where one of the partials is with respect to y_2. On input, this pattern corresponds to the function G. On output, this pattern corresponds to the function H. \n \n If y_3 is a variable, -the set with index \a arg[5] in \a hes_sparsity -is the Hessian sparsity pattern +the set with index \a arg[5] in \a hes_sparsity +is the Hessian sparsity pattern where one of the partials is with respect to y_3. On input, this pattern corresponds to the function G. On output, this pattern corresponds to the function H. @@ -1308,46 +1278,31 @@ template inline void reverse_sparse_hessian_cond_op( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , bool* jac_reverse , Vector_set& hes_sparsity ) -{ +{ CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < static_cast (CompareNe) ); CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); CPPAD_ASSERT_UNKNOWN( NumRes(CExpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( arg[1] != 0 ); - # ifndef NDEBUG - if( arg[1] & 1 ) - { - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); - } - if( arg[1] & 2 ) - { - } - else - { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); - } - if( ! ( arg[1] & 4 ) ) - { CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < num_par ); - } - if( ! ( arg[1] & 8 ) ) - { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < num_par ); + size_t k = 1; + for( size_t j = 0; j < 4; j++) + { if( ! ( arg[1] & k ) ) + CPPAD_ASSERT_UNKNOWN( size_t(arg[2+j]) < num_par ); + k *= 2; } # endif if( arg[1] & 4 ) { - hes_sparsity.binary_union(arg[4], arg[4], i_z, hes_sparsity); jac_reverse[ arg[4] ] |= jac_reverse[i_z]; } if( arg[1] & 8 ) { - hes_sparsity.binary_union(arg[5], arg[5], i_z, hes_sparsity); jac_reverse[ arg[5] ] |= jac_reverse[i_z]; } diff -Nru cppad-2015.00.00.9/cppad/local/config.h.in cppad-2016.00.00.1/cppad/local/config.h.in --- cppad-2015.00.00.9/cppad/local/config.h.in 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/config.h.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* cppad/local/config.h.in. Generated from configure.ac by autoheader. */ - -/* is CPPAD_TESTVECTOR = boost vector (overriden if _MSC_VER defined) */ -#undef CPPAD_BOOSTVECTOR - -/* is CPPAD_TESTVECTOR == CppAD::vector */ -#undef CPPAD_CPPADVECTOR - -/* does system support gettimeofday (overriden if _MSC_VER defined) */ -#undef CPPAD_HAS_GETTIMEOFDAY - -/* is CPPAD_TESTVECTOR == std::vector */ -#undef CPPAD_STDVECTOR - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Version number of package */ -#undef VERSION - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif diff -Nru cppad-2015.00.00.9/cppad/local/convert.hpp cppad-2016.00.00.1/cppad/local/convert.hpp --- cppad-2015.00.00.9/cppad/local/convert.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/convert.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: convert.hpp 2691 2012-12-30 23:39:57Z bradbell $ */ -# ifndef CPPAD_CONVERT_INCLUDED -# define CPPAD_CONVERT_INCLUDED +// $Id: convert.hpp 3769 2015-12-29 16:13:16Z bradbell $ +# ifndef CPPAD_CONVERT_HPP +# define CPPAD_CONVERT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,14 +18,14 @@ $spell $$ -$index convert, from AD$$ -$index AD, convert from$$ $section Conversion and I/O of AD Objects$$ +$mindex convert from$$ $children% cppad/local/value.hpp% cppad/local/integer.hpp% + cppad/local/ad_to_string.hpp% cppad/local/ad_io.hpp% cppad/local/print_for.hpp% cppad/local/var2par.hpp @@ -37,13 +37,14 @@ $rref PrintFor$$ $rref Var2Par$$ $tend - + $end */ # include # include +# include # include # include # include diff -Nru cppad-2015.00.00.9/cppad/local/cosh_op.hpp cppad-2016.00.00.1/cppad/local/cosh_op.hpp --- cppad-2015.00.00.9/cppad/local/cosh_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/cosh_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: cosh_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_COSH_OP_INCLUDED -# define CPPAD_COSH_OP_INCLUDED +// $Id: cosh_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_COSH_OP_HPP +# define CPPAD_COSH_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,9 +43,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(CoshOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(CoshOp) == 2 ); @@ -100,9 +100,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(CoshOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(CoshOp) == 2 ); @@ -151,7 +151,7 @@ inline void forward_cosh_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -188,7 +188,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -211,6 +211,7 @@ const Base* s = c - cap_order; // called y in documentation Base* ps = pc - nc_partial; + // rest of this routine is identical for the following cases: // reverse_sin_op, reverse_cos_op, reverse_sinh_op, reverse_cosh_op. size_t j = d; @@ -221,17 +222,17 @@ pc[j] /= Base(j); for(k = 1; k <= j; k++) { - px[k] += ps[j] * Base(k) * c[j-k]; - px[k] += pc[j] * Base(k) * s[j-k]; - - ps[j-k] += pc[j] * Base(k) * x[k]; - pc[j-k] += ps[j] * Base(k) * x[k]; + px[k] += Base(k) * azmul(ps[j], c[j-k]); + px[k] += Base(k) * azmul(pc[j], s[j-k]); + + ps[j-k] += Base(k) * azmul(pc[j], x[k]); + pc[j-k] += Base(k) * azmul(ps[j], x[k]); } --j; } - px[0] += ps[0] * c[0]; - px[0] += pc[0] * s[0]; + px[0] += azmul(ps[0], c[0]); + px[0] += azmul(pc[0], s[0]); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/cos_op.hpp cppad-2016.00.00.1/cppad/local/cos_op.hpp --- cppad-2015.00.00.9/cppad/local/cos_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/cos_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: cos_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_COS_OP_INCLUDED -# define CPPAD_COS_OP_INCLUDED +// $Id: cos_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_COS_OP_HPP +# define CPPAD_COS_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -42,9 +42,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(CosOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 2 ); @@ -100,9 +100,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(CosOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 2 ); @@ -151,7 +151,7 @@ inline void forward_cos_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -188,7 +188,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -222,17 +222,17 @@ pc[j] /= Base(j); for(k = 1; k <= j; k++) { - px[k] += ps[j] * Base(k) * c[j-k]; - px[k] -= pc[j] * Base(k) * s[j-k]; - - ps[j-k] -= pc[j] * Base(k) * x[k]; - pc[j-k] += ps[j] * Base(k) * x[k]; + px[k] += Base(k) * azmul(ps[j], c[j-k]); + px[k] -= Base(k) * azmul(pc[j], s[j-k]); + + ps[j-k] -= Base(k) * azmul(pc[j], x[k]); + pc[j-k] += Base(k) * azmul(ps[j], x[k]); } --j; } - px[0] += ps[0] * c[0]; - px[0] -= pc[0] * s[0]; + px[0] += azmul(ps[0], c[0]); + px[0] -= azmul(pc[0], s[0]); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/cppad_assert.hpp cppad-2016.00.00.1/cppad/local/cppad_assert.hpp --- cppad-2015.00.00.9/cppad/local/cppad_assert.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/cppad_assert.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: cppad_assert.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_CPPAD_ASSERT_INCLUDED -# define CPPAD_CPPAD_ASSERT_INCLUDED +// $Id: cppad_assert.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_CPPAD_ASSERT_HPP +# define CPPAD_CPPAD_ASSERT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,11 +28,9 @@ bool $$ -$index assert, error macro $$ -$index error, assert macro$$ -$index macro, error assert$$ $section CppAD Assertions During Execution$$ +$mindex assert macro CPPAD_ASSERT_KNOWN CPPAD_ASSERT_UNKNOWN$$ $head Syntax$$ $codei%CPPAD_ASSERT_KNOWN(%exp%, %msg%) @@ -46,8 +44,7 @@ source code that the error is reported at. $head NDEBUG$$ -$index NDEBUG$$ -If the preprocessor symbol +If the preprocessor symbol $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined, these macros do nothing; i.e., they are optimized out. @@ -56,18 +53,16 @@ You can however write your own macros that do not begin with $code CPPAD$$ and that call the $cref/CppAD error handler/ErrorHandler/$$. -$subhead Known$$ -$index CPPAD_ASSERT_KNOWN$$ +$head Known$$ The $code CPPAD_ASSERT_KNOWN$$ macro is used to check for an error with a known cause. For example, many CppAD routines uses these macros to make sure their arguments conform to their specifications. -$subhead Unknown$$ -$index CPPAD_ASSERT_UNKNOWN$$ -The $code CPPAD_ASSERT_UNKNOWN$$ macro is used to check that the +$head Unknown$$ +The $code CPPAD_ASSERT_UNKNOWN$$ macro is used to check that the CppAD internal data structures conform as expected. -If this is not the case, CppAD does not know why the error has +If this is not the case, CppAD does not know why the error has occurred; for example, the user may have written past the end of an allocated array. @@ -75,7 +70,7 @@ The argument $icode exp$$ is a C++ source code expression that results in a $code bool$$ value that should be true. If it is false, an error has occurred. -This expression may be execute any number of times +This expression may be execute any number of times (including zero times) so it must have not side effects. $head Msg$$ @@ -84,11 +79,11 @@ const char *%msg% %$$ and contains a $code '\0'$$ terminated character string. -This string is a description of the error +This string is a description of the error corresponding to $icode exp$$ being false. $head Error Handler$$ -These macros use the +These macros use the $cref/CppAD error handler/ErrorHandler/$$ to report errors. This error handler can be replaced by the user. @@ -98,12 +93,7 @@ # include # include -# include - -# ifdef _OPENMP -# include -# endif - +# include /*! \def CPPAD_ASSERT_KNOWN(exp, msg) @@ -126,7 +116,7 @@ CppAD::ErrorHandler::Call( \ true , \ __LINE__ , \ - __FILE__ , \ + __FILE__ , \ #exp , \ msg ); \ } @@ -152,7 +142,7 @@ CppAD::ErrorHandler::Call( \ false , \ __LINE__ , \ - __FILE__ , \ + __FILE__ , \ #exp , \ "" ); \ } @@ -162,21 +152,21 @@ \def CPPAD_ASSERT_NARG_NRES(op, n_arg, n_res) Check that operator \a op has the specified number of of arguments and results. -If \a NDEBUG is not defined and either the number of arguments +If \a NDEBUG is not defined and either the number of arguments or the number of results are not as expected, execution is terminated and the source code line number is reported. */ # define CPPAD_ASSERT_NARG_NRES(op, n_arg, n_res) \ CPPAD_ASSERT_UNKNOWN( NumArg(op) == n_arg ) \ - CPPAD_ASSERT_UNKNOWN( NumRes(op) == n_res ) + CPPAD_ASSERT_UNKNOWN( NumRes(op) == n_res ) /*! \def CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -Check that the first call to a routine is not during parallel execution mode. +Check that the first call to a routine is not during parallel execution mode. If \c NDEBUG is defined, this macro has no effect (not even the definition of (\c assert_first_call). -Otherwise, the variable +Otherwise, the variable \code static bool assert_first_call \endcode @@ -209,7 +199,7 @@ # else # define CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, result) \ assert_arg_before_result(op, arg, result) - + # endif # endif diff -Nru cppad-2015.00.00.9/cppad/local/cppad_colpack.cpp cppad-2016.00.00.1/cppad/local/cppad_colpack.cpp --- cppad-2015.00.00.9/cppad/local/cppad_colpack.cpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/cppad_colpack.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -/* $Id: cppad_colpack.cpp 3240 2014-04-29 13:12:19Z bradbell $ */ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -# include -# include -# include - -namespace CppAD { - void cppad_colpack_general( - CppAD::vector& color , - size_t m , - size_t n , - const CppAD::vector& adolc_pattern ) - { size_t i, k; - CPPAD_ASSERT_UNKNOWN( adolc_pattern.size() == m ); - - // Use adolc sparsity pattern to create corresponding bipartite graph - ColPack::BipartiteGraphPartialColoringInterface graph( - SRC_MEM_ADOLC, - adolc_pattern.data(), - m, - n - ); - - // row ordered Partial-Distance-Two-Coloring of the bipartite graph - graph.PartialDistanceTwoColoring( - "SMALLEST_LAST", "ROW_PARTIAL_DISTANCE_TWO" - ); - - // Use coloring information to create seed matrix - int n_seed_row; - int n_seed_col; - double** seed_matrix = graph.GetSeedMatrix(&n_seed_row, &n_seed_col); - CPPAD_ASSERT_UNKNOWN( size_t(n_seed_col) == m ); - - // now return coloring in format required by CppAD - for(i = 0; i < m; i++) - color[i] = m; - for(k = 0; k < size_t(n_seed_row); k++) - { for(i = 0; i < m; i++) - { if( seed_matrix[k][i] != 0.0 ) - { // check that no row appears twice in the coloring - CPPAD_ASSERT_UNKNOWN( color[i] == m ); - color[i] = k; - } - } - } -# ifndef NDEBUG - // check that all non-zero rows appear in the coloring - for(i = 0; i < m; i++) - CPPAD_ASSERT_UNKNOWN(color[i] < m || adolc_pattern[i][0] == 0); - - // check that no rows with the same color have overlapping entries - CppAD::vector found(n); - for(k = 0; k < size_t(n_seed_row); k++) - { size_t j, ell; - for(j = 0; j < n; j++) - found[j] = false; - for(i = 0; i < m; i++) if( color[i] == k ) - { for(ell = 0; ell < adolc_pattern[i][0]; ell++) - { j = adolc_pattern[i][1 + ell]; - CPPAD_ASSERT_UNKNOWN( ! found[j] ); - found[j] = true; - } - } - } -# endif - return; - } - // The following routine is not yet used or tested. - void cppad_colpack_symmetric( - CppAD::vector& color , - size_t n , - const CppAD::vector& adolc_pattern ) - { size_t i, k; - CPPAD_ASSERT_UNKNOWN( adolc_pattern.size() == n ); - - // Use adolc sparsity pattern to create corresponding bipartite graph - ColPack::GraphColoringInterface graph( - SRC_MEM_ADOLC, - adolc_pattern.data(), - n - ); - - // Color the graph with the speciied ordering - // graph.Coloring("SMALLEST_LAST", "STAR") is slower in adolc testing - graph.Coloring("SMALLEST_LAST", "ACYCLIC_FOR_INDIRECT_RECOVERY"); - - // Use coloring information to create seed matrix - int n_seed_row; - int n_seed_col; - double** seed_matrix = graph.GetSeedMatrix(&n_seed_row, &n_seed_col); - CPPAD_ASSERT_UNKNOWN( size_t(n_seed_col) == n ); - - // now return coloring in format required by CppAD - for(i = 0; i < n; i++) - color[i] = n; - for(k = 0; k < size_t(n_seed_row); k++) - { for(i = 0; i < n; i++) - { if( seed_matrix[k][i] != 0.0 ) - { CPPAD_ASSERT_UNKNOWN( color[i] == n ); - color[i] = k; - } - } - } -# ifndef NDEBUG - for(i = 0; i < n; i++) - CPPAD_ASSERT_UNKNOWN(color[i] < n || adolc_pattern[i][0] == 0); - - // The coloring above will probably fail this test. - // Check that no rows with the same color have overlapping entries: - CppAD::vector found(n); - for(k = 0; k < size_t(n_seed_row); k++) - { size_t j, ell; - for(j = 0; j < n; j++) - found[j] = false; - for(i = 0; i < n; i++) if( color[i] == k ) - { for(ell = 0; ell < adolc_pattern[i][0]; ell++) - { j = adolc_pattern[i][1 + ell]; - CPPAD_ASSERT_UNKNOWN( ! found[j] ); - found[j] = true; - } - } - } -# endif - return; - } -} diff -Nru cppad-2015.00.00.9/cppad/local/cppad_colpack.hpp cppad-2016.00.00.1/cppad/local/cppad_colpack.hpp --- cppad-2015.00.00.9/cppad/local/cppad_colpack.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/cppad_colpack.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,16 +1,16 @@ -/* $Id: cppad_colpack.hpp 3240 2014-04-29 13:12:19Z bradbell $ */ +// $Id: cppad_colpack.hpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -# ifndef CPPAD_CPPAD_COLPACK_INCLUDED -# define CPPAD_CPPAD_COLPACK_INCLUDED +# ifndef CPPAD_CPPAD_COLPACK_HPP +# define CPPAD_CPPAD_COLPACK_HPP # if CPPAD_HAS_COLPACK namespace CppAD { // BEGIN_CPPAD_NAMESPACE @@ -22,7 +22,7 @@ /*! Link from CppAD to ColPack used for general sparse matrices. -This CppAD library routine is necessary because +This CppAD library routine is necessary because ColPack/ColPackHeaders.h has a using namespace std at the global level. @@ -36,7 +36,7 @@ This vector has size \c m, adolc_pattern[i][0] is the number of non-zeros in row \c i. For j = 1 , ... , adolc_sparsity[i], -adolc_pattern[i][j] is the column index (base zero) for the +adolc_pattern[i][j] is the column index (base zero) for the non-zeros in row \c i. \param color [out] @@ -45,7 +45,7 @@ Upon return, it is a coloring for the rows of the sparse matrix. \n \n -If for some \c i, color[i] == m, then +If for some \c i, color[i] == m, then adolc_pattern[i][0] == 0. Otherwise, color[i] < m. \n @@ -70,7 +70,7 @@ Link from CppAD to ColPack used for symmetric sparse matrices (not yet used or tested). -This CppAD library routine is necessary because +This CppAD library routine is necessary because ColPack/ColPackHeaders.h has a using namespace std at the global level. @@ -81,7 +81,7 @@ This vector has size \c n, adolc_pattern[i][0] is the number of non-zeros in row \c i. For j = 1 , ... , adolc_sparsity[i], -adolc_pattern[i][j] is the column index (base zero) for the +adolc_pattern[i][j] is the column index (base zero) for the non-zeros in row \c i. \param color [out] diff -Nru cppad-2015.00.00.9/cppad/local/cskip_op.hpp cppad-2016.00.00.1/cppad/local/cskip_op.hpp --- cppad-2015.00.00.9/cppad/local/cskip_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/cskip_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: cskip_op.hpp 3370 2014-09-28 10:52:36Z bradbell $ -# ifndef CPPAD_CSKIP_OP_INCLUDED -# define CPPAD_CSKIP_OP_INCLUDED +// $Id: cskip_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_CSKIP_OP_HPP +# define CPPAD_CSKIP_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,10 +22,17 @@ /*! Zero order forward mode execution of op = CSkipOp. +\par Parameters and Variables +The terms parameter and variable depend on if we are referring to its +AD or Base value. +We use Base parameter and Base variable to refer to the +correspond Base value. +We use AD parameter and AD variable to refer to the +correspond AD value. + \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type -\a Base. +using AD and computations by this routine are done using type Base. \param i_z variable index corresponding to the result of the previous operation. @@ -39,11 +46,11 @@ is static cast to size_t from the enum type \verbatim enum CompareOp { - CompareLt, - CompareLe, - CompareEq, - CompareGe, - CompareGt, + CompareLt, + CompareLe, + CompareEq, + CompareGe, + CompareGt, CompareNe } \endverbatim @@ -53,56 +60,60 @@ \n \a arg[1] & 1 \n -If this is zero, left is a a parameter. Otherwise it is a variable. +If this is zero, left is an AD parameter. +Otherwise it is an AD variable. \n \n \a arg[1] & 2 \n -If this is zero, right is a parameter. Otherwise it is a variable. +If this is zero, right is an AD parameter. +Otherwise it is an AD variable. \n -\a arg[2] +\a arg[2] is the index corresponding to left in comparision. \n -\a arg[3] +\a arg[3] is the index corresponding to right in comparision. \n -\a arg[4] +\a arg[4] is the number of operations to skip if the comparision result is true. \n -\a arg[5] +\a arg[5] is the number of operations to skip if the comparision result is false. \n arg[5+i] for i = 1 , ... , arg[4] are the operations to skip if the -comparision result is true. +comparision result is true and both left and right are +identically Base parameters. \n arg[5+arg[4]+i] for i = 1 , ... , arg[5] are the operations to skip if the -comparision result is false. +comparision result is false and both left and right are +identically Base parameters. \param num_par [in] -is the total number of values in the vector \a parameter. +is the total number of values in the vector parameter. \param parameter [in] -If left is a parameter, +If left is an AD parameter, parameter [ arg[2] ] is its value. -If right is a parameter, +If right is an AD parameter, parameter [ arg[3] ] is its value. \param cap_order [in] number of columns in the matrix containing the Taylor coefficients. \param taylor [in] -If left is a variable, +If left is an AD variable, taylor [ arg[2] * cap_order + 0 ] is the zeroth order Taylor coefficient corresponding to left. -If right is a variable, +If right is an AD variable, taylor [ arg[3] * cap_order + 0 ] is the zeroth order Taylor coefficient corresponding to right. -\param \cskip_op [in,out] +\param cskip_op [in,out] is vector specifying which operations are at this point are know to be -unecessary and can be skipped. +unecessary and can be skipped. This is both an input and an output. */ template @@ -123,25 +134,23 @@ { // If varialbe arg[2] <= i_z, it has already been computed, // but it will be skipped for higher orders. left = taylor[ arg[2] * cap_order + 0 ]; - CPPAD_ASSERT_UNKNOWN( IdenticalPar(left) ); } else { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); left = parameter[ arg[2] ]; - CPPAD_ASSERT_UNKNOWN( IdenticalPar(left) ); } if( arg[1] & 2 ) { // If varialbe arg[3] <= i_z, it has already been computed, // but it will be skipped for higher orders. right = taylor[ arg[3] * cap_order + 0 ]; - CPPAD_ASSERT_UNKNOWN( IdenticalPar(right) ); } else { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); right = parameter[ arg[3] ]; - CPPAD_ASSERT_UNKNOWN( IdenticalPar(right) ); } - + bool ok_to_skip = IdenticalPar(left) & IdenticalPar(right); + if( ! ok_to_skip ) + return; // initialize to avoid compiler warning bool true_case = false; @@ -177,11 +186,11 @@ } if( true_case ) { for(size_t i = 0; i < size_t(arg[4]); i++) - cskip_op[ arg[6+i] ] = true; + cskip_op[ arg[6+i] ] = true; } else { for(size_t i = 0; i < size_t(arg[5]); i++) - cskip_op[ arg[6+arg[4]+i] ] = true; + cskip_op[ arg[6+arg[4]+i] ] = true; } return; } diff -Nru cppad-2015.00.00.9/cppad/local/csum_op.hpp cppad-2016.00.00.1/cppad/local/csum_op.hpp --- cppad-2015.00.00.9/cppad/local/csum_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/csum_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: csum_op.hpp 3301 2014-05-24 05:20:21Z bradbell $ -# ifndef CPPAD_CSUM_OP_INCLUDED -# define CPPAD_CSUM_OP_INCLUDED +// $Id: csum_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_CSUM_OP_HPP +# define CPPAD_CSUM_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,7 +22,7 @@ /*! Compute forward mode Taylor coefficients for result of op = CsumOp. -This operation is +This operation is \verbatim z = s + x(1) + ... + x(m) - y(1) - ... - y(n). \endverbatim @@ -43,11 +43,11 @@ i.e. the row index in \a taylor corresponding to z. \param arg -\a arg[0] +\a arg[0] is the number of addition variables in this cummulative summation; i.e., m. \n -\a arg[1] +\a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n @@ -55,10 +55,10 @@ is the parameter value \c s in this cummunative summation. \n arg[2+i] -for i = 1 , ... , m is the variable index of x(i). +for i = 1 , ... , m is the variable index of x(i). \n arg[2+arg[0]+i] -for i = 1 , ... , n is the variable index of y(i). +for i = 1 , ... , n is the variable index of y(i). \param num_par is the number of parameters in \a parameter. @@ -71,12 +71,12 @@ \param taylor \b Input: taylor [ arg[2+i] * cap_order + k ] -for i = 1 , ... , m +for i = 1 , ... , m and k = 0 , ... , q is the k-th order Taylor coefficient corresponding to x(i) \n \b Input: taylor [ arg[2+m+i] * cap_order + k ] -for i = 1 , ... , n +for i = 1 , ... , n and k = 0 , ... , q is the k-th order Taylor coefficient corresponding to y(i) \n @@ -90,8 +90,8 @@ */ template inline void forward_csum_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , size_t num_par , @@ -106,9 +106,9 @@ CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); - CPPAD_ASSERT_UNKNOWN( + CPPAD_ASSERT_UNKNOWN( arg[0] + arg[1] == arg[ arg[0] + arg[1] + 3 ] - ); + ); // Taylor coefficients corresponding to result Base* z = taylor + i_z * cap_order; @@ -124,20 +124,20 @@ x = taylor + arg[++j] * cap_order; for(k = p; k <= q; k++) z[k] += x[k]; - } + } i = arg[1]; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); x = taylor + arg[++j] * cap_order; for(k = p; k <= q; k++) z[k] -= x[k]; - } + } } /*! Multiple direction forward mode Taylor coefficients for op = CsumOp. -This operation is +This operation is \verbatim z = s + x(1) + ... + x(m) - y(1) - ... - y(n). \endverbatim @@ -158,11 +158,11 @@ i.e. the row index in \a taylor corresponding to z. \param arg -\a arg[0] +\a arg[0] is the number of addition variables in this cummulative summation; i.e., m. \n -\a arg[1] +\a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n @@ -170,10 +170,10 @@ is the parameter value \c s in this cummunative summation. \n arg[2+i] -for i = 1 , ... , m is the variable index of x(i). +for i = 1 , ... , m is the variable index of x(i). \n arg[2+arg[0]+i] -for i = 1 , ... , n is the variable index of y(i). +for i = 1 , ... , n is the variable index of y(i). \param num_par is the number of parameters in \a parameter. @@ -186,20 +186,20 @@ \param taylor \b Input: taylor [ arg[2+i]*((cap_order-1)*r + 1) + 0 ] -for i = 1 , ... , m +for i = 1 , ... , m is the 0-th order Taylor coefficient corresponding to x(i) and taylor [ arg[2+i]*((cap_order-1)*r + 1) + (q-1)*r + ell + 1 ] for i = 1 , ... , m, -ell = 0 , ... , r-1 +ell = 0 , ... , r-1 is the q-th order Taylor coefficient corresponding to x(i) and direction ell. \n \b Input: taylor [ arg[2+m+i]*((cap_order-1)*r + 1) + 0 ] -for i = 1 , ... , n +for i = 1 , ... , n is the 0-th order Taylor coefficient corresponding to y(i) and taylor [ arg[2+m+i]*((cap_order-1)*r + 1) + (q-1)*r + ell + 1 ] for i = 1 , ... , n, -ell = 0 , ... , r-1 +ell = 0 , ... , r-1 is the q-th order Taylor coefficient corresponding to y(i) and direction ell. \n @@ -209,8 +209,8 @@ */ template inline void forward_csum_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , size_t num_par , @@ -225,9 +225,9 @@ CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( 0 < q ); CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); - CPPAD_ASSERT_UNKNOWN( + CPPAD_ASSERT_UNKNOWN( arg[0] + arg[1] == arg[ arg[0] + arg[1] + 3 ] - ); + ); // Taylor coefficients corresponding to result size_t num_taylor_per_var = (cap_order-1) * r + 1; @@ -243,23 +243,23 @@ x = taylor + arg[++j] * num_taylor_per_var + m; for(ell = 0; ell < r; ell++) z[ell] += x[ell]; - } + } i = arg[1]; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); x = taylor + arg[++j] * num_taylor_per_var + m; for(ell = 0; ell < r; ell++) z[ell] -= x[ell]; - } + } } /*! Compute reverse mode Taylor coefficients for result of op = CsumOp. -This operation is +This operation is \verbatim z = q + x(1) + ... + x(m) - y(1) - ... - y(n). - H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] + H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] \endverbatim \tparam Base @@ -276,11 +276,11 @@ i.e. the row index in \a taylor corresponding to z. \param arg -\a arg[0] +\a arg[0] is the number of addition variables in this cummulative summation; i.e., m. \n -\a arg[1] +\a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n @@ -288,41 +288,41 @@ is the parameter value \c q in this cummunative summation. \n arg[2+i] -for i = 1 , ... , m is the value x(i). +for i = 1 , ... , m is the value x(i). \n arg[2+arg[0]+i] -for i = 1 , ... , n is the value y(i). +for i = 1 , ... , n is the value y(i). \param nc_partial number of colums in the matrix containing all the partial derivatives. \param partial \b Input: partial [ arg[2+i] * nc_partial + k ] -for i = 1 , ... , m +for i = 1 , ... , m and k = 0 , ... , d is the partial derivative of G(z, y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to x(i) \n \b Input: partial [ arg[2+m+i] * nc_partial + k ] -for i = 1 , ... , n +for i = 1 , ... , n and k = 0 , ... , d is the partial derivative of G(z, y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to y(i) \n \b Input: partial [ i_z * nc_partial + k ] -for i = 1 , ... , n +for i = 1 , ... , n and k = 0 , ... , d is the partial derivative of G(z, y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to \c z. \n \b Output: partial [ arg[2+i] * nc_partial + k ] -for i = 1 , ... , m +for i = 1 , ... , m and k = 0 , ... , d is the partial derivative of H(y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to x(i) \n \b Output: partial [ arg[2+m+i] * nc_partial + k ] -for i = 1 , ... , n +for i = 1 , ... , n and k = 0 , ... , d is the partial derivative of H(y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to y(i) @@ -330,7 +330,7 @@ template inline void reverse_csum_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , size_t nc_partial , @@ -353,7 +353,7 @@ k = d1; while(k--) px[k] += pz[k]; - } + } i = arg[1]; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); @@ -361,14 +361,14 @@ k = d1; while(k--) px[k] -= pz[k]; - } + } } /*! -Forward mode Jacobian sparsity pattern for CSumOp operator. +Forward mode Jacobian sparsity pattern for CSumOp operator. -This operation is +This operation is \verbatim z = q + x(1) + ... + x(m) - y(1) - ... - y(n). \endverbatim @@ -382,11 +382,11 @@ i.e. the index in \a sparsity corresponding to z. \param arg -\a arg[0] +\a arg[0] is the number of addition variables in this cummulative summation; i.e., m + n. \n -\a arg[1] +\a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n @@ -394,31 +394,31 @@ is the parameter value \c q in this cummunative summation. \n arg[2+i] -for i = 1 , ... , m is the value x(i). +for i = 1 , ... , m is the value x(i). \n arg[2+arg[1]+i] -for i = 1 , ... , n is the value y(i). +for i = 1 , ... , n is the value y(i). \param sparsity -\b Input: +\b Input: For i = 1 , ... , m, the set with index \a arg[2+i] in \a sparsity is the sparsity bit pattern for x(i). -This identifies which of the independent variables the variable -x(i) depends on. +This identifies which of the independent variables the variable +x(i) depends on. \n -\b Input: +\b Input: For i = 1 , ... , n, the set with index \a arg[2+arg[0]+i] in \a sparsity is the sparsity bit pattern for x(i). -This identifies which of the independent variables the variable -y(i) depends on. +This identifies which of the independent variables the variable +y(i) depends on. \n -\b Output: +\b Output: The set with index \a i_z in \a sparsity is the sparsity bit pattern for z. This identifies which of the independent variables the variable z -depends on. +depends on. */ template @@ -436,19 +436,19 @@ sparsity.binary_union( i_z , // index in sparsity for result i_z , // index in sparsity for left operand - arg[++j] , // index for right operand + arg[++j] , // index for right operand sparsity // sparsity vector for right operand ); - } + } } /*! -Reverse mode Jacobian sparsity pattern for CSumOp operator. +Reverse mode Jacobian sparsity pattern for CSumOp operator. -This operation is +This operation is \verbatim z = q + x(1) + ... + x(m) - y(1) - ... - y(n). - H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] + H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] \endverbatim \tparam Vector_set @@ -460,11 +460,11 @@ i.e. the index in \a sparsity corresponding to z. \param arg -\a arg[0] +\a arg[0] is the number of addition variables in this cummulative summation; i.e., m + n. \n -\a arg[1] +\a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n @@ -472,27 +472,27 @@ is the parameter value \c q in this cummunative summation. \n arg[2+i] -for i = 1 , ... , m is the value x(i). +for i = 1 , ... , m is the value x(i). \n arg[2+arg[1]+i] -for i = 1 , ... , n is the value y(i). +for i = 1 , ... , n is the value y(i). \param sparsity For i = 1 , ... , m, the set with index \a arg[2+i] in \a sparsity is the sparsity bit pattern for x(i). -This identifies which of the dependent variables depend on x(i). +This identifies which of the dependent variables depend on x(i). On input, the sparsity patter corresponds to \c G, and on ouput it corresponds to \c H. \n For i = 1 , ... , m, the set with index \a arg[2+arg[0]+i] in \a sparsity is the sparsity bit pattern for y(i). -This identifies which of the dependent variables depend on y(i). +This identifies which of the dependent variables depend on y(i). On input, the sparsity patter corresponds to \c G, and on ouput it corresponds to \c H. \n -\b Input: +\b Input: The set with index \a i_z in \a sparsity is the sparsity bit pattern for z. On input it corresponds to \c G and on output it is undefined. @@ -513,18 +513,18 @@ sparsity.binary_union( arg[j] , // index in sparsity for result arg[j] , // index in sparsity for left operand - i_z , // index for right operand + i_z , // index for right operand sparsity // sparsity vector for right operand ); - } + } } /*! -Reverse mode Hessian sparsity pattern for CSumOp operator. +Reverse mode Hessian sparsity pattern for CSumOp operator. -This operation is +This operation is \verbatim z = q + x(1) + ... + x(m) - y(1) - ... - y(n). - H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] + H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] \endverbatim \tparam Vector_set @@ -536,11 +536,11 @@ i.e. the index in \a sparsity corresponding to z. \param arg -\a arg[0] +\a arg[0] is the number of addition variables in this cummulative summation; i.e., m + n. \n -\a arg[1] +\a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n @@ -548,10 +548,10 @@ is the parameter value \c q in this cummunative summation. \n arg[2+i] -for i = 1 , ... , m is the value x(i). +for i = 1 , ... , m is the value x(i). \n arg[2+arg[0]+i] -for i = 1 , ... , n is the value y(i). +for i = 1 , ... , n is the value y(i). \param rev_jacobian rev_jacobian[i_z] @@ -559,7 +559,7 @@ (may be non-zero). \n \n -For i = 1 , ... , m +For i = 1 , ... , m rev_jacobian[ arg[2+i] ] is all false (true) if the Jacobian with respect to x(i) is zero (may be non-zero). @@ -567,7 +567,7 @@ and on output it corresponds to the function H. \n \n -For i = 1 , ... , n +For i = 1 , ... , n rev_jacobian[ arg[2+arg[0]+i] ] is all false (true) if the Jacobian with respect to y(i) is zero (may be non-zero). @@ -580,17 +580,17 @@ where one of the partials derivative is with respect to z. \n \n -For i = 1 , ... , m +For i = 1 , ... , m The set with index arg[2+i] in \a rev_hes_sparsity -is the Hessian sparsity pattern +is the Hessian sparsity pattern where one of the partials derivative is with respect to x(i). On input, it corresponds to the function G, and on output it corresponds to the function H. \n \n -For i = 1 , ... , n +For i = 1 , ... , n The set with index arg[2+arg[0]+i] in \a rev_hes_sparsity -is the Hessian sparsity pattern +is the Hessian sparsity pattern where one of the partials derivative is with respect to y(i). On input, it corresponds to the function G, and on output it corresponds to the function H. @@ -612,11 +612,11 @@ rev_hes_sparsity.binary_union( arg[j] , // index in sparsity for result arg[j] , // index in sparsity for left operand - i_z , // index for right operand + i_z , // index for right operand rev_hes_sparsity // sparsity vector for right operand ); rev_jacobian[arg[j]] |= rev_jacobian[i_z]; - } + } } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/declare_ad.hpp cppad-2016.00.00.1/cppad/local/declare_ad.hpp --- cppad-2015.00.00.9/cppad/local/declare_ad.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/declare_ad.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: declare_ad.hpp 3476 2014-12-16 17:15:01Z bradbell $ */ -# ifndef CPPAD_DECLARE_AD_INCLUDED -# define CPPAD_DECLARE_AD_INCLUDED +// $Id: declare_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DECLARE_AD_HPP +# define CPPAD_DECLARE_AD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,13 +14,13 @@ -------------------------------------------------------------------------- */ # include -# if CPPAD_HAS_CSTDINT_8_TO_64 +# if CPPAD_USE_CPLUSPLUS_2011 # include # endif namespace CppAD { // The conditional expression operator enum type - enum CompareOp + enum CompareOp { CompareLt, // less than CompareLe, // less than or equal CompareEq, // equal @@ -49,7 +49,7 @@ // functions with one VecAD argument template bool Parameter (const VecAD &u); template bool Variable (const VecAD &u); - + // functions with one AD argument template int Integer (const AD &u); template bool Parameter (const AD &u); @@ -104,6 +104,10 @@ template AD pow ( const AD &x, const AD &y); + // azmul + template AD azmul ( + const AD &x, const AD &y); + // NearEqual template bool NearEqual( const AD &x, const AD &y, const Base &r, const Base &a); @@ -113,30 +117,30 @@ template bool NearEqual( const AD &x, const Base &y, const Base &r, const Base &a); - + // CondExpOp template AD CondExpOp ( enum CompareOp cop , - const AD &left , - const AD &right , - const AD &trueCase , - const AD &falseCase + const AD &left , + const AD &right , + const AD &trueCase , + const AD &falseCase ); - + // IdenticalEqualPar - template + template bool IdenticalEqualPar (const AD &u, const AD &v); - + // EqualOpSeq - template + template bool EqualOpSeq (const AD &u, const AD &v); - + // PrintFor - template + template void PrintFor( const AD& flag , const char* before , - const AD& var , + const AD& var , const char* after ); diff -Nru cppad-2015.00.00.9/cppad/local/define.hpp cppad-2016.00.00.1/cppad/local/define.hpp --- cppad-2015.00.00.9/cppad/local/define.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/define.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: define.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_DEFINE_INCLUDED -# define CPPAD_DEFINE_INCLUDED +// $Id: define.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DEFINE_HPP +# define CPPAD_DEFINE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,10 @@ Define processor symbols and macros that are used by CppAD. */ +// ---------------------------------------------------------------------------- /*! \def CPPAD_OP_CODE_TYPE -Is the type used to store enum OpCode values. If not the same as OpCode, then +Is the type used to store enum OpCode values. If not the same as OpCode, then sizeof(CPPAD_OP_CODE_TYPE) <= sizeof( enum OpCode ) to conserve memory. This type must support \c std::numeric_limits, @@ -32,20 +33,21 @@ # define CPPAD_OP_CODE_TYPE unsigned char +// ---------------------------------------------------------------------------- /*! \def CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION A version of the inline command that works with MC compiler. Microsoft Visual C++ version 9.0 generates a warning if a template function is declared as a friend -(this was not a problem for version 7.0). +(this was not a problem for version 7.0). The warning identifier is \verbatim warning C4396 -\endverbatim +\endverbatim and it contains the text \verbatim - the inline specifier cannot be used when a friend declaration refers + the inline specifier cannot be used when a friend declaration refers to a specialization of a function template \endverbatim This happens even if the function is not a specialization. @@ -57,21 +59,24 @@ # define CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION inline # endif +// ---------------------------------------------------------------------------- /*! -\def CPPAD_NULL -This preprocessor symbol is used for a null pointer. - -If it is not yet defined, -it is defined when cppad/local/define.hpp is included. -*/ -# ifndef CPPAD_NULL -# if CPPAD_HAS_NULLPTR -# define CPPAD_NULL nullptr +\def CPPAD_LIB_EXPORT +Special macro for exporting windows DLL symbols; see +https://cmake.org/Wiki/BuildingWinDLL +*/ +# ifdef _MSC_VER +# ifdef cppad_lib_EXPORTS +# define CPPAD_LIB_EXPORT __declspec(dllexport) # else -# define CPPAD_NULL 0 +# define CPPAD_LIB_EXPORT __declspec(dllimport) +# endif // cppad_lib_EXPORTS +# else // _MSC_VER +# define CPPAD_LIB_EXPORT # endif -# endif - + + +// ============================================================================ /*! \def CPPAD_FOLD_ASSIGNMENT_OPERATOR(Op) Declares automatic coercion for certain AD assignment operations. @@ -88,7 +93,7 @@ double. The argument right is const and call by reference. This macro converts the operands to AD and then -uses the definition of the same operation for that case. +uses the definition of the same operation for that case. */ # define CPPAD_FOLD_ASSIGNMENT_OPERATOR(Op) \ @@ -121,8 +126,8 @@ \verbatim left Op right \endverbatim -is defined for the case where left and right -and the result of the operation all +is defined for the case where left and right +and the result of the operation all have type AD. It uses this case to define the cases either left or right has type VecAD_reference or AD @@ -130,7 +135,7 @@ VecAD_reference, AD, Base, double. All of the arguments are const and call by reference. This macro converts the operands to AD and then -uses the definition of the same operation for that case. +uses the definition of the same operation for that case. */ # define CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(Op) \ /* ----------------------------------------------------------------*/ \ @@ -224,7 +229,7 @@ \verbatim left Op right \endverbatim -is defined for the case where left and right +is defined for the case where left and right have type AD and the result has type bool. It uses this case to define the cases either left or right has type @@ -233,7 +238,7 @@ VecAD_reference, AD, Base, double. All of the arguments are const and call by reference. This macro converts the operands to AD and then -uses the definition of the same operation for that case. +uses the definition of the same operation for that case. */ # define CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(Op) \ /* ----------------------------------------------------------------*/ \ diff -Nru cppad-2015.00.00.9/cppad/local/dependent.hpp cppad-2016.00.00.1/cppad/local/dependent.hpp --- cppad-2015.00.00.9/cppad/local/dependent.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/dependent.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: dependent.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_DEPENDENT_INCLUDED -# define CPPAD_DEPENDENT_INCLUDED +// $Id: dependent.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DEPENDENT_HPP +# define CPPAD_DEPENDENT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,7 +14,7 @@ -------------------------------------------------------------------------- */ /* $begin Dependent$$ -$spell +$spell alloc num taylor_ @@ -26,13 +26,8 @@ $$ $section Stop Recording and Store Operation Sequence$$ +$mindex ADFun tape Dependent$$ -$index ADFun, operation sequence$$ -$index operation, sequence store$$ -$index sequence, operation store$$ -$index recording, stop$$ -$index tape, stop recording$$ -$index Dependent$$ $head Syntax$$ $icode%f%.Dependent(%x%, %y%)%$$ @@ -45,15 +40,15 @@ Independent(%x%) %$$ and store the operation sequence in $icode f$$. -The operation sequence defines an +The operation sequence defines an $cref/AD function/glossary/AD Function/$$ $latex \[ F : B^n \rightarrow B^m \] $$ where $latex B$$ is the space corresponding to objects of type $icode Base$$. -The value $latex n$$ is the dimension of the +The value $latex n$$ is the dimension of the $cref/domain/seq_property/Domain/$$ space for the operation sequence. -The value $latex m$$ is the dimension of the +The value $latex m$$ is the dimension of the $cref/range/seq_property/Range/$$ space for the operation sequence (which is determined by the size of $icode y$$). @@ -65,10 +60,10 @@ The AD of $icode Base$$ operation sequence is stored in $icode f$$; i.e., it becomes the operation sequence corresponding to $icode f$$. If a previous operation sequence was stored in $icode f$$, -it is deleted. +it is deleted. $head x$$ -The argument $icode x$$ +The argument $icode x$$ must be the vector argument in a previous call to $cref Independent$$. Neither its size, or any of its values, are allowed to change @@ -76,7 +71,7 @@ $codei% Independent(%x%) %$$ -and +and $codei% %f%.Dependent(%x%, %y%) %$$. @@ -99,7 +94,7 @@ $head Taping$$ The tape, -that was created when $codei%Independent(%x%)%$$ was called, +that was created when $codei%Independent(%x%)%$$ was called, will stop recording. The AD operation sequence will be transferred from the tape to the object $icode f$$ and the tape will then be deleted. @@ -109,18 +104,16 @@ Thus, directly after this operation, $codei% %f%.size_order() -%$$ +%$$ is zero (see $cref size_order$$). $head Parallel Mode$$ -$index parallel, Dependent$$ -$index Dependent, parallel$$ The call to $code Independent$$, and the corresponding call to $codei% ADFun<%Base%> %f%( %x%, %y%) %$$ -or +or $codei% %f%.Dependent( %x%, %y%) %$$ @@ -130,7 +123,7 @@ $head Example$$ The file -$cref fun_check.cpp$$ +$cref fun_check.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. @@ -235,7 +228,7 @@ The dependent variable vector for the function being stored in this object. \par -All of the private member data in ad_fun.hpp is set to correspond to the +All of the private member data in ad_fun.hpp is set to correspond to the new tape except for check_for_nan_. */ @@ -254,7 +247,7 @@ CPPAD_ASSERT_KNOWN( y.size() > 0, "ADFun operation sequence dependent variable size is zero size" - ); + ); // --------------------------------------------------------------------- // Begin setting ad_fun.hpp private member data // --------------------------------------------------------------------- @@ -265,7 +258,7 @@ for(i = 0; i < m; i++) { dep_parameter_[i] = CppAD::Parameter(y[i]); if( dep_parameter_[i] ) - { // make a tape copy of dependent variables that are parameters, + { // make a tape copy of dependent variables that are parameters, y_taddr = tape->RecordParOp( y[i].value_ ); } else y_taddr = y[i].taddr_; @@ -278,10 +271,13 @@ tape->Rec_.PutOp(EndOp); // some size_t values in ad_fun.hpp - compare_change_ = 0; - num_order_taylor_ = 0; - num_direction_taylor_ = 0; - cap_order_taylor_ = 0; + has_been_optimized_ = false; + compare_change_count_ = 1; + compare_change_number_ = 0; + compare_change_op_index_ = 0; + num_order_taylor_ = 0; + num_direction_taylor_ = 0; + cap_order_taylor_ = 0; // num_var_tape_ // Now that all the variables are in the tape, we can set this value. @@ -300,7 +296,7 @@ // play_ // Now that each dependent variable has a place in the tape, - // and there is a EndOp at the end of the tape, we can transfer the + // and there is a EndOp at the end of the tape, we can transfer the // recording to the player and and erase the tape. play_.get(tape->Rec_); @@ -323,7 +319,7 @@ // now we can delete the tape AD::tape_manage(tape_manage_delete); - // total number of varables in this recording + // total number of varables in this recording CPPAD_ASSERT_UNKNOWN( num_var_tape_ == play_.num_var_rec() ); // used to determine if there is an operation sequence in *this diff -Nru cppad-2015.00.00.9/cppad/local/discrete.hpp cppad-2016.00.00.1/cppad/local/discrete.hpp --- cppad-2015.00.00.9/cppad/local/discrete.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/discrete.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: discrete.hpp 3359 2014-09-26 00:12:56Z bradbell $ */ -# ifndef CPPAD_DISCRETE_INCLUDED -# define CPPAD_DISCRETE_INCLUDED +// $Id: discrete.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DISCRETE_HPP +# define CPPAD_DISCRETE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,9 +27,8 @@ $$ $section Discrete AD Functions$$ +$mindex CPPAD_DISCRETE_FUNCTION$$ -$index discrete, AD function$$ -$index function, discrete AD$$ $head Syntax$$ $codei%CPPAD_DISCRETE_FUNCTION(%Base%, %name%) @@ -47,12 +46,12 @@ The value of a discrete function can depend on the $cref/independent variables/glossary/Tape/Independent Variable/$$, but its derivative is identically zero. -For example, suppose that the integer part of -a $cref/variable/glossary/Variable/$$ $icode x$$ is the -index into an array of values. +For example, suppose that the integer part of +a $cref/variable/glossary/Variable/$$ $icode x$$ is the +index into an array of values. $head Base$$ -This is the +This is the $cref/base type/base_require/$$ corresponding to the operations sequence; i.e., use of the $icode name$$ with arguments of type @@ -97,13 +96,12 @@ $head Create AD Version$$ -$index CPPAD_DISCRETE_FUNCTION$$ The preprocessor macro invocation $codei% CPPAD_DISCRETE_FUNCTION(%Base%, %name%) -%$$ +%$$ defines the $codei%AD<%Base%>%$$ version of $icode name$$. -This can be with in a namespace (not the $code CppAD$$ namespace) +This can be with in a namespace (not the $code CppAD$$ namespace) but must be outside of any routine. $head Operation Sequence$$ @@ -120,14 +118,12 @@ All the derivatives of $icode name$$ will be evaluated as zero. $head Parallel Mode$$ -$index discrete, parallel$$ -$index parallel, discrete$$ -The first call to +The first call to $codei% %ay% = %name%(%ax%) %$$ must not be in $cref/parallel/ta_in_parallel/$$ execution mode. - + $head Example$$ $children% @@ -137,7 +133,7 @@ %$$ The file $cref tape_index.cpp$$ -contains an example and test that uses a discrete function +contains an example and test that uses a discrete function to vary an array index during $cref Forward$$ mode calculations. The file $cref interp_onetape.cpp$$ @@ -147,9 +143,7 @@ $cref interp_retape.cpp$$ shows how interpolation can be done with retaping.) -$head Deprecated$$ -$index CppADCreateDiscrete, deprecated$$ -$index deprecated, CppADCreateDiscrete$$ +$head CppADCreateDiscrete Deprecated 2007-07-28$$ The preprocessor symbol $code CppADCreateDiscrete$$ is defined to be the same as $code CPPAD_DISCRETE_FUNCTION$$ but its use is deprecated. @@ -161,7 +155,7 @@ # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -171,13 +165,13 @@ /*! \def CPPAD_DISCRETE_FUNCTION(Base, name) -Defines the function name(ax, ay) +Defines the function name(ax, ay) where \c ax and \c ay are vectors with AD elements. \par Base is the base type for the discrete function. -\par name +\par name is the name of the user defined function that corresponding to this operation. */ @@ -187,7 +181,7 @@ static CppAD::discrete fun(#name, name); \ \ return fun.ad(ax); \ -} +} # define CppADCreateDiscrete CPPAD_DISCRETE_FUNCTION @@ -216,7 +210,7 @@ /*! List of all objects in this class. - If we use CppAD::vector for this vector, it will appear that + If we use CppAD::vector for this vector, it will appear that there is a memory leak because this list is not distroyed before thread_alloc::free_available(thread) is called by the testing routines. */ @@ -242,11 +236,11 @@ This constructor can ont be used in parallel mode because it changes the static object \c List. */ - discrete(const char* Name, F f) : + discrete(const char* Name, F f) : name_(Name) - , f_(f) + , f_(f) , index_( List().size() ) - { + { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "discrete: First call the function *Name is in parallel mode." @@ -255,7 +249,7 @@ } /*! - Implement the user call to ay = name(ax). + Implement the user call to ay = name(ax). \param ax is the argument for this call. @@ -280,7 +274,7 @@ ay.tape_id_ = tape->id_; CPPAD_ASSERT_UNKNOWN( Variable(ay) ); - } + } return ay; } @@ -289,10 +283,10 @@ { return List()[index]->name_.c_str(); } /*! - Link from forward mode sweep to users routine + Link from forward mode sweep to users routine \param index - index for this function in the list of all discrete object + index for this function in the list of all discrete object \param x argument value at which to evaluate this function diff -Nru cppad-2015.00.00.9/cppad/local/discrete_op.hpp cppad-2016.00.00.1/cppad/local/discrete_op.hpp --- cppad-2015.00.00.9/cppad/local/discrete_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/discrete_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: discrete_op.hpp 3321 2014-09-12 09:50:39Z bradbell $ */ -# ifndef CPPAD_DISCRETE_OP_INCLUDED -# define CPPAD_DISCRETE_OP_INCLUDED +// $Id: discrete_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DISCRETE_OP_HPP +# define CPPAD_DISCRETE_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -33,7 +33,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param p @@ -43,17 +43,17 @@ is the highest order Taylor coefficient that will be calculated. \param r -is the number of directions, for each order, +is the number of directions, for each order, that will be calculated (except for order zero wich only has one direction). \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in \a taylor corresponding to z. \param arg \a arg[0] \n -is the index, in the order of the discrete functions defined by the user, +is the index, in the order of the discrete functions defined by the user, for this discrete function. \n \n @@ -75,7 +75,7 @@ \n \b Output: if p == 0 taylor [ i_z * tpv + 0 ] -is the zero order Taylor coefficient corresponding to z. +is the zero order Taylor coefficient corresponding to z. For k = max(p, 1), ... , q, taylor [ i_z * tpv + (k-1)*r + 1 + ell ] is the k-th order Taylor coefficient corresponding to z @@ -94,9 +94,9 @@ size_t r , size_t i_z , const addr_t* arg , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(DisOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(DisOp) == 1 ); diff -Nru cppad-2015.00.00.9/cppad/local/div_eq.hpp cppad-2016.00.00.1/cppad/local/div_eq.hpp --- cppad-2015.00.00.9/cppad/local/div_eq.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/div_eq.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: div_eq.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_DIV_EQ_INCLUDED -# define CPPAD_DIV_EQ_INCLUDED +// $Id: div_eq.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DIV_EQ_HPP +# define CPPAD_DIV_EQ_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -51,7 +51,7 @@ else if( IdenticalOne( right.value_ ) ) { // this = variable * 1 } - else + else { // this = variable / parameter CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(DivvpOp) == 2 ); @@ -90,4 +90,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/div.hpp cppad-2016.00.00.1/cppad/local/div.hpp --- cppad-2015.00.00.9/cppad/local/div.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/div.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: div.hpp 2773 2013-03-09 06:00:18Z bradbell $ */ -# ifndef CPPAD_DIV_INCLUDED -# define CPPAD_DIV_INCLUDED +// $Id: div.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DIV_HPP +# define CPPAD_DIV_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -98,4 +98,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/div_op.hpp cppad-2016.00.00.1/cppad/local/div_op.hpp --- cppad-2015.00.00.9/cppad/local/div_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/div_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: div_op.hpp 3321 2014-09-12 09:50:39Z bradbell $ */ -# ifndef CPPAD_DIV_OP_INCLUDED -# define CPPAD_DIV_OP_INCLUDED +// $Id: div_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DIV_OP_HPP +# define CPPAD_DIV_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,8 +36,8 @@ template inline void forward_divvv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -82,8 +82,8 @@ template inline void forward_divvv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -108,7 +108,7 @@ size_t m = (q-1) * r + 1; for(size_t ell = 0; ell < r; ell++) { z[m+ell] = x[m+ell] - z[0] * y[m+ell]; - for(size_t k = 1; k < q; k++) + for(size_t k = 1; k < q; k++) z[m+ell] -= z[(q-k-1)*r+1+ell] * y[(k-1)*r+1+ell]; z[m+ell] /= y[0]; } @@ -165,7 +165,7 @@ template inline void reverse_divvv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -191,6 +191,7 @@ // Using CondExp, it can make sense to divide by zero // so do not make it an error. + Base inv_y0 = Base(1) / y[0]; size_t k; // number of indices to access @@ -198,14 +199,14 @@ while(j) { --j; // scale partial w.r.t. z[j] - pz[j] /= y[0]; + pz[j] = azmul(pz[j], inv_y0); px[j] += pz[j]; for(k = 1; k <= j; k++) - { pz[j-k] -= pz[j] * y[k]; - py[k] -= pz[j] * z[j-k]; - } - py[0] -= pz[j] * z[j]; + { pz[j-k] -= azmul(pz[j], y[k] ); + py[k] -= azmul(pz[j], z[j-k]); + } + py[0] -= azmul(pz[j], z[j]); } } @@ -225,8 +226,8 @@ template inline void forward_divpv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -275,8 +276,8 @@ template inline void forward_divpv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -355,7 +356,7 @@ template inline void reverse_divpv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -380,6 +381,7 @@ // Using CondExp, it can make sense to divide by zero so do not // make it an error. + Base inv_y0 = Base(1) / y[0]; size_t k; // number of indices to access @@ -387,13 +389,13 @@ while(j) { --j; // scale partial w.r.t z[j] - pz[j] /= y[0]; + pz[j] = azmul(pz[j], inv_y0); for(k = 1; k <= j; k++) - { pz[j-k] -= pz[j] * y[k]; - py[k] -= pz[j] * z[j-k]; - } - py[0] -= pz[j] * z[j]; + { pz[j-k] -= azmul(pz[j], y[k] ); + py[k] -= azmul(pz[j], z[j-k] ); + } + py[0] -= azmul(pz[j], z[j]); } } @@ -414,8 +416,8 @@ template inline void forward_divvp_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -435,7 +437,7 @@ // Parameter value Base y = parameter[ arg[1] ]; - // Using CondExp and multiple levels of AD, it can make sense + // Using CondExp and multiple levels of AD, it can make sense // to divide by zero so do not make it an error. for(size_t d = p; d <= q; d++) z[d] = x[d] / y; @@ -455,8 +457,8 @@ template inline void forward_divvp_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -477,7 +479,7 @@ // Parameter value Base y = parameter[ arg[1] ]; - // Using CondExp and multiple levels of AD, it can make sense + // Using CondExp and multiple levels of AD, it can make sense // to divide by zero so do not make it an error. size_t m = (q-1)*r + 1; for(size_t ell = 0; ell < r; ell++) @@ -535,7 +537,7 @@ template inline void reverse_divvp_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -559,12 +561,13 @@ // Using CondExp, it can make sense to divide by zero // so do not make it an error. + Base inv_y = Base(1) / y; // number of indices to access size_t j = d + 1; while(j) { --j; - px[j] += pz[j] / y; + px[j] += azmul(pz[j], inv_y); } } diff -Nru cppad-2015.00.00.9/cppad/local/drivers.hpp cppad-2016.00.00.1/cppad/local/drivers.hpp --- cppad-2015.00.00.9/cppad/local/drivers.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/drivers.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: drivers.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_DRIVERS_INCLUDED -# define CPPAD_DRIVERS_INCLUDED +// $Id: drivers.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DRIVERS_HPP +# define CPPAD_DRIVERS_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-08 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,12 +18,9 @@ $spell $$ -$index forward, easy driver$$ -$index reverse, easy driver$$ -$index easy, driver$$ -$index driver, easy$$ $section First and Second Derivatives: Easy Drivers$$ +$mindex forward reverse$$ $childtable% @@ -47,5 +44,5 @@ # include # include # include - + # endif diff -Nru cppad-2015.00.00.9/cppad/local/epsilon.hpp cppad-2016.00.00.1/cppad/local/epsilon.hpp --- cppad-2015.00.00.9/cppad/local/epsilon.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/epsilon.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: epsilon.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_EPSILON_INCLUDED -# define CPPAD_EPSILON_INCLUDED +// $Id: epsilon.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_EPSILON_HPP +# define CPPAD_EPSILON_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,15 +22,12 @@ namespace const $$ -$index AD, epsilon$$ -$index epsilon, AD$$ $section Machine Epsilon For AD Types$$ -$head Deprecated$$ -$index deprecated, epsilon$$ -This routine has bee deprecated. -You should use the $cref/numeric_limits/limits/$$ $code epsilon$$ instead. +$head Deprecated 2012-06-17$$ +This routine has been deprecated. +You should use the $cref numeric_limits$$ $code epsilon$$ instead. $head Syntax$$ $icode%eps% = epsilon<%Float%>()%$$ @@ -49,17 +46,15 @@ %Float% eps %$$ -$end +$end ------------------------------------------------------------------------------ */ namespace CppAD { - template - inline ADtype epsilon(void) - { typedef typename ADtype::value_type value_type; - return ADtype ( epsilon() ); - } + template + inline Type epsilon(void) + { return Type ( numeric_limits::epsilon() ); } } # endif diff -Nru cppad-2015.00.00.9/cppad/local/equal_op_seq.hpp cppad-2016.00.00.1/cppad/local/equal_op_seq.hpp --- cppad-2015.00.00.9/cppad/local/equal_op_seq.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/equal_op_seq.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: equal_op_seq.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_EQUAL_OP_SEQ_INCLUDED -# define CPPAD_EQUAL_OP_SEQ_INCLUDED +// $Id: equal_op_seq.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_EQUAL_OP_SEQ_HPP +# define CPPAD_EQUAL_OP_SEQ_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,19 +15,16 @@ /* ------------------------------------------------------------------------------ -$begin EqualOpSeq$$ +$begin EqualOpSeq$$ $spell Op const bool $$ -$index EqualOpSeq$$ -$index operation, equal sequence$$ -$index sequence, equal operation$$ -$index equal, operation sequence$$ $section Check if Two Value are Identically Equal$$ +$mindex EqualOpSeq operation sequence$$ $head Syntax$$ $icode%b% = EqualOpSeq(%x%, %y%)%$$ @@ -42,10 +39,10 @@ $head Motivation$$ Sometimes it is useful to cache information and only recalculate when a function's arguments change. -In the case of AD variables, +In the case of AD variables, it may be important not only when the argument values are equal, but when they are related to the -$cref/independent variables/glossary/Tape/Independent Variable/$$ +$cref/independent variables/glossary/Tape/Independent Variable/$$ by the same operation sequence. After the assignment $codei% @@ -74,7 +71,7 @@ The result is true if and only if one of the following cases holds: $list number$$ -Both $icode x$$ and $icode y$$ are variables +Both $icode x$$ and $icode y$$ are variables and correspond to the same operation sequence. $lnext Both $icode x$$ and $icode y$$ are parameters, @@ -97,7 +94,7 @@ It returns true if it succeeds and false otherwise. -$end +$end ------------------------------------------------------------------------------ */ @@ -106,7 +103,7 @@ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool EqualOpSeq(const AD &x, const AD &y) - { + { if( Parameter(x) ) { if( Parameter(y) ) return EqualOpSeq(x.value_, y.value_); @@ -117,7 +114,7 @@ return (x.taddr_ == y.taddr_); } - + } # endif diff -Nru cppad-2015.00.00.9/cppad/local/erf.hpp cppad-2016.00.00.1/cppad/local/erf.hpp --- cppad-2015.00.00.9/cppad/local/erf.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/erf.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: erf.hpp 3495 2014-12-24 01:16:15Z bradbell $ -# ifndef CPPAD_ERF_INCLUDED -# define CPPAD_ERF_INCLUDED +// $Id: erf.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ERF_HPP +# define CPPAD_ERF_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,72 +16,47 @@ /* ------------------------------------------------------------------------------- $begin erf$$ - -$section The AD Error Function$$ $spell + erf + const + Vec std cmath + CppAD Vedder - Cpp - namespace - Vec - erf - const $$ - -$index erf, AD function$$ -$index error, AD function$$ -$index function, error AD$$ +$section The Error Function$$ $head Syntax$$ $icode%y% = erf(%x%)%$$ - $head Description$$ Returns the value of the error function which is defined by $latex \[ {\rm erf} (x) = \frac{2}{ \sqrt{\pi} } \int_0^x \exp( - t * t ) \; {\bf d} t \] $$ -$head x$$ -The argument $icode x$$, and the result $icode y$$ -have one of the following paris of prototypes: -$codei% - const float%% &%x%, float%% %y% - const double%% &%x%, double%% %y% - const AD<%Base%> &%x%, AD<%Base%> %y% - const VecAD<%Base%>::reference &%x%, AD<%Base%> %y% -%$$ - - -$head Operation Sequence$$ -The AD of $icode Base$$ -operation sequence used to calculate $icode y$$ is -$cref/independent/glossary/Operation/Independent/$$ -of $icode x$$. - -$head Method$$ - -$subhead CPPAD_COMPILER_HAS_ERF$$ -$index CPPAD_COMPILER_HAS_ERF$$ -This preprocessor symbol is one if -the function $codei%std::erf(double %x%)%$$ is defined the in the -include file $code $$. -Otherwise this preprocessor symbol is zero. -If this preprocessor symbols is one, -CppAD uses the compiler's version of $code erf$$ -and it corresponds to an $cref/atomic/glossary/Operation/Atomic/$$ operation. - -$subhead Other$$ -If the function $codei%std::erf(double %x%)%$$ is not defined, -CppAD uses a fast approximation (few numerical operations) +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head CPPAD_USE_CPLUSPLUS_2011$$ + +$subhead true$$ +If this preprocessor symbol is true ($code 1$$), +and $icode x$$ is an AD type, +this is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$subhead false$$ +If this preprocessor symbol is false ($code 0$$), +CppAD uses a fast approximation (few numerical operations) with relative error bound $latex 4 \times 10^{-4}$$; see Vedder, J.D., $icode Simple approximations for the error function and its inverse$$, -American Journal of Physics, -v 55, -n 8, -1987, +American Journal of Physics, +v 55, +n 8, +1987, p 762-3. $head Example$$ @@ -90,28 +65,23 @@ %$$ The file $cref erf.cpp$$ -contains an example and test of this function. +contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ # include -# include - -// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include - -# if ! CPPAD_COMPILER_HAS_ERF +# if ! CPPAD_USE_CPLUSPLUS_2011 // BEGIN CppAD namespace -namespace CppAD { +namespace CppAD { template Type erf_template(const Type &x) { using CppAD::exp; const Type a = static_cast(993./880.); - const Type b = static_cast(89./880.); + const Type b = static_cast(89./880.); return tanh( (a + b * x * x) * x ); } @@ -133,5 +103,5 @@ } // END CppAD namespace -# endif // CPPAD_COMPILER_HAS_ERF +# endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_ERF_INCLUDED diff -Nru cppad-2015.00.00.9/cppad/local/erf_op.hpp cppad-2016.00.00.1/cppad/local/erf_op.hpp --- cppad-2015.00.00.9/cppad/local/erf_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/erf_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,10 +1,10 @@ -/* $Id$ */ -# ifndef CPPAD_ERF_OP_INCLUDED -# define CPPAD_ERF_OP_INCLUDED -# if CPPAD_COMPILER_HAS_ERF +// $Id$ +# ifndef CPPAD_ERF_OP_HPP +# define CPPAD_ERF_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -105,7 +105,7 @@ const Base* parameter , size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(ErfOp) == 5 ); @@ -351,7 +351,7 @@ const Base* taylor , size_t nc_partial , Base* partial ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(ErfOp) == 5 ); @@ -360,6 +360,15 @@ // array used to pass parameter values for sub-operations addr_t addr[2]; + // If pz is zero, make sure this operation has no effect + // (zero times infinity or nan would be non-zero). + Base* pz = partial + i_z * nc_partial; + bool skip(true); + for(size_t i_d = 0; i_d <= d; i_d++) + skip &= IdenticalZero(pz[i_d]); + if( skip ) + return; + // convert from final result to first result i_z -= 4; // 4 = NumRes(ErfOp) - 1; @@ -379,12 +388,12 @@ while(j) { pz_4[j] /= Base(j); for(size_t k = 1; k <= j; k++) - { px[k] += pz_4[j] * z_3[j-k] * Base(k); - pz_3[j-k] += pz_4[j] * x[k] * Base(k); + { px[k] += azmul(pz_4[j], z_3[j-k]) * Base(k); + pz_3[j-k] += azmul(pz_4[j], x[k]) * Base(k); } j--; } - px[0] += pz_4[0] * z_3[0]; + px[0] += azmul(pz_4[0], z_3[0]); // z_3 = (2 / sqrt(pi)) * exp( - x * x ) addr[0] = arg[2]; // 2 / sqrt(pi) @@ -416,5 +425,5 @@ } // END_CPPAD_NAMESPACE -# endif // CPPAD_COMPILER_HAS_ERF +# endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_ERF_OP_INCLUDED diff -Nru cppad-2015.00.00.9/cppad/local/expm1.hpp cppad-2016.00.00.1/cppad/local/expm1.hpp --- cppad-2015.00.00.9/cppad/local/expm1.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/expm1.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,97 @@ +// $Id$ +# ifndef CPPAD_EXPM1_HPP +# define CPPAD_EXPM1_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin expm1$$ +$spell + exp + expm1 + const + Vec + std + cmath + CppAD +$$ +$section The Exponential Function Minus One: expm1$$ + +$head Syntax$$ +$icode%y% = expm1(%x%)%$$ + +$head Description$$ +Returns the value of the exponential function minus one which is defined +by $icode%y% == exp(%x%) - 1%$$. + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head CPPAD_USE_CPLUSPLUS_2011$$ + +$subhead true$$ +If this preprocessor symbol is true ($code 1$$), +and $icode x$$ is an AD type, +this is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$subhead false$$ +If this preprocessor symbol is false ($code 0$$), +CppAD uses the representation +$latex \[ +\R{expm1} (x) = \exp(x) - 1 +\] $$ +to compute this function. + +$head Example$$ +$children% + example/expm1.cpp +%$$ +The file +$cref expm1.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +*/ +# include +# if ! CPPAD_USE_CPLUSPLUS_2011 + +// BEGIN CppAD namespace +namespace CppAD { + +template +Type expm1_template(const Type &x) +{ return CppAD::exp(x) - Type(1); +} + +inline float expm1(const float &x) +{ return expm1_template(x); } + +inline double expm1(const double &x) +{ return expm1_template(x); } + +template +inline AD expm1(const AD &x) +{ return expm1_template(x); } + +template +inline AD expm1(const VecAD_reference &x) +{ return expm1_template( x.ADBase() ); } + + +} // END CppAD namespace + +# endif // CPPAD_USE_CPLUSPLUS_2011 +# endif // CPPAD_EXPM1_INCLUDED diff -Nru cppad-2015.00.00.9/cppad/local/expm1_op.hpp cppad-2016.00.00.1/cppad/local/expm1_op.hpp --- cppad-2015.00.00.9/cppad/local/expm1_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/expm1_op.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,201 @@ +// $Id$ +# ifndef CPPAD_EXPM1_OP_HPP +# define CPPAD_EXPM1_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file expm1_op.hpp +Forward and reverse mode calculations for z = expm1(x). +*/ + + +/*! +Forward mode Taylor coefficient for result of op = Expm1Op. + +The C++ source code corresponding to this operation is +\verbatim + z = expm1(x) +\endverbatim + +\copydetails forward_unary1_op +*/ +template +inline void forward_expm1_op( + size_t p , + size_t q , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(Expm1Op) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(Expm1Op) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + + size_t k; + if( p == 0 ) + { z[0] = expm1( x[0] ); + p++; + } + for(size_t j = p; j <= q; j++) + { + z[j] = x[1] * z[j-1]; + for(k = 2; k <= j; k++) + z[j] += Base(k) * x[k] * z[j-k]; + z[j] /= Base(j); + z[j] += x[j]; + } +} + + +/*! +Multiple direction forward mode Taylor coefficient for op = Expm1Op. + +The C++ source code corresponding to this operation is +\verbatim + z = expm1(x) +\endverbatim + +\copydetails forward_unary1_op_dir +*/ +template +inline void forward_expm1_op_dir( + size_t q , + size_t r , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(Expm1Op) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(Expm1Op) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + + // Taylor coefficients corresponding to argument and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + i_x * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + + size_t m = (q-1)*r + 1; + for(size_t ell = 0; ell < r; ell++) + { z[m+ell] = Base(q) * x[m+ell] * z[0]; + for(size_t k = 1; k < q; k++) + z[m+ell] += Base(k) * x[(k-1)*r+ell+1] * z[(q-k-1)*r+ell+1]; + z[m+ell] /= Base(q); + z[m+ell] += x[m+ell]; + } +} + +/*! +Zero order forward mode Taylor coefficient for result of op = Expm1Op. + +The C++ source code corresponding to this operation is +\verbatim + z = expm1(x) +\endverbatim + +\copydetails forward_unary1_op_0 +*/ +template +inline void forward_expm1_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(Expm1Op) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(Expm1Op) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = expm1( x[0] ); +} +/*! +Reverse mode partial derivatives for result of op = Expm1Op. + +The C++ source code corresponding to this operation is +\verbatim + z = expm1(x) +\endverbatim + +\copydetails reverse_unary1_op +*/ + +template +inline void reverse_expm1_op( + size_t d , + size_t i_z , + size_t i_x , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(Expm1Op) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(Expm1Op) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Taylor coefficients and partials corresponding to argument + const Base* x = taylor + i_x * cap_order; + Base* px = partial + i_x * nc_partial; + + // Taylor coefficients and partials corresponding to result + const Base* z = taylor + i_z * cap_order; + Base* pz = partial + i_z * nc_partial; + + // If pz is zero, make sure this operation has no effect + // (zero times infinity or nan would be non-zero). + bool skip(true); + for(size_t i_d = 0; i_d <= d; i_d++) + skip &= IdenticalZero(pz[i_d]); + if( skip ) + return; + + // loop through orders in reverse + size_t j, k; + j = d; + while(j) + { px[j] += pz[j]; + + // scale partial w.r.t z[j] + pz[j] /= Base(j); + + for(k = 1; k <= j; k++) + { px[k] += Base(k) * azmul(pz[j], z[j-k]); + pz[j-k] += Base(k) * azmul(pz[j], x[k]); + } + --j; + } + px[0] += pz[0] + azmul(pz[0], z[0]); +} + +} // END_CPPAD_NAMESPACE +# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/exp_op.hpp cppad-2016.00.00.1/cppad/local/exp_op.hpp --- cppad-2015.00.00.9/cppad/local/exp_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/exp_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: exp_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_EXP_OP_INCLUDED -# define CPPAD_EXP_OP_INCLUDED +// $Id: exp_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_EXP_OP_HPP +# define CPPAD_EXP_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -37,9 +37,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ExpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(ExpOp) == 1 ); @@ -81,9 +81,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ExpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(ExpOp) == 1 ); @@ -93,7 +93,7 @@ // Taylor coefficients corresponding to argument and result size_t num_taylor_per_var = (cap_order-1) * r + 1; Base* x = taylor + i_x * num_taylor_per_var; - Base* z = taylor + i_z * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; size_t m = (q-1)*r + 1; for(size_t ell = 0; ell < r; ell++) @@ -118,7 +118,7 @@ inline void forward_exp_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -148,7 +148,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -167,6 +167,14 @@ const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; + // If pz is zero, make sure this operation has no effect + // (zero times infinity or nan would be non-zero). + bool skip(true); + for(size_t i_d = 0; i_d <= d; i_d++) + skip &= IdenticalZero(pz[i_d]); + if( skip ) + return; + // loop through orders in reverse size_t j, k; j = d; @@ -175,12 +183,12 @@ pz[j] /= Base(j); for(k = 1; k <= j; k++) - { px[k] += pz[j] * Base(k) * z[j-k]; - pz[j-k] += pz[j] * Base(k) * x[k]; + { px[k] += Base(k) * azmul(pz[j], z[j-k]); + pz[j-k] += Base(k) * azmul(pz[j], x[k]); } --j; } - px[0] += pz[0] * z[0]; + px[0] += azmul(pz[0], z[0]); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/for_jac_sweep.hpp cppad-2016.00.00.1/cppad/local/for_jac_sweep.hpp --- cppad-2015.00.00.9/cppad/local/for_jac_sweep.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/for_jac_sweep.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,8 +1,8 @@ -/* $Id: for_jac_sweep.hpp 3639 2015-02-11 02:01:35Z bradbell $ */ -# ifndef CPPAD_FOR_JAC_SWEEP_INCLUDED -# define CPPAD_FOR_JAC_SWEEP_INCLUDED +// $Id: for_jac_sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FOR_JAC_SWEEP_HPP +# define CPPAD_FOR_JAC_SWEEP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -62,6 +62,14 @@ is the type used for vectors of sets. It can be either \c sparse_pack, \c sparse_set, or \c sparse_list. +\param dependency +Are the derivatives with respect to left and right of the expression below +considered to be non-zero: +\code + CondExpRel(left, right, if_true, if_false) +\endcode +This is used by the optimizer to obtain the correct dependency relations. + \param n is the number of independent variables on the tape. @@ -99,6 +107,7 @@ template void ForJacSweep( + bool dependency , size_t n , size_t numvar , player* play , @@ -160,6 +169,9 @@ vector bool_r; // bool sparsity pattern for the argument x vector bool_s; // bool sparisty pattern for the result y // + vectorBool pack_r; // pack sparsity pattern for the argument x + vectorBool pack_s; // pack sparisty pattern for the result y + // const size_t user_q = limit; // maximum element plus one size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator @@ -169,7 +181,9 @@ size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator - bool user_bool = false; // use bool or set sparsity ? + bool user_pack = false; // sparsity pattern type is pack + bool user_bool = false; // sparsity pattern type is bool + bool user_set = false; // sparsity pattern type is set # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif @@ -231,6 +245,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AcoshOp: + // sqrt(x * x - 1), acosh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; +# endif + // ------------------------------------------------- + case AsinOp: // sqrt(1 - x * x), asin(x) CPPAD_ASSERT_NARG_NRES(op, 1, 2); @@ -240,6 +265,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AsinhOp: + // sqrt(1 + x * x), asinh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; +# endif + // ------------------------------------------------- + case AtanOp: // 1 + x * x, atan(x) CPPAD_ASSERT_NARG_NRES(op, 1, 2); @@ -249,6 +285,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AtanhOp: + // 1 - x * x, atanh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; +# endif + // ------------------------------------------------- + case CSkipOp: // CSipOp has a variable number of arguments and // forward_next thinks it has no arguments. @@ -270,15 +317,9 @@ case CExpOp: forward_sparse_jacobian_cond_op( - i_var, arg, num_par, var_sparsity + dependency, i_var, arg, num_par, var_sparsity ); break; - // --------------------------------------------------- - - case ComOp: - CPPAD_ASSERT_NARG_NRES(op, 4, 0); - CPPAD_ASSERT_UNKNOWN( arg[1] > 1 ); - break; // -------------------------------------------------- case CosOp: @@ -301,7 +342,12 @@ case DisOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); - var_sparsity.clear(i_var); + // derivative is identically zero but dependency is not + if( dependency ) forward_sparse_jacobian_unary_op( + i_var, arg[1], var_sparsity + ); + else + var_sparsity.clear(i_var); break; // ------------------------------------------------- @@ -336,6 +382,8 @@ // ------------------------------------------------- case ErfOp: + // arg[1] is always the parameter 0 + // arg[0] is always the parameter 2 / sqrt(pi) CPPAD_ASSERT_NARG_NRES(op, 3, 5); forward_sparse_jacobian_unary_op( i_var, arg[0], var_sparsity @@ -351,6 +399,16 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + forward_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; +# endif + // ------------------------------------------------- + case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); // sparsity pattern is already defined @@ -359,6 +417,7 @@ case LdpOp: forward_sparse_load_op( + dependency, op, i_var, arg, @@ -372,6 +431,7 @@ case LdvOp: forward_sparse_load_op( + dependency, op, i_var, arg, @@ -383,6 +443,20 @@ break; // ------------------------------------------------- + case EqpvOp: + case EqvvOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NepvOp: + case NevvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + break; + // ------------------------------------------------- + case LogOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); forward_sparse_jacobian_unary_op( @@ -391,12 +465,14 @@ break; // ------------------------------------------------- - case MulvvOp: - CPPAD_ASSERT_NARG_NRES(op, 2, 1); - forward_sparse_jacobian_binary_op( - i_var, arg, var_sparsity +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + forward_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity ); break; +# endif // ------------------------------------------------- case MulpvOp: @@ -407,6 +483,14 @@ break; // ------------------------------------------------- + case MulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + case ParOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); var_sparsity.clear(i_var); @@ -444,9 +528,12 @@ case SignOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); - forward_sparse_jacobian_unary_op( + // derivative is identically zero but dependency is not + if( dependency ) forward_sparse_jacobian_unary_op( i_var, arg[0], var_sparsity ); + else + var_sparsity.clear(i_var); break; // ------------------------------------------------- @@ -478,12 +565,14 @@ case StppOp: CPPAD_ASSERT_NARG_NRES(op, 3, 0); - // storing a parameter does not affect vector sparsity + // if both arguments are parameters does not affect sparsity + // or dependency break; // ------------------------------------------------- case StpvOp: forward_sparse_store_op( + dependency, op, arg, num_vecad_ind, @@ -496,12 +585,21 @@ case StvpOp: CPPAD_ASSERT_NARG_NRES(op, 3, 0); - // storing a parameter does not affect vector sparsity + forward_sparse_store_op( + dependency, + op, + arg, + num_vecad_ind, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); break; // ------------------------------------------------- case StvvOp: forward_sparse_store_op( + dependency, op, arg, num_vecad_ind, @@ -572,8 +670,22 @@ CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif + user_pack = user_atom->sparsity() == + atomic_base::pack_sparsity_enum; user_bool = user_atom->sparsity() == atomic_base::bool_sparsity_enum; + user_set = user_atom->sparsity() == + atomic_base::set_sparsity_enum; + CPPAD_ASSERT_UNKNOWN( user_pack || user_bool || user_set ); + if( user_pack ) + { if( pack_r.size() != user_n * user_q ) + pack_r.resize( user_n * user_q ); + if( pack_s.size() != user_m * user_q ) + pack_s.resize( user_m * user_q ); + for(i = 0; i < user_n; i++) + for(j = 0; j < user_q; j++) + pack_r[ i * user_q + j] = false; + } if( user_bool ) { if( bool_r.size() != user_n * user_q ) bool_r.resize( user_n * user_q ); @@ -583,7 +695,7 @@ for(j = 0; j < user_q; j++) bool_r[ i * user_q + j] = false; } - else + if( user_set) { if(set_r.size() != user_n ) set_r.resize(user_n); if(set_s.size() != user_m ) @@ -605,7 +717,13 @@ if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) - + ": atomic_base.for_sparse_jac: returned false"; + + ": atomic_base.for_sparse_jac: returned false\n"; + if( user_pack ) + msg += "sparsity = pack_sparsity_enum"; + if( user_bool ) + msg += "sparsity = bool_sparsity_enum"; + if( user_set ) + msg += "sparsity = set_sparsity_enum"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif @@ -623,14 +741,12 @@ if( user_j == user_n ) { // call users function for this operation user_atom->set_id(user_id); + if( user_pack ) + CPPAD_ATOMIC_CALL( user_q, pack_r, pack_s); if( user_bool ) - CPPAD_ATOMIC_CALL( - user_q, bool_r, bool_s - ); - else - CPPAD_ATOMIC_CALL( - user_q, set_r, set_s - ); + CPPAD_ATOMIC_CALL( user_q, bool_r, bool_s); + if( user_set ) + CPPAD_ATOMIC_CALL( user_q, set_r, set_s); user_state = user_ret; } break; @@ -644,9 +760,11 @@ var_sparsity.begin(arg[0]); i = var_sparsity.next_element(); while( i < user_q ) - { if( user_bool ) + { if( user_pack ) + pack_r[user_j * user_q + i] = true; + if( user_bool ) bool_r[user_j * user_q + i] = true; - else + if( user_set ) set_r[user_j].insert(i); i = var_sparsity.next_element(); } @@ -654,14 +772,12 @@ if( user_j == user_n ) { // call users function for this operation user_atom->set_id(user_id); + if( user_pack ) + CPPAD_ATOMIC_CALL( user_q, pack_r, pack_s); if( user_bool ) - CPPAD_ATOMIC_CALL( - user_q, bool_r, bool_s - ); - else - CPPAD_ATOMIC_CALL( - user_q, set_r, set_s - ); + CPPAD_ATOMIC_CALL( user_q, bool_r, bool_s); + if( user_set ) + CPPAD_ATOMIC_CALL( user_q, set_r, set_s); user_state = user_ret; } break; @@ -681,12 +797,17 @@ CPPAD_ASSERT_UNKNOWN( user_i < user_m ); // It might be faster if we add set union to var_sparsity // where one of the sets is not in var_sparsity + if( user_pack ) + { for(j = 0; j < user_q; j++) + if( pack_s[ user_i * user_q + j ] ) + var_sparsity.add_element(i_var, j); + } if( user_bool ) { for(j = 0; j < user_q; j++) if( bool_s[ user_i * user_q + j ] ) var_sparsity.add_element(i_var, j); } - else + if( user_set ) { set_itr = set_s[user_i].begin(); set_end = set_s[user_i].end(); while( set_itr != set_end ) @@ -698,6 +819,30 @@ break; // ------------------------------------------------- + case ZmulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, arg[1], var_sparsity + ); + break; + // ------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; + // ------------------------------------------------- + + case ZmulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + default: CPPAD_ASSERT_UNKNOWN(0); } diff -Nru cppad-2015.00.00.9/cppad/local/for_one.hpp cppad-2016.00.00.1/cppad/local/for_one.hpp --- cppad-2015.00.00.9/cppad/local/for_one.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/for_one.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: for_one.hpp 2683 2012-12-30 18:17:03Z bradbell $ */ -# ifndef CPPAD_FOR_ONE_INCLUDED -# define CPPAD_FOR_ONE_INCLUDED +// $Id: for_one.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FOR_ONE_HPP +# define CPPAD_FOR_ONE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,15 +23,10 @@ $$ -$index partial, first order driver$$ -$index first, order partial driver$$ -$index driver, first order partial$$ - -$index easy, partial$$ -$index driver, easy partial$$ -$index partial, easy$$ + $section First Order Partial Derivative: Driver Routine$$ +$mindex easy$$ $head Syntax$$ $icode%dy% = %f%.ForOne(%x%, %j%)%$$ @@ -43,10 +38,10 @@ The syntax above sets $icode dy$$ to the partial of $latex F$$ with respect to $latex x_j$$; i.e., $latex \[ -dy -= \D{F}{ x_j } (x) -= \left[ - \D{ F_0 }{ x_j } (x) , \cdots , \D{ F_{m-1} }{ x_j } (x) +dy += \D{F}{ x_j } (x) += \left[ + \D{ F_0 }{ x_j } (x) , \cdots , \D{ F_{m-1} }{ x_j } (x) \right] \] $$ @@ -64,7 +59,7 @@ const %Vector% &%x% %$$ (see $cref/Vector/ForOne/Vector/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. It specifies @@ -77,7 +72,7 @@ %$$ an is less than $icode n$$, $cref/domain/seq_property/Domain/$$ space for $icode f$$. -It specifies the component of $icode F$$ +It specifies the component of $icode F$$ for which we are computing the partial derivative. $head dy$$ @@ -105,7 +100,7 @@ $head ForOne Uses Forward$$ After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After a call to $code ForOne$$, the zero order Taylor coefficients correspond to @@ -116,7 +111,7 @@ $children% example/for_one.cpp %$$ -The routine +The routine $cref/ForOne/for_one.cpp/$$ is both an example and test. It returns $code true$$, if it succeeds and $code false$$ otherwise. @@ -141,7 +136,7 @@ CPPAD_ASSERT_KNOWN( x.size() == n, "ForOne: Length of x not equal domain dimension for f" - ); + ); CPPAD_ASSERT_KNOWN( j < n, "ForOne: the index j is not less than domain dimension for f" diff -Nru cppad-2015.00.00.9/cppad/local/for_sparse_jac.hpp cppad-2016.00.00.1/cppad/local/for_sparse_jac.hpp --- cppad-2015.00.00.9/cppad/local/for_sparse_jac.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/for_sparse_jac.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: for_sparse_jac.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_FOR_SPARSE_JAC_INCLUDED -# define CPPAD_FOR_SPARSE_JAC_INCLUDED +// $Id: for_sparse_jac.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FOR_SPARSE_JAC_HPP +# define CPPAD_FOR_SPARSE_JAC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,19 +24,17 @@ Bool proportional VecAD + CondExpRel + optimizer + cpp $$ -$section Jacobian Sparsity Pattern: Forward Mode$$ - -$index ForSparseJac$$ -$index forward, sparsity Jacobian$$ -$index sparsity, forward Jacobian$$ -$index pattern, forward Jacobian$$ +$section Jacobian Sparsity Pattern: Forward Mode$$ $head Syntax$$ $icode%s% = %f%.ForSparseJac(%q%, %r%) %$$ -$icode%s% = %f%.ForSparseJac(%q%, %r%, %transpose%)%$$ +$icode%s% = %f%.ForSparseJac(%q%, %r%, %transpose%, %dependency%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the @@ -48,7 +46,7 @@ S(x) = F^{(1)} ( x ) * R \] $$ Given a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R$$, $code ForSparseJac$$ returns a sparsity pattern for the $latex S(x)$$. @@ -64,9 +62,9 @@ These sparsity patterns are stored with elements of type $code bool$$ or elements of type $code std::set$$ (see $cref/VectorSet/ForSparseJac/VectorSet/$$ below). - + $subhead size_forward_bool$$ -After $code ForSparseJac$$, if $icode k$$ is a $code size_t$$ object, +After $code ForSparseJac$$, if $icode k$$ is a $code size_t$$ object, $codei% %k% = %f%.size_forward_bool() %$$ @@ -78,15 +76,15 @@ the return value for $code size_forward_bool$$ will be non-zero. Otherwise, its return value will be zero. This sparsity pattern is stored for use by $cref RevSparseHes$$ and -when it is not longer needed, it can be deleted -(and the corresponding memory freed) using +when it is not longer needed, it can be deleted +(and the corresponding memory freed) using $codei% %f%.size_forward_bool(0) %$$ After this call, $icode%f%.size_forward_bool()%$$ will return zero. - + $subhead size_forward_set$$ -After $code ForSparseJac$$, if $icode k$$ is a $code size_t$$ object, +After $code ForSparseJac$$, if $icode k$$ is a $code size_t$$ object, $codei% %k% = %f%.size_forward_set() %$$ @@ -97,7 +95,7 @@ Otherwise, its return value will be non-zero (unless the entire sparsity pattern is false). This sparsity pattern is stored for use by $cref RevSparseHes$$ and -when it is not longer needed, it can be deleted +when it is not longer needed, it can be deleted (and the corresponding memory freed) using $codei% %f%.size_forward_set(0) @@ -105,7 +103,7 @@ After this call, $icode%f%.size_forward_set()%$$ will return zero. $head x$$ -the sparsity pattern is valid for all values of the independent +the sparsity pattern is valid for all values of the independent variables in $latex x \in B^n$$ (even if it has $cref CondExp$$ or $cref VecAD$$ operations). @@ -114,9 +112,9 @@ $codei% size_t %q% %$$ -It specifies the number of columns in -$latex R \in B^{n \times q}$$ and the Jacobian -$latex S(x) \in B^{m \times q}$$. +It specifies the number of columns in +$latex R \in B^{n \times q}$$ and the Jacobian +$latex S(x) \in B^{m \times q}$$. $head transpose$$ The argument $icode transpose$$ has prototype @@ -125,6 +123,14 @@ %$$ The default value $code false$$ is used when $icode transpose$$ is not present. +$head dependency$$ +The argument $icode dependency$$ has prototype +$codei% + bool %dependency% +%$$ +If $icode dependency$$ is true, +the $cref/dependency pattern/dependency.cpp/Dependency Pattern/$$ +(instead of sparsity pattern) is computed. $head r$$ The argument $icode r$$ has prototype @@ -139,9 +145,9 @@ If it has elements of type $code std::set$$, its size is $latex n$$ and all the set elements must be between zero and $icode%q%-1%$$ inclusive. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ -for the matrix $icode R \in B^{n \times q}$$. +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +for the matrix $latex R \in B^{n \times q}$$. $subhead transpose true$$ If $icode r$$ has elements of type $code bool$$, @@ -149,9 +155,9 @@ If it has elements of type $code std::set$$, its size is $latex q$$ and all the set elements must be between zero and $icode%n%-1%$$ inclusive. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ -for the matrix $icode R^\R{T} \in B^{q \times n}$$. +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +for the matrix $latex R^\R{T} \in B^{q \times n}$$. $head s$$ The return value $icode s$$ has prototype @@ -166,8 +172,8 @@ If it has elements of type $code std::set$$, its size is $latex m$$ and all its set elements are between zero and $icode%q%-1%$$ inclusive. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex S(x) \in B^{m \times q}$$. $subhead transpose true$$ @@ -176,8 +182,8 @@ If it has elements of type $code std::set$$, its size is $latex q$$ and all its set elements are between zero and $icode%m%-1%$$ inclusive. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex S(x)^\R{T} \in B^{q \times m}$$. $head VectorSet$$ @@ -190,8 +196,8 @@ $head Entire Sparsity Pattern$$ Suppose that $latex q = n$$ and $latex R$$ is the $latex n \times n$$ identity matrix. -In this case, -the corresponding value for $icode s$$ is a +In this case, +the corresponding value for $icode s$$ is a sparsity pattern for the Jacobian $latex S(x) = F^{(1)} ( x )$$. $head Example$$ @@ -202,6 +208,10 @@ $cref for_sparse_jac.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. +The file +$cref/sparsity_sub.cpp/sparsity_sub.cpp/ForSparseJac/$$ +contains an example and test of using $code ForSparseJac$$ +to compute the sparsity pattern for a subset of the Jacobian. $end ----------------------------------------------------------------------------- @@ -233,6 +243,14 @@ \param transpose are the sparsity patterns transposed. +\param dependency +Are the derivatives with respect to left and right of the expression below +considered to be non-zero: +\code + CondExpRel(left, right, if_true, if_false) +\endcode +This is used by the optimizer to obtain the correct dependency relations. + \param q is the number of columns in the matrix \f$ R \f$. @@ -242,7 +260,7 @@ \param s The input value of \a s must be a vector with size \c m*q where \c m is the number of dependent variables -corresponding to the operation sequence stored in \a play. +corresponding to the operation sequence stored in \a play. The input value of the components of \c s does not matter. On output, \a s is the sparsity pattern for the matrix \f[ @@ -263,7 +281,7 @@ to the corresponding variable in the tape. \param play -is the recording that defines the function we are computing the sparsity +is the recording that defines the function we are computing the sparsity pattern for. \param for_jac_sparsity @@ -273,10 +291,11 @@ It contains the forward sparsity pattern for all of the variables on the tape (given the sparsity pattern for the independent variables is \f$ R \f$). */ -template +template void ForSparseJacBool( bool transpose , - size_t q , + bool dependency , + size_t q , const VectorSet& r , VectorSet& s , size_t total_num_var , @@ -296,7 +315,7 @@ q > 0, "ForSparseJac: q is not greater than zero" ); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( size_t(r.size()) == n * q, "ForSparseJac: size of r is not equal to\n" "q times domain dimension for ADFun object." @@ -324,6 +343,7 @@ // evaluate the sparsity patterns ForJacSweep( + dependency, n, total_num_var, &play, @@ -373,6 +393,9 @@ \param transpose see \c SparseJacBool. +\param dependency +see \c SparseJacBool. + \param q see \c SparseJacBool. @@ -398,10 +421,11 @@ see \c SparseJacBool. */ -template +template void ForSparseJacSet( - bool transpose , - size_t q , + bool transpose , + bool dependency , + size_t q , const VectorSet& r , VectorSet& s , size_t total_num_var , @@ -474,6 +498,7 @@ } // evaluate the sparsity patterns ForJacSweep( + dependency, n, total_num_var, &play, @@ -500,24 +525,27 @@ } } // --------------------------------------------------------------------------- -/*! +/*! Private helper function for ForSparseJac(q, r). -All of the description in the public member function ForSparseJac(q, r) -applies. +All of the description in the public member function ForSparseJac(q, r) +applies. \param set_type is a \c bool value. This argument is used to dispatch to the proper source code depending on the value of \c VectorSet::value_type. \param transpose -See \c ForSparseJac(q, r). +See \c ForSparseJac(q, r, transpose, dependency). + +\param dependency +See \c ForSparseJac(q, r, transpose, dependency). \param q -See \c ForSparseJac(q, r). +See \c ForSparseJac(q, r, transpose, dependency). \param r -See \c ForSparseJac(q, r). +See \c ForSparseJac(q, r, transpose, dependency). \param s is the return value for the corresponding call to \c ForSparseJac(q, r). @@ -528,6 +556,7 @@ void ADFun::ForSparseJacCase( bool set_type , bool transpose , + bool dependency , size_t q , const VectorSet& r , VectorSet& s ) @@ -541,38 +570,42 @@ // store results in s and for_jac_sparse_pack_ ForSparseJacBool( - transpose , - q , + transpose , + dependency , + q , r , s , num_var_tape_ , dep_taddr_ , ind_taddr_ , play_ , - for_jac_sparse_pack_ + for_jac_sparse_pack_ ); } -/*! +/*! Private helper function for \c ForSparseJac(q, r). -All of the description in the public member function \c ForSparseJac(q, r) -applies. +All of the description in the public member function \c ForSparseJac(q, r) +applies. \param set_type -is a \c std::set object. +is a \c std::set object. This argument is used to dispatch to the proper source code depending on the value of \c VectorSet::value_type. \param transpose -See \c ForSparseJac(q, r). +See \c ForSparseJac(q, r, transpose, dependency). + +\param dependency +See \c ForSparseJac(q, r, transpose, dependency). \param q -See \c ForSparseJac(q, r). +See \c ForSparseJac(q, r, transpose, dependency). \param r -See \c ForSparseJac(q, r). +See \c ForSparseJac(q, r, transpose, dependency). \param s is the return value for the corresponding call to \c ForSparseJac(q, r). @@ -582,6 +615,7 @@ void ADFun::ForSparseJacCase( const std::set& set_type , bool transpose , + bool dependency , size_t q , const VectorSet& r , VectorSet& s ) @@ -599,8 +633,9 @@ // store results in r and for_jac_sparse_pack_ CppAD::ForSparseJacSet( - transpose , - q , + transpose , + dependency , + q , r , s , num_var_tape_ , @@ -617,7 +652,7 @@ The C++ source code corresponding to this operation is \verbatim - s = f.ForSparseJac(q, r) + s = f.ForSparseJac(q, r, transpose, dependency) \endverbatim \tparam Base @@ -636,6 +671,14 @@ \param transpose are sparsity patterns for \f$ R \f$ and \f$ S(x) \f$ transposed. +\param dependency +Are the derivatives with respect to left and right of the expression below +considered to be non-zero: +\code + CondExpRel(left, right, if_true, if_false) +\endcode +This is used by the optimizer to obtain the correct dependency relations. + \return The value of \c transpose is false (true), the return value is a sparsity pattern for \f$ S(x) \f$ (\f$ S(x)^T \f$) where @@ -645,19 +688,19 @@ where \f$ F \f$ is the function corresponding to the operation sequence and \a x is any argument value. If \c VectorSet::value_type is \c bool, -the return value has size \f$ m * q \f$ (\f$ q * m \f$). +the return value has size \f$ m * q \f$ (\f$ q * m \f$). where \c m is the number of dependent variables -corresponding to the operation sequence stored in \c f. +corresponding to the operation sequence stored in \c f. If \c VectorSet::value_type is \c std::set, the return value has size \f$ m \f$ ( \f$ q \f$ ) -and with all its elements between zero and +and with all its elements between zero and \f$ q - 1 \f$ ( \f$ m - 1 \f$). \par Side Effects If \c VectorSet::value_type is \c bool, the forward sparsity pattern for all of the variables on the tape is stored in \c for_jac_sparse_pack__. -In this case +In this case \verbatim for_jac_sparse_pack_.n_set() == num_var_tape_ for_jac_sparse_pack_.end() == q @@ -669,7 +712,7 @@ If \c VectorSet::value_type is \c std::set, the forward sparsity pattern for all of the variables on the tape is stored in \c for_jac_sparse_set__. -In this case +In this case \verbatim for_jac_sparse_set_.n_set() == num_var_tape_ for_jac_sparse_set_.end() == q @@ -680,11 +723,12 @@ template template VectorSet ADFun::ForSparseJac( - size_t q , + size_t q , const VectorSet& r , - bool transpose ) + bool transpose , + bool dependency ) { VectorSet s; - typedef typename VectorSet::value_type Set_type; + typedef typename VectorSet::value_type Set_type; // free all memory currently in sparsity patterns for_jac_sparse_pack_.resize(0, 0); @@ -693,6 +737,7 @@ ForSparseJacCase( Set_type() , transpose , + dependency , q , r , s @@ -700,6 +745,156 @@ return s; } +// =========================================================================== +// ForSparseJacCheckpoint +/*! +Forward mode Jacobian sparsity calculation used by checkpoint functions. + +\tparam Base +is the base type for this recording. + +\param transpose +is true (false) s is equal to \f$ S(x) \f$ (\f$ S(x)^T \f$) +where +\f[ + S(x) = F^{(1)} (x) * R +\f] +where \f$ F \f$ is the function corresponding to the operation sequence +and \f$ x \f$ is any argument value. + +\param q +is the number of columns in the matrix \f$ R \f$. + +\param r +is a sparsity pattern for the matrix \f$ R \f$. + +\param transpose +are the sparsity patterns for \f$ R \f$ and \f$ S(x) \f$ transposed. + +\param dependency +Are the derivatives with respect to left and right of the expression below +considered to be non-zero: +\code + CondExpRel(left, right, if_true, if_false) +\endcode +This is used by the optimizer to obtain the correct dependency relations. + +\param s +The input size and elements of s do not matter. +On output, s is the sparsity pattern for the matrix \f$ S(x) \f$ +or \f$ S(x)^T \f$ depending on transpose. + +\par Side Effects +If \c VectorSet::value_type is \c bool, +the forward sparsity pattern for all of the variables on the +tape is stored in \c for_jac_sparse_pack__. +In this case +\verbatim + for_jac_sparse_pack_.n_set() == num_var_tape_ + for_jac_sparse_pack_.end() == q + for_jac_sparse_set_.n_set() == 0 + for_jac_sparse_set_.end() == 0 +\endverbatim +\n +\n +If \c VectorSet::value_type is \c std::set, +the forward sparsity pattern for all of the variables on the +tape is stored in \c for_jac_sparse_set__. +In this case +\verbatim + for_jac_sparse_set_.n_set() == num_var_tape_ + for_jac_sparse_set_.end() == q + for_jac_sparse_pack_.n_set() == 0 + for_jac_sparse_pack_.end() == 0 +\endverbatim +*/ +template +void ADFun::ForSparseJacCheckpoint( + size_t q , + CPPAD_INTERNAL_SPARSE_SET& r , + bool transpose , + bool dependency , + CPPAD_INTERNAL_SPARSE_SET& s ) +{ size_t n = Domain(); + size_t m = Range(); + +# ifndef NDEBUG + if( transpose ) + { CPPAD_ASSERT_UNKNOWN( r.n_set() == q ); + CPPAD_ASSERT_UNKNOWN( r.end() == n ); + } + else + { CPPAD_ASSERT_UNKNOWN( r.n_set() == n ); + CPPAD_ASSERT_UNKNOWN( r.end() == q ); + } + for(size_t j = 0; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == (j+1) ); + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == InvOp ); + } +# endif + + // free all memory currently in sparsity patterns + for_jac_sparse_pack_.resize(0, 0); + for_jac_sparse_set_.resize(0, 0); + + // allocate new sparsity pattern + for_jac_sparse_set_.resize(num_var_tape_, q); + + // set sparsity pattern for dependent variables + if( transpose ) + { for(size_t i = 0; i < q; i++) + { r.begin(i); + size_t j = r.next_element(); + while( j < n ) + { for_jac_sparse_set_.add_element( ind_taddr_[j], i ); + j = r.next_element(); + } + } + } + else + { for(size_t j = 0; j < n; j++) + { r.begin(j); + size_t i = r.next_element(); + while( i < q ) + { for_jac_sparse_set_.add_element( ind_taddr_[j], i ); + i = r.next_element(); + } + } + } + + // evaluate the sparsity pattern for all variables + ForJacSweep( + dependency, + n, + num_var_tape_, + &play_, + for_jac_sparse_set_ + ); + + // dimension the return value + if( transpose ) + s.resize(q, m); + else + s.resize(m, q); + + // return values corresponding to dependent variables + for(size_t i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + + // extract the result from for_jac_sparse_set_ + CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.end() == q ); + for_jac_sparse_set_.begin( dep_taddr_[i] ); + size_t j = for_jac_sparse_set_.next_element(); + while( j < q ) + { if( transpose ) + s.add_element(j, i); + else + s.add_element(i, j); + j = for_jac_sparse_set_.next_element(); + } + } + +} } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/for_two.hpp cppad-2016.00.00.1/cppad/local/for_two.hpp --- cppad-2015.00.00.9/cppad/local/for_two.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/for_two.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: for_two.hpp 2683 2012-12-30 18:17:03Z bradbell $ */ -# ifndef CPPAD_FOR_TWO_INCLUDED -# define CPPAD_FOR_TWO_INCLUDED +// $Id: for_two.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FOR_TWO_HPP +# define CPPAD_FOR_TWO_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,16 +23,11 @@ $$ -$index partial, second order driver$$ -$index second, order partial driver$$ -$index driver, second order partial$$ - -$index easy, partial$$ -$index driver, easy partial$$ -$index partial, easy$$ + $section Forward Mode Second Partial Derivative Driver$$ +$mindex order easy$$ $head Syntax$$ $icode%ddy% = %f%.ForTwo(%x%, %j%, %k%)%$$ @@ -41,11 +36,11 @@ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. -The syntax above sets +The syntax above sets $latex \[ ddy [ i * p + \ell ] = - \DD{ F_i }{ x_{j[ \ell ]} }{ x_{k[ \ell ]} } (x) + \DD{ F_i }{ x_{j[ \ell ]} }{ x_{k[ \ell ]} } (x) \] $$ for $latex i = 0 , \ldots , m-1$$ and $latex \ell = 0 , \ldots , p$$, @@ -65,7 +60,7 @@ const %VectorBase% &%x% %$$ (see $cref/VectorBase/ForTwo/VectorBase/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. It specifies @@ -78,7 +73,7 @@ %$$ (see $cref/VectorSize_t/ForTwo/VectorSize_t/$$ below) We use $icode p$$ to denote the size of the vector $icode j$$. -All of the indices in $icode j$$ +All of the indices in $icode j$$ must be less than $icode n$$; i.e., for $latex \ell = 0 , \ldots , p-1$$, $latex j[ \ell ] < n$$. @@ -90,7 +85,7 @@ (see $cref/VectorSize_t/ForTwo/VectorSize_t/$$ below) and its size must be equal to $icode p$$, the size of the vector $icode j$$. -All of the indices in $icode k$$ +All of the indices in $icode k$$ must be less than $icode n$$; i.e., for $latex \ell = 0 , \ldots , p-1$$, $latex k[ \ell ] < n$$. @@ -102,12 +97,12 @@ (see $cref/VectorBase/ForTwo/VectorBase/$$ below) and its size is $latex m * p$$. It contains the requested partial derivatives; to be specific, -for $latex i = 0 , \ldots , m - 1 $$ +for $latex i = 0 , \ldots , m - 1 $$ and $latex \ell = 0 , \ldots , p - 1$$ $latex \[ ddy [ i * p + \ell ] = - \DD{ F_i }{ x_{j[ \ell ]} }{ x_{k[ \ell ]} } (x) + \DD{ F_i }{ x_{j[ \ell ]} }{ x_{k[ \ell ]} } (x) \] $$ $head VectorBase$$ @@ -124,7 +119,7 @@ $head ForTwo Uses Forward$$ After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After a call to $code ForTwo$$, the zero order Taylor coefficients correspond to @@ -135,7 +130,7 @@ $children% example/for_two.cpp %$$ -The routine +The routine $cref/ForTwo/for_two.cpp/$$ is both an example and test. It returns $code true$$, if it succeeds and $code false$$ otherwise. @@ -149,7 +144,7 @@ template template VectorBase ADFun::ForTwo( - const VectorBase &x, + const VectorBase &x, const VectorSize_t &j, const VectorSize_t &k) { size_t i; @@ -170,7 +165,7 @@ CPPAD_ASSERT_KNOWN( x.size() == n, "ForTwo: Length of x not equal domain dimension for f." - ); + ); CPPAD_ASSERT_KNOWN( j.size() == k.size(), "ForTwo: Lenght of the j and k vectors are not equal." @@ -224,7 +219,7 @@ dy = Forward(2, dx); for(i = 0; i < m; i++) D[i * n + j1 ] = dy[i]; - } + } j1 = k1; } } diff -Nru cppad-2015.00.00.9/cppad/local/forward0sweep.hpp cppad-2016.00.00.1/cppad/local/forward0sweep.hpp --- cppad-2015.00.00.9/cppad/local/forward0sweep.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/forward0sweep.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: forward0sweep.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_FORWARD0SWEEP_INCLUDED -# define CPPAD_FORWARD0SWEEP_INCLUDED +// $Id: forward0sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FORWARD0SWEEP_HPP +# define CPPAD_FORWARD0SWEEP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,7 +30,7 @@ \code user_ok = user_atom->forward \endcode -This maco is undefined at the end of this file to facillitate is +This maco is undefined at the end of this file to facillitate is use with a different definition in other files. */ # ifdef NDEBUG @@ -41,7 +41,7 @@ /*! \def CPPAD_FORWARD0SWEEP_TRACE -This value is either zero or one. +This value is either zero or one. Zero is the normal operational value. If it is one, a trace of every forward0sweep computation is printed. (Note that forward0sweep is not used if CPPAD_USE_FORWARD0SWEEP is zero). @@ -85,7 +85,7 @@ The object play is effectly constant. The exception to this is that while palying back the tape the object play holds information about the current location -with in the tape and this changes during palyback. +with in the tape and this changes during palyback. \param J Is the number of columns in the coefficient matrix taylor. @@ -98,42 +98,51 @@ \b Input: For i = 1 , ... , n, taylor [i * J + 0] -variable with index j on the tape +variable with index j on the tape (these are the independent variables). \n \n -\b Output: +\b Output: For i = n + 1, ... , numvar - 1, taylor [i * J + 0] -is the zero order Taylor coefficient for the variable with +is the zero order Taylor coefficient for the variable with index i on the tape. \param cskip_op Is a vector with size play->num_op_rec(). The input value of the elements does not matter. -Upon return, if cskip_op[i] is true, the operator index i -does not affect any of the dependent variable +Upon return, if cskip_op[i] is true, the operator index i +does not affect any of the dependent variable (given the value of the independent variables). \param var_by_load_op Is a vector with size play->num_load_op_rec(). The input value of the elements does not matter. -Upon return, +Upon return, it is the variable index corresponding the result for each load operator. In the case where the index is zero, the load operator results in a parameter (not a variable). Note that the is no variable with index zero on the tape. -\return -The return value is equal to the number of ComOp operations -that have a different result from when the information in +\param compare_change_count +Is the count value for changing number and op_index during +zero order foward mode. + +\param compare_change_number +If compare_change_count is zero, this value is set to zero. +Otherwise, the return value is the number of comparision operations +that have a different result from when the information in +play was recorded. + +\param compare_change_op_index +If compare_change_count is zero, this value is set to zero. +Otherwise it is the operator index (see forward_next) for the count-th +comparision operation that has a different result from when the information in play was recorded. -(Note that if NDEBUG is true, there are no ComOp operations -in play and hence this return value is always zero.) */ template -size_t forward0sweep( +void forward0sweep( std::ostream& s_out, bool print, size_t n, @@ -142,7 +151,10 @@ size_t J, Base* taylor, bool* cskip_op, - pod_vector& var_by_load_op + pod_vector& var_by_load_op, + size_t compare_change_count, + size_t& compare_change_number, + size_t& compare_change_op_index ) { CPPAD_ASSERT_UNKNOWN( J >= 1 ); CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); @@ -160,14 +172,17 @@ // index for current instruction size_t i_op; - // next variables + // next variables size_t i_var; // operation argument indices const addr_t* arg = CPPAD_NULL; - // initialize the comparision operator (ComOp) counter - size_t compareCount = 0; + // initialize the comparision operator counter + if( p == 0 ) + { compare_change_number = 0; + compare_change_op_index = 0; + } // If this includes a zero calculation, initialize this information pod_vector isvar_by_ind; @@ -194,8 +209,8 @@ // work space used by UserOp. vector user_vx; // empty vecotor vector user_vy; // empty vecotor - vector user_tx; // argument vector Taylor coefficients - vector user_ty; // result vector Taylor coefficients + vector user_tx; // argument vector Taylor coefficients + vector user_ty; // result vector Taylor coefficients size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector @@ -232,9 +247,9 @@ */ # if CPPAD_FORWARD0SWEEP_TRACE - // variable indices for results vector + // variable indices for results vector // (done differently for order zero). - vector user_iy; + vector user_iy; # endif // skip the BeginOp at the beginning of the recording @@ -248,8 +263,8 @@ { // this op play->forward_next(op, arg, i_op, i_var); - CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); - CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); + CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); + CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, i_var); @@ -262,7 +277,7 @@ CPPAD_ASSERT_UNKNOWN( op != CSkipOp ); // if( op == CSkipOp ) // { // CSkip has a variable number of arguments - // play->forward_cskip(op, arg, i_op, i_var); + // play->forward_cskip(op, arg, i_op, i_var); // } play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); @@ -294,6 +309,15 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AcoshOp: + // sqrt(x * x - 1), acosh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_acosh_op_0(i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case AsinOp: // sqrt(1 - x * x), asin(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); @@ -301,6 +325,15 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AsinhOp: + // sqrt(1 + x * x), asinh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_asinh_op_0(i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case AtanOp: // 1 + x * x, atan(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); @@ -308,20 +341,23 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AtanhOp: + // 1 - x * x, atanh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_atanh_op_0(i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case CExpOp: - // Use the general case with d == 0 + // Use the general case with d == 0 // (could create an optimzied verison for this case) forward_cond_op_0( i_var, arg, num_par, parameter, J, taylor ); break; // --------------------------------------------------- - case ComOp: - forward_comp_op_0( - compareCount, arg, num_par, parameter, J, taylor - ); - break; - // --------------------------------------------------- case CosOp: // sin(x), cos(x) @@ -387,10 +423,32 @@ break; // ------------------------------------------------- -# if CPPAD_COMPILER_HAS_ERF + case EqpvOp: + if( compare_change_count ) + { forward_eqpv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + + case EqvvOp: + if( compare_change_count ) + { forward_eqvv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 case ErfOp: - CPPAD_ASSERT_UNKNOWN( CPPAD_COMPILER_HAS_ERF ); - // 2DO: implement zero order version of this function forward_erf_op_0(i_var, arg, parameter, J, taylor); break; # endif @@ -401,18 +459,25 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + forward_expm1_op_0(i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); break; - // ------------------------------------------------- + // --------------------------------------------------- case LdpOp: forward_load_p_op_0( play, - i_var, - arg, - parameter, - J, + i_var, + arg, + parameter, + J, taylor, isvar_by_ind.data(), index_by_ind.data(), @@ -424,10 +489,10 @@ case LdvOp: forward_load_v_op_0( play, - i_var, - arg, - parameter, - J, + i_var, + arg, + parameter, + J, taylor, isvar_by_ind.data(), index_by_ind.data(), @@ -436,13 +501,87 @@ break; // ------------------------------------------------- + case LepvOp: + if( compare_change_count ) + { forward_lepv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + + case LevpOp: + if( compare_change_count ) + { forward_levp_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + + case LevvOp: + if( compare_change_count ) + { forward_levv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + case LogOp: forward_log_op_0(i_var, arg[0], J, taylor); break; // ------------------------------------------------- - case MulvvOp: - forward_mulvv_op_0(i_var, arg, parameter, J, taylor); +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + forward_log1p_op_0(i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + + case LtpvOp: + if( compare_change_count ) + { forward_ltpv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + + case LtvpOp: + if( compare_change_count ) + { forward_ltvp_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + + case LtvvOp: + if( compare_change_count ) + { forward_ltvv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } break; // ------------------------------------------------- @@ -452,6 +591,35 @@ break; // ------------------------------------------------- + case MulvvOp: + forward_mulvv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case NepvOp: + if( compare_change_count ) + { forward_nepv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + + case NevvOp: + if( compare_change_count ) + { forward_nevv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + } + break; + // ------------------------------------------------- + case ParOp: forward_par_op_0( i_var, arg, num_par, parameter, J, taylor @@ -511,10 +679,10 @@ case StppOp: forward_store_pp_op_0( - i_var, - arg, - num_par, - J, + i_var, + arg, + num_par, + J, taylor, isvar_by_ind.data(), index_by_ind.data() @@ -524,10 +692,10 @@ case StpvOp: forward_store_pv_op_0( - i_var, - arg, - num_par, - J, + i_var, + arg, + num_par, + J, taylor, isvar_by_ind.data(), index_by_ind.data() @@ -537,10 +705,10 @@ case StvpOp: forward_store_vp_op_0( - i_var, - arg, - num_par, - J, + i_var, + arg, + num_par, + J, taylor, isvar_by_ind.data(), index_by_ind.data() @@ -550,10 +718,10 @@ case StvvOp: forward_store_vv_op_0( - i_var, - arg, - num_par, - J, + i_var, + arg, + num_par, + J, taylor, isvar_by_ind.data(), index_by_ind.data() @@ -604,7 +772,7 @@ user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); @@ -630,7 +798,7 @@ CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); # ifndef NDEBUG if( ! user_ok ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.forward: returned false"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); @@ -653,7 +821,7 @@ if( user_j == user_n ) { // call users function for this operation user_atom->set_id(user_id); - CPPAD_ATOMIC_CALL(p, q, + CPPAD_ATOMIC_CALL(p, q, user_vx, user_vy, user_tx, user_ty ); user_state = user_ret; @@ -669,7 +837,7 @@ if( user_j == user_n ) { // call users function for this operation user_atom->set_id(user_id); - CPPAD_ATOMIC_CALL(p, q, + CPPAD_ATOMIC_CALL(p, q, user_vx, user_vy, user_tx, user_ty ); user_state = user_ret; @@ -701,6 +869,23 @@ break; // ------------------------------------------------- + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_zmulpv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_zmulvp_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case ZmulvvOp: + forward_zmulvv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + default: CPPAD_ASSERT_UNKNOWN(false); } @@ -714,19 +899,19 @@ for(size_t i = 0; i < user_m; i++) if( user_iy[i] > 0 ) { size_t i_tmp = (i_op + i) - user_m; printOp( - std::cout, + std::cout, play, i_tmp, user_iy[i], - UsrrvOp, + UsrrvOp, CPPAD_NULL ); Base* Z_tmp = taylor + user_iy[i] * J; printOpResult( - std::cout, - d + 1, + std::cout, + d + 1, Z_tmp, - 0, + 0, (Base *) CPPAD_NULL ); std::cout << std::endl; @@ -741,18 +926,18 @@ if( op != UsrrvOp ) { printOp( - std::cout, + std::cout, play, i_op, i_var, - op, + op, arg_tmp ); if( NumRes(op) > 0 ) printOpResult( - std::cout, - d + 1, - Z_tmp, - 0, + std::cout, + d + 1, + Z_tmp, + 0, (Base *) CPPAD_NULL ); std::cout << std::endl; @@ -765,7 +950,7 @@ CPPAD_ASSERT_UNKNOWN( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( i_var + 1 == play->num_var_rec() ); - return compareCount; + return; } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/forward1sweep.hpp cppad-2016.00.00.1/cppad/local/forward1sweep.hpp --- cppad-2015.00.00.9/cppad/local/forward1sweep.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/forward1sweep.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: forward1sweep.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_FORWARD1SWEEP_INCLUDED -# define CPPAD_FORWARD1SWEEP_INCLUDED +// $Id: forward1sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FORWARD1SWEEP_HPP +# define CPPAD_FORWARD1SWEEP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,7 +30,7 @@ \code user_ok = user_atom->forward \endcode -This macro is undefined at the end of this file to facillitate its +This macro is undefined at the end of this file to facillitate its use with a different definition in other files. */ # ifdef NDEBUG @@ -41,7 +41,7 @@ /*! \def CPPAD_FORWARD1SWEEP_TRACE -This value is either zero or one. +This value is either zero or one. Zero is the normal operational value. If it is one, a trace of every forward1sweep computation is printed. */ @@ -84,7 +84,7 @@ The object play is effectly constant. The exception to this is that while palying back the tape the object play holds information about the current location -with in the tape and this changes during palyback. +with in the tape and this changes during palyback. \param J Is the number of columns in the coefficient matrix taylor. @@ -101,13 +101,13 @@ In this case, the input value of the elements does not matter. Upon return, if cskip_op[i] is true, the operator with index i -does not affect any of the dependent variable +does not affect any of the dependent variable (given the value of the independent variables). \n \n p > 0 \n -In this case cskip_op is not modified and has the same meaning +In this case cskip_op is not modified and has the same meaning as its return value above. \param var_by_load_op @@ -118,7 +118,7 @@ \n In this case, The input value of the elements does not matter. -Upon return, +Upon return, it is the variable index corresponding the result for each load operator. In the case where the index is zero, the load operator results in a parameter (not a variable). @@ -127,16 +127,16 @@ \n p > 0 \n -In this case var_by_load_op is not modified and has the meaning +In this case var_by_load_op is not modified and has the meaning as its return value above. \param p is the lowest order of the Taylor coefficients -that are computed during this call. +that are computed during this call. \param q is the highest order of the Taylor coefficients -that are computed during this call. +that are computed during this call. \param taylor \n @@ -144,7 +144,7 @@ For i = 1 , ... , numvar-1, k = 0 , ... , p-1, taylor[ J*i + k] -is the k-th order Taylor coefficient corresponding to +is the k-th order Taylor coefficient corresponding to the i-th variable. \n \n @@ -152,30 +152,40 @@ For i = 1 , ... , n, k = p , ... , q, taylor[ J*j + k] -is the k-th order Taylor coefficient corresponding to -the i-th variable +is the k-th order Taylor coefficient corresponding to +the i-th variable (these are the independent varaibles). \n \n -\b Output: -For i = n+1 , ... , numvar-1, and +\b Output: +For i = n+1 , ... , numvar-1, and k = 0 , ... , p-1, taylor[ J*i + k] is the k-th order Taylor coefficient corresponding to -the i-th variable. +the i-th variable. + -\return -If p is not zero, the return value is zero. -If p is zero, -the return value is equal to the number of ComOp operations -that have a different result from when the information in -a play was recorded. -(Note that if NDEBUG is true, there are no ComOp operations -in play and hence this return value is always zero.) +\param compare_change_count +Is the count value for changing number and op_index during +zero order foward mode. + +\param compare_change_number +If p is non-zero, this value is not changed, otherwise: +If compare_change_count is zero, this value is set to zero, otherwise: +this value is set to the number of comparision operations +that have a different result from when the information in +play was recorded. + +\param compare_change_op_index +if p is non-zero, this value is not changed, otherwise: +If compare_change_count is zero, this value is set to zero. +Otherwise it is the operator index (see forward_next) for the count-th +comparision operation that has a different result from when the information in +play was recorded. */ template -size_t forward1sweep( +void forward1sweep( std::ostream& s_out, const bool print, const size_t p, @@ -186,7 +196,10 @@ const size_t J, Base* taylor, bool* cskip_op, - pod_vector& var_by_load_op + pod_vector& var_by_load_op, + size_t compare_change_count, + size_t& compare_change_number, + size_t& compare_change_op_index ) { // number of directions @@ -205,14 +218,17 @@ // index for current instruction size_t i_op; - // next variables + // next variables size_t i_var; // operation argument indices const addr_t* arg = CPPAD_NULL; - // initialize the comparision operator (ComOp) counter - size_t compareCount = 0; + // initialize the comparision operator counter + if( p == 0 ) + { compare_change_number = 0; + compare_change_op_index = 0; + } // If this includes a zero calculation, initialize this information pod_vector isvar_by_ind; @@ -239,8 +255,8 @@ // work space used by UserOp. vector user_vx; // empty vecotor vector user_vy; // empty vecotor - vector user_tx; // argument vector Taylor coefficients - vector user_ty; // result vector Taylor coefficients + vector user_tx; // argument vector Taylor coefficients + vector user_ty; // result vector Taylor coefficients size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector @@ -282,9 +298,9 @@ // (not needed for order zero) const size_t user_q1 = q+1; - // variable indices for results vector + // variable indices for results vector // (done differently for order zero). - vector user_iy; + vector user_iy; // skip the BeginOp at the beginning of the recording play->forward_start(op, arg, i_op, i_var); @@ -297,21 +313,21 @@ { // this op play->forward_next(op, arg, i_op, i_var); - CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); - CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); + CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); + CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, i_var); // check if we are skipping this operation while( cskip_op[i_op] ) { if( op == CSumOp ) - { // CSumOp has a variable number of arguments + { // CSumOp has a variable number of arguments play->forward_csum(op, arg, i_op, i_var); } CPPAD_ASSERT_UNKNOWN( op != CSkipOp ); // if( op == CSkipOp ) // { // CSkip has a variable number of arguments - // play->forward_cskip(op, arg, i_op, i_var); + // play->forward_cskip(op, arg, i_op, i_var); // } play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); @@ -343,6 +359,15 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AcoshOp: + // sqrt(x * x - 1), acosh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_acosh_op(p, q, i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case AsinOp: // sqrt(1 - x * x), asin(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); @@ -350,6 +375,15 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AsinhOp: + // sqrt(1 + x * x), asinh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_asinh_op(p, q, i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case AtanOp: // 1 + x * x, atan(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); @@ -357,11 +391,11 @@ break; // ------------------------------------------------- -# if CPPAD_COMPILER_HAS_ERF - case ErfOp: - CPPAD_ASSERT_UNKNOWN( CPPAD_COMPILER_HAS_ERF ); - // 2DO: implement zero order version of this function - forward_erf_op(p, q, i_var, arg, parameter, J, taylor); +# if CPPAD_USE_CPLUSPLUS_2011 + case AtanhOp: + // 1 - x * x, atanh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_atanh_op(p, q, i_var, arg[0], J, taylor); break; # endif // ------------------------------------------------- @@ -373,13 +407,6 @@ break; // --------------------------------------------------- - case ComOp: - if( p == 0 ) forward_comp_op_0( - compareCount, arg, num_par, parameter, J, taylor - ); - break; - // --------------------------------------------------- - case CosOp: // sin(x), cos(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); @@ -446,10 +473,48 @@ break; // ------------------------------------------------- + case EqpvOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_eqpv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + // ------------------------------------------------- + + case EqvvOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_eqvv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case ErfOp: + CPPAD_ASSERT_UNKNOWN( CPPAD_USE_CPLUSPLUS_2011 ); + // 2DO: implement zero order version of this function + forward_erf_op(p, q, i_var, arg, parameter, J, taylor); + break; +# endif + // ------------------------------------------------- + case ExpOp: forward_exp_op(p, q, i_var, arg[0], J, taylor); break; - // ------------------------------------------------- + // --------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + forward_expm1_op(p, q, i_var, arg[0], J, taylor); + break; +# endif + // --------------------------------------------------- case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); @@ -460,16 +525,16 @@ if( p == 0 ) { forward_load_p_op_0( play, - i_var, - arg, - parameter, - J, + i_var, + arg, + parameter, + J, taylor, isvar_by_ind.data(), index_by_ind.data(), var_by_load_op.data() ); - if( p < q ) forward_load_op( + if( p < q ) forward_load_op( play, op, p+1, @@ -482,7 +547,7 @@ taylor ); } - else forward_load_op( + else forward_load_op( play, op, p, @@ -501,16 +566,16 @@ if( p == 0 ) { forward_load_v_op_0( play, - i_var, - arg, - parameter, - J, + i_var, + arg, + parameter, + J, taylor, isvar_by_ind.data(), index_by_ind.data(), var_by_load_op.data() ); - if( p < q ) forward_load_op( + if( p < q ) forward_load_op( play, op, p+1, @@ -523,7 +588,7 @@ taylor ); } - else forward_load_op( + else forward_load_op( play, op, p, @@ -538,13 +603,79 @@ break; // ------------------------------------------------- + case LepvOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_lepv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + + case LevpOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_levp_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + // ------------------------------------------------- + + case LevvOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_levv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + // ------------------------------------------------- + case LogOp: forward_log_op(p, q, i_var, arg[0], J, taylor); break; // ------------------------------------------------- - case MulvvOp: - forward_mulvv_op(p, q, i_var, arg, parameter, J, taylor); +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + forward_log1p_op(p, q, i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + + case LtpvOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_ltpv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + + case LtvpOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_ltvp_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + // ------------------------------------------------- + + case LtvvOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_ltvv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } break; // ------------------------------------------------- @@ -554,6 +685,33 @@ break; // ------------------------------------------------- + case MulvvOp: + forward_mulvv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case NepvOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_nepv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + // ------------------------------------------------- + + case NevvOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_nevv_op_0( + compare_change_number, arg, parameter, J, taylor + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = i_op; + } + break; + // ------------------------------------------------- + case ParOp: i = p; if( i == 0 ) @@ -563,7 +721,7 @@ i++; } while(i <= q) - { taylor[ i_var * J + i] = Base(0); + { taylor[ i_var * J + i] = Base(0); i++; } break; @@ -622,10 +780,10 @@ case StppOp: if( p == 0 ) { forward_store_pp_op_0( - i_var, - arg, - num_par, - J, + i_var, + arg, + num_par, + J, taylor, isvar_by_ind.data(), index_by_ind.data() @@ -637,10 +795,10 @@ case StpvOp: if( p == 0 ) { forward_store_pv_op_0( - i_var, - arg, - num_par, - J, + i_var, + arg, + num_par, + J, taylor, isvar_by_ind.data(), index_by_ind.data() @@ -652,10 +810,10 @@ case StvpOp: if( p == 0 ) { forward_store_vp_op_0( - i_var, - arg, - num_par, - J, + i_var, + arg, + num_par, + J, taylor, isvar_by_ind.data(), index_by_ind.data() @@ -667,10 +825,10 @@ case StvvOp: if( p == 0 ) { forward_store_vv_op_0( - i_var, - arg, - num_par, - J, + i_var, + arg, + num_par, + J, taylor, isvar_by_ind.data(), index_by_ind.data() @@ -722,7 +880,7 @@ user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); @@ -752,16 +910,16 @@ ); # ifndef NDEBUG if( ! user_ok ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.forward: returned false"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif - for(i = 0; i < user_m; i++) + for(i = 0; i < user_m; i++) if( user_iy[i] > 0 ) for(k = p; k <= q; k++) - taylor[ user_iy[i] * J + k ] = + taylor[ user_iy[i] * J + k ] = user_ty[ i * user_q1 + k ]; # if CPPAD_FORWARD1SWEEP_TRACE user_state = user_trace; @@ -822,6 +980,23 @@ break; // ------------------------------------------------- + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_zmulpv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_zmulvp_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case ZmulvvOp: + forward_zmulvv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + default: CPPAD_ASSERT_UNKNOWN(0); } @@ -834,19 +1009,19 @@ for(i = 0; i < user_m; i++) if( user_iy[i] > 0 ) { size_t i_tmp = (i_op + i) - user_m; printOp( - std::cout, + std::cout, play, i_tmp, user_iy[i], - UsrrvOp, + UsrrvOp, CPPAD_NULL ); Base* Z_tmp = taylor + user_iy[i] * J; printOpResult( - std::cout, - q + 1, + std::cout, + q + 1, Z_tmp, - 0, + 0, (Base *) CPPAD_NULL ); std::cout << std::endl; @@ -861,18 +1036,18 @@ if( op != UsrrvOp ) { printOp( - std::cout, + std::cout, play, i_op, i_var, - op, + op, arg_tmp ); if( NumRes(op) > 0 ) printOpResult( - std::cout, - q + 1, - Z_tmp, - 0, + std::cout, + q + 1, + Z_tmp, + 0, (Base *) CPPAD_NULL ); std::cout << std::endl; @@ -885,7 +1060,9 @@ CPPAD_ASSERT_UNKNOWN( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( i_var + 1 == play->num_var_rec() ); - return compareCount; + if( (p == 0) & (compare_change_count == 0) ) + compare_change_number = 0; + return; } // preprocessor symbols that are local to this file diff -Nru cppad-2015.00.00.9/cppad/local/forward2sweep.hpp cppad-2016.00.00.1/cppad/local/forward2sweep.hpp --- cppad-2015.00.00.9/cppad/local/forward2sweep.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/forward2sweep.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: forward2sweep.hpp 3589 2015-01-11 14:07:42Z bradbell $ */ -# ifndef CPPAD_FORWARD2SWEEP_INCLUDED -# define CPPAD_FORWARD2SWEEP_INCLUDED +// $Id: forward2sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FORWARD2SWEEP_HPP +# define CPPAD_FORWARD2SWEEP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,7 +30,7 @@ \code user_ok = user_atom->forward \endcode -This macro is undefined at the end of this file to facillitate its +This macro is undefined at the end of this file to facillitate its use with a different definition in other files. */ # ifdef NDEBUG @@ -41,7 +41,7 @@ /*! \def CPPAD_FORWARD2SWEEP_TRACE -This value is either zero or one. +This value is either zero or one. Zero is the normal operational value. If it is one, a trace of every forward2sweep computation is printed. */ @@ -84,7 +84,7 @@ The object play is effectly constant. The exception to this is that while palying back the tape the object play holds information about the current location -with in the tape and this changes during palyback. +with in the tape and this changes during palyback. \param J Is the number of columns in the coefficient matrix taylor. @@ -95,30 +95,30 @@ \b Input: For i = 1 , ... , numvar-1, taylor[ (J-1)*r*i + i + 0 ] -is the zero order Taylor coefficient corresponding to +is the zero order Taylor coefficient corresponding to the i-th variable and all directions. For i = 1 , ... , numvar-1, For k = 1 , ... , q-1, ell = 0 , ... , r-1, taylor[ (J-1)*r*i + i + (k-1)*r + ell + 1 ] -is the k-th order Taylor coefficient corresponding to +is the k-th order Taylor coefficient corresponding to the i-th variabel and ell-th direction. \n \n \b Input: -For i = 1 , ... , n, +For i = 1 , ... , n, ell = 0 , ... , r-1, taylor[ (J-1)*r*i + i + (q-1)*r + ell + 1 ] -is the q-th order Taylor coefficient corresponding to +is the q-th order Taylor coefficient corresponding to the i-th variable and ell-th direction (these are the independent varaibles). \n \n -\b Output: -For i = n+1 , ... , numvar-1, +\b Output: +For i = n+1 , ... , numvar-1, ell = 0 , ... , r-1, taylor[ (J-1)*r*i + i + (q-1)*r + ell + 1 ] -is the q-th order Taylor coefficient corresponding to +is the q-th order Taylor coefficient corresponding to the i-th variable and ell-th direction. \param cskip_op @@ -134,12 +134,10 @@ In the case where the index is zero, the instruction corresponds to a parameter (not variable). -\return -The return value is zero. */ template -size_t forward2sweep( +void forward2sweep( const size_t q, const size_t r, const size_t n, @@ -164,21 +162,18 @@ // index for current instruction size_t i_op; - // next variables + // next variables size_t i_var; // operation argument indices const addr_t* arg = CPPAD_NULL; - // initialize the comparision operator (ComOp) counter - const size_t compareCount = 0; - // work space used by UserOp. vector user_vx; // empty vecotor vector user_vy; // empty vecotor - vector user_tx_one; // argument vector Taylor coefficients + vector user_tx_one; // argument vector Taylor coefficients vector user_tx_all; - vector user_ty_one; // result vector Taylor coefficients + vector user_ty_one; // result vector Taylor coefficients vector user_ty_all; size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator @@ -211,9 +206,9 @@ // (not needed for order zero) const size_t user_q1 = q+1; - // variable indices for results vector + // variable indices for results vector // (done differently for order zero). - vector user_iy; + vector user_iy; // skip the BeginOp at the beginning of the recording play->forward_start(op, arg, i_op, i_var); @@ -227,21 +222,21 @@ { // this op play->forward_next(op, arg, i_op, i_var); - CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); - CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); + CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); + CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, i_var); // check if we are skipping this operation while( cskip_op[i_op] ) { if( op == CSumOp ) - { // CSumOp has a variable number of arguments + { // CSumOp has a variable number of arguments play->forward_csum(op, arg, i_op, i_var); } CPPAD_ASSERT_UNKNOWN( op != CSkipOp ); // if( op == CSkipOp ) // { // CSkip has a variable number of arguments - // play->forward_cskip(op, arg, i_op, i_var); + // play->forward_cskip(op, arg, i_op, i_var); // } play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); @@ -273,6 +268,15 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AcoshOp: + // sqrt(x * x - 1), acosh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_acosh_op_dir(q, r, i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case AsinOp: // sqrt(1 - x * x), asin(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); @@ -280,6 +284,15 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AsinhOp: + // sqrt(1 + x * x), asinh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_asinh_op_dir(q, r, i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case AtanOp: // 1 + x * x, atan(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); @@ -287,6 +300,15 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AtanhOp: + // 1 - x * x, atanh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_atanh_op_dir(q, r, i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case CExpOp: forward_cond_op_dir( q, r, i_var, arg, num_par, parameter, J, taylor @@ -294,11 +316,6 @@ break; // --------------------------------------------------- - case ComOp: - CPPAD_ASSERT_UNKNOWN(q > 0 ); - break; - // --------------------------------------------------- - case CosOp: // sin(x), cos(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); @@ -366,6 +383,13 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + forward_expm1_op_dir(q, r, i_var, arg[0], J, taylor); + break; +# endif + // ------------------------------------------------- + case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); break; @@ -386,17 +410,33 @@ taylor ); break; + // --------------------------------------------------- + + case EqpvOp: + case EqvvOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NepvOp: + case NevvOp: + CPPAD_ASSERT_UNKNOWN(q > 0 ); + break; // ------------------------------------------------- case LogOp: forward_log_op_dir(q, r, i_var, arg[0], J, taylor); break; - // ------------------------------------------------- + // --------------------------------------------------- - case MulvvOp: - forward_mulvv_op_dir(q, r, i_var, arg, parameter, J, taylor); +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + forward_log1p_op_dir(q, r, i_var, arg[0], J, taylor); break; - // ------------------------------------------------- +# endif + // --------------------------------------------------- case MulpvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); @@ -404,10 +444,15 @@ break; // ------------------------------------------------- + case MulvvOp: + forward_mulvv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + case ParOp: k = i_var*(J-1)*r + i_var + (q-1)*r + 1; for(ell = 0; ell < r; ell++) - taylor[k + ell] = Base(0); + taylor[k + ell] = Base(0); break; // ------------------------------------------------- @@ -510,7 +555,7 @@ user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); @@ -569,15 +614,15 @@ ); # ifndef NDEBUG if( ! user_ok ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.forward: returned false"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif - for(i = 0; i < user_m; i++) + for(i = 0; i < user_m; i++) { if( user_iy[i] > 0 ) - { size_t i_taylor = user_iy[i]*((J-1)*r+1); + { size_t i_taylor = user_iy[i]*((J-1)*r+1); size_t q_taylor = i_taylor + (q-1)*r+1+ell; size_t q_one = i * user_q1 + q; taylor[q_taylor] = user_ty_one[q_one]; @@ -614,7 +659,7 @@ user_tx_all[user_j*(q*r+1)+0] = taylor[arg[0]*((J-1)*r+1)+0]; for(ell = 0; ell < r; ell++) { for(k = 1; k < user_q1; k++) - { user_tx_all[user_j*(q*r+1) + (k-1)*r+1+ell] = + { user_tx_all[user_j*(q*r+1) + (k-1)*r+1+ell] = taylor[arg[0]*((J-1)*r+1) + (k-1)*r+1+ell]; } } @@ -645,7 +690,7 @@ user_ty_all[user_i*(q*r+1)+0] = taylor[i_var*((J-1)*r+1)+0]; for(ell = 0; ell < r; ell++) { for(k = 1; k < user_q1; k++) - { user_ty_all[user_i*(q*r+1) + (k-1)*r+1+ell] = + { user_ty_all[user_i*(q*r+1) + (k-1)*r+1+ell] = taylor[i_var*((J-1)*r+1) + (k-1)*r+1+ell]; } } @@ -655,6 +700,23 @@ break; // ------------------------------------------------- + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_zmulpv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_zmulvp_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case ZmulvvOp: + forward_zmulvv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + default: CPPAD_ASSERT_UNKNOWN(0); } @@ -666,11 +728,11 @@ for(i = 0; i < user_m; i++) if( user_iy[i] > 0 ) { size_t i_tmp = (i_op + i) - user_m; printOp( - std::cout, + std::cout, play, i_tmp, user_iy[i], - UsrrvOp, + UsrrvOp, CPPAD_NULL ); Base* Z_tmp = taylor + user_iy[i]*((J-1) * r + 1); @@ -680,10 +742,10 @@ for(size_t p_tmp = 1; p_tmp <= q; p_tmp++) Z_vec[p_tmp] = Z_tmp[(p_tmp-1)*r+ell+1]; printOpResult( - std::cout, - q + 1, + std::cout, + q + 1, Z_vec.data(), - 0, + 0, (Base *) CPPAD_NULL ); } @@ -698,11 +760,11 @@ arg_tmp = arg - arg[-1] - 7; if( op != UsrrvOp ) { printOp( - std::cout, + std::cout, play, i_op, i_var, - op, + op, arg_tmp ); Base* Z_tmp = CPPAD_NULL; @@ -717,10 +779,10 @@ for(size_t p_tmp = 1; p_tmp <= q; p_tmp++) Z_vec[p_tmp] = Z_tmp[ (p_tmp-1)*r + ell + 1]; printOpResult( - std::cout, - q + 1, + std::cout, + q + 1, Z_vec.data(), - 0, + 0, (Base *) CPPAD_NULL ); } @@ -735,7 +797,7 @@ CPPAD_ASSERT_UNKNOWN( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( i_var + 1 == play->num_var_rec() ); - return compareCount; + return; } // preprocessor symbols that are local to this file diff -Nru cppad-2015.00.00.9/cppad/local/forward.hpp cppad-2016.00.00.1/cppad/local/forward.hpp --- cppad-2015.00.00.9/cppad/local/forward.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/forward.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: forward.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_FORWARD_INCLUDED -# define CPPAD_FORWARD_INCLUDED +// $Id: forward.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FORWARD_HPP +# define CPPAD_FORWARD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,6 +16,7 @@ // documened after Forward but included here so easy to see # include # include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -34,14 +35,14 @@ is a Simple Vector class with eleements of type Base. \param q -is the hightest order for this forward mode computation; i.e., +is the hightest order for this forward mode computation; i.e., after this calculation there will be q+1 Taylor coefficients per variable. \param xq contains Taylor coefficients for the independent variables. The size of xq must either be n or (q+1)*n, -We define p = q + 1 - xq.size()/n. +We define p = q + 1 - xq.size()/n. For j = 0 , ... , n-1, k = p, ... , q, are xq[ (q+1-p)*j + k - p ] @@ -55,7 +56,7 @@ The size of the return value y is m*(q+1-p). For i = 0, ... , m-1, k = p, ..., q, -y[(q+1-p)*i + (k-p)] +y[(q+1-p)*i + (k-p)] is the k-th order coefficient for the i-th dependent variable. \par taylor_ @@ -69,15 +70,15 @@ taylor_[ C*i + k ] is the k-th order cofficent, for the i-th varaible on the tape. -(The first independent variable has index one on the tape +(The first independent variable has index one on the tape and there is no variable with index zero.) */ template template VectorBase ADFun::Forward( - size_t q , - const VectorBase& xq , + size_t q , + const VectorBase& xq , std::ostream& s ) { // temporary indices size_t i, j, k; @@ -104,7 +105,7 @@ q <= num_order_taylor_ || p == 0, "Forward(q, xq): Number of Taylor coefficient orders stored in this" " ADFun\nis less than q and xq.size() != n*(q+1)." - ); + ); CPPAD_ASSERT_KNOWN( p <= 1 || num_direction_taylor_ == 1, "Forward(q, xq): computing order q >= 2" @@ -147,22 +148,21 @@ CPPAD_ASSERT_UNKNOWN( cskip_op_.size() == play_.num_op_rec() ); CPPAD_ASSERT_UNKNOWN( load_op_.size() == play_.num_load_op_rec() ); if( q == 0 ) - { - compare_change_ = forward0sweep(s, true, - n, num_var_tape_, &play_, C, - taylor_.data(), cskip_op_.data(), load_op_ - ); - } - else if( p == 0 ) - { compare_change_ = forward1sweep(s, true, p, q, - n, num_var_tape_, &play_, C, - taylor_.data(), cskip_op_.data(), load_op_ + { forward0sweep(s, true, + n, num_var_tape_, &play_, C, + taylor_.data(), cskip_op_.data(), load_op_, + compare_change_count_, + compare_change_number_, + compare_change_op_index_ ); } else - { forward1sweep(s, true, p, q, - n, num_var_tape_, &play_, C, - taylor_.data(), cskip_op_.data(), load_op_ + { forward1sweep(s, true, p, q, + n, num_var_tape_, &play_, C, + taylor_.data(), cskip_op_.data(), load_op_, + compare_change_count_, + compare_change_number_, + compare_change_op_index_ ); } @@ -177,25 +177,59 @@ } else { yq.resize(m * (q+1) ); - for(i = 0; i < m; i++) + for(i = 0; i < m; i++) { for(k = 0; k <= q; k++) - yq[ (q+1) * i + k] = - taylor_[ C * dep_taddr_[i] + k ]; + yq[ (q+1) * i + k] = + taylor_[ C * dep_taddr_[i] + k ]; } } # ifndef NDEBUG if( check_for_nan_ ) { bool ok = true; + size_t index = m; if( p == 0 ) { for(i = 0; i < m; i++) { // Visual Studio 2012, CppAD required in front of isnan ? - ok &= ! CppAD::isnan( yq[ (q+1) * i + 0 ] ); + if( CppAD::isnan( yq[ (q+1) * i + 0 ] ) ) + { ok = false; + if( index == m ) + index = i; + } } - } + } + if( ! ok ) + { CPPAD_ASSERT_UNKNOWN( index < m ); + // + CppAD::vector x0(n); + for(j = 0; j < n; j++) + x0[j] = taylor_[ C * ind_taddr_[j] + 0 ]; + std::string file_name; + put_check_for_nan(x0, file_name); + std::stringstream ss; + ss << + "yq = f.Forward(q, xq): a zero order Taylor coefficient is nan.\n" + "Corresponding independent variables vector was written " + "to binary a file.\n" + "vector_size = " << n << "\n" << + "file_name = " << file_name << "\n" << + "index = " << index << "\n"; + // ss.str() returns a string object with a copy of the current + // contents in the stream buffer. + std::string msg_str = ss.str(); + // msg_str.c_str() returns a pointer to the c-string + // representation of the string object's value. + const char* msg_char_star = msg_str.c_str(); + ErrorHandler::Call( + true, + __LINE__, + __FILE__, + "if( CppAD::isnan( yq[ (q+1) * index + 0 ] )", + msg_char_star + ); + } CPPAD_ASSERT_KNOWN(ok, - "yq = f.Forward(q, xq): has a zero order Taylor coefficient " "with the value nan." - ); + ); if( 0 < q ) { for(i = 0; i < m; i++) { for(k = p; k <= q; k++) @@ -244,7 +278,7 @@ contains Taylor coefficients for the independent variables. The size of xq must either be r*n, For j = 0 , ... , n-1, -ell = 0, ... , r-1, +ell = 0, ... , r-1, xq[ ( r*j + ell ] is the q-th order coefficient for the j-th independent variable and the ell-th direction. @@ -253,8 +287,8 @@ contains Taylor coefficients for the dependent variables. The size of the return value \c y is r*m. For i = 0, ... , m-1, -ell = 0, ... , r-1, -y[ r*i + ell ] +ell = 0, ... , r-1, +y[ r*i + ell ] is the q-th order coefficient for the i-th dependent variable and the ell-th direction. @@ -274,15 +308,15 @@ taylor_[ (C-1)*r*i + i + (k-1)*r + ell + 1 ] is the k-th order cofficent, for the i-th varaible, and ell-th direction. -(The first independent variable has index one on the tape +(The first independent variable has index one on the tape and there is no variable with index zero.) */ template template VectorBase ADFun::Forward( - size_t q , - size_t r , + size_t q , + size_t r , const VectorBase& xq ) { // temporary indices size_t i, j, ell; @@ -305,13 +339,13 @@ q <= num_order_taylor_ , "Forward(q, r, xq): Number of Taylor coefficient orders stored in" " this ADFun is less than q" - ); + ); CPPAD_ASSERT_KNOWN( q == 1 || num_direction_taylor_ == r , "Forward(q, r, xq): q > 1 and number of Taylor directions r" " is not same as previous Forward(1, r, xq)" ); - + // does taylor_ need more orders or new number of directions if( cap_order_taylor_ <= q || num_direction_taylor_ != r ) { if( num_direction_taylor_ != r ) @@ -343,14 +377,14 @@ CPPAD_ASSERT_UNKNOWN( cskip_op_.size() == play_.num_op_rec() ); CPPAD_ASSERT_UNKNOWN( load_op_.size() == play_.num_load_op_rec() ); forward2sweep( - q, - r, - n, - num_var_tape_, - &play_, - c, - taylor_.data(), - cskip_op_.data(), + q, + r, + n, + num_var_tape_, + &play_, + c, + taylor_.data(), + cskip_op_.data(), load_op_ ); diff -Nru cppad-2015.00.00.9/cppad/local/fun_check.hpp cppad-2016.00.00.1/cppad/local/fun_check.hpp --- cppad-2015.00.00.9/cppad/local/fun_check.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/fun_check.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: fun_check.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_FUN_CHECK_INCLUDED -# define CPPAD_FUN_CHECK_INCLUDED +// $Id: fun_check.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FUN_CHECK_HPP +# define CPPAD_FUN_CHECK_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,9 +22,6 @@ Taylor $$ -$index FunCheck$$ -$index check, ADFun$$ -$index ADFun, check$$ $section Check an ADFun Sequence of Operations$$ @@ -77,7 +74,7 @@ const %Vector% &%x% %$$ (see $cref/Vector/FunCheck/Vector/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. @@ -87,7 +84,7 @@ %Vector% %y% %$$ and its value is $latex G(x)$$. -The size of $icode y$$ +The size of $icode y$$ is equal to $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. @@ -96,11 +93,11 @@ $codei% const %Vector% &%x% %$$ -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. This specifies that point at which to compare the values -calculated by $icode f$$ and $icode G$$. +calculated by $icode f$$ and $icode G$$. $head r$$ The $code FunCheck$$ argument $icode r$$ has prototype @@ -123,12 +120,12 @@ $codei% bool %ok% %$$ -It is true, if for $latex i = 0 , \ldots , m-1$$ +It is true, if for $latex i = 0 , \ldots , m-1$$ either the relative error bound is satisfied $latex \[ -| F_i (x) - G_i (x) | -\leq -r ( | F_i (x) | + | G_i (x) | ) +| F_i (x) - G_i (x) | +\leq +r ( | F_i (x) | + | G_i (x) | ) \] $$ or the absolute error bound is satisfied $latex \[ @@ -146,7 +143,7 @@ $head FunCheck Uses Forward$$ After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After $code FunCheck$$, the previous calls to $cref Forward$$ are undefined. @@ -157,13 +154,13 @@ if( %x% >= 0 ) %y% = exp(%x%) else %y% = exp(-%x%) -%$$ +%$$ where $icode x$$ and $icode y$$ are $codei%AD%$$ objects. -It follows that the +It follows that the AD of $code double$$ $cref/operation sequence/glossary/Operation/Sequence/$$ depends on the value of $icode x$$. -If the sequence of operations stored in $icode f$$ corresponds to -$icode g$$ with $latex x \geq 0$$, +If the sequence of operations stored in $icode f$$ corresponds to +$icode g$$ with $latex x \geq 0$$, the function values computed using $icode f$$ when $latex x < 0$$ will not agree with the function values computed by $latex g$$. This is because the operation sequence corresponding to $icode g$$ changed @@ -171,8 +168,8 @@ $latex G$$ for this value of $icode x$$). In this case, you probably want to re-tape the calculations performed by $icode g$$ with the -$cref/independent variables/glossary/Tape/Independent Variable/$$ -equal to the values in $icode x$$ +$cref/independent variables/glossary/Tape/Independent Variable/$$ +equal to the values in $icode x$$ (so AD operation sequence properly represents the algorithm for this value of independent variables). @@ -183,7 +180,7 @@ %$$ The file $cref fun_check.cpp$$ -contains an example and test of this function. +contains an example and test of this function. It returns true if it succeeds and false otherwise. $end @@ -193,17 +190,17 @@ namespace CppAD { template bool FunCheck( - ADFun &f , - Fun &g , - const Vector &x , + ADFun &f , + Fun &g , + const Vector &x , const Base &r , const Base &a ) { bool ok = true; - + size_t m = f.Range(); - Vector yf = f.Forward(0, x); + Vector yf = f.Forward(0, x); Vector yg = g(x); - + size_t i; for(i = 0; i < m; i++) ok &= NearEqual(yf[i], yg[i], r, a); diff -Nru cppad-2015.00.00.9/cppad/local/fun_construct.hpp cppad-2016.00.00.1/cppad/local/fun_construct.hpp --- cppad-2015.00.00.9/cppad/local/fun_construct.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/fun_construct.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: fun_construct.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_FUN_CONSTRUCT_INCLUDED -# define CPPAD_FUN_CONSTRUCT_INCLUDED +// $Id: fun_construct.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FUN_CONSTRUCT_HPP +# define CPPAD_FUN_CONSTRUCT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,7 +14,7 @@ -------------------------------------------------------------------------- */ /* $begin FunConstruct$$ -$spell +$spell alloc num Jac @@ -30,11 +30,8 @@ $$ $section Construct an ADFun Object and Stop Recording$$ +$mindex tape$$ -$index ADFun, construct$$ -$index construct, ADFun$$ -$index tape, stop recording$$ -$index recording, stop tape$$ $head Syntax$$ $codei%ADFun<%Base%> %f%, %g% @@ -46,7 +43,7 @@ $head Purpose$$ -The $codei%AD<%Base%>%$$ object $icode f$$ can +The $codei%AD<%Base%>%$$ object $icode f$$ can store an AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. It can then be used to calculate derivatives of the corresponding @@ -68,7 +65,7 @@ $codei% Independent(%x%) %$$ -and +and $codei% ADFun<%Base%> %f%(%x%, %y%) %$$ @@ -83,20 +80,17 @@ $head VectorAD$$ The type $icode VectorAD$$ must be a $cref SimpleVector$$ class with -$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ $codei%AD<%Base%>%$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Default Constructor$$ -$index default, ADFun constructor$$ -$index ADFun, default constructor$$ -$index constructor, ADFun constructor$$ -The default constructor +The default constructor $codei% ADFun<%Base%> %f% %$$ -creates an +creates an $codei%AD<%Base%>%$$ object with no corresponding operation sequence; i.e., $codei% %f%.size_var() @@ -104,10 +98,7 @@ returns the value zero (see $cref/size_var/seq_property/size_var/$$). $head Sequence Constructor$$ -$index sequence, ADFun constructor$$ -$index ADFun, sequence constructor$$ -$index constructor, ADFun sequence$$ -The sequence constructor +The sequence constructor $codei% ADFun<%Base%> %f%(%x%, %y%) %$$ @@ -118,7 +109,7 @@ Independent(%x%) %$$ and stores the corresponding operation sequence in the object $icode f$$. -It then stores the zero order Taylor coefficients +It then stores the zero order Taylor coefficients (corresponding to the value of $icode x$$) in $icode f$$. This is equivalent to the following steps using the default constructor: @@ -134,7 +125,7 @@ %$$ (see $cref Dependent$$). $lnext -Calculate the zero order Taylor coefficients for all +Calculate the zero order Taylor coefficients for all the variables in the operation sequence using $codei% %f%.Forward(%p%, %x_p%) @@ -145,9 +136,6 @@ $lend $head Copy Constructor$$ -$index copy, ADFun constructor$$ -$index ADFun, copy constructor$$ -$index constructor, ADFun copy$$ It is an error to attempt to use the $codei%ADFun<%Base%>%$$ copy constructor; i.e., the following syntax is not allowed: $codei% @@ -158,9 +146,6 @@ and its assignment operator. $head Assignment Operator$$ -$index ADFun, assignment operator$$ -$index assignment, ADFun operator$$ -$index operator, ADFun assignment$$ The $codei%ADFun<%Base%>%$$ assignment operation $codei% %g% = %f% @@ -173,8 +158,8 @@ and any information originally in $icode g$$ is lost. $subhead Taylor Coefficients$$ -The Taylor coefficient information currently stored in $icode f$$ -(computed by $cref/f.Forward/Forward/$$) is +The Taylor coefficient information currently stored in $icode f$$ +(computed by $cref/f.Forward/Forward/$$) is copied to $icode g$$. Hence, directly after this operation $codei% @@ -182,8 +167,8 @@ %$$ $subhead Sparsity Patterns$$ -The forward Jacobian sparsity pattern currently stored in $icode f$$ -(computed by $cref/f.ForSparseJac/ForSparseJac/$$) is +The forward Jacobian sparsity pattern currently stored in $icode f$$ +(computed by $cref/f.ForSparseJac/ForSparseJac/$$) is copied to $icode g$$. Hence, directly after this operation $codei% @@ -192,14 +177,12 @@ %$$ $head Parallel Mode$$ -$index parallel, ADFun$$ -$index ADFun, parallel$$ The call to $code Independent$$, and the corresponding call to $codei% ADFun<%Base%> %f%( %x%, %y%) %$$ -or +or $codei% %f%.Dependent( %x%, %y%) %$$ @@ -211,13 +194,13 @@ $subhead Sequence Constructor$$ The file -$cref independent.cpp$$ +$cref independent.cpp$$ contains an example and test of the sequence constructor. It returns true if it succeeds and false otherwise. $subhead Default Constructor$$ The files -$cref fun_check.cpp$$ +$cref fun_check.cpp$$ and $cref hes_lagrangian.cpp$$ contain an examples and tests using the default constructor. @@ -227,7 +210,7 @@ example/fun_assign.cpp %$$ $subhead Assignment Operator$$ -The file +The file $cref fun_assign.cpp$$ contains an example and test of the $codei%ADFun<%Base%>%$$ assignment operator. @@ -250,7 +233,7 @@ \verbatim ADFun f \endverbatim -An empty ADFun object is created. +An empty ADFun object is created. The Dependent member function, or the ADFun assingment operator, can then be used to put an operation sequence in this ADFun object. @@ -260,9 +243,13 @@ i.e., operation sequences that were recorded using the type \c AD. */ template -ADFun::ADFun(void) : +ADFun::ADFun(void) : +has_been_optimized_(false), check_for_nan_(true) , -num_var_tape_(0) +compare_change_count_(1), +compare_change_number_(0), +compare_change_op_index_(0), +num_var_tape_(0) { } /*! @@ -273,7 +260,7 @@ g = f \endverbatim where \c g and \c f are ADFun ADFun objects. -A copy of the the operation sequence currently stored in \c f +A copy of the the operation sequence currently stored in \c f is placed in this ADFun object (called \c g above). Any information currently stored in this ADFun object is lost. @@ -291,10 +278,13 @@ size_t i; // go through member variables in ad_fun.hpp order - // + // // size_t objects + has_been_optimized_ = f.has_been_optimized_; check_for_nan_ = f.check_for_nan_; - compare_change_ = f.compare_change_; + compare_change_count_ = f.compare_change_count_; + compare_change_number_ = f.compare_change_number_; + compare_change_op_index_ = f.compare_change_op_index_; num_order_taylor_ = f.num_order_taylor_; cap_order_taylor_ = f.cap_order_taylor_; num_direction_taylor_ = f.num_direction_taylor_; @@ -383,7 +373,7 @@ depenedent variables are checked against the values in \a y. Thus, the zero order Taylor coefficients corresponding to the value of the \a x vector -are stored in this ADFun object. +are stored in this ADFun object. */ template template @@ -427,6 +417,7 @@ // stop the tape and store the operation sequence Dependent(tape, y); + // ad_fun.hpp member values not set by dependent check_for_nan_ = true; @@ -450,34 +441,45 @@ // use independent variable values to fill in values for others CPPAD_ASSERT_UNKNOWN( cskip_op_.size() == play_.num_op_rec() ); CPPAD_ASSERT_UNKNOWN( load_op_.size() == play_.num_load_op_rec() ); - compare_change_ = forward0sweep(std::cout, false, + forward0sweep(std::cout, false, n, num_var_tape_, &play_, cap_order_taylor_, taylor_.data(), - cskip_op_.data(), load_op_ + cskip_op_.data(), load_op_, + compare_change_count_, + compare_change_number_, + compare_change_op_index_ ); - CPPAD_ASSERT_UNKNOWN( compare_change_ == 0 ); + CPPAD_ASSERT_UNKNOWN( compare_change_count_ == 1 ); + CPPAD_ASSERT_UNKNOWN( compare_change_number_ == 0 ); + CPPAD_ASSERT_UNKNOWN( compare_change_op_index_ == 0 ); // now set the number of orders stored num_order_taylor_ = 1; # ifndef NDEBUG // on MS Visual Studio 2012, CppAD required in front of isnan ? - for(i = 0; i < m; i++) + for(i = 0; i < m; i++) if( taylor_[dep_taddr_[i]] != y[i].value_ || CppAD::isnan( y[i].value_ ) ) { using std::endl; std::ostringstream buf; buf << "A dependent variable value is not equal to " << "its tape evaluation value," << endl << "perhaps it is nan." << endl - << "Dependent variable value = " + << "Dependent variable value = " << y[i].value_ << endl - << "Tape evaluation value = " + << "Tape evaluation value = " << taylor_[dep_taddr_[i]] << endl - << "Difference = " + << "Difference = " << y[i].value_ - taylor_[dep_taddr_[i]] << endl ; + // buf.str() returns a string object with a copy of the current + // contents in the stream buffer. + std::string msg_str = buf.str(); + // msg_str.c_str() returns a pointer to the c-string + // representation of the string object's value. + const char* msg_char_star = msg_str.c_str(); CPPAD_ASSERT_KNOWN( 0, - buf.str().c_str() + msg_char_star ); } # endif diff -Nru cppad-2015.00.00.9/cppad/local/fun_eval.hpp cppad-2016.00.00.1/cppad/local/fun_eval.hpp --- cppad-2015.00.00.9/cppad/local/fun_eval.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/fun_eval.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: fun_eval.hpp 3174 2014-03-10 01:26:06Z bradbell $ */ -# ifndef CPPAD_FUN_EVAL_INCLUDED -# define CPPAD_FUN_EVAL_INCLUDED +// $Id: fun_eval.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FUN_EVAL_HPP +# define CPPAD_FUN_EVAL_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,8 +18,6 @@ $spell $$ -$index evaluate, ADFun$$ -$index ADFun, evaluate$$ $section Evaluate ADFun Functions, Derivatives, and Sparsity Patterns$$ diff -Nru cppad-2015.00.00.9/cppad/local/hash_code.hpp cppad-2016.00.00.1/cppad/local/hash_code.hpp --- cppad-2015.00.00.9/cppad/local/hash_code.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/hash_code.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: hash_code.hpp 3639 2015-02-11 02:01:35Z bradbell $ */ -# ifndef CPPAD_HASH_CODE_INCLUDED -# define CPPAD_HASH_CODE_INCLUDED +// $Id: hash_code.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_HASH_CODE_HPP +# define CPPAD_HASH_CODE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,8 +21,8 @@ /*! \def CPPAD_HASH_TABLE_SIZE -the codes retruned by hash_code are between zero and CPPAD_HASH_TABLE_SIZE -minus one. +the codes retruned by hash_code are between zero and CPPAD_HASH_TABLE_SIZE +minus one. */ # define CPPAD_HASH_TABLE_SIZE 10000 @@ -43,13 +43,13 @@ \par Checked Assertions \li \c std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE -\li \c sizeof(value) is even +\li \c sizeof(value) is even \li \c sizeof(unsigned short) == 2 */ template unsigned short hash_code(const Value& value) -{ CPPAD_ASSERT_UNKNOWN( +{ CPPAD_ASSERT_UNKNOWN( std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE @@ -79,20 +79,20 @@ hash coded and zero is returned: \li unary operators: -AbsOp, AcosOp, AsinOp, AtanOp, CosOp, CoshOp -ExpOp, LogOp, SinOp, SinhOp, SqrtOp, TanOp, TanhOp +AbsOp, AcosOp, AcoshOp, AsinOp, AsinhOp, AtanOp, AtanhOp, CosOp, CoshOp +ExpOp, Expm1Op, LogOp, Log1pOp, SinOp, SinhOp, SqrtOp, TanOp, TanhOp \li binary operators where first argument is a parameter: -AddpvOp, DivpvOp, MulpvOp, PowpvOp, SubpvOp, +AddpvOp, DivpvOp, MulpvOp, PowpvOp, SubpvOp, ZmulpvOp \li binary operators where second argument is a parameter: -DivvpOp, PowvpOp, SubvpOp +DivvpOp, PowvpOp, SubvpOp, Zmulvp \li binary operators where first is an index and second is a variable: DisOp \li binary operators where both arguments are variables: -AddvvOp, DivvvOp, MulvvOp, PowvvOp, SubvvOp +AddvvOp, DivvvOp, MulvvOp, PowvvOp, SubvvOp, ZmulvvOp \param arg is a vector of length \c NumArg(op) or 2 (which ever is smaller), @@ -113,9 +113,9 @@ \par Checked Assertions \c op must be one of the operators specified above. In addition, -\li \c std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE -\li \c sizeof(size_t) is even -\li \c sizeof(Base) is even +\li \c std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE +\li \c sizeof(size_t) is even +\li \c sizeof(Base) is even \li \c sizeof(unsigned short) == 2 \li \c size_t(op) < size_t(NumberOp) <= CPPAD_HASH_TABLE_SIZE \li if the j-th argument for this operation is a parameter, arg[j] < npar. @@ -123,11 +123,11 @@ template unsigned short hash_code( - OpCode op , - const addr_t* arg , - size_t npar , + OpCode op , + const addr_t* arg , + size_t npar , const Base* par ) -{ CPPAD_ASSERT_UNKNOWN( +{ CPPAD_ASSERT_UNKNOWN( std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE @@ -167,6 +167,7 @@ case MulpvOp: case PowpvOp: case SubpvOp: + case ZmulpvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); v = reinterpret_cast(par + arg[0]); i = short_base; @@ -188,6 +189,7 @@ case MulvvOp: case PowvvOp: case SubvvOp: + case ZmulvvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); v = reinterpret_cast(arg + 0); i = 2 * short_addr_t; @@ -199,6 +201,7 @@ case DivvpOp: case PowvpOp: case SubvpOp: + case ZmulvpOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); v = reinterpret_cast(arg + 0); i = short_addr_t; @@ -213,19 +216,25 @@ // Unary operators case AbsOp: case AcosOp: + case AcoshOp: case AsinOp: + case AsinhOp: case AtanOp: + case AtanhOp: case CosOp: case CoshOp: case ErfOp: case ExpOp: + case Expm1Op: case LogOp: + case Log1pOp: case SignOp: case SinOp: case SinhOp: case SqrtOp: case TanOp: case TanhOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 || op == ErfOp ); v = reinterpret_cast(arg + 0); i = short_addr_t; while(i--) diff -Nru cppad-2015.00.00.9/cppad/local/hessian.hpp cppad-2016.00.00.1/cppad/local/hessian.hpp --- cppad-2015.00.00.9/cppad/local/hessian.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/hessian.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: hessian.hpp 2683 2012-12-30 18:17:03Z bradbell $ */ -# ifndef CPPAD_HESSIAN_INCLUDED -# define CPPAD_HESSIAN_INCLUDED +// $Id: hessian.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_HESSIAN_HPP +# define CPPAD_HESSIAN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,11 +23,9 @@ const $$ -$index Hessian, driver$$ -$index second, derivative$$ -$index driver, Hessian$$ $section Hessian: Easy Driver$$ +$mindex second derivative$$ $head Syntax$$ $icode%hes% = %f%.Hessian(%x%, %w%) @@ -39,10 +37,10 @@ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. -The syntax above sets $icode hes$$ to the Hessian -The syntax above sets $icode h$$ to the Hessian +The syntax above sets $icode hes$$ to the Hessian +The syntax above sets $icode h$$ to the Hessian $latex \[ - hes = \dpow{2}{x} \sum_{i=1}^m w_i F_i (x) + hes = \dpow{2}{x} \sum_{i=1}^m w_i F_i (x) \] $$ The routine $cref sparse_hessian$$ may be faster in the case where the Hessian is sparse. @@ -61,7 +59,7 @@ const %Vector% &%x% %$$ (see $cref/Vector/Hessian/Vector/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. It specifies @@ -90,7 +88,7 @@ const %Vector% &%w% %$$ and size $latex m$$. -It specifies the value of $latex w_i$$ in the expression +It specifies the value of $latex w_i$$ in the expression for $icode h$$. $head hes$$ @@ -100,7 +98,7 @@ %$$ (see $cref/Vector/Hessian/Vector/$$ below) and its size is $latex n * n$$. -For $latex j = 0 , \ldots , n - 1 $$ +For $latex j = 0 , \ldots , n - 1 $$ and $latex \ell = 0 , \ldots , n - 1$$ $latex \[ hes [ j * n + \ell ] = \DD{ w^{\rm T} F }{ x_j }{ x_\ell } ( x ) @@ -115,7 +113,7 @@ $head Hessian Uses Forward$$ After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After a call to $code Hessian$$, the zero order Taylor coefficients correspond to @@ -127,7 +125,7 @@ example/hessian.cpp% example/hes_lagrangian.cpp %$$ -The routines +The routines $cref hessian.cpp$$ and $cref hes_lagrangian.cpp$$ are examples and tests of $code Hessian$$. @@ -173,7 +171,7 @@ CPPAD_ASSERT_KNOWN( size_t(x.size()) == n, "Hessian: length of x not equal domain dimension for f" - ); + ); CPPAD_ASSERT_KNOWN( size_t(w.size()) == Range(), "Hessian: length of w not equal range dimension for f" @@ -208,7 +206,7 @@ for(k = 0; k < n; k++) hes[k * n + j] = ddw[k * 2 + 1]; } - + return hes; } diff -Nru cppad-2015.00.00.9/cppad/local/identical.hpp cppad-2016.00.00.1/cppad/local/identical.hpp --- cppad-2015.00.00.9/cppad/local/identical.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/identical.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: identical.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_IDENTICAL_INCLUDED -# define CPPAD_IDENTICAL_INCLUDED +// $Id: identical.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_IDENTICAL_HPP +# define CPPAD_IDENTICAL_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,7 +23,7 @@ // --------------------------------------------------------------------------- /*! -Determine if an AD object is a parameter, and could never have +Determine if an AD object is a parameter, and could never have a different value during any tape playback. An AD object \c x is identically a parameter if and only if @@ -78,7 +78,7 @@ { return Parameter(x) && IdenticalOne(x.value_); } // Equal =================================================================== /*! -Determine if two AD objects are equal, +Determine if two AD objects are equal, and must be equal during any tape playback. \param x @@ -97,7 +97,7 @@ (const AD &x, const AD &y) { bool parameter; parameter = ( Parameter(x) & Parameter(y) ); - return parameter && IdenticalEqualPar(x.value_, y.value_); + return parameter && IdenticalEqualPar(x.value_, y.value_); } // ========================================================================== diff -Nru cppad-2015.00.00.9/cppad/local/independent.hpp cppad-2016.00.00.1/cppad/local/independent.hpp --- cppad-2015.00.00.9/cppad/local/independent.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/independent.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: independent.hpp 3146 2014-03-03 12:33:40Z bradbell $ */ -# ifndef CPPAD_INDEPENDENT_INCLUDED -# define CPPAD_INDEPENDENT_INCLUDED +// $Id: independent.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_INDEPENDENT_HPP +# define CPPAD_INDEPENDENT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,6 +17,7 @@ $begin Independent$$ $spell + op alloc num Cpp @@ -26,28 +27,27 @@ typename $$ -$index Independent$$ -$index start, recording$$ -$index recording, start$$ -$index variable, independent$$ - $section Declare Independent Variables and Start Recording$$ $head Syntax$$ -$codei%Independent(%x%)%$$ +$codei%Independent(%x%) +%$$ +$codei%Independent(%x%, %abort_op_index%) +%$$ $head Purpose$$ -Start recording +Start recording $cref/AD of Base/glossary/AD of Base/$$ operations with $icode x$$ as the independent variable vector. -Once the +Once the $cref/operation sequence/glossary/Operation/Sequence/$$ is completed, it must be transferred to a function object; see below. $head Start Recording$$ -An operation sequence recording is started by the command +An operation sequence recording is started by the commands $codei% Independent(%x%) + Independent(%x%, %abort_op_index%) %$$ $head Stop Recording$$ @@ -55,18 +55,18 @@ and the operation sequence is transferred to the AD function object $icode f$$, using either the $cref/function constructor/FunConstruct/$$ $codei% - ADFun<%Base%> %f%( %x%, %y%) + ADFun<%Base%> %f%(%x%, %y%) %$$ or the $cref/dependent variable specifier/Dependent/$$ $codei% - %f%.Dependent( %x%, %y%) + %f%.Dependent(%x%, %y%) %$$ The only other way to stop a recording is using $cref abort_recording$$. Between when the recording is started and when it stopped, -we refer to the elements of $icode x$$, +we refer to the elements of $icode x$$, and the values that depend on the elements of $icode x$$, -as $codei%AD<%Base%>%$$ variables. +as $codei%AD<%Base%>%$$ variables. $head x$$ The vector $icode x$$ has prototype @@ -78,6 +78,16 @@ and is the number of independent variables for this AD operation sequence. +$head abort_op_index$$ +It specifies the operator index at which the execution is be aborted +by calling the CppAD $cref/error handler/ErrorHandler/$$. +When this error handler leads to an assert, the user +can inspect the call stack to see the source code corresponding to +this operator index; see +$cref/purpose/compare_change/op_index/Purpose/$$. +No abort will occur if $icode abort_op_index$$ is zero, +of if $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined. + $head VectorAD$$ The type $icode VectorAD$$ must be a $cref SimpleVector$$ class with $cref/elements of type/SimpleVector/Elements of Specified Type/$$ @@ -86,19 +96,18 @@ if this is not the case. $head Parallel Mode$$ -$index parallel, Independent$$ -$index Independent, parallel$$ -The call to $code Independent$$, -and the corresponding call to +Each thread can have one, and only one, active recording. +A call to $code Independent$$ starts the recording for the current thread. +The recording must be stopped by a corresponding call to $codei% ADFun<%Base%> %f%( %x%, %y%) %$$ -or +or $codei% %f%.Dependent( %x%, %y%) %$$ -or $cref abort_recording$$, -must be preformed by the same thread; i.e., +or $cref abort_recording$$ +preformed by the same thread; i.e., $cref/thread_alloc::thread_num/ta_thread_num/$$ must be the same. $head Example$$ @@ -120,7 +129,7 @@ template template -void ADTape::Independent(VectorAD &x) +void ADTape::Independent(VectorAD &x, size_t abort_op_index) { // check VectorAD is Simple Vector class with AD elements CheckSimpleVector< AD, VectorAD>(); @@ -133,7 +142,10 @@ ); CPPAD_ASSERT_UNKNOWN( Rec_.num_var_rec() == 0 ); - // mark the beginning of the tape and skip the first variable index + // set the abort index before doing anything else + Rec_.set_abort_op_index(abort_op_index); + + // mark the beginning of the tape and skip the first variable index // (zero) because parameters use taddr zero CPPAD_ASSERT_NARG_NRES(BeginOp, 1, 1); Rec_.PutOp(BeginOp); @@ -155,7 +167,7 @@ } template -inline void Independent(VectorAD &x) +inline void Independent(VectorAD &x, size_t abort_op_index) { typedef typename VectorAD::value_type ADBase; typedef typename ADBase::value_type Base; CPPAD_ASSERT_KNOWN( @@ -165,11 +177,13 @@ "AD::abort_recording() would abort this previous recording." ); ADTape* tape = ADBase::tape_manage(tape_manage_new); - tape->Independent(x); + tape->Independent(x, abort_op_index); +} +template +inline void Independent(VectorAD &x) +{ size_t abort_op_index = 0; + Independent(x, abort_op_index); } } - - -} // END CppAD namespace # endif diff -Nru cppad-2015.00.00.9/cppad/local/integer.hpp cppad-2016.00.00.1/cppad/local/integer.hpp --- cppad-2015.00.00.9/cppad/local/integer.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/integer.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: integer.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_INTEGER_INCLUDED -# define CPPAD_INTEGER_INCLUDED +// $Id: integer.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_INTEGER_HPP +# define CPPAD_INTEGER_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,10 +25,7 @@ bool $$ -$index Integer$$ -$index AD, convert to integer$$ -$index convert, AD to integer$$ $section Convert From AD to Integer$$ @@ -55,9 +52,9 @@ %$$ the fractional part is dropped to form the integer value. For example, if $icode x$$ is 1.5, $icode i$$ is 1. -In general, if $latex x \geq 0$$, $icode i$$ is the +In general, if $latex x \geq 0$$, $icode i$$ is the greatest integer less than or equal $icode x$$. -If $latex x \leq 0$$, $icode i$$ is the +If $latex x \leq 0$$, $icode i$$ is the smallest integer greater than or equal $icode x$$. $subhead Complex Types$$ @@ -95,7 +92,7 @@ $cref integer.cpp$$ contains an example and test of this operation. -$end +$end ------------------------------------------------------------------------------ */ diff -Nru cppad-2015.00.00.9/cppad/local/jacobian.hpp cppad-2016.00.00.1/cppad/local/jacobian.hpp --- cppad-2015.00.00.9/cppad/local/jacobian.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/jacobian.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: jacobian.hpp 3307 2014-05-25 13:17:40Z bradbell $ */ -# ifndef CPPAD_JACOBIAN_INCLUDED -# define CPPAD_JACOBIAN_INCLUDED +// $Id: jacobian.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_JACOBIAN_HPP +# define CPPAD_JACOBIAN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,11 +24,9 @@ const $$ -$index Jacobian, driver$$ -$index first, derivative$$ -$index driver, Jacobian$$ $section Jacobian: Driver Routine$$ +$mindex Jacobian first derivative$$ $head Syntax$$ $icode%jac% = %f%.Jacobian(%x%)%$$ @@ -57,7 +55,7 @@ const %Vector% &%x% %$$ (see $cref/Vector/Jacobian/Vector/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. It specifies @@ -74,7 +72,7 @@ and $cref/range/seq_property/Range/$$ dimensions for $icode f$$. -For $latex i = 0 , \ldots , m - 1 $$ +For $latex i = 0 , \ldots , m - 1 $$ and $latex j = 0 , \ldots , n - 1$$ $latex \[. jac[ i * n + j ] = \D{ F_i }{ x_j } ( x ) @@ -93,7 +91,7 @@ order one Forward or order one Reverse to compute the Jacobian (depending on which it estimates will require less work). After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After a call to $code Jacobian$$, the zero order Taylor coefficients correspond to @@ -104,7 +102,7 @@ $children% example/jacobian.cpp %$$ -The routine +The routine $cref/Jacobian/jacobian.cpp/$$ is both an example and test. It returns $code true$$, if it succeeds and $code false$$ otherwise. @@ -136,7 +134,7 @@ // initialize all the components for(j = 0; j < n; j++) u[j] = Base(0); - + // loop through the different coordinate directions for(j = 0; j < n; j++) { // set u to the j-th coordinate direction @@ -171,7 +169,7 @@ // initialize all the components for(i = 0; i < m; i++) v[i] = Base(0); - + // loop through the different coordinate directions for(i = 0; i < m; i++) { if( f.Parameter(i) ) @@ -180,7 +178,7 @@ jac[ i * n + j ] = Base(0); } else - { + { // set v to the i-th coordinate direction v[i] = Base(1); @@ -207,13 +205,13 @@ CPPAD_ASSERT_KNOWN( size_t(x.size()) == n, "Jacobian: length of x not equal domain dimension for F" - ); + ); // point at which we are evaluating the Jacobian Forward(0, x); // work factor for forward mode - size_t workForward = n; + size_t workForward = n; // work factor for reverse mode size_t workReverse = 0; diff -Nru cppad-2015.00.00.9/cppad/local/limits.hpp cppad-2016.00.00.1/cppad/local/limits.hpp --- cppad-2015.00.00.9/cppad/local/limits.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/limits.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,175 +0,0 @@ -/* $Id: limits.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_LIMITS_INCLUDED -# define CPPAD_LIMITS_INCLUDED -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------------------- -$begin limits$$ -$spell - std - eps - CppAD - namespace - const -$$ -$index limits, AD$$ -$index AD, limits$$ -$index epsilon, AD$$ -$index limit, max$$ -$index limit, min$$ -$index limit, epsilon$$ - -$section Numeric Limits For an AD and Base Types$$ - -$head Syntax$$ -$icode%eps% = numeric_limits<%Float%>::epsilon() -%$$ -$icode%min% = numeric_limits<%Float%>::min() -%$$ -$icode%max% = numeric_limits<%Float%>::max() -%$$ - -$head Purpose$$ -Obtain the value of some of the C++ standard numeric limits -using the CppAD namespace version of $code numeric_limits$$. -These are all functions and have the prototype -$codei% - %Float% numeric_limits<%Float%>::%fun%(%void%) -%$$ -where $icode fun$$ is $code epsilon$$, $code min$$, or $code max$$. -$pre - -$$ -Note that C++ standard specifies that Non-fundamental standard -types, such as $codei%std::complex<%T%>%$$ shall not have specializations -of $code std::numeric_limits$$; see Section 18.2 of -ISO/IEC 14882:1998(E). - -$head Float$$ -These functions are defined for all $codei%AD<%Base%>%$$, -and for all corresponding $icode Base$$ types; -see $icode Base$$ type $cref/limits/base_std_math/limits/$$. - -$head eps$$ -The result $icode eps$$ is equal to machine epsilon and has prototype -$codei% - %Float% %eps% -%$$ -CppAD tests the value $icode eps$$ by checking that the following are true -$codei% - 1 != 1 + %eps% - 1 == 1 + %eps% / 2 -%$$ -where all the values, and calculations, are done with the precision -corresponding to $icode Float$$. - - -$head min$$ -The result $icode min$$ is equal to -the minimum positive normalized value and has prototype -$codei% - %Float% %min% -%$$ -CppAD tests the value $icode min$$ by checking that the following are true -$codei% - abs( ((%min% / 100) * 100) / %min% - 1 ) > 3 * %eps% - abs( ((%min% * 100) / (100 * (1 - %eps%)) / %min% - 1 ) < 3 * %eps% -%$$ -where all the values, and calculations, are done with the precision -corresponding to $icode Float$$. - -$head max$$ -The result $icode max$$ is equal to -the maximum finite value and has prototype -$codei% - %Float% %max% -%$$ -CppAD tests the value $icode max$$ by checking that the following are true -$codei% - abs( ((%max% * 100) / 100) / %max% - 1 ) > 3 * %eps% - abs( ((%max% / 100) * (100 * (1 - %eps%)) / %max% - 1 ) < 3 * %eps% -%$$ -where all the values, and calculations, are done with the precision -corresponding to $icode Float$$. - -$head Example$$ -$children% - example/limits.cpp -%$$ -The file -$cref limits.cpp$$ -contains an example and test of these functions. - -$end ------------------------------------------------------------------------------- -*/ -# include - -# include -# include -# include -# include - -namespace CppAD { // BEGIN_CPPAD_NAMESPACE -/*! -\file limits.hpp -File that defines CppAD numeric_limits for AD types -*/ - -/// Default value for all undefined numeric_limits types -template -class numeric_limits { -public: - /// machine epsilon - static Float epsilon(void) - { CPPAD_ASSERT_KNOWN( - false, - "numeric_limits::epsilon() is not specialized for this Float" - ); - return Float(0); - } - /// minimum positive normalized value - static Float min(void) - { CPPAD_ASSERT_KNOWN( - false, - "numeric_limits::min() is not specialized for this Float" - ); - return Float(0); - } - /// maximum finite value - static Float max(void) - { CPPAD_ASSERT_KNOWN( - false, - "numeric_limits::max() is not specialized for this Float" - ); - return Float(0); - } -}; - -/// Partial specialization that defines limits for for all AD types -template -class numeric_limits< AD > { -public: - /// machine epsilon - static AD epsilon(void) - { return AD( numeric_limits::epsilon() ); } - /// minimum positive normalized value - static AD min(void) - { return AD( numeric_limits::min() ); } - /// maximum finite value - static AD max(void) - { return AD( numeric_limits::max() ); } -}; - -} // END_CPPAD_NAMESPACE -# endif diff -Nru cppad-2015.00.00.9/cppad/local/load_op.hpp cppad-2016.00.00.1/cppad/local/load_op.hpp --- cppad-2015.00.00.9/cppad/local/load_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/load_op.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: load_op.hpp 3624 2015-01-29 11:45:00Z bradbell $ */ -# ifndef CPPAD_LOAD_OP_INCLUDED -# define CPPAD_LOAD_OP_INCLUDED +// $Id: load_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_LOAD_OP_HPP +# define CPPAD_LOAD_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,21 +19,40 @@ \file load_op.hpp Setting a variable so that it corresponds to current value of a VecAD element. */ - +/* +============================================================================== + +The C++ source code corresponding to this operation is +\verbatim + v[x] = y +\endverbatim +where v is a VecAD vector, x is an AD object, +and y is AD or Base objects. +We define the index corresponding to v[x] by +\verbatim + i_v_x = index_by_ind[ arg[0] + i_vec ] +\endverbatim +where i_vec is defined under the heading arg[1] below: + +============================================================================== +*/ /*! -Shared documentation for zero order forward mode implementation of +Shared documentation for zero order forward mode implementation of op = LdpOp or LdvOp (not called). + The C++ source code corresponding to this operation is \verbatim - z = v[x] + v[x] = y \endverbatim -where v is a VecAD vector and x is an AD index. +where v is a VecAD vector, x is an AD object, +and y is AD or Base objects. We define the index corresponding to v[x] by \verbatim i_v_x = index_by_ind[ arg[0] + i_vec ] \endverbatim where i_vec is defined under the heading arg[1] below: + \tparam Base base type for the operator; i.e., this operation was recorded @@ -49,18 +68,18 @@ \param arg \n arg[0] -is the offset of this VecAD vector relative to the beginning +is the offset of this VecAD vector relative to the beginning of the isvar_by_ind and index)_by_ind arrays. \n -\n -arg[1] +\n +arg[1] \n If this is the LdpOp operation (if x is a parameter), i_vec is defined by \verbatim i_vec = arg[1] \endverbatim -If this is the LdvOp operation (if x is a variable), +If this is the LdvOp operation (if x is a variable), i_vec is defined by \verbatim i_vec = floor( taylor[ arg[1] * cap_order + 0 ] ) @@ -100,16 +119,16 @@ This vector has size play->num_vec_ind_rec(). \param index_by_ind -index_by_ind[ arg[0] - 1 ] +index_by_ind[ arg[0] - 1 ] is the number of elements in the user vector containing this element. -index_by_ind[ arg[0] + i_vec ] is the variable or +index_by_ind[ arg[0] + i_vec ] is the variable or parameter index for this element, This array has size play->num_vec_ind_rec(). \param var_by_load_op is a vector with size play->num_load_op_rec(). The input value of its elements does not matter. -Upon return, it contains the variable index corresponding to each load +Upon return, it contains the variable index corresponding to each load instruction. In the case where the index is zero, the instruction corresponds to a parameter (not variable). @@ -117,8 +136,8 @@ \par Check User Errors \li In the LdvOp case check that the index is with in range; i.e. -i_vec < index_by_ind[ arg[0] - 1 ]. -Note that, if x is a parameter, +i_vec < index_by_ind[ arg[0] - 1 ]. +Note that, if x is a parameter, the corresponding vector index and it does not change. In this case, the error above should be detected during tape recording. */ @@ -126,7 +145,7 @@ inline void forward_load_op_0( player* play , size_t i_z , - const addr_t* arg , + const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor , @@ -138,23 +157,30 @@ CPPAD_ASSERT_UNKNOWN( false ); } /*! -Shared documentation for sparsity operations corresponding to +Shared documentation for sparsity operations corresponding to op = LdpOp or LdvOp (not called). - + The C++ source code corresponding to this operation is \verbatim - z = v[x] + v[x] = y \endverbatim -where v is a VecAD vector and x is an AD index. +where v is a VecAD vector, x is an AD object, +and y is AD or Base objects. +We define the index corresponding to v[x] by +\verbatim + i_v_x = index_by_ind[ arg[0] + i_vec ] +\endverbatim +where i_vec is defined under the heading arg[1] below: + \tparam Vector_set is the type used for vectors of sets. It can be either \c sparse_pack, \c sparse_set, or \c sparse_list. \param op -is the code corresponding to this operator; i.e., LdpOp or LdvOp -(only used for error checking). +is the code corresponding to this operator; +i.e., LdpOp or LdvOp. \param i_z is the AD variable index corresponding to the variable z; i.e., @@ -191,19 +217,18 @@ For reverse mode operations, the sparsity pattern for z is added to the sparsity pattern for v. -\par Checked Assertions +\par Checked Assertions \li NumArg(op) == 3 \li NumRes(op) == 1 \li 0 < \a arg[0] \li \a arg[0] < \a num_combined \li i_v < \a vecad_sparsity.n_set() - */ template inline void sparse_load_op( OpCode op , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , @@ -223,7 +248,7 @@ inline void forward_load_p_op_0( player* play , size_t i_z , - const addr_t* arg , + const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor , @@ -266,7 +291,7 @@ inline void forward_load_v_op_0( player* play , size_t i_z , - const addr_t* arg , + const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor , @@ -279,13 +304,13 @@ CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < play->num_load_op_rec() ); size_t i_vec = Integer( taylor[ arg[1] * cap_order + 0 ] ); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( i_vec < index_by_ind[ arg[0] - 1 ] , "VecAD: index during zero order forward sweep is out of range" ); CPPAD_ASSERT_UNKNOWN( arg[0] + i_vec < play->num_vec_ind_rec() ); - size_t i_v_x = index_by_ind[ arg[0] + i_vec ]; + size_t i_v_x = index_by_ind[ arg[0] + i_vec ]; Base* z = taylor + i_z * cap_order; if( isvar_by_ind[ arg[0] + i_vec ] ) { CPPAD_ASSERT_UNKNOWN( i_v_x < i_z ); @@ -304,11 +329,20 @@ /*! Forward mode, except for zero order, for op = LdpOp or op = LdvOp + + The C++ source code corresponding to this operation is \verbatim - z = v[x] + v[x] = y \endverbatim -where v is a VecAD vector and x is an AD or Base index. +where v is a VecAD vector, x is an AD object, +and y is AD or Base objects. +We define the index corresponding to v[x] by +\verbatim + i_v_x = index_by_ind[ arg[0] + i_vec ] +\endverbatim +where i_vec is defined under the heading arg[1] below: + \tparam Base base type for the operator; i.e., this operation was recorded @@ -384,10 +418,10 @@ size_t r , size_t cap_order , size_t i_z , - const addr_t* arg , + const addr_t* arg , const addr_t* var_by_load_op , Base* taylor ) -{ +{ CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); @@ -423,22 +457,30 @@ /*! Reverse mode for op = LdpOp or LdvOp. + The C++ source code corresponding to this operation is \verbatim - z = y[x] + v[x] = y \endverbatim -where y is a VecAD vector and x is an AD or Base index. +where v is a VecAD vector, x is an AD object, +and y is AD or Base objects. +We define the index corresponding to v[x] by +\verbatim + i_v_x = index_by_ind[ arg[0] + i_vec ] +\endverbatim +where i_vec is defined under the heading arg[1] below: + -This routine is given the partial derivatives of a function +This routine is given the partial derivatives of a function G(z , y[x] , w , u ... ) -and it uses them to compute the partial derivatives of +and it uses them to compute the partial derivatives of \verbatim H( y[x] , w , u , ... ) = G[ z( y[x] ) , y[x] , w , u , ... ] \endverbatim \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param op @@ -474,7 +516,7 @@ Otherwise, y[x] is a variable and: \n \n -\a partial [ \a i_z * \a nc_partial + k ] +\a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G with respect to the k-th order Taylor coefficient for z. @@ -483,10 +525,10 @@ If \a arg[2] is not zero, \a partial [ \a arg[2] * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative with respect to +is the partial derivative with respect to the k-th order Taylor coefficient for x. On input, it corresponds to the function G, -and on output it corresponds to the the function H. +and on output it corresponds to the the function H. \param var_by_load_op is a vector with size play->num_load_op_rec(). @@ -494,7 +536,7 @@ In the case where the index is zero, the instruction corresponds to a parameter (not variable). -\par Checked Assertions +\par Checked Assertions \li NumArg(op) == 3 \li NumRes(op) == 1 \li d < cap_order @@ -505,7 +547,7 @@ OpCode op , size_t d , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t cap_order , const Base* taylor , size_t nc_partial , @@ -532,13 +574,17 @@ /*! Forward mode sparsity operations for LdpOp and LdvOp +\param dependency +is this a dependency (or sparsity) calculation. + \copydetails sparse_load_op */ template inline void forward_sparse_load_op( + bool dependency , OpCode op , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , @@ -552,6 +598,8 @@ CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); var_sparsity.assignment(i_z, i_v, vecad_sparsity); + if( dependency & (op == LdvOp) ) + var_sparsity.binary_union(i_z, i_z, arg[1], var_sparsity); return; } @@ -560,13 +608,17 @@ /*! Reverse mode Jacobian sparsity operations for LdpOp and LdvOp +\param dependency +is this a dependency (or sparsity) calculation. + \copydetails sparse_load_op */ template inline void reverse_sparse_jacobian_load_op( + bool dependency , OpCode op , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , @@ -580,6 +632,8 @@ CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); vecad_sparsity.binary_union(i_v, i_v, i_z, var_sparsity); + if( dependency & (op == LdvOp) ) + var_sparsity.binary_union(arg[1], arg[1], i_z, var_sparsity); return; } @@ -588,79 +642,16 @@ /*! Reverse mode Hessian sparsity operations for LdpOp and LdvOp -This routine is given the sparsity patterns for -G(z , v[x] , w , u ... ) -and it uses them to compute the sparsity patterns for -\verbatim - H( v[x] , w , u , ... ) = G[ z( v[x] ) , v[x] , w , u , ... ] -\endverbatim - - -The C++ source code corresponding to this operation is -\verbatim - z = v[x] -\endverbatim -where v is a VecAD vector and x is an AD index. - -\tparam Vector_set -is the type used for vectors of sets. It can be either -\c sparse_pack, \c sparse_set, or \c sparse_list. - -\param op -is the code corresponding to this operator; i.e., LdpOp or LdvOp -(only used for error checking). - -\param i_z -is the AD variable index corresponding to the variable z; i.e., -the set with index \a i_z in \a var_sparsity is the sparsity pattern -correpsonding to z. - -\param arg -\n -\a arg[0] -is the offset corresponding to this VecAD vector in the VecAD combined array. - -\param num_combined -is the total number of elements in the VecAD combinded array. - -\param combined -is the VecAD combined array. -\n -\n -\a combined[ \a arg[0] - 1 ] -is the index of the set corresponding to the vector v in \a vecad_sparsity. -We use the notation i_v for this value; i.e., -\verbatim - i_v = combined[ \a arg[0] - 1 ] -\endverbatim - -\param var_sparsity -The set with index \a i_z in \a var_sparsity is the sparsity pattern for z. -This is an output for forward mode operations, -and an input for reverse mode operations. - -\param vecad_sparsity -The set with index \a i_v is the sparsity pattern for the vector v. -This is an input for forward mode operations. -For reverse mode operations, -the sparsity pattern for z is added to the sparsity pattern for v. - -\par Checked Assertions -\li NumArg(op) == 3 -\li NumRes(op) == 1 -\li 0 < \a arg[0] -\li \a arg[0] < \a num_combined -\li i_v < \a vecad_sparsity.n_set() - +\copydetails sparse_load_op \param var_jacobian -\a var_jacobian[i_z] -is false (true) if the Jacobian of G with respect to z is always zero +\a var_jacobian[i_z] +is false (true) if the Jacobian of G with respect to z is always zero (many be non-zero). \param vecad_jacobian -\a vecad_jacobian[i_v] -is false (true) if the Jacobian with respect to x is always zero +\a vecad_jacobian[i_v] +is false (true) if the Jacobian with respect to x is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. @@ -670,7 +661,7 @@ inline void reverse_sparse_hessian_load_op( OpCode op , size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , diff -Nru cppad-2015.00.00.9/cppad/local/log1p.hpp cppad-2016.00.00.1/cppad/local/log1p.hpp --- cppad-2015.00.00.9/cppad/local/log1p.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/log1p.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,92 @@ +// $Id$ +# ifndef CPPAD_LOG1P_HPP +# define CPPAD_LOG1P_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin log1p$$ +$spell + CppAD +$$ + +$section The Logarithm of One Plus Argument: log1p$$ + +$head Syntax$$ +$icode%y% = log1p(%x%)%$$ + +$head Description$$ +Returns the value of the logarithm of one plus argument which is defined +by $icode%y% == log(1 + %x%)%$$. + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head CPPAD_USE_CPLUSPLUS_2011$$ + +$subhead true$$ +If this preprocessor symbol is true ($code 1$$), +and $icode x$$ is an AD type, +this is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$subhead false$$ +If this preprocessor symbol is false ($code 0$$), +CppAD uses the representation +$latex \[ +\R{log1p} (x) = \log(1 + x) +\] $$ +to compute this function. + +$head Example$$ +$children% + example/log1p.cpp +%$$ +The file +$cref log1p.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +*/ +# include +# if ! CPPAD_USE_CPLUSPLUS_2011 + +// BEGIN CppAD namespace +namespace CppAD { + +template +Type log1p_template(const Type &x) +{ return CppAD::log(Type(1) + x); +} + +inline float log1p(const float &x) +{ return log1p_template(x); } + +inline double log1p(const double &x) +{ return log1p_template(x); } + +template +inline AD log1p(const AD &x) +{ return log1p_template(x); } + +template +inline AD log1p(const VecAD_reference &x) +{ return log1p_template( x.ADBase() ); } + + +} // END CppAD namespace + +# endif // CPPAD_USE_CPLUSPLUS_2011 +# endif // CPPAD_LOG1P_INCLUDED diff -Nru cppad-2015.00.00.9/cppad/local/log1p_op.hpp cppad-2016.00.00.1/cppad/local/log1p_op.hpp --- cppad-2015.00.00.9/cppad/local/log1p_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/log1p_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -0,0 +1,205 @@ +// $Id$ +# ifndef CPPAD_LOG1P_OP_HPP +# define CPPAD_LOG1P_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file log1p_op.hpp +Forward and reverse mode calculations for z = log1p(x). +*/ + +/*! +Compute forward mode Taylor coefficient for result of op = Log1pOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log1p(x) +\endverbatim + +\copydetails forward_unary1_op +*/ +template +inline void forward_log1p_op( + size_t p , + size_t q , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + size_t k; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(Log1pOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(Log1pOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + + if( p == 0 ) + { z[0] = log1p( x[0] ); + p++; + if( q == 0 ) + return; + } + if ( p == 1 ) + { z[1] = x[1] / (Base(1) + x[0]); + p++; + } + for(size_t j = p; j <= q; j++) + { + z[j] = -z[1] * x[j-1]; + for(k = 2; k < j; k++) + z[j] -= Base(k) * z[k] * x[j-k]; + z[j] /= Base(j); + z[j] += x[j]; + z[j] /= (Base(1) + x[0]); + } +} + +/*! +Muiltiple directions Taylor coefficient for op = Log1pOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log1p(x) +\endverbatim + +\copydetails forward_unary1_op_dir +*/ +template +inline void forward_log1p_op_dir( + size_t q , + size_t r , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(Log1pOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(Log1pOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + + // Taylor coefficients corresponding to argument and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + i_x * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { z[m+ell] = Base(q) * x[m+ell]; + for(size_t k = 1; k < q; k++) + z[m+ell] -= Base(k) * z[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; + z[m+ell] /= (Base(q) + Base(q) * x[0]); + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = Log1pOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log1p(x) +\endverbatim + +\copydetails forward_unary1_op_0 +*/ +template +inline void forward_log1p_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(Log1pOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(Log1pOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = log1p( x[0] ); +} + +/*! +Compute reverse mode partial derivatives for result of op = Log1pOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log1p(x) +\endverbatim + +\copydetails reverse_unary1_op +*/ + +template +inline void reverse_log1p_op( + size_t d , + size_t i_z , + size_t i_x , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ size_t j, k; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(Log1pOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(Log1pOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Taylor coefficients and partials corresponding to argument + const Base* x = taylor + i_x * cap_order; + Base* px = partial + i_x * nc_partial; + + // Taylor coefficients and partials corresponding to result + const Base* z = taylor + i_z * cap_order; + Base* pz = partial + i_z * nc_partial; + + Base inv_1px0 = Base(1) / (Base(1) + x[0]); + + j = d; + while(j) + { // scale partial w.r.t z[j] + pz[j] = azmul(pz[j] , inv_1px0); + + px[0] -= azmul(pz[j], z[j]); + px[j] += pz[j]; + + // further scale partial w.r.t. z[j] + pz[j] /= Base(j); + + for(k = 1; k < j; k++) + { pz[k] -= Base(k) * azmul(pz[j], x[j-k]); + px[j-k] -= Base(k) * azmul(pz[j], z[k]); + } + --j; + } + px[0] += azmul(pz[0], inv_1px0); +} + +} // END_CPPAD_NAMESPACE +# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/log_op.hpp cppad-2016.00.00.1/cppad/local/log_op.hpp --- cppad-2015.00.00.9/cppad/local/log_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/log_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: log_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_LOG_OP_INCLUDED -# define CPPAD_LOG_OP_INCLUDED +// $Id: log_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_LOG_OP_HPP +# define CPPAD_LOG_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -35,9 +35,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ size_t k; // check assumptions @@ -87,9 +87,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(LogOp) == 1 ); @@ -108,7 +108,7 @@ for(size_t k = 1; k < q; k++) z[m+ell] -= Base(k) * z[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; z[m+ell] /= (Base(q) * x[0]); - } + } } /*! @@ -125,7 +125,7 @@ inline void forward_log_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { @@ -157,11 +157,11 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) -{ size_t j, k; +{ size_t j, k; // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(LogOp) == 1 ); @@ -177,24 +177,26 @@ const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; + Base inv_x0 = Base(1) / x[0]; + j = d; while(j) { // scale partial w.r.t z[j] - pz[j] /= x[0]; + pz[j] = azmul(pz[j] , inv_x0); - px[0] -= pz[j] * z[j]; + px[0] -= azmul(pz[j], z[j]); px[j] += pz[j]; // further scale partial w.r.t. z[j] pz[j] /= Base(j); for(k = 1; k < j; k++) - { pz[k] -= pz[j] * Base(k) * x[j-k]; - px[j-k] -= pz[j] * Base(k) * z[k]; + { pz[k] -= Base(k) * azmul(pz[j], x[j-k]); + px[j-k] -= Base(k) * azmul(pz[j], z[k]); } --j; } - px[0] += pz[0] / x[0]; + px[0] += azmul(pz[0], inv_x0); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/lu_ratio.hpp cppad-2016.00.00.1/cppad/local/lu_ratio.hpp --- cppad-2015.00.00.9/cppad/local/lu_ratio.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/lu_ratio.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: lu_ratio.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_LU_RATIO_INCLUDED -# define CPPAD_LU_RATIO_INCLUDED +// $Id: lu_ratio.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_LU_RATIO_HPP +# define CPPAD_LU_RATIO_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,13 +28,9 @@ ADvector $$ -$index LuRatio$$ -$index linear, Lu factor equation$$ -$index equation, Lu factor$$ -$index determinant, Lu factor$$ -$index solve, Lu factor$$ $section LU Factorization of A Square Matrix and Stability Calculation$$ +$mindex LuRatio linear equation solve$$ $head Syntax$$ $code# include $$ @@ -44,7 +40,7 @@ $head Description$$ -Computes an LU factorization of the matrix $icode A$$ +Computes an LU factorization of the matrix $icode A$$ where $icode A$$ is a square matrix. A measure of the numerical stability called $icode ratio$$ is calculated. This ratio is useful when the results of $code LuRatio$$ are @@ -107,7 +103,7 @@ (see description of $cref/ADvector/LuRatio/ADvector/$$ below). $subhead A$$ -We define $icode A$$ as the matrix corresponding to the input +We define $icode A$$ as the matrix corresponding to the input value of $icode LU$$. $subhead P$$ @@ -117,7 +113,7 @@ %$$ $subhead L$$ -We define the lower triangular matrix $icode L$$ in terms of the +We define the lower triangular matrix $icode L$$ in terms of the output value of $icode LU$$. The matrix $icode L$$ is zero above the diagonal and the rest of the elements are defined by @@ -143,17 +139,16 @@ %L% * %U% = %P% %$$ If the return value of $icode sign$$ is zero, -the contents of $icode L$$ and $icode U$$ are not defined. +the contents of $icode L$$ and $icode U$$ are not defined. $subhead Determinant$$ -$index determinant$$ If the return value $icode sign$$ is zero, the determinant of $icode A$$ is zero. If $icode sign$$ is non-zero, using the output value of $icode LU$$ the determinant of the matrix $icode A$$ is equal to $codei% -%sign% * %LU%[%ip%[0], %jp%[0]] * %...% * %LU%[%ip%[%n%-1], %jp%[%n%-1]] +%sign% * %LU%[%ip%[0], %jp%[0]] * %...% * %LU%[%ip%[%n%-1], %jp%[%n%-1]] %$$ $head ratio$$ @@ -163,8 +158,8 @@ %$$ On input, the value of $icode ratio$$ does not matter. On output it is a measure of how good the choice of pivots is. -For $latex p = 0 , \ldots , n-1$$, -the $th p$$ pivot element is the element of maximum absolute value of a +For $latex p = 0 , \ldots , n-1$$, +the $th p$$ pivot element is the element of maximum absolute value of a $latex (n-p) \times (n-p)$$ sub-matrix. The ratio of each element of sub-matrix divided by the pivot element is computed. @@ -172,7 +167,7 @@ such ratios over with respect to all elements and all the pivots. $subhead Purpose$$ -Suppose that the execution of a call to $code LuRatio$$ +Suppose that the execution of a call to $code LuRatio$$ is recorded in the $codei%ADFun<%Base%>%$$ object $icode F$$. Then a call to $cref Forward$$ of the form $codei% @@ -181,7 +176,7 @@ with $icode k$$ equal to zero will revaluate this Lu factorization with the same pivots and a new value for $icode A$$. In this case, the resulting $icode ratio$$ may not be one. -If $icode ratio$$ is too large (the meaning of too large is up to you), +If $icode ratio$$ is too large (the meaning of too large is up to you), the current pivots do not yield a stable LU factorization of $icode A$$. A better choice for the pivots (for this value of $icode A$$) will be made if you recreate the $code ADFun$$ object @@ -195,7 +190,7 @@ if this is not the case. $head ADvector$$ -The type $icode ADvector$$ must be a +The type $icode ADvector$$ must be a $cref/simple vector class/SimpleVector/$$ with elements of type $codei%AD<%Base%>%$$. The routine $cref CheckSimpleVector$$ will generate an error message @@ -218,7 +213,7 @@ // Lines different from the code in cppad/lu_factor.hpp end with // template // int LuRatio(SizeVector &ip, SizeVector &jp, ADvector &LU, AD &ratio) // -{ +{ typedef ADvector FloatVector; // typedef AD Float; // @@ -264,7 +259,7 @@ // Reduce the matrix P to L * U using n pivots for(p = 0; p < n; p++) - { // determine row and column corresponding to element of + { // determine row and column corresponding to element of // maximum absolute value in remaining part of P imax = jmax = n; emax = zero; @@ -290,7 +285,7 @@ CondExpGt(etmp, ratio, etmp, ratio); // } // } // - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( (imax < n) & (jmax < n) , "AbsGeq must return true when second argument is zero" ); @@ -317,27 +312,27 @@ return 0; } - // Reduce U by the elementary transformations that maps + // Reduce U by the elementary transformations that maps // LU( ip[p], jp[p] ) to one. Only need transform elements // above the diagonal in U and LU( ip[p] , jp[p] ) is // corresponding value below diagonal in L. for(j = p+1; j < n; j++) LU[ ip[p] * n + jp[j] ] /= pivot; - // Reduce U by the elementary transformations that maps - // LU( ip[i], jp[p] ) to zero. Only need transform elements - // above the diagonal in U and LU( ip[i], jp[p] ) is + // Reduce U by the elementary transformations that maps + // LU( ip[i], jp[p] ) to zero. Only need transform elements + // above the diagonal in U and LU( ip[i], jp[p] ) is // corresponding value below diagonal in L. for(i = p+1; i < n; i++ ) { etmp = LU[ ip[i] * n + jp[p] ]; for(j = p+1; j < n; j++) - { LU[ ip[i] * n + jp[j] ] -= + { LU[ ip[i] * n + jp[j] ] -= etmp * LU[ ip[p] * n + jp[j] ]; - } + } } } return sign; } -} // END CppAD namespace +} // END CppAD namespace # endif diff -Nru cppad-2015.00.00.9/cppad/local/math_other.hpp cppad-2016.00.00.1/cppad/local/math_other.hpp --- cppad-2015.00.00.9/cppad/local/math_other.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/math_other.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* $Id: math_other.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_MATH_OTHER_INCLUDED -# define CPPAD_MATH_OTHER_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin MathOther$$ -$spell - atan -$$ -$index other, AD math$$ -$index math, AD other$$ -$index AD, other math$$ - -$section Other AD Math Functions$$ - -$childtable% - cppad/local/abs.hpp% - cppad/local/sign.hpp% - cppad/local/atan2.hpp% - cppad/local/erf.hpp% - cppad/local/pow.hpp% - cppad/local/limits.hpp -%$$ - -$end -*/ - -# include -# include -# include -# include -# include - -# endif diff -Nru cppad-2015.00.00.9/cppad/local/mul_eq.hpp cppad-2016.00.00.1/cppad/local/mul_eq.hpp --- cppad-2015.00.00.9/cppad/local/mul_eq.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/mul_eq.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: mul_eq.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_MUL_EQ_INCLUDED -# define CPPAD_MUL_EQ_INCLUDED +// $Id: mul_eq.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_MUL_EQ_HPP +# define CPPAD_MUL_EQ_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -99,4 +99,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/mul.hpp cppad-2016.00.00.1/cppad/local/mul.hpp --- cppad-2015.00.00.9/cppad/local/mul.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/mul.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: mul.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_MUL_INCLUDED -# define CPPAD_MUL_INCLUDED +// $Id: mul.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_MUL_HPP +# define CPPAD_MUL_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -99,4 +99,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/mul_op.hpp cppad-2016.00.00.1/cppad/local/mul_op.hpp --- cppad-2015.00.00.9/cppad/local/mul_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/mul_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: mul_op.hpp 3321 2014-09-12 09:50:39Z bradbell $ */ -# ifndef CPPAD_MUL_OP_INCLUDED -# define CPPAD_MUL_OP_INCLUDED +// $Id: mul_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_MUL_OP_HPP +# define CPPAD_MUL_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,8 +36,8 @@ template inline void forward_mulvv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -78,8 +78,8 @@ template inline void forward_mulvv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -101,7 +101,7 @@ size_t k, ell, m; for(ell = 0; ell < r; ell++) { m = (q-1)*r + ell + 1; - z[m] = x[0] * y[m] + x[m] * y[0]; + z[m] = x[0] * y[m] + x[m] * y[0]; for(k = 1; k < q; k++) z[m] += x[(q-k-1)*r + ell + 1] * y[(k-1)*r + ell + 1]; } @@ -157,7 +157,7 @@ template inline void reverse_mulvv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -188,9 +188,9 @@ while(j) { --j; for(k = 0; k <= j; k++) - { - px[j-k] += pz[j] * y[k]; - py[k] += pz[j] * x[j-k]; + { + px[j-k] += azmul(pz[j], y[k]); + py[k] += azmul(pz[j], x[j-k]); } } } @@ -210,8 +210,8 @@ template inline void forward_mulpv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -249,8 +249,8 @@ template inline void forward_mulpv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -325,7 +325,7 @@ template inline void reverse_mulpv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -335,8 +335,8 @@ Base* partial ) { // check assumptions - CPPAD_ASSERT_UNKNOWN( NumArg(MulvvOp) == 2 ); - CPPAD_ASSERT_UNKNOWN( NumRes(MulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumArg(MulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); @@ -351,7 +351,7 @@ size_t j = d + 1; while(j) { --j; - py[j] += pz[j] * x; + py[j] += azmul(pz[j], x); } } diff -Nru cppad-2015.00.00.9/cppad/local/near_equal_ext.hpp cppad-2016.00.00.1/cppad/local/near_equal_ext.hpp --- cppad-2015.00.00.9/cppad/local/near_equal_ext.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/near_equal_ext.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: near_equal_ext.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_NEAR_EQUAL_EXT_INCLUDED -# define CPPAD_NEAR_EQUAL_EXT_INCLUDED +// $Id: near_equal_ext.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_NEAR_EQUAL_EXT_HPP +# define CPPAD_NEAR_EQUAL_EXT_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,8 +26,8 @@ $$ $section Compare AD and Base Objects for Nearly Equal$$ +$mindex NearEqual with$$ -$index NearEqual, AD with Base$$ $head Syntax$$ $icode%b% = NearEqual(%x%, %y%, %r%, %a%)%$$ @@ -42,7 +42,7 @@ $codei%AD< std::complex<%Type%> >%$$. $head x$$ -The arguments $icode x$$ +The arguments $icode x$$ has one of the following possible prototypes: $codei% const %Type% &%x% @@ -51,7 +51,7 @@ %$$ $head y$$ -The arguments $icode y$$ +The arguments $icode y$$ has one of the following possible prototypes: $codei% const %Type% &%y% @@ -87,9 +87,9 @@ $codei% bool %b% %$$ -If either $icode x$$ or $icode y$$ is infinite or not a number, +If either $icode x$$ or $icode y$$ is infinite or not a number, the return value is false. -Otherwise, if either the relative or absolute error +Otherwise, if either the relative or absolute error condition (defined above) is satisfied, the return value is true. Otherwise, the return value is false. @@ -99,11 +99,11 @@ The routine $cref CheckNumericType$$ will generate an error message if this is not the case. If $icode a$$ and $icode b$$ have type $icode Type$$, -the following operation must be defined +the following operation must be defined $table -$bold Operation$$ $cnext +$bold Operation$$ $cnext $bold Description$$ $rnext -$icode%a% <= %b%$$ $cnext +$icode%a% <= %b%$$ $cnext less that or equal operator (returns a $code bool$$ object) $tend @@ -155,31 +155,31 @@ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool NearEqual( - const VecAD_reference &x, const VecAD_reference &y, + const VecAD_reference &x, const VecAD_reference &y, const Base &r, const Base &a) { return NearEqual(x.ADBase(), y.ADBase(), r, a); } template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool NearEqual(const VecAD_reference &x, const AD &y, +bool NearEqual(const VecAD_reference &x, const AD &y, const Base &r, const Base &a) { return NearEqual(x.ADBase(), y, r, a); } template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool NearEqual(const VecAD_reference &x, const Base &y, +bool NearEqual(const VecAD_reference &x, const Base &y, const Base &r, const Base &a) { return NearEqual(x.ADBase(), y, r, a); } template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool NearEqual(const AD &x, const VecAD_reference &y, +bool NearEqual(const AD &x, const VecAD_reference &y, const Base &r, const Base &a) { return NearEqual(x, y.ADBase(), r, a); } template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -bool NearEqual(const Base &x, const VecAD_reference &y, +bool NearEqual(const Base &x, const VecAD_reference &y, const Base &r, const Base &a) { return NearEqual(x, y.ADBase(), r, a); } diff -Nru cppad-2015.00.00.9/cppad/local/numeric_limits.hpp cppad-2016.00.00.1/cppad/local/numeric_limits.hpp --- cppad-2015.00.00.9/cppad/local/numeric_limits.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/numeric_limits.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,199 @@ +// $Id$ +# ifndef CPPAD_NUMERIC_LIMITS_HPP +# define CPPAD_NUMERIC_LIMITS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------ +$begin numeric_limits$$ +$spell + std + eps + CppAD + namespace + const +$$ + +$section Numeric Limits For an AD and Base Types$$ + +$head Syntax$$ +$icode%eps% = numeric_limits<%Float%>::epsilon() +%$$ +$icode%min% = numeric_limits<%Float%>::min() +%$$ +$icode%max% = numeric_limits<%Float%>::max() +%$$ +$icode%nan% = numeric_limits<%Float%>::quiet_NaN() +%$$ + +$head CppAD::numeric_limits$$ +These functions and have the prototype +$codei% + static %Float% CppAD::numeric_limits<%Float%>::%fun%(%void%) +%$$ +where $icode fun$$ is +$code epsilon$$, $code min$$, $code max$$, and $code quiet_NaN$$. + +$head std::numeric_limits$$ +CppAD does not use a specialization of $code std::numeric_limits$$ +because this would be to restrictive. +The C++ standard specifies that Non-fundamental standard +types, such as +$cref/std::complex/base_complex.hpp/$$ shall not have specializations +of $code std::numeric_limits$$; see Section 18.2 of +ISO/IEC 14882:1998(E). +In addition, since C++11, a only literal types can have a specialization +of $code std::numeric_limits$$. + +$head Float$$ +These functions are defined for all $codei%AD<%Base%>%$$, +and for all corresponding $icode Base$$ types; +see $icode Base$$ type $cref base_limits$$. + +$head epsilon$$ +The result $icode eps$$ is equal to machine epsilon and has prototype +$codei% + %Float% %eps% +%$$ +The file $cref num_limits.cpp$$ +tests the value $icode eps$$ by checking that the following are true +$codei% + 1 != 1 + %eps% + 1 == 1 + %eps% / 2 +%$$ +where all the values, and calculations, are done with the precision +corresponding to $icode Float$$. + +$head min$$ +The result $icode min$$ is equal to +the minimum positive normalized value and has prototype +$codei% + %Float% %min% +%$$ +The file $cref num_limits.cpp$$ +tests the value $icode min$$ by checking that the following are true +$codei% + abs( ((%min% / 100) * 100) / %min% - 1 ) > 3 * %eps% + abs( ((%min% * 100) / 100) / %min% - 1 ) < 3 * %eps% +%$$ +where all the values, and calculations, are done with the precision +corresponding to $icode Float$$. + +$head max$$ +The result $icode max$$ is equal to +the maximum finite value and has prototype +$codei% + %Float% %max% +%$$ +The file $cref num_limits.cpp$$ +tests the value $icode max$$ by checking that the following are true +$codei% + abs( ((%max% * 100) / 100) / %max% - 1 ) > 3 * %eps% + abs( ((%max% / 100) * 100) / %max% - 1 ) < 3 * %eps% +%$$ +where all the values, and calculations, are done with the precision +corresponding to $icode Float$$. + +$head quiet_NaN$$ +The result $icode nan$$ is not a number and has prototype +$codei% + %Float% %nan% +%$$ +The file $cref num_limits.cpp$$ +tests the value $icode nan$$ by checking that the following is true +$codei% + %nan% != %nan% +%$$ + + +$head Example$$ +$children% + example/num_limits.cpp +%$$ +The file +$cref num_limits.cpp$$ +contains an example and test of these functions. + +$end +------------------------------------------------------------------------------ +*/ +# include + +# include +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file numeric_limits.hpp +File that defines CppAD numeric_limits for AD types +*/ + +/// Default value for all undefined numeric_limits types +template +class numeric_limits { +public: + /// machine epsilon + static Float epsilon(void) + { CPPAD_ASSERT_KNOWN( + false, + "numeric_limits::epsilon() is not specialized for this Float" + ); + return Float(0); + } + /// minimum positive normalized value + static Float min(void) + { CPPAD_ASSERT_KNOWN( + false, + "numeric_limits::min() is not specialized for this Float" + ); + return Float(0); + } + /// maximum finite value + static Float max(void) + { CPPAD_ASSERT_KNOWN( + false, + "numeric_limits::max() is not specialized for this Float" + ); + return Float(0); + } + /// not a number + static Float quiet_NaN(void) + { CPPAD_ASSERT_KNOWN( + false, + "numeric_limits::quiet_NaN() is not specialized for this Float" + ); + return Float(0); + } +}; + +/// Partial specialization that defines limits for for all AD types +template +class numeric_limits< AD > { +public: + /// machine epsilon + static AD epsilon(void) + { return AD( numeric_limits::epsilon() ); } + /// minimum positive normalized value + static AD min(void) + { return AD( numeric_limits::min() ); } + /// maximum finite value + static AD max(void) + { return AD( numeric_limits::max() ); } + /// note a number + static AD quiet_NaN(void) + { return AD( numeric_limits::quiet_NaN() ); } +}; + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2015.00.00.9/cppad/local/num_skip.hpp cppad-2016.00.00.1/cppad/local/num_skip.hpp --- cppad-2015.00.00.9/cppad/local/num_skip.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/num_skip.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: num_skip.hpp 3132 2014-03-01 16:55:48Z bradbell $ */ -# ifndef CPPAD_NUM_SKIP_INCLUDED -# define CPPAD_NUM_SKIP_INCLUDED +// $Id: num_skip.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_NUM_SKIP_HPP +# define CPPAD_NUM_SKIP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,12 +21,9 @@ taylor_ $$ -$index number_skip$$ -$index number, skip variables$$ -$index skip, number variables$$ -$index variables, skip$$ $section Number of Variables that Can be Skipped$$ +$mindex number_skip$$ $head Syntax$$ $icode%n% = %f%.number_skip()%$$ @@ -39,13 +36,13 @@ $cref/if_true/CondExp/$$ or $cref/if_false/CondExp/$$. This leads to the fact that some terms only need to be evaluated depending on the value of the comparison in the conditional expression. -The $cref optimize$$ option is capable of detecting some of these +The $cref optimize$$ option is capable of detecting some of these case and determining variables that can be skipped. This routine returns the number such variables. $head n$$ The return value $icode n$$ has type $code size_t$$ -is the number of variables that the optimizer has determined can be skipped +is the number of variables that the optimizer has determined can be skipped (given the independent variable values specified by the previous call to $cref/f.Forward/Forward/$$ for order zero). @@ -101,6 +98,6 @@ } } // END CppAD namespace - + # endif diff -Nru cppad-2015.00.00.9/cppad/local/old_atomic.hpp cppad-2016.00.00.1/cppad/local/old_atomic.hpp --- cppad-2015.00.00.9/cppad/local/old_atomic.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/old_atomic.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: old_atomic.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_OLD_ATOMIC_INCLUDED -# define CPPAD_OLD_ATOMIC_INCLUDED +// $Id: old_atomic.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_OLD_ATOMIC_HPP +# define CPPAD_OLD_ATOMIC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -34,18 +34,14 @@ $$ $section User Defined Atomic AD Functions$$ -$index CPPAD_USER_ATOMIC$$ -$index atomic, user function$$ -$index user, atomic function$$ -$index operation, user atomic$$ -$index function, user atomic$$ +$mindex operation old_atomic$$ -$head Syntax$$ -Using $code CPPAD_USER_ATOMIC$$ has been deprecated. +$head Deprecated 2013-05-27$$ +Using $code CPPAD_USER_ATOMIC$$ has been deprecated. Use $cref atomic_base$$ instead. -$subhead Define Function$$ -$codei%CPPAD_USER_ATOMIC(%afun%, %Tvector%, %Base%, +$head Syntax Function$$ +$codei%CPPAD_USER_ATOMIC(%afun%, %Tvector%, %Base%, %forward%, %reverse%, %for_jac_sparse%, %rev_jac_sparse%, %rev_hes_sparse% ) %$$ @@ -71,61 +67,60 @@ $head Purpose$$ In some cases, the user knows how to compute the derivative -of a function +of a function $latex \[ - y = f(x) \; {\rm where} \; f : B^n \rightarrow B^m + y = f(x) \; {\rm where} \; f : B^n \rightarrow B^m \] $$ -more efficiently than by coding it using $codei%AD<%Base%>%$$ +more efficiently than by coding it using $codei%AD<%Base%>%$$ $cref/atomic/glossary/Operation/Atomic/$$ operations and letting CppAD do the rest. In this case, $code CPPAD_USER_ATOMIC$$ can be used add the user code for $latex f(x)$$, and its derivatives, -to the set of $codei%AD<%Base%>%$$ atomic operations. +to the set of $codei%AD<%Base%>%$$ atomic operations. $pre $$ -Another possible purpose is to reduce the size of the tape; +Another possible purpose is to reduce the size of the tape; see $cref/use AD/old_atomic/Example/Use AD/$$ $head Partial Implementation$$ -The routines +The routines $cref/forward/old_atomic/forward/$$, $cref/reverse/old_atomic/reverse/$$, $cref/for_jac_sparse/old_atomic/for_jac_sparse/$$, $cref/rev_jac_sparse/old_atomic/rev_jac_sparse/$$, and $cref/rev_hes_sparse/old_atomic/rev_hes_sparse/$$, must be defined by the user. -The $icode forward$$ the routine, +The $icode forward$$ the routine, for the case $icode%k% = 0%$$, must be implemented. Functions with the correct prototype, -that just return $code false$$, -can be used for the other cases -(unless they are required by your calculations). +that just return $code false$$, +can be used for the other cases +(unless they are required by your calculations). For example, you need not implement $icode forward$$ for the case $icode%k% == 2%$$ until you require forward mode calculation of second derivatives. $head CPPAD_USER_ATOMIC$$ -$index CPPAD_USER_ATOMIC$$ -The macro +The macro $codei% -CPPAD_USER_ATOMIC(%afun%, %Tvector%, %Base%, +CPPAD_USER_ATOMIC(%afun%, %Tvector%, %Base%, %forward%, %reverse%, %for_jac_sparse%, %rev_jac_sparse%, %rev_hes_sparse% ) -%$$ +%$$ defines the $codei%AD<%Base%>%$$ routine $icode afun$$. -This macro can be placed within a namespace -(not the $code CppAD$$ namespace) +This macro can be placed within a namespace +(not the $code CppAD$$ namespace) but must be outside of any routine. $subhead Tvector$$ The macro argument $icode Tvector$$ must be a $cref/simple vector template class/SimpleVector/$$. -It determines the type of vectors used as arguments to the routine +It determines the type of vectors used as arguments to the routine $icode afun$$. $subhead Base$$ -The macro argument $icode Base$$ specifies the +The macro argument $icode Base$$ specifies the $cref/base type/base_require/$$ corresponding to $codei%AD<%Base>%$$ operation sequences. Calling the routine $icode afun$$ will add the operator defined @@ -149,7 +144,7 @@ Its value in all other calls is the same as in the corresponding call to $icode afun$$. It can be used to store and retrieve extra information about -a specific call to $icode afun$$. +a specific call to $icode afun$$. $head k$$ For all routines documented below, the argument $icode k$$ has prototype @@ -161,7 +156,7 @@ or taking the derivative of ($cref/reverse/old_atomic/reverse/$$). $head n$$ -For all routines documented below, +For all routines documented below, the argument $icode n$$ has prototype $codei% size_t %n% @@ -180,7 +175,7 @@ the dimension of the range space for $latex y = f(x)$$. $head tx$$ -For all routines documented below, +For all routines documented below, the argument $icode tx$$ has prototype $codei% const CppAD::vector<%Base%>& %tx% @@ -206,7 +201,7 @@ \] $$ $head ty$$ -In calls to $cref/forward/old_atomic/forward/$$, +In calls to $cref/forward/old_atomic/forward/$$, the argument $icode ty$$ has prototype $codei% CppAD::vector<%Base%>& %ty% @@ -251,7 +246,7 @@ operation (as it is used in the source code). CppAD uses the other functions, where the arguments are vectors with elements of type $icode Base$$, -to implement the function +to implement the function $codei% %afun%(%id%, %ax%, %ay%) %$$ @@ -262,8 +257,8 @@ $codei% const %Tvector%< AD<%Base%> >& %ax% %$$ -It is the argument vector $latex x \in B^n$$ -at which the $codei%AD<%Base%>%$$ version of +It is the argument vector $latex x \in B^n$$ +at which the $codei%AD<%Base%>%$$ version of $latex y = f(x)$$ is to be evaluated. The dimension of the domain space for $latex y = f (x)$$ is specified by $cref/n/old_atomic/n/$$ $codei%= %ax%.size()%$$, @@ -274,18 +269,16 @@ $codei% %Tvector%< AD<%Base%> >& %ay% %$$ -The input values of its elements +The input values of its elements are not specified (must not matter). -Upon return, it is the $codei%AD<%Base%>%$$ version of the +Upon return, it is the $codei%AD<%Base%>%$$ version of the result vector $latex y = f(x)$$. The dimension of the range space for $latex y = f (x)$$ is specified by $cref/m/old_atomic/m/$$ $codei%= %ay%.size()%$$, which must be greater than zero. $subhead Parallel Mode$$ -$index parallel, old_atomic$$ -$index old_atomic, parallel$$ -The first call to +The first call to $codei% %afun%(%id%, %ax%, %ay%) %$$ @@ -301,29 +294,29 @@ %ok% = %forward%(%id%, %k%, %n%, %m%, %vx%, %vy%, %tx%, %ty%) %$$ that computes results during a $cref/forward/Forward/$$ mode sweep. -For this call, we are given the Taylor coefficients in $icode tx$$ +For this call, we are given the Taylor coefficients in $icode tx$$ form order zero through $icode k$$, and the Taylor coefficients in $icode ty$$ with order less than $icode k$$. -The $icode forward$$ routine computes the +The $icode forward$$ routine computes the $icode k$$ order Taylor coefficients for $latex y$$ using the definition -$latex Y(t) = f[ X(t) ]$$. +$latex Y(t) = f[ X(t) ]$$. For example, for $latex i = 0 , \ldots , m-1$$, $latex \[ \begin{array}{rcl} -y_i^0 & = & Y(0) +y_i^0 & = & Y(0) = f_i ( x^0 ) \\ -y_i^1 & = & Y^{(1)} ( 0 ) - = f_i^{(1)} ( x^0 ) X^{(1)} ( 0 ) - = f_i^{(1)} ( x^0 ) x^1 +y_i^1 & = & Y^{(1)} ( 0 ) + = f_i^{(1)} ( x^0 ) X^{(1)} ( 0 ) + = f_i^{(1)} ( x^0 ) x^1 \\ -y_i^2 +y_i^2 & = & \frac{1}{2 !} Y^{(2)} (0) \\ & = & \frac{1}{2} X^{(1)} (0)^\R{T} f_i^{(2)} ( x^0 ) X^{(1)} ( 0 ) + \frac{1}{2} f_i^{(1)} ( x^0 ) X^{(2)} ( 0 ) \\ -& = & \frac{1}{2} (x^1)^\R{T} f_i^{(2)} ( x^0 ) x^1 +& = & \frac{1}{2} (x^1)^\R{T} f_i^{(2)} ( x^0 ) x^1 + f_i^{(1)} ( x^0 ) x^2 \end{array} \] $$ @@ -347,15 +340,15 @@ $codei% const CppAD::vector& %vx% %$$ -The case $icode%vx%.size() > 0%$$ occurs +The case $icode%vx%.size() > 0%$$ occurs once for each call to $icode afun$$, during the call, and before any of the other callbacks corresponding to that call. -Hence such a call can be used to cache information attached to +Hence such a call can be used to cache information attached to the corresponding $icode id$$ (such as the elements of $icode vx$$). If $icode%vx%.size() > 0%$$ then -$icode%k% == 0%$$, +$icode%k% == 0%$$, $icode%vx%.size() >= %n%$$, and for $latex j = 0 , \ldots , n-1$$, $icode%vx%[%j%]%$$ is true if and only if @@ -363,7 +356,7 @@ $pre $$ -If $icode%vx%.size() == 0%$$, +If $icode%vx%.size() == 0%$$, then $icode%vy%.size() == 0%$$ and neither of these vectors should be used. @@ -373,9 +366,9 @@ CppAD::vector& %vy% %$$ If $icode%vy%.size() == 0%$$, it should not be used. -Otherwise, +Otherwise, $icode%k% == 0%$$ and $icode%vy%.size() >= %m%$$. -The input values of the elements of $icode vy$$ +The input values of the elements of $icode vy$$ are not specified (must not matter). Upon return, for $latex j = 0 , \ldots , m-1$$, $icode%vy%[%i%]%$$ is true if and only if @@ -388,7 +381,7 @@ $codei% %ok% = %reverse%(%id%, %k%, %n%, %m%, %tx%, %ty%, %px%, %py%) %$$ -that computes results during a $cref/reverse/Reverse/$$ mode sweep. +that computes results during a $cref/reverse/Reverse/$$ mode sweep. The input value of the vectors $icode tx$$ and $icode ty$$ contain Taylor coefficient, up to order $icode k$$, for $latex X(t)$$ and $latex Y(t)$$ respectively. @@ -406,7 +399,7 @@ y_i^\ell = F_i^\ell ( \{ x_j^\ell \} ) \] $$ We use $latex G : B^{m \times (k+1)} \rightarrow B$$ -to denote an arbitrary scalar valued function of the Taylor coefficients for +to denote an arbitrary scalar valued function of the Taylor coefficients for $latex Y(t)$$ and write $latex z = G( \{ y_i^\ell \} )$$. The $code reverse$$ routine is given the derivative of $latex z$$ with respect to @@ -432,7 +425,7 @@ the other components of $icode py$$ are not specified and should not be used. $subhead px$$ -We define the function +We define the function $latex \[ H ( \{ x_j^\ell \} ) = G[ F( \{ x_j^\ell \} ) ] \] $$ @@ -441,7 +434,7 @@ CppAD::vector<%Base%>& %px% %$$ and $icode%px%.size() >= (%k% + 1) * %n%$$. -The input values of the elements of $icode px$$ +The input values of the elements of $icode px$$ are not specified (must not matter). Upon return, for $latex j = 0 , \ldots , n-1$$ and $latex p = 0 , \ldots , k$$, @@ -449,15 +442,15 @@ \begin{array}{rcl} px [ j * (k + 1) + p ] & = & \partial H / \partial x_j^p \\ -& = & -( \partial G / \partial \{ y_i^\ell \} ) +& = & +( \partial G / \partial \{ y_i^\ell \} ) ( \partial \{ y_i^\ell \} / \partial x_j^p ) \\ -& = & +& = & \sum_{i=0}^{m-1} \sum_{\ell=0}^k ( \partial G / \partial y_i^\ell ) ( \partial y_i^\ell / \partial x_j^p ) \\ -& = & +& = & \sum_{i=0}^{m-1} \sum_{\ell=p}^k py[ i * (k + 1 ) + \ell ] ( \partial F_i^\ell / \partial x_j^p ) \end{array} @@ -490,9 +483,9 @@ $codei% size_t %q% %$$ -It specifies the number of columns in -$latex R \in B^{n \times q}$$ and the Jacobian -$latex S(x) \in B^{m \times q}$$. +It specifies the number of columns in +$latex R \in B^{n \times q}$$ and the Jacobian +$latex S(x) \in B^{m \times q}$$. $subhead r$$ The $icode for_jac_sparse$$ argument $icode r$$ has prototype @@ -511,8 +504,8 @@ CppAD::vector< std::set >& %s% %$$ and $icode%s%.size() >= %m%%$$. -The input values of its sets -are not specified (must not matter). Upon return +The input values of its sets +are not specified (must not matter). Upon return for $latex i = 0 , \ldots , m-1$$, all the elements of $icode%s%[%i%]%$$ are between zero and $icode%q%-1%$$ inclusive. @@ -543,9 +536,9 @@ $codei% size_t %q% %$$ -It specifies the number of rows in -$latex S \in B^{q \times m}$$ and the Jacobian -$latex R(x) \in B^{q \times n}$$. +It specifies the number of rows in +$latex S \in B^{q \times m}$$ and the Jacobian +$latex R(x) \in B^{q \times n}$$. $subhead s$$ The $icode rev_jac_sparse$$ argument $icode s$$ has prototype @@ -553,7 +546,7 @@ const CppAD::vector< std::set >& %s% %$$ and $icode%s%.size() >= %m%$$. -For $latex i = 0 , \ldots , m-1$$, +For $latex i = 0 , \ldots , m-1$$, all the elements of $icode%s%[%i%]%$$ are between zero and $icode%q%-1%$$ inclusive. This specifies a sparsity pattern for the matrix $latex S^\R{T}$$. @@ -564,7 +557,7 @@ CppAD::vector< std::set >& %r% %$$ and $icode%r%.size() >= %n%$$. -The input values of its sets +The input values of its sets are not specified (must not matter). Upon return for $latex j = 0 , \ldots , n-1$$, all the elements of $icode%r%[%j%]%$$ @@ -577,7 +570,7 @@ $codei% %ok% = %rev_hes_sparse%(%id%, %n%, %m%, %q%, %r%, %s%, %t%, %u%, %v%) %$$ -There is an unspecified scalar valued function +There is an unspecified scalar valued function $latex g : B^m \rightarrow B$$. Given a sparsity pattern for $latex R$$ and information about the function $latex z = g(y)$$, @@ -613,7 +606,7 @@ const CppAD::vector& %s% %$$ and $icode%s%.size() >= %m%$$. -This specifies a sparsity pattern for the matrix +This specifies a sparsity pattern for the matrix $latex S(x) = g^{(1)} (y) \in B^{1 \times m}$$. $subhead t$$ @@ -622,9 +615,9 @@ CppAD::vector& %t% %$$ and $icode%t%.size() >= %n%$$. -The input values of its elements +The input values of its elements are not specified (must not matter). -Upon return it represents a sparsity pattern for the matrix +Upon return it represents a sparsity pattern for the matrix $latex T(x) \in B^{1 \times n}$$ defined by $latex \[ T(x) = (g \circ f)^{(1)} (x) = S(x) * f^{(1)} (x) @@ -643,11 +636,11 @@ for the matrix $latex U(x) \in B^{m \times q}$$ defined by $latex \[ \begin{array}{rcl} -U(x) -& = & +U(x) +& = & \partial_u \{ \partial_y g[ y + f^{(1)} (x) R u ] \}_{u=0} \\ -& = & +& = & \partial_u \{ g^{(1)} [ y + f^{(1)} (x) R u ] \}_{u=0} \\ & = & @@ -661,17 +654,17 @@ CppAD::vector< std::set >& %v% %$$ and $icode%v%.size() >= %n%$$. -The input values of its elements +The input values of its elements are not specified (must not matter). Upon return, for $latex j = 0, \ldots , n-1$$, all the elements of $icode%v%[%j%]%$$ are between zero and $icode%q%-1%$$ inclusive. -This represents a sparsity pattern for the matrix +This represents a sparsity pattern for the matrix $latex V(x) \in B^{n \times q}$$ defined by $latex \[ \begin{array}{rcl} -V(x) -& = & +V(x) +& = & \partial_u [ \partial_x (g \circ f) ( x + R u ) ]_{u=0} \\ & = & @@ -697,10 +690,10 @@ increase speed by avoiding system memory allocation calls. The function call $codei% user_atomic<%Base%>::clear() -%$$ +%$$ makes to work space $cref/available/ta_available/$$ to for other uses by the same thread. -This should be called when you are done using the +This should be called when you are done using the user atomic functions for a specific value of $icode Base$$. $subhead Restriction$$ @@ -708,11 +701,11 @@ while in $cref/parallel/ta_in_parallel/$$ execution mode. $children% - example/atomic/old_reciprocal.cpp% - example/atomic/old_usead_1.cpp% - example/atomic/old_usead_2.cpp% - example/atomic/old_tan.cpp% - example/atomic/old_mat_mul.cpp + test_more/old_reciprocal.cpp% + test_more/old_usead_1.cpp% + test_more/old_usead_2.cpp% + test_more/old_tan.cpp% + test_more/old_mat_mul.cpp %$$ $head Example$$ @@ -721,9 +714,9 @@ of a user atomic operation. $subhead Use AD$$ -The examples +The examples $cref old_usead_1.cpp$$ and $cref old_usead_2.cpp$$ -use AD to compute the derivatives +use AD to compute the derivatives inside a user defined atomic function. This may have the advantage of reducing the size of the tape, because a repeated section of code would only be taped once. @@ -743,7 +736,7 @@ # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -752,10 +745,10 @@ */ /*! -\def CPPAD_USER_ATOMIC(afun, Tvector, - forward, reverse, for_jac_sparse, rev_jac_sparse, rev_hes_sparse +\def CPPAD_USER_ATOMIC(afun, Tvector, + forward, reverse, for_jac_sparse, rev_jac_sparse, rev_hes_sparse ) -Defines the function afun(id, ax, ay) +Defines the function afun(id, ax, ay) where \c id is \c ax and \c ay are vectors with AD elements. \par Tvector @@ -764,9 +757,9 @@ \par Base the base type for the atomic operation. -\par afun +\par afun name of the CppAD defined function that corresponding to this operation. -Note that \c afun, preceeded by a pound sign, +Note that \c afun, preceeded by a pound sign, is a version of \c afun with quotes arround it. \par forward @@ -791,7 +784,7 @@ \par memory allocation Note that old_atomic is used as a static object, so its objects -do note get deallocated until the program terminates. +do note get deallocated until the program terminates. */ # define CPPAD_USER_ATOMIC( \ afun , \ @@ -843,21 +836,21 @@ /// type for user routine that computes forward mode results typedef bool (*F) ( size_t id , - size_t k , + size_t k , size_t n , size_t m , const vector& vx , vector& vy , - const vector& tx , + const vector& tx , vector& ty ); /// type for user routine that computes reverse mode results typedef bool (*R) ( size_t id , - size_t k , - size_t n , - size_t m , - const vector& tx , + size_t k , + size_t n , + size_t m , + const vector& tx , const vector& ty , vector& px , const vector& py @@ -890,7 +883,7 @@ const vector& s , vector& t , const vector< std::set >& u , - vector< std::set >& v + vector< std::set >& v ); private: /// id value corresponding to next virtual callback @@ -908,7 +901,7 @@ public: /*! - Constructor called for each invocation of CPPAD_USER_ATOMIC. + Constructor called for each invocation of CPPAD_USER_ATOMIC. Put this object in the list of all objects for this class and set the constant private data f_, r_, fjs_, rjs_, rhs_. @@ -935,7 +928,7 @@ This constructor can not be used in parallel mode because atomic_base has this restriction. */ - old_atomic(const char* afun, F f, R r, FJS fjs, RJS rjs, RHS rhs) : + old_atomic(const char* afun, F f, R r, FJS fjs, RJS rjs, RHS rhs) : atomic_base(afun) // name = afun , f_(f) , r_(r) @@ -945,7 +938,7 @@ { this->option( atomic_base::set_sparsity_enum ); } /*! - Implement the user call to afun(id, ax, ay). + Implement the user call to afun(id, ax, ay). \tparam ADVector A simple vector class with elements of type AD. @@ -961,7 +954,7 @@ \param ay is the result vector for this call, ay.size() determines the number of results. - */ + */ template void operator()(size_t id, const ADVector& ax, ADVector& ay) { // call atomic_base function object @@ -977,15 +970,15 @@ virtual void set_id(size_t id) { id_ = id; } /*! - Link from old_atomic to forward mode + Link from old_atomic to forward mode \copydetails atomic_base::forward - */ + */ virtual bool forward( size_t p , size_t q , - const vector& vx , - vector& vy , + const vector& vx , + vector& vy , const vector& tx , vector& ty ) { CPPAD_ASSERT_UNKNOWN( tx.size() % (q+1) == 0 ); @@ -1018,10 +1011,10 @@ return ok; } /*! - Link from old_atomic to reverse mode + Link from old_atomic to reverse mode \copydetails atomic_base::reverse - */ + */ virtual bool reverse( size_t q , const vector& tx , @@ -1036,7 +1029,7 @@ return ok; } /*! - Link from forward Jacobian sparsity sweep to old_atomic + Link from forward Jacobian sparsity sweep to old_atomic \copydetails atomic_base::for_sparse_jac */ @@ -1051,7 +1044,7 @@ } /*! - Link from reverse Jacobian sparsity sweep to old_atomic. + Link from reverse Jacobian sparsity sweep to old_atomic. \copydetails atomic_base::rev_sparse_jac */ @@ -1065,7 +1058,7 @@ return ok; } /*! - Link from reverse Hessian sparsity sweep to old_atomic + Link from reverse Hessian sparsity sweep to old_atomic \copydetails atomic_base::rev_sparse_hes */ diff -Nru cppad-2015.00.00.9/cppad/local/omp_max_thread.hpp cppad-2016.00.00.1/cppad/local/omp_max_thread.hpp --- cppad-2015.00.00.9/cppad/local/omp_max_thread.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/omp_max_thread.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: omp_max_thread.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_OMP_MAX_THREAD_INCLUDED -# define CPPAD_OMP_MAX_THREAD_INCLUDED +// $Id: omp_max_thread.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_OMP_MAX_THREAD_HPP +# define CPPAD_OMP_MAX_THREAD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,11 +23,10 @@ $$ $section OpenMP Parallel Setup$$ +$mindex omp_max_thread$$ -$head Deprecated$$ -$index depreciated, omp_max_thread$$ -$index omp_max_thread, depreciated$$ -Use $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ +$head Deprecated 2011-06-23$$ +Use $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ to set the number of threads. $head Syntax$$ @@ -35,14 +34,14 @@ %$$ $head Purpose$$ -By default, for each $codei%AD<%Base%>%$$ class there is only one +By default, for each $codei%AD<%Base%>%$$ class there is only one tape that records $cref/AD of Base/glossary/AD of Base/$$ operations. This tape is a global variable and hence it cannot be used -by multiple OpenMP threads at the same time. -The $code omp_max_thread$$ function is used to set the +by multiple OpenMP threads at the same time. +The $code omp_max_thread$$ function is used to set the maximum number of OpenMP threads that can be active. -In this case, there is a different tape corresponding to each -$codei%AD<%Base%>%$$ class and thread pair. +In this case, there is a different tape corresponding to each +$codei%AD<%Base%>%$$ class and thread pair. $head number$$ The argument $icode number$$ has prototype @@ -54,18 +53,18 @@ $head Independent$$ -Each call to $cref/Independent(x)/Independent/$$ +Each call to $cref/Independent(x)/Independent/$$ creates a new $cref/active/glossary/Tape/Active/$$ tape. -All of the operations with the corresponding variables +All of the operations with the corresponding variables must be preformed by the same OpenMP thread. -This includes the corresponding call to -$cref/f.Dependent(x,y)/Dependent/$$ or the +This includes the corresponding call to +$cref/f.Dependent(x,y)/Dependent/$$ or the $cref/ADFun f(x, y)/FunConstruct/Sequence Constructor/$$ during which the tape stops recording and the variables become parameters. $head Restriction$$ -No tapes can be +No tapes can be $cref/active/glossary/Tape/Active/$$ when this function is called. $end diff -Nru cppad-2015.00.00.9/cppad/local/op_code.hpp cppad-2016.00.00.1/cppad/local/op_code.hpp --- cppad-2015.00.00.9/cppad/local/op_code.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/op_code.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: op_code.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_OP_CODE_INCLUDED -# define CPPAD_OP_CODE_INCLUDED +// $Id: op_code.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_OP_CODE_HPP +# define CPPAD_OP_CODE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -38,21 +38,24 @@ operands have type AD< \a Base > use the following convention for thier endings: \verbatim Ending Left-Operand Right-Operand - pvOp parameter variable - vpOp variable parameter - vvOp variable variable + pvOp parameter variable + vpOp variable parameter + vvOp variable variable \endverbatim For example, AddpvOp represents the addition operator where the left operand is a parameter and the right operand is a variable. */ // alphabetical order is checked by bin/check_op_code.sh enum OpCode { - AbsOp, // abs(variable) - AcosOp, // asin(variable) - AddpvOp, // parameter + variable - AddvvOp, // variable + variable + AbsOp, // abs(variable) + AcosOp, // acos(variable) + AcoshOp, // acosh(variable) + AddpvOp, // parameter + variable + AddvvOp, // variable + variable AsinOp, // asin(variable) + AsinhOp, // asinh(variable) AtanOp, // atan(variable) + AtanhOp, // atanh(variable) BeginOp, // used to mark the beginning of the tape CExpOp, // CondExpRel(left, right, trueCase, falseCase) // arg[0] = the Rel operator: Lt, Le, Eq, Ge, Gt, or Ne @@ -60,73 +63,87 @@ // arg[1] & 2 = is right a variable // arg[1] & 4 = is trueCase a variable // arg[1] & 8 = is falseCase a variable - // arg[2] = index correspoding to left - // arg[3] = index correspoding to right - // arg[4] = index correspoding to trueCase - // arg[5] = index correspoding to falseCase - ComOp, // Compare(cop, result, left, right) - CosOp, // cos(variable) + // arg[2] = index correspoding to left + // arg[3] = index correspoding to right + // arg[4] = index correspoding to trueCase + // arg[5] = index correspoding to falseCase + CosOp, // cos(variable) CoshOp, // cosh(variable) CSkipOp, // Conditional skip // arg[0] = the Rel operator: Lt, Le, Eq, Ge, Gt, or Ne // arg[1] & 1 = is left a variable // arg[1] & 2 = is right a variable - // arg[2] = index correspoding to left - // arg[3] = index correspoding to right + // arg[2] = index correspoding to left + // arg[3] = index correspoding to right // arg[4] = number of operations to skip if CExpOp comparision is true // arg[5] = number of operations to skip if CExpOp comparision is false // arg[6] -> arg[5+arg[4]] = skip operations if true // arg[6+arg[4]] -> arg[5+arg[4]+arg[5]] = skip operations if false // arg[6+arg[4]+arg[5]] = arg[4] + arg[5] - CSumOp, // Cummulative summation + CSumOp, // Cummulative summation // arg[0] = number of addition variables in summation // arg[1] = number of subtraction variables in summation // arg[2] = index of parameter that initializes summation // arg[3] -> arg[2+arg[0]] = index for positive variables - // arg[3+arg[0]] -> arg[2+arg[0]+arg[1]] = index for minus variables + // arg[3+arg[0]] -> arg[2+arg[0]+arg[1]] = index for minus variables // arg[3+arg[0]+arg[1]] = arg[0] + arg[1] - DisOp, // discrete::eval(index, variable) - DivpvOp, // parameter / variable - DivvpOp, // variable / parameter - DivvvOp, // variable / variable - EndOp, // used to mark the end of the tape - ErfOp, // erf(variable) - ExpOp, // exp(variable) - InvOp, // independent variable - LdpOp, // z[parameter] - LdvOp, // z[variable] - LogOp, // log(variable) - MulpvOp, // parameter * variable - MulvvOp, // variable * variable - ParOp, // parameter - PowpvOp, // pow(parameter, variable) - PowvpOp, // pow(variable, parameter) - PowvvOp, // pow(variable, variable) - PriOp, // PrintFor(text, parameter or variable, parameter or variable) + DisOp, // discrete::eval(index, variable) + DivpvOp, // parameter / variable + DivvpOp, // variable / parameter + DivvvOp, // variable / variable + EndOp, // used to mark the end of the tape + EqpvOp, // parameter == variable + EqvvOp, // variable == variable + ErfOp, // erf(variable) + ExpOp, // exp(variable) + Expm1Op, // expm1(variable) + InvOp, // independent variable + LdpOp, // z[parameter] + LdvOp, // z[variable] + LepvOp, // parameter <= variable + LevpOp, // variable <= parameter + LevvOp, // variable <= variable + LogOp, // log(variable) + Log1pOp, // log1p(variable) + LtpvOp, // parameter < variable + LtvpOp, // variable < parameter + LtvvOp, // variable < variable + MulpvOp, // parameter * variable + MulvvOp, // variable * variable + NepvOp, // parameter != variable + NevvOp, // variable != variable + ParOp, // parameter + PowpvOp, // pow(parameter, variable) + PowvpOp, // pow(variable, parameter) + PowvvOp, // pow(variable, variable) + PriOp, // PrintFor(text, parameter or variable, parameter or variable) SignOp, // sign(variable) - SinOp, // sin(variable) + SinOp, // sin(variable) SinhOp, // sinh(variable) SqrtOp, // sqrt(variable) - StppOp, // z[parameter] = parameter - StpvOp, // z[parameter] = variable - StvpOp, // z[variable] = parameter - StvvOp, // z[variable] = variable - SubpvOp, // parameter - variable - SubvpOp, // variable - parameter - SubvvOp, // variable - variable - TanOp, // tan(variable) - TanhOp, // tan(variable) + StppOp, // z[parameter] = parameter + StpvOp, // z[parameter] = variable + StvpOp, // z[variable] = parameter + StvvOp, // z[variable] = variable + SubpvOp, // parameter - variable + SubvpOp, // variable - parameter + SubvvOp, // variable - variable + TanOp, // tan(variable) + TanhOp, // tan(variable) // user atomic operation codes - UserOp, // start of a user atomic operaiton + UserOp, // start of a user atomic operaiton // arg[0] = index of the operation if atomic_base class // arg[1] = extra information passed trough by deprecated old atomic class // arg[2] = number of arguments to this atomic function // arg[3] = number of results for this atomic function - UsrapOp, // this user atomic argument is a parameter - UsravOp, // this user atomic argument is a variable - UsrrpOp, // this user atomic result is a parameter - UsrrvOp, // this user atomic result is a variable - NumberOp + UsrapOp, // this user atomic argument is a parameter + UsravOp, // this user atomic argument is a variable + UsrrpOp, // this user atomic result is a parameter + UsrrvOp, // this user atomic result is a variable + ZmulpvOp, // azmul(parameter, variable) + ZmulvpOp, // azmul(variabe, parameter) + ZmulvvOp, // azmul(variable, variable) + NumberOp // number of operator codes (not an operator) }; // Note that bin/check_op_code.sh assumes the pattern '^\tNumberOp$' occurs // at the end of this list and only at the end of this list. @@ -137,7 +154,7 @@ \return Number of arguments corresponding to the specified operator. -\param op +\param op Operator for which we are fetching the number of arugments. \par NumArgTable @@ -147,8 +164,8 @@ \verbatim OpCode j NumArgTable[j] Meaning AbsOp 0 1 index of variable we are taking absolute value of -AcosOp 1 1 index of variable we are taking cosine of -AddpvOp 1 2 indices of parameter and variable we are adding +AcosOp 1 1 index of variable we are taking acos of +AcoshOp 2 1 index of variable we are taking acosh of \endverbatim Note that the meaning of the arguments depends on the operator. */ @@ -159,13 +176,15 @@ static const size_t NumArgTable[] = { 1, // AbsOp 1, // AcosOp + 1, // AcoshOp 2, // AddpvOp 2, // AddvvOp 1, // AsinOp + 1, // AsinhOp 1, // AtanOp + 1, // AtanhOp 1, // BeginOp offset first real argument to have index 1 6, // CExpOp - 4, // ComOp 1, // CosOp 1, // CoshOp 0, // CSkipOp (actually has a variable number of arguments, not zero) @@ -175,14 +194,26 @@ 2, // DivvpOp 2, // DivvvOp 0, // EndOp + 2, // EqpvOp + 2, // EqvvOp 3, // ErfOp 1, // ExpOp + 1, // Expm1Op 0, // InvOp 3, // LdpOp 3, // LdvOp + 2, // LepvOp + 2, // LevpOp + 2, // LevvOp 1, // LogOp + 1, // Log1pOp + 2, // LtpvOp + 2, // LtvpOp + 2, // LtvvOp 2, // MulpvOp 2, // MulvvOp + 2, // NepvOp + 2, // NevvOp 1, // ParOp 2, // PowpvOp 2, // PowvpOp @@ -205,13 +236,17 @@ 1, // UsrapOp 1, // UsravOp 1, // UsrrpOp - 0 // UsrrvOp + 0, // UsrrvOp + 2, // ZmulpvOp + 2, // ZmulvpOp + 2, // ZmulvvOp + 0 // NumberOp not used }; # ifndef NDEBUG // only do these checks once to save time static bool first = true; if( first ) - { CPPAD_ASSERT_UNKNOWN( size_t(NumberOp) == + { CPPAD_ASSERT_UNKNOWN( size_t(NumberOp) + 1 == sizeof(NumArgTable) / sizeof(NumArgTable[0]) ); CPPAD_ASSERT_UNKNOWN( size_t(NumberOp) <= @@ -240,7 +275,7 @@ OpCode j NumResTable[j] Meaning AbsOp 0 1 variable that is the result of the absolute value AcosOp 1 2 acos(x) and sqrt(1-x*x) are required for this op -AddpvOp 1 1 variable that is the result of the addition +AcoshOp 2 2 acosh(x) and sqrt(x*x-1) are required for this op \endverbatim */ inline size_t NumRes(OpCode op) @@ -250,13 +285,15 @@ static const size_t NumResTable[] = { 1, // AbsOp 2, // AcosOp + 2, // AcoshOp 1, // AddpvOp 1, // AddvvOp 2, // AsinOp + 2, // AsinhOp 2, // AtanOp + 2, // AtanhOp 1, // BeginOp offsets first variable to have index one (not zero) 1, // CExpOp - 0, // ComOp 2, // CosOp 2, // CoshOp 0, // CSkipOp @@ -266,14 +303,26 @@ 1, // DivvpOp 1, // DivvvOp 0, // EndOp + 0, // EqpvOp + 0, // EqvvOp 5, // ErfOp 1, // ExpOp + 1, // Expm1Op 1, // InvOp 1, // LdpOp 1, // LdvOp + 0, // LepvOp + 0, // LevpOp + 0, // LevvOp 1, // LogOp + 1, // Log1pOp + 0, // LtpvOp + 0, // LtvpOp + 0, // LtvvOp 1, // MulpvOp 1, // MulvvOp + 0, // NepvOp + 0, // NevvOp 1, // ParOp 3, // PowpvOp 3, // PowvpOp @@ -297,11 +346,14 @@ 0, // UsravOp 0, // UsrrpOp 1, // UsrrvOp - 0 // Last entry not used: avoids g++ 4.3.2 warn when pycppad builds + 1, // ZmulpvOp + 1, // ZmulvpOp + 1, // ZmulvvOp + 0 // NumberOp not used and avoids g++ 4.3.2 warn when pycppad builds }; // check ensuring conversion to size_t is as expected - CPPAD_ASSERT_UNKNOWN( size_t(NumberOp) == - sizeof(NumResTable) / sizeof(NumResTable[0]) - 1 + CPPAD_ASSERT_UNKNOWN( size_t(NumberOp) + 1 == + sizeof(NumResTable) / sizeof(NumResTable[0]) ); // this test ensures that all indices are within the table CPPAD_ASSERT_UNKNOWN( size_t(op) < size_t(NumberOp) ); @@ -316,7 +368,7 @@ \return name of the specified operation. -\param op +\param op Operator for which we are fetching the name */ inline const char* OpName(OpCode op) @@ -324,13 +376,15 @@ static const char *OpNameTable[] = { "Abs" , "Acos" , + "Acosh" , "Addpv" , "Addvv" , "Asin" , + "Asinh" , "Atan" , + "Atanh" , "Begin" , "CExp" , - "Com" , "Cos" , "Cosh" , "CSkip" , @@ -340,14 +394,26 @@ "Divvp" , "Divvv" , "End" , + "Eqpv" , + "Eqvv" , "Erf" , "Exp" , + "Expm1" , "Inv" , "Ldp" , "Ldv" , + "Lepv" , + "Levp" , + "Levv" , "Log" , + "Log1p" , + "Ltpv" , + "Ltvp" , + "Ltvv" , "Mulpv" , "Mulvv" , + "Nepv" , + "Nevv" , "Par" , "Powpv" , "Powvp" , @@ -370,11 +436,15 @@ "Usrap" , "Usrav" , "Usrrp" , - "Usrrv" + "Usrrv" , + "Zmulpv", + "Zmulvp", + "Zmulvv", + "Number" // not used }; // check ensuring conversion to size_t is as expected - CPPAD_ASSERT_UNKNOWN( - size_t(NumberOp) == sizeof(OpNameTable)/sizeof(OpNameTable[0]) + CPPAD_ASSERT_UNKNOWN( + size_t(NumberOp) + 1 == sizeof(OpNameTable)/sizeof(OpNameTable[0]) ); // this test ensures that all indices are within the table CPPAD_ASSERT_UNKNOWN( size_t(op) < size_t(NumberOp) ); @@ -407,9 +477,9 @@ */ template void printOpField( - std::ostream &os , + std::ostream &os , const char * leader , - const Type &value , + const Type &value , size_t width ) { std::ostringstream buffer; @@ -433,7 +503,7 @@ } // count number of spaces at begining - size_t nspace = 0; + size_t nspace = 0; while(str[nspace] == ' ' && nspace < len) nspace++; @@ -444,7 +514,7 @@ i = width - len + nspace; while(i--) - os << " "; + os << " "; } /*! @@ -475,10 +545,10 @@ */ template void printOp( - std::ostream& os , + std::ostream& os , const player* play , - size_t i_op , - size_t i_var , + size_t i_op , + size_t i_var , OpCode op , const addr_t* ind ) { size_t i; @@ -486,7 +556,7 @@ ! thread_alloc::in_parallel() , "cannot print trace of AD operations in parallel mode" ); - static const char *CompareOpName[] = + static const char *CompareOpName[] = { "Lt", "Le", "Eq", "Ge", "Gt", "Ne" }; // print operator @@ -494,11 +564,11 @@ if( NumRes(op) > 0 && op != BeginOp ) printOpField(os, "v=", i_var, 5); else printOpField(os, "v=", "", 5); - if( op == CExpOp || op == CSkipOp || op == ComOp ) - { printOpField(os, "", OpName(op), 5); + if( op == CExpOp || op == CSkipOp ) + { printOpField(os, "", OpName(op), 5); printOpField(os, "", CompareOpName[ ind[0] ], 3); } - else printOpField(os, "", OpName(op), 8); + else printOpField(os, "", OpName(op), 8); // print other fields size_t ncol = 5; @@ -509,8 +579,8 @@ ind[0] = the Rel operator: Lt, Le, Eq, Ge, Gt, or Ne ind[1] & 1 = is left a variable ind[1] & 2 = is right a variable - ind[2] = index correspoding to left - ind[3] = index correspoding to right + ind[2] = index correspoding to left + ind[3] = index correspoding to right ind[4] = number of operations to skip if CExpOp comparision is true ind[5] = number of operations to skip if CExpOp comparision is false ind[6] -> ind[5+ind[4]] = skip operations if true @@ -527,12 +597,12 @@ else printOpField(os, " pr=", play->GetPar(ind[3]), ncol); if( size_t(ind[4]) < 3 ) { for(i = 0; i < size_t(ind[4]); i++) - printOpField(os, " ot=", ind[6+i], ncol); + printOpField(os, " ot=", ind[6+i], ncol); } else { printOpField(os, "\n\tot=", ind[6+0], ncol); for(i = 1; i < size_t(ind[4]); i++) - printOpField(os, " ot=", ind[6+i], ncol); + printOpField(os, " ot=", ind[6+i], ncol); } if( size_t(ind[5]) < 3 ) { for(i = 0; i < size_t(ind[5]); i++) @@ -552,7 +622,7 @@ ind[1] = number of subtraction variables in summation ind[2] = index of parameter that initializes summation ind[3], ... , ind[2+ind[0]] = index for positive variables - ind[3+ind[0]], ..., ind[2+ind[0]+ind[1]] = negative variables + ind[3+ind[0]], ..., ind[2+ind[0]+ind[1]] = negative variables ind[3+ind[0]+ind[1]] == ind[0] + ind[1] */ CPPAD_ASSERT_UNKNOWN( ind[3+ind[0]+ind[1]] == ind[0]+ind[1] ); @@ -605,27 +675,40 @@ case AddvvOp: case DivvvOp: + case EqvvOp: + case LevvOp: + case LtvvOp: + case NevvOp: case MulvvOp: case PowvvOp: case SubvvOp: + case ZmulvvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); printOpField(os, " vl=", ind[0], ncol); printOpField(os, " vr=", ind[1], ncol); break; case AddpvOp: + case EqpvOp: + case DivpvOp: + case LepvOp: + case LtpvOp: + case NepvOp: case SubpvOp: case MulpvOp: case PowpvOp: - case DivpvOp: + case ZmulpvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); printOpField(os, " pl=", play->GetPar(ind[0]), ncol); printOpField(os, " vr=", ind[1], ncol); break; case DivvpOp: + case LevpOp: + case LtvpOp: case PowvpOp: case SubvpOp: + case ZmulvpOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); printOpField(os, " vl=", ind[0], ncol); printOpField(os, " pr=", play->GetPar(ind[1]), ncol); @@ -633,12 +716,17 @@ case AbsOp: case AcosOp: + case AcoshOp: case AsinOp: + case AsinhOp: case AtanOp: + case AtanhOp: case CosOp: case CoshOp: case ExpOp: + case Expm1Op: case LogOp: + case Log1pOp: case SignOp: case SinOp: case SinhOp: @@ -652,8 +740,8 @@ case ErfOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); - // ind[2] points to the parameter 0 - // ind[3] points to the parameter 2 / sqrt(pi) + // ind[1] points to the parameter 0 + // ind[2] points to the parameter 2 / sqrt(pi) printOpField(os, " v=", ind[0], ncol); break; @@ -704,7 +792,7 @@ printOpField(os, " x=", ind[1], ncol); } break; - + case CExpOp: CPPAD_ASSERT_UNKNOWN(ind[1] != 0); @@ -723,20 +811,6 @@ else printOpField(os, " pf=", play->GetPar(ind[5]), ncol); break; - case ComOp: - CPPAD_ASSERT_UNKNOWN(ind[1] != 0); - CPPAD_ASSERT_UNKNOWN( NumArg(op) == 4 ); - if( ind[1] & 1 ) - printOpField(os, "res=", 1, ncol); - else printOpField(os, "res=", 0, ncol); - if( ind[1] & 2 ) - printOpField(os, " vl=", ind[2], ncol); - else printOpField(os, " pl=", play->GetPar(ind[2]), ncol); - if( ind[1] & 4 ) - printOpField(os, " vr=", ind[3], ncol); - else printOpField(os, " pr=", play->GetPar(ind[3]), ncol); - break; - default: CPPAD_ASSERT_UNKNOWN(0); } @@ -776,7 +850,7 @@ */ template void printOpResult( - std::ostream &os , + std::ostream &os , size_t nfz , const Value *fz , size_t nrz , @@ -834,7 +908,9 @@ // 1 argument , 1 result case AbsOp: case ExpOp: + case Expm1Op: case LogOp: + case Log1pOp: case ParOp: case SignOp: case SqrtOp: @@ -843,8 +919,11 @@ // 1 argument, 2 results case AcosOp: + case AcoshOp: case AsinOp: + case AsinhOp: case AtanOp: + case AtanhOp: case CosOp: case CoshOp: case SinOp: @@ -859,12 +938,33 @@ CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) + 4 < result ); break; // ------------------------------------------------------------------ + // 2 arguments, no results + case LepvOp: + case LtpvOp: + case EqpvOp: + case NepvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) <= result ); + break; + // + case LevpOp: + case LtvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= result ); + break; + // + case LevvOp: + case LtvvOp: + case EqvvOp: + case NevvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= result ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) <= result ); + break; // 2 arguments (both variables), 1 results case AddvvOp: case DivvvOp: case MulvvOp: case SubvvOp: + case ZmulvvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < result ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < result ); break; @@ -872,6 +972,7 @@ // 2 arguments (first variables), 1 results case DivvpOp: case SubvpOp: + case ZmulvpOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < result ); break; @@ -881,6 +982,7 @@ case DivpvOp: case MulpvOp: case SubpvOp: + case ZmulpvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < result ); break; @@ -910,7 +1012,7 @@ case LdvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < result ); break; - + // 3 arguments, third variable, no result case StpvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) <= result ); @@ -928,17 +1030,6 @@ break; // ------------------------------------------------------------------ - // 4 arguments, no result - case ComOp: - if( arg[1] & 2 ) - { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) <= result ); - } - if( arg[1] & 4 ) - { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) <= result ); - } - break; - // ------------------------------------------------------------------ - // 5 arguments, no result case PriOp: if( arg[0] & 1 ) diff -Nru cppad-2015.00.00.9/cppad/local/op.hpp cppad-2016.00.00.1/cppad/local/op.hpp --- cppad-2015.00.00.9/cppad/local/op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: op.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_OP_INCLUDED -# define CPPAD_OP_INCLUDED +// $Id: op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_OP_HPP +# define CPPAD_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,12 +17,15 @@ # include // operations -# include +# include # include # include # include +# include # include +# include # include +# include # include # include # include @@ -33,8 +36,10 @@ # include # include # include +# include # include # include +# include # include # include # include @@ -49,6 +54,7 @@ # include # include # include +# include # endif diff -Nru cppad-2015.00.00.9/cppad/local/optimize.hpp cppad-2016.00.00.1/cppad/local/optimize.hpp --- cppad-2015.00.00.9/cppad/local/optimize.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/optimize.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: optimize.hpp 3643 2015-02-12 11:47:46Z bradbell $ */ -# ifndef CPPAD_OPTIMIZE_INCLUDED -# define CPPAD_OPTIMIZE_INCLUDED +// $Id: optimize.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_OPTIMIZE_HPP +# define CPPAD_OPTIMIZE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,6 +16,7 @@ /* $begin optimize$$ $spell + enum jac bool Taylor @@ -27,13 +28,8 @@ $$ $section Optimize an ADFun Object Tape$$ +$mindex sequence operations speed memory NDEBUG$$ -$index optimize$$ -$index tape, optimize$$ -$index sequence, optimize operations$$ -$index operations, optimize sequence$$ -$index speed, optimize$$ -$index memory, optimize$$ $head Syntax$$ $icode%f%.optimize()%$$ @@ -45,7 +41,7 @@ size functions in $cref seq_property$$. The $icode%f%.optimize%$$ procedure reduces the number of operations, and thereby the time and the memory, required to -compute function and derivative values. +compute function and derivative values. $head f$$ The object $icode f$$ has prototype @@ -63,18 +59,18 @@ $subhead Testing$$ You can run the CppAD $cref/speed/speed_main/$$ tests and see -the corresponding changes in number of variables and execution time; +the corresponding changes in number of variables and execution time; see $cref cmake_check$$. $head Efficiency$$ The $code optimize$$ member function -may greatly reduce the number of variables +may greatly reduce the number of variables in the operation sequence; see $cref/size_var/seq_property/size_var/$$. If a $cref/zero order forward/forward_zero/$$ calculation is done during the construction of $icode f$$, it will require more memory and time than required after the optimization procedure. In addition, it will need to be redone. -For this reason, it is more efficient to use +For this reason, it is more efficient to use $codei% ADFun<%Base%> %f%; %f%.Dependent(%x%, %y%); @@ -84,15 +80,10 @@ $codei% ADFun<%Base%> %f%(%x%, %y%) %f%.optimize(); -%$$ +%$$ See the discussion about $cref/sequence constructors/FunConstruct/Sequence Constructor/$$. -$head Comparison Operators$$ -Any comparison operators that are in the tape are removed by this operation. -Hence the return value of $cref CompareChange$$ will always be zero -for an optimized tape (even if $code NDEBUG$$ is not defined). - $head Atomic Functions$$ There are some subtitle issue with optimized $cref atomic$$ functions $latex v = g(u)$$: @@ -100,10 +91,11 @@ $subhead rev_sparse_jac$$ The $cref atomic_rev_sparse_jac$$ function is be used to determine which components of $icode u$$ affect the dependent variables of $icode f$$. -The current setting of the -$cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for each -atomic function is used to determine if the $code bool$$ or -$code std::set$$ version of $cref atomic_rev_sparse_jac$$ is used. +For each atomic operation, the current +$cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ setting is used +to determine if $code pack_sparsity_enum$$, $code bool_sparsity_enum$$, +or $code set_sparsity_enum$$ is used to determine dependency relations +between argument and result variables. $subhead nan$$ If $icode%u%[%i%]%$$ does not affect the value of @@ -112,7 +104,6 @@ $head Checking Optimization$$ -$index NDEBUG$$ If $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is not defined, and $cref/f.size_order()/size_order/$$ is greater than zero, a $cref forward_zero$$ calculation is done using the optimized version @@ -156,16 +147,16 @@ /// independent variables. yes_connected , - /// There is only one parrent that connects this variable to the + /// There is only one parrent that connects this variable to the /// independent variables and the parent is a summation operation; i.e., /// AddvvOp, AddpvOp, SubpvOp, SubvpOp, or SubvvOp. sum_connected , - /// Satisfies the sum_connected assumptions above and in addition + /// Satisfies the sum_connected assumptions above and in addition /// this variable is the result of summation operator. csum_connected , - /// This node is only connected in the case where the comparision is + /// This node is only connected in the case where the comparision is /// true for the conditional expression with index \c connect_index. cexp_connected @@ -176,59 +167,184 @@ */ class class_cexp_pair { public: + /// packs both the compare and index information + /// compare = pack_ % 2 + /// index = pack_ / 2 + size_t pack_; + /// If this is true (false) this connection is only for the case where /// the comparision in the conditional expression is true (false) - bool compare_; + bool compare(void) const + { return pack_ % 2 != 0; } + /// This is the index of the conditional expression (in cksip_info) /// for this connection - size_t index_; + size_t index(void) const + { return pack_ / 2; } + /// constructor - class_cexp_pair(const bool& compare, const size_t& index) - : compare_(compare), index_(index) - { } + class_cexp_pair(const bool& compare_arg, const size_t& index_arg) + : pack_(size_t(compare_arg) + 2 * index_arg ) + { CPPAD_ASSERT_UNKNOWN( compare_arg == compare() ); + CPPAD_ASSERT_UNKNOWN( index_arg == index() ); + } + /// assignment operator void operator=(const class_cexp_pair& right) - { index_ = right.index_; - compare_ = right.compare_; - } + { pack_ = right.pack_; } + /// not equal operator bool operator!=(const class_cexp_pair& right) - { return (index_ != right.index_) | (compare_ != right.compare_); - } - /// Less than operator + { return pack_ != right.pack_; } + + /// Less than operator /// (required for intersection of two sets of class_cexp_pair elements). bool operator<(const class_cexp_pair& right) const - { if( index_ == right.index_ ) - return size_t(compare_) < size_t(right.compare_); - return index_ < right.index_; - } + { return pack_ < right.pack_; } }; + /*! -Compute intersection of two sets of class_cexp_pair elements. +A container that is like std::set except that it does +not allocate empty sets and only has a few operations. +*/ +class class_set_cexp_pair { +private: + // This set is empty if and only if ptr_ == CPPAD_NULL; + std::set* ptr_; + + void new_ptr(void) + { CPPAD_ASSERT_UNKNOWN( ptr_ == CPPAD_NULL ); + ptr_ = new std::set; + CPPAD_ASSERT_UNKNOWN( ptr_ != CPPAD_NULL ); + // std::cout << "new ptr_ = " << ptr_ << std::endl; + } + + void delete_ptr(void) + { if( ptr_ != CPPAD_NULL ) + { // std::cout << "delete ptr_ = " << ptr_ << std::endl; + delete ptr_; + } + ptr_ = CPPAD_NULL; + } -\param left -first operand of the intersection +public: + /// constructor + class_set_cexp_pair(void) + { ptr_ = CPPAD_NULL; } -\param right -second operand of the intersection + /// destructor + ~class_set_cexp_pair(void) + { delete_ptr(); } + + void print(void) + { if( ptr_ == CPPAD_NULL ) + { std::cout << "{ }"; + return; + } + CPPAD_ASSERT_UNKNOWN( ! empty() ); + const char* sep = "{ "; + std::set::const_iterator itr; + for(itr = ptr_->begin(); itr != ptr_->end(); itr++) + { std::cout << sep; + std::cout << "(" << itr->compare() << "," << itr->index() << ")"; + sep = ", "; + } + std::cout << "}"; + } -\result -the intersection of left and right -*/ -inline std::set intersection( - std::set& left , - std::set& right ) -{ std::set result; - std::set_intersection( - left.begin() , - left.end() , - right.begin() , - right.end() , - std::inserter(result, result.begin()) - ); - return result; -} + /// assignment operator + void operator=(const class_set_cexp_pair& other) + { // make this a copy of the other set + if( other.ptr_ == CPPAD_NULL ) + { if( ptr_ == CPPAD_NULL ) + return; + delete_ptr(); + return; + } + CPPAD_ASSERT_UNKNOWN( ! other.empty() ); + if( ptr_ == CPPAD_NULL ) + new_ptr(); + *ptr_ = *other.ptr_; + } + + /// insert an element in this set + void insert(const class_cexp_pair& element) + { if( ptr_ == CPPAD_NULL ) + new_ptr(); + ptr_->insert(element); + CPPAD_ASSERT_UNKNOWN( ! empty() ); + } + + /// is this set empty + bool empty(void) const + { if( ptr_ == CPPAD_NULL ) + return true; + CPPAD_ASSERT_UNKNOWN( ! ptr_->empty() ); + return false; + } + + /// remove the elements in this set + void clear(void) + { if( ptr_ == CPPAD_NULL ) + return; + CPPAD_ASSERT_UNKNOWN( ! empty() ); + delete_ptr(); + } + + // returns begin pointer for the set + std::set::const_iterator begin(void) + { CPPAD_ASSERT_UNKNOWN( ! empty() ); + return ptr_->begin(); + } + + // returns end pointer for the set + std::set::const_iterator end(void) + { CPPAD_ASSERT_UNKNOWN( ! empty() ); + return ptr_->end(); + } + + /*! + Make this set the intersection of itself with another set. + \param other + the other set + + */ + void intersection(const class_set_cexp_pair& other ) + { // empty result case + if( ptr_ == CPPAD_NULL ) + return; + + // empty result case + if( other.ptr_ == CPPAD_NULL ) + { delete_ptr(); + return; + } + + // put result here + class_set_cexp_pair result; + CPPAD_ASSERT_UNKNOWN( result.ptr_ == CPPAD_NULL ); + result.new_ptr(); + CPPAD_ASSERT_UNKNOWN( result.ptr_ != CPPAD_NULL ); + + // do the intersection + std::set_intersection( + ptr_->begin() , + ptr_->end() , + other.ptr_->begin() , + other.ptr_->end() , + std::inserter(*result.ptr_, result.ptr_->begin()) + ); + if( result.ptr_->empty() ) + result.delete_ptr(); + + // swap this and the result + std::swap(ptr_, result.ptr_); + + return; + } + +}; /*! Structure used by \c optimize to hold information about one variable. in the old operation seqeunce. @@ -236,20 +352,14 @@ struct struct_old_variable { /// Operator for which this variable is the result, \c NumRes(op) > 0. /// Set by the reverse sweep at beginning of optimization. - OpCode op; + OpCode op; /// Pointer to first argument (child) for this operator. /// Set by the reverse sweep at beginning of optimization. const addr_t* arg; /// How is this variable connected to the independent variables - enum_connect_type connect_type; - - /*! - If \c connect_type is \c cexp_connected, - this is the corresponding infromation for the conditional connections. - */ - std::set cexp_set; + enum_connect_type connect_type; /// New operation sequence corresponding to this old varable. /// Set during forward sweep to the index in the new tape @@ -274,7 +384,7 @@ */ struct struct_csum_variable { /// Operator for which this variable is the result, \c NumRes(op) > 0. - OpCode op; + OpCode op; /// Pointer to first argument (child) for this operator. /// Set by the reverse sweep at beginning of optimization. @@ -290,7 +400,7 @@ (so that stacks do not start from zero size every time). */ struct struct_csum_stacks { - /// stack of operations in the cummulative summation + /// stack of operations in the cummulative summation std::stack op_stack; /// stack of variables to be added std::stack add_stack; @@ -308,9 +418,9 @@ /// (flag & 2) is true if and only if right is a variable size_t flag; /// index for left comparison operand - size_t left; + size_t left; /// index for right comparison operand - size_t right; + size_t right; /// maximum variable index between left and right size_t max_left_right; /// set of variables to skip on true @@ -336,7 +446,7 @@ enum_connect_type connect_type; /// If this is an conditional connection, this is the information /// of the correpsonding CondExpOp operators - std::set cexp_set; + class_set_cexp_pair cexp_set; /// If this is a conditional connection, this is the operator /// index of the beginning of the atomic call sequence; i.e., /// the first UserOp. @@ -354,34 +464,34 @@ \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. -Note that the index for this vector must be greater than or equal zero and +Note that the index for this vector must be greater than or equal zero and less than tape.size(). -\li tape[i].op +\li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. -\li tape[i].arg +\li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var -Suppose +Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var -has alread been set to the variable in the new operation sequence +has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current -is the index in the old operation sequence for +is the index in the old operation sequence for the variable corresponding to the result for the current operator. -Assertions: +Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. @@ -415,34 +525,34 @@ \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. -Note that the index for this vector must be greater than or equal zero and +Note that the index for this vector must be greater than or equal zero and less than tape.size(). -\li tape[i].op +\li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. -\li tape[i].arg +\li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var -Suppose +Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var -has alread been set to the variable in the new operation sequence +has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current -is the index in the old operation sequence for +is the index in the old operation sequence for the variable corresponding to the result for the current operator. -Assertions: +Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. @@ -460,7 +570,7 @@ \param hash_table_var is a vector with size CPPAD_HASH_TABLE_SIZE -that maps a hash code to the corresponding +that maps a hash code to the corresponding variable index in the old operation sequence. All the values in this table must be less than \a current. @@ -490,14 +600,16 @@ { const addr_t* arg = tape[current].arg; OpCode op = tape[current].op; addr_t new_arg[1]; - - CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + + // ErfOp has three arguments, but the second and third are always the + // parameters 0 and 2 / sqrt(pi) respectively. + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 || op == ErfOp); CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < current ); new_arg[0] = tape[arg[0]].new_var; CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < current ); code = hash_code( - op , + op , new_arg , npar , par @@ -511,7 +623,7 @@ return i_var; } return 0; -} +} /*! Check a binary operator for a complete match with a previous operator, @@ -520,34 +632,34 @@ \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. -Note that the index for this vector must be greater than or equal zero and +Note that the index for this vector must be greater than or equal zero and less than tape.size(). -\li tape[i].op +\li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. -\li tape[i].arg +\li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var -Suppose +Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var -has alread been set to the variable in the new operation sequence +has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current -is the index in the old operation sequence for +is the index in the old operation sequence for the variable corresponding to the result for the current operator. -Assertions: +Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. @@ -565,7 +677,7 @@ \param hash_table_var is a vector with size CPPAD_HASH_TABLE_SIZE -that maps a hash code to the corresponding +that maps a hash code to the corresponding variable index in the old operation sequence. All the values in this table must be less than \a current. @@ -578,7 +690,7 @@ If the return value is zero, no match was found. If the return value is greater than zero, -it is the index of a new variable that can be used to replace the +it is the index of a new variable that can be used to replace the old variable. @@ -619,6 +731,7 @@ case DivpvOp: case PowpvOp: case SubpvOp: + case ZmulpvOp: // arg[0] parameter[0] = true; new_arg[0] = arg[0]; @@ -633,6 +746,7 @@ case DivvpOp: case PowvpOp: case SubvpOp: + case ZmulvpOp: // arg[0] parameter[0] = false; new_arg[0] = tape[arg[0]].new_var; @@ -649,6 +763,7 @@ case DivvvOp: case PowvvOp: case SubvvOp: + case ZmulvvOp: // arg[0] parameter[0] = false; new_arg[0] = tape[arg[0]].new_var; @@ -664,7 +779,7 @@ CPPAD_ASSERT_UNKNOWN(false); } code = hash_code( - op , + op , new_arg , npar , par @@ -703,7 +818,7 @@ CPPAD_ASSERT_UNKNOWN( op == AddvvOp || op == MulvvOp ); std::swap(new_arg[0], new_arg[1]); unsigned short code_switch = hash_code( - op , + op , new_arg , npar , par @@ -722,7 +837,7 @@ match_var = i_var; } return match_var; -} +} /*! Record an operation of the form (parameter op variable). @@ -731,34 +846,34 @@ \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. -Note that the index for this vector must be greater than or equal zero and +Note that the index for this vector must be greater than or equal zero and less than tape.size(). -\li tape[i].op +\li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. -\li tape[i].arg +\li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var -Suppose +Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var -has alread been set to the variable in the new operation sequence +has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current -is the index in the old operation sequence for +is the index in the old operation sequence for the variable corresponding to the result for the current operator. -Assertions: +Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. @@ -779,8 +894,8 @@ \param op is the operator that we are recording which must be one of the following: -AddpvOp, DivpvOp, MulpvOp, PowvpOp, SubpvOp. - +AddpvOp, DivpvOp, MulpvOp, PowpvOp, SubpvOp, ZmulpvOp. + \param arg is the vector of arguments for this operator. @@ -805,6 +920,7 @@ case MulpvOp: case PowpvOp: case SubpvOp: + case ZmulpvOp: break; default: @@ -833,34 +949,34 @@ \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. -Note that the index for this vector must be greater than or equal zero and +Note that the index for this vector must be greater than or equal zero and less than tape.size(). -\li tape[i].op +\li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. -\li tape[i].arg +\li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var -Suppose +Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var -has alread been set to the variable in the new operation sequence +has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current -is the index in the old operation sequence for +is the index in the old operation sequence for the variable corresponding to the result for the current operator. -Assertions: +Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. @@ -881,8 +997,8 @@ \param op is the operator that we are recording which must be one of the following: -DivvpOp, PowvpOp, SubvpOp. - +DivvpOp, PowvpOp, SubvpOp, ZmulvpOp. + \param arg is the vector of arguments for this operator. @@ -905,6 +1021,7 @@ { case DivvpOp: case PowvpOp: case SubvpOp: + case ZmulvpOp: break; default: @@ -932,34 +1049,34 @@ \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. -Note that the index for this vector must be greater than or equal zero and +Note that the index for this vector must be greater than or equal zero and less than tape.size(). -\li tape[i].op +\li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. -\li tape[i].arg +\li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var -Suppose +Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var -has alread been set to the variable in the new operation sequence +has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current -is the index in the old operation sequence for +is the index in the old operation sequence for the variable corresponding to the result for the current operator. -Assertions: +Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. @@ -980,8 +1097,8 @@ \param op is the operator that we are recording which must be one of the following: -AddvvOp, DivvvOp, MulvvOp, PowvpOp, SubvvOp. - +AddvvOp, DivvvOp, MulvvOp, PowvvOp, SubvvOp, ZmulvvOp. + \param arg is the vector of arguments for this operator. @@ -1006,6 +1123,7 @@ case MulvvOp: case PowvvOp: case SubvvOp: + case ZmulvvOp: break; default: @@ -1036,34 +1154,34 @@ \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. -Note that the index for this vector must be greater than or equal zero and +Note that the index for this vector must be greater than or equal zero and less than tape.size(). -\li tape[i].op +\li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. -\li tape[i].arg +\li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var -Suppose +Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var -has alread been set to the variable in the new operation sequence +has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current -is the index in the old operation sequence for +is the index in the old operation sequence for the variable corresponding to the result for the current operator. -Assertions: +Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. @@ -1099,13 +1217,13 @@ For example; suppose that index \c j corresponds to a variable in the current operator, i = tape[current].arg[j], -and +and tape[arg[j]].connect_type == csum_connected. It then follows that tape[i].new_var == tape.size(). \par Restriction: -\li tape[current].op +\li tape[current].op must be one of AddpvOp, AddvvOp, SubpvOp, SubvpOp, SubvvOp. \li tape[current].connect_type must be \c yes_connected. @@ -1124,7 +1242,7 @@ recorder* rec , struct_csum_stacks& work ) { - + CPPAD_ASSERT_UNKNOWN( work.op_stack.empty() ); CPPAD_ASSERT_UNKNOWN( work.add_stack.empty() ); CPPAD_ASSERT_UNKNOWN( work.sub_stack.empty() ); @@ -1138,7 +1256,7 @@ var.op = tape[current].op; var.arg = tape[current].arg; - var.add = true; + var.add = true; work.op_stack.push( var ); Base sum_par(0); @@ -1179,7 +1297,7 @@ ); var.op = tape[arg[0]].op; var.arg = tape[arg[0]].arg; - var.add = add; + var.add = add; work.op_stack.push( var ); } else if( add ) @@ -1263,9 +1381,15 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. +\param options +The possible values for this string are: +"", "no_conditional_skip". +If it is "no_conditional_skip", then no conditional skip operations +will be generated. + \param n is the number of independent variables on the tape. @@ -1288,14 +1412,22 @@ template void optimize_run( + const std::string& options , size_t n , CppAD::vector& dep_taddr , player* play , - recorder* rec ) + recorder* rec ) { + // nan with type Base + Base base_nan = Base( std::numeric_limits::quiet_NaN() ); + // temporary indices size_t i, j, k; + // check options + bool conditional_skip = + options.find("no_conditional_skip", 0) == std::string::npos; + // temporary variables OpCode op; // current operator const addr_t* arg; // operator arguments @@ -1305,14 +1437,14 @@ size_t m = dep_taddr.size(); // number of variables in the player - const size_t num_var = play->num_var_rec(); + const size_t num_var = play->num_var_rec(); # ifndef NDEBUG // number of parameters in the player const size_t num_par = play->num_par_rec(); # endif - // number of VecAD indices + // number of VecAD indices size_t num_vecad_ind = play->num_vec_ind_rec(); // number of VecAD vectors @@ -1322,6 +1454,12 @@ // data structure that maps variable index in original operation // sequence to corresponding operator information CppAD::vector tape(num_var); + + // if tape[i].connect_type == exp_connected, cexp_set[i] is the + // corresponding information for the conditional connection. + CppAD::vector cexp_vec_set; + if( conditional_skip ) + cexp_vec_set.resize(num_var); // ------------------------------------------------------------- // Determine how each variable is connected to the dependent variables @@ -1345,7 +1483,7 @@ // length of this VecAD size_t length = play->GetVecInd(j); // set to proper index for this VecAD - vecad[j] = i; + vecad[j] = i; for(k = 1; k <= length; k++) vecad[j+k] = num_vecad_vec; // invalid index // start of next VecAD @@ -1355,11 +1493,16 @@ // work space used by UserOp. typedef std::set size_set; + // vector user_r_set; // set sparsity pattern for result vector user_s_set; // set sparisty pattern for argument - vector user_r_bool; // bool sparsity pattern for result + // + vector user_r_bool; // bool sparsity pattern for result vector user_s_bool; // bool sparisty pattern for argument // + vectorBool user_r_pack; // pack sparsity pattern for result + vectorBool user_s_pack; // pack sparisty pattern for argument + // size_t user_q = 0; // column dimension for sparsity patterns size_t user_index = 0; // indentifier for this user_atomic operation size_t user_id = 0; // user identifier for this call to operator @@ -1368,8 +1511,10 @@ size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // - atomic_base* user_atom = CPPAD_NULL; // current user atomic function - bool user_set = true; // use set sparsity (or bool) + atomic_base* user_atom = CPPAD_NULL; // current user atomic function + bool user_pack = false; // sparsity pattern type is pack + bool user_bool = false; // sparsity pattern type is bool + bool user_set = false; // sparsity pattern type is set // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end } user_state; @@ -1404,20 +1549,27 @@ else CPPAD_ASSERT_UNKNOWN((op != InvOp) & (op != BeginOp)); # endif enum_connect_type connect_type = tape[i_var].connect_type; - std::set& cexp_set = tape[i_var].cexp_set; + class_set_cexp_pair* cexp_set = CPPAD_NULL; + if( conditional_skip ) + cexp_set = &cexp_vec_set[i_var]; switch( op ) { // One variable corresponding to arg[0] case AbsOp: case AcosOp: + case AcoshOp: case AsinOp: + case AsinhOp: case AtanOp: + case AtanhOp: case CosOp: case CoshOp: case DivvpOp: case ErfOp: case ExpOp: + case Expm1Op: case LogOp: + case Log1pOp: case PowvpOp: case SignOp: case SinOp: @@ -1425,26 +1577,26 @@ case SqrtOp: case TanOp: case TanhOp: + case ZmulvpOp: switch( connect_type ) { case not_connected: break; - + case yes_connected: case sum_connected: - case csum_connected: + case csum_connected: tape[arg[0]].connect_type = yes_connected; break; case cexp_connected: + CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[0]].connect_type == not_connected ) { tape[arg[0]].connect_type = cexp_connected; - tape[arg[0]].cexp_set = cexp_set; + cexp_vec_set[arg[0]] = *cexp_set; } else if( tape[arg[0]].connect_type == cexp_connected ) - { tape[arg[0]].cexp_set = intersection( - tape[arg[0]].cexp_set, cexp_set - ); - if( tape[arg[0]].cexp_set.empty() ) + { cexp_vec_set[arg[0]].intersection(*cexp_set); + if( cexp_vec_set[arg[0]].empty() ) tape[arg[0]].connect_type = yes_connected; } else tape[arg[0]].connect_type = yes_connected; @@ -1460,26 +1612,26 @@ case DivpvOp: case MulpvOp: case PowpvOp: + case ZmulpvOp: switch( connect_type ) { case not_connected: break; - + case yes_connected: case sum_connected: - case csum_connected: + case csum_connected: tape[arg[1]].connect_type = yes_connected; break; case cexp_connected: + CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[1]].connect_type == not_connected ) { tape[arg[1]].connect_type = cexp_connected; - tape[arg[1]].cexp_set = cexp_set; + cexp_vec_set[arg[1]] = *cexp_set; } else if( tape[arg[1]].connect_type == cexp_connected ) - { tape[arg[1]].cexp_set = intersection( - tape[arg[1]].cexp_set, cexp_set - ); - if( tape[arg[1]].cexp_set.empty() ) + { cexp_vec_set[arg[1]].intersection(*cexp_set); + if( cexp_vec_set[arg[1]].empty() ) tape[arg[1]].connect_type = yes_connected; } else tape[arg[1]].connect_type = yes_connected; @@ -1489,31 +1641,30 @@ CPPAD_ASSERT_UNKNOWN(false); } break; // -------------------------------------------- - + // Special case for SubvpOp case SubvpOp: switch( connect_type ) { case not_connected: break; - + case yes_connected: case sum_connected: - case csum_connected: + case csum_connected: if( tape[arg[0]].connect_type == not_connected ) tape[arg[0]].connect_type = sum_connected; else tape[arg[0]].connect_type = yes_connected; break; case cexp_connected: + CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[0]].connect_type == not_connected ) { tape[arg[0]].connect_type = cexp_connected; - tape[arg[0]].cexp_set = cexp_set; + cexp_vec_set[arg[0]] = *cexp_set; } else if( tape[arg[0]].connect_type == cexp_connected ) - { tape[arg[0]].cexp_set = intersection( - tape[arg[0]].cexp_set, cexp_set - ); - if( tape[arg[0]].cexp_set.empty() ) + { cexp_vec_set[arg[0]].intersection(*cexp_set); + if( cexp_vec_set[arg[0]].empty() ) tape[arg[0]].connect_type = yes_connected; } else tape[arg[0]].connect_type = yes_connected; @@ -1527,14 +1678,14 @@ tape[i_var].connect_type = connect_type = csum_connected; } break; // -------------------------------------------- - + // Special case for AddpvOp and SubpvOp case AddpvOp: case SubpvOp: switch( connect_type ) { case not_connected: break; - + case yes_connected: case sum_connected: case csum_connected: @@ -1544,15 +1695,14 @@ break; case cexp_connected: + CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[1]].connect_type == not_connected ) { tape[arg[1]].connect_type = cexp_connected; - tape[arg[1]].cexp_set = cexp_set; + cexp_vec_set[arg[1]] = *cexp_set; } else if( tape[arg[1]].connect_type == cexp_connected ) - { tape[arg[1]].cexp_set = intersection( - tape[arg[1]].cexp_set, cexp_set - ); - if( tape[arg[1]].cexp_set.empty() ) + { cexp_vec_set[arg[1]].intersection(*cexp_set); + if( cexp_vec_set[arg[1]].empty() ) tape[arg[1]].connect_type = yes_connected; } else tape[arg[1]].connect_type = yes_connected; @@ -1567,7 +1717,7 @@ } break; // -------------------------------------------- - + // Special case for AddvvOp and SubvvOp case AddvvOp: case SubvvOp: @@ -1584,15 +1734,14 @@ break; case cexp_connected: + CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[i]].connect_type == not_connected ) { tape[arg[i]].connect_type = cexp_connected; - tape[arg[i]].cexp_set = cexp_set; + cexp_vec_set[arg[i]] = *cexp_set; } else if( tape[arg[i]].connect_type == cexp_connected ) - { tape[arg[i]].cexp_set = intersection( - tape[arg[i]].cexp_set, cexp_set - ); - if( tape[arg[i]].cexp_set.empty() ) + { cexp_vec_set[arg[i]].intersection(*cexp_set); + if( cexp_vec_set[arg[i]].empty() ) tape[arg[i]].connect_type = yes_connected; } else tape[arg[i]].connect_type = yes_connected; @@ -1607,11 +1756,12 @@ } break; // -------------------------------------------- - // Other binary operators + // Other binary operators // where operands are arg[0], arg[1] case DivvvOp: case MulvvOp: case PowvvOp: + case ZmulvvOp: for(i = 0; i < 2; i++) switch( connect_type ) { case not_connected: break; @@ -1623,15 +1773,14 @@ break; case cexp_connected: + CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[i]].connect_type == not_connected ) { tape[arg[i]].connect_type = cexp_connected; - tape[arg[i]].cexp_set = cexp_set; + cexp_vec_set[arg[i]] = *cexp_set; } else if( tape[arg[i]].connect_type == cexp_connected ) - { tape[arg[i]].cexp_set = intersection( - tape[arg[i]].cexp_set, cexp_set - ); - if( tape[arg[i]].cexp_set.empty() ) + { cexp_vec_set[arg[i]].intersection(*cexp_set); + if( cexp_vec_set[arg[i]].empty() ) tape[arg[i]].connect_type = yes_connected; } else tape[arg[i]].connect_type = yes_connected; @@ -1671,33 +1820,37 @@ cskip_info.push_back(info); // if( arg[1] & 4 ) - { if( tape[arg[4]].connect_type == not_connected ) + { if( conditional_skip && + tape[arg[4]].connect_type == not_connected ) { tape[arg[4]].connect_type = cexp_connected; - tape[arg[4]].cexp_set = cexp_set; - tape[arg[4]].cexp_set.insert( + cexp_vec_set[arg[4]] = *cexp_set; + cexp_vec_set[arg[4]].insert( class_cexp_pair(true, index) ); } else - { // if arg[4] is cexp_connected, it could be + { // if arg[4] is cexp_connected, it could be // connected for both the true and false case // 2DO: if previously cexp_connected // and the true/false sense is the same, should // keep this conditional connnection. - tape[arg[4]].cexp_set.clear(); + if(conditional_skip) + cexp_vec_set[arg[4]].clear(); tape[arg[4]].connect_type = yes_connected; } } if( arg[1] & 8 ) - { if( tape[arg[5]].connect_type == not_connected ) + { if( conditional_skip && + tape[arg[5]].connect_type == not_connected ) { tape[arg[5]].connect_type = cexp_connected; - tape[arg[5]].cexp_set = cexp_set; - tape[arg[5]].cexp_set.insert( + cexp_vec_set[arg[5]] = *cexp_set; + cexp_vec_set[arg[5]].insert( class_cexp_pair(false, index) ); } else - { tape[arg[5]].cexp_set.clear(); + { if(conditional_skip) + cexp_vec_set[arg[5]].clear(); tape[arg[5]].connect_type = yes_connected; } } @@ -1705,7 +1858,6 @@ break; // -------------------------------------------- // Operations where there is nothing to do - case ComOp: case EndOp: case ParOp: case PriOp: @@ -1717,7 +1869,28 @@ tape[i_var].connect_type = yes_connected; break; - // Load using a parameter index + // Compare operators never get removed ----------------- + case LepvOp: + case LtpvOp: + case EqpvOp: + case NepvOp: + tape[arg[1]].connect_type = yes_connected; + break; + + case LevpOp: + case LtvpOp: + tape[arg[0]].connect_type = yes_connected; + break; + + case LevvOp: + case LtvvOp: + case EqvvOp: + case NevvOp: + tape[arg[0]].connect_type = yes_connected; + tape[arg[1]].connect_type = yes_connected; + break; + + // Load using a parameter index ---------------------- case LdpOp: if( tape[i_var].connect_type != not_connected ) { @@ -1750,7 +1923,7 @@ { tape[arg[1]].connect_type = yes_connected; tape[arg[2]].connect_type = yes_connected; } - break; + break; // ============================================================ case UserOp: // start or end atomic operation sequence @@ -1763,19 +1936,50 @@ user_m = arg[3]; user_q = 1; user_atom = atomic_base::class_object(user_index); + if( user_atom == CPPAD_NULL ) + { std::string msg = + atomic_base::class_name(user_index) + + ": atomic_base function has been deleted"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } + user_pack = user_atom->sparsity() == + atomic_base::pack_sparsity_enum; + user_bool = user_atom->sparsity() == + atomic_base::bool_sparsity_enum; + user_set = user_atom->sparsity() == + atomic_base::set_sparsity_enum; + CPPAD_ASSERT_UNKNOWN( user_pack || user_bool || user_set ); + user_set = user_atom->sparsity() == atomic_base::set_sparsity_enum; // - if(user_s_set.size() != user_n ) - user_s_set.resize(user_n); - if(user_r_set.size() != user_m ) - user_r_set.resize(user_m); - // // Note user_q is 1, but use it for clarity of code - if(user_s_bool.size() != user_n * user_q ) - user_s_bool.resize(user_n * user_q); - if(user_r_bool.size() != user_m * user_q ) - user_r_bool.resize(user_m * user_q); + if( user_pack ) + { if( user_r_pack.size() != user_m * user_q ) + user_r_pack.resize( user_m * user_q ); + if( user_s_pack.size() != user_n * user_q ) + user_s_pack.resize( user_n * user_q ); + for(i = 0; i < user_m; i++) + for(j = 0; j < user_q; j++) + user_r_pack[ i * user_q + j] = false; + } + if( user_bool ) + { if( user_r_bool.size() != user_m * user_q ) + user_r_bool.resize( user_m * user_q ); + if( user_s_bool.size() != user_n * user_q ) + user_s_bool.resize( user_n * user_q ); + for(i = 0; i < user_m; i++) + for(j = 0; j < user_q; j++) + user_r_bool[ i * user_q + j] = false; + } + if( user_set ) + { if(user_s_set.size() != user_n ) + user_s_set.resize(user_n); + if(user_r_set.size() != user_m ) + user_r_set.resize(user_m); + for(i = 0; i < user_m; i++) + user_r_set[i].clear(); + } // user_j = user_n; user_i = user_m; @@ -1785,7 +1989,7 @@ info.connect_type = not_connected; info.op_end = i_op + 1; user_info.push_back(info); - + } else { CPPAD_ASSERT_UNKNOWN( user_state == user_start ); @@ -1822,12 +2026,17 @@ --user_j; if( user_set ) { if( ! user_s_set[user_j].empty() ) - tape[arg[0]].connect_type = + tape[arg[0]].connect_type = user_info[user_curr].connect_type; } - else + if( user_bool ) { if( user_s_bool[user_j] ) - tape[arg[0]].connect_type = + tape[arg[0]].connect_type = + user_info[user_curr].connect_type; + } + if( user_pack ) + { if( user_s_pack[user_j] ) + tape[arg[0]].connect_type = user_info[user_curr].connect_type; } if( user_j == 0 ) @@ -1839,8 +2048,6 @@ CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); --user_i; - user_r_set[user_i].clear(); - user_r_bool[user_i] = false; switch( connect_type ) { case not_connected: break; @@ -1849,25 +2056,32 @@ case sum_connected: case csum_connected: user_info[user_curr].connect_type = yes_connected; - user_r_set[user_i].insert(0); - user_r_bool[user_i] = true; + if( user_set ) + user_r_set[user_i].insert(0); + if( user_bool ) + user_r_bool[user_i] = true; + if( user_pack ) + user_r_pack[user_i] = true; break; case cexp_connected: + CPPAD_ASSERT_UNKNOWN( conditional_skip ); if( user_info[user_curr].connect_type == not_connected ) { user_info[user_curr].connect_type = connect_type; - user_info[user_curr].cexp_set = cexp_set; + user_info[user_curr].cexp_set = *cexp_set; } else if(user_info[user_curr].connect_type==cexp_connected) - { user_info[user_curr].cexp_set = intersection( - user_info[user_curr].cexp_set, cexp_set - ); + { user_info[user_curr].cexp_set.intersection(*cexp_set); if( user_info[user_curr].cexp_set.empty() ) user_info[user_curr].connect_type = yes_connected; } else user_info[user_curr].connect_type = yes_connected; - user_r_set[user_i].insert(0); - user_r_bool[user_i] = true; + if( user_set ) + user_r_set[user_i].insert(0); + if( user_bool ) + user_r_bool[user_i] = true; + if( user_pack ) + user_r_pack[user_i] = true; break; default: @@ -1884,31 +2098,23 @@ CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_i; - user_r_set[user_i].clear(); - user_r_bool[user_i] = false; } if( user_i == 0 ) { // call users function for this operation user_atom->set_id(user_id); -# ifdef NDEBUG - if( user_set ) - { user_atom-> - rev_sparse_jac(user_q, user_r_set, user_s_set); - } - else - { user_atom-> - rev_sparse_jac(user_q, user_r_bool, user_s_bool); - } -# else - bool flag; + bool flag = false; if( user_set ) { flag = user_atom-> rev_sparse_jac(user_q, user_r_set, user_s_set); } - else + if( user_bool ) { flag = user_atom-> rev_sparse_jac(user_q, user_r_bool, user_s_bool); } + if( user_pack ) + { flag = user_atom-> + rev_sparse_jac(user_q, user_r_pack, user_s_pack); + } if( ! flag ) { std::string s = "Optimizing an ADFun object" @@ -1917,13 +2123,15 @@ s += "\nCurrent atomic_sparsity is set to"; // if( user_set ) - s += " std::set\nand std::set"; - else s += " bool\nand bool"; + s += "set_sparsity_enum.\n"; + if( user_bool ) + s += "bool_sparsity_enum.\n"; + if( user_pack ) + s += "pack_sparsity_enum.\n"; // - s += " version of rev_sparse_jac returned false"; + s += "This version of rev_sparse_jac returned false"; CPPAD_ASSERT_KNOWN(false, s.c_str() ); } -# endif user_state = user_arg; } break; @@ -1936,35 +2144,38 @@ } // values corresponding to BeginOp CPPAD_ASSERT_UNKNOWN( i_op == 0 && i_var == 0 && op == BeginOp ); - tape[i_var].op = op; + tape[i_var].op = op; + tape[i_var].connect_type = yes_connected; // ------------------------------------------------------------- // Determine which variables can be conditionally skipped for(i = 0; i < num_var; i++) - { if( tape[i].connect_type == cexp_connected ) - { std::set::const_iterator itr = - tape[i].cexp_set.begin(); - while( itr != tape[i].cexp_set.end() ) - { j = itr->index_; - if( itr->compare_ == true ) + { if( tape[i].connect_type == cexp_connected && + ! cexp_vec_set[i].empty() ) + { std::set::const_iterator itr = + cexp_vec_set[i].begin(); + while( itr != cexp_vec_set[i].end() ) + { j = itr->index(); + if( itr->compare() == true ) cskip_info[j].skip_var_false.push_back(i); else cskip_info[j].skip_var_true.push_back(i); itr++; } } } - // Determine size of skip information in user_info + // Determine size of skip information in user_info for(i = 0; i < user_info.size(); i++) - { if( user_info[i].connect_type == cexp_connected ) - { std::set::const_iterator itr = + { if( user_info[i].connect_type == cexp_connected && + ! user_info[i].cexp_set.empty() ) + { std::set::const_iterator itr = user_info[i].cexp_set.begin(); while( itr != user_info[i].cexp_set.end() ) - { j = itr->index_; - if( itr->compare_ == true ) - cskip_info[j].n_op_false = + { j = itr->index(); + if( itr->compare() == true ) + cskip_info[j].n_op_false = user_info[i].op_end - user_info[i].op_begin; else - cskip_info[j].n_op_true = + cskip_info[j].n_op_true = user_info[i].op_end - user_info[i].op_begin; itr++; } @@ -1992,7 +2203,7 @@ hash_table_var[i] = 0; CPPAD_ASSERT_UNKNOWN( tape[0].op == BeginOp ); - // initialize mapping from old variable index to new + // initialize mapping from old variable index to new // operator and variable index for(i = 0; i < num_var; i++) { tape[i].new_op = 0; // invalid index (except for BeginOp) @@ -2005,7 +2216,7 @@ // initialize mapping from old VecAD index to new VecAD index CppAD::vector new_vecad_ind(num_vecad_ind); for(i = 0; i < num_vecad_ind; i++) - new_vecad_ind[i] = num_vecad_ind; // invalid index + new_vecad_ind[i] = num_vecad_ind; // invalid index j = 0; // index into the old set of indices for(i = 0; i < num_vecad_vec; i++) @@ -2018,7 +2229,7 @@ for(k = 1; k <= length; k++) new_vecad_ind[j+k] = rec->PutVecInd( rec->PutPar( - play->GetPar( + play->GetPar( play->GetVecInd(j+k) ) ) ); } @@ -2077,8 +2288,8 @@ skip &= n_true > 0 || n_false > 0; if( skip ) { CPPAD_ASSERT_UNKNOWN( NumRes(CSkipOp) == 0 ); - size_t n_arg = 7 + n_true + n_false; - // reserve space for the arguments to this operator but + size_t n_arg = 7 + n_true + n_false; + // reserve space for the arguments to this operator but // delay setting them until we have all the new addresses cskip_info[j].i_arg = rec->ReserveArg(n_arg); CPPAD_ASSERT_UNKNOWN( cskip_info[j].i_arg > 0 ); @@ -2090,7 +2301,20 @@ // operation sequence bool keep; switch( op ) - { case ComOp: + { // see wish_list/Optimize/CompareChange entry. + case EqpvOp: + case EqvvOp: + case LepvOp: + case LevpOp: + case LevvOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case NepvOp: + case NevvOp: + keep = true; + break; + case PriOp: keep = false; break; @@ -2116,7 +2340,7 @@ case SubvvOp: keep = tape[i_var].connect_type != not_connected; keep &= tape[i_var].connect_type != csum_connected; - break; + break; case UserOp: case UsrapOp: @@ -2140,12 +2364,18 @@ // Unary operator where operand is arg[0] case AbsOp: case AcosOp: + case AcoshOp: case AsinOp: + case AsinhOp: case AtanOp: + case AtanhOp: case CosOp: case CoshOp: + case ErfOp: case ExpOp: + case Expm1Op: case LogOp: + case Log1pOp: case SignOp: case SinOp: case SinhOp: @@ -2153,7 +2383,7 @@ case TanOp: case TanhOp: match_var = unary_match( - tape , // inputs + tape , // inputs i_var , play->num_par_rec() , play->GetPar() , @@ -2173,27 +2403,20 @@ tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = i = rec->PutOp(op); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < i ); + if( op == ErfOp ) + { // Error function is a special case + // second argument is always the parameter 0 + // third argument is always the parameter 2 / sqrt(pi) + CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); + rec->PutArg( rec->PutPar( Base(0) ) ); + rec->PutArg( rec->PutPar( + Base( 1.0 / std::sqrt( std::atan(1.0) ) ) + ) ); + } } break; - - case ErfOp: - // 20150000 version does not optimzie this out - // next years version does. - { CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); - // second argument is always parameter 0 - // third argument is always parameter 2 / sqrt(pi) - tape[i_var].new_op = rec->num_op_rec(); - tape[i_var].new_var = rec->PutOp(op); - rec->PutArg( tape[ arg[0] ].new_var ); - rec->PutArg( rec->PutPar( Base(0) ) ); - rec->PutArg( rec->PutPar( - Base( 1.0 / std::sqrt( std::atan(1.0) ) ) - ) ); - } - break; - // --------------------------------------------------- - // Binary operators where + // Binary operators where // left is a variable and right is a parameter case SubvpOp: if( tape[arg[0]].connect_type == csum_connected ) @@ -2214,8 +2437,9 @@ } case DivvpOp: case PowvpOp: + case ZmulvpOp: match_var = binary_match( - tape , // inputs + tape , // inputs i_var , play->num_par_rec() , play->GetPar() , @@ -2243,11 +2467,11 @@ } break; // --------------------------------------------------- - // Binary operators where + // Binary operators where // left is an index and right is a variable case DisOp: match_var = binary_match( - tape , // inputs + tape , // inputs i_var , play->num_par_rec() , play->GetPar() , @@ -2262,10 +2486,10 @@ else { new_arg[0] = arg[0]; new_arg[1] = tape[ arg[1] ].new_var; - rec->PutArg( new_arg[0], new_arg[1] ); + rec->PutArg( new_arg[0], new_arg[1] ); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(op); - CPPAD_ASSERT_UNKNOWN( + CPPAD_ASSERT_UNKNOWN( new_arg[1] < tape[i_var].new_var ); replace_hash = true; @@ -2273,7 +2497,7 @@ break; // --------------------------------------------------- - // Binary operators where + // Binary operators where // left is a parameter and right is a variable case SubpvOp: case AddpvOp: @@ -2296,8 +2520,9 @@ case DivpvOp: case MulpvOp: case PowpvOp: + case ZmulpvOp: match_var = binary_match( - tape , // inputs + tape , // inputs i_var , play->num_par_rec() , play->GetPar() , @@ -2325,7 +2550,7 @@ } break; // --------------------------------------------------- - // Binary operator where + // Binary operator where // both operators are variables case AddvvOp: case SubvvOp: @@ -2350,8 +2575,9 @@ case DivvvOp: case MulvvOp: case PowvvOp: + case ZmulvvOp: match_var = binary_match( - tape , // inputs + tape , // inputs i_var , play->num_par_rec() , play->GetPar() , @@ -2388,11 +2614,11 @@ for(i = 2; i < 6; i++) { if( arg[1] & mask ) { new_arg[i] = tape[arg[i]].new_var; - CPPAD_ASSERT_UNKNOWN( - size_t(new_arg[i]) < num_var + CPPAD_ASSERT_UNKNOWN( + size_t(new_arg[i]) < num_var ); } - else new_arg[i] = rec->PutPar( + else new_arg[i] = rec->PutPar( play->GetPar( arg[i] ) ); mask = mask << 1; @@ -2403,12 +2629,12 @@ new_arg[2] , new_arg[3] , new_arg[4] , - new_arg[5] + new_arg[5] ); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(op); // - // The new addresses for left and right are used during + // The new addresses for left and right are used during // fill in the arguments for the CSkip operations. This does not // affect max_left_right which is used during this sweep. CPPAD_ASSERT_UNKNOWN( cskip_info_index > 0 ); @@ -2423,13 +2649,46 @@ rec->PutOp(op); break; // --------------------------------------------------- + // Operations with two arguments and no results + case LepvOp: + case LtpvOp: + case EqpvOp: + case NepvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + new_arg[0] = rec->PutPar( play->GetPar(arg[0]) ); + new_arg[1] = tape[arg[1]].new_var; + rec->PutArg(new_arg[0], new_arg[1]); + rec->PutOp(op); + break; + // + case LevpOp: + case LtvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + new_arg[0] = tape[arg[0]].new_var; + new_arg[1] = rec->PutPar( play->GetPar(arg[1]) ); + rec->PutArg(new_arg[0], new_arg[1]); + rec->PutOp(op); + break; + // + case LevvOp: + case LtvvOp: + case EqvvOp: + case NevvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + new_arg[0] = tape[arg[0]].new_var; + new_arg[1] = tape[arg[1]].new_var; + rec->PutArg(new_arg[0], new_arg[1]); + rec->PutOp(op); + break; + + // --------------------------------------------------- // Operations with no arguments and one result case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(op); break; - // --------------------------------------------------- + // --------------------------------------------------- // Operations with one argument that is a parameter case ParOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); @@ -2447,9 +2706,9 @@ new_arg[1] = arg[1]; new_arg[2] = rec->num_load_op_rec(); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); - rec->PutArg( - new_arg[0], - new_arg[1], + rec->PutArg( + new_arg[0], + new_arg[1], new_arg[2] ); tape[i_var].new_op = rec->num_op_rec(); @@ -2464,9 +2723,9 @@ new_arg[2] = rec->num_load_op_rec(); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[1]) < num_var ); - rec->PutArg( - new_arg[0], - new_arg[1], + rec->PutArg( + new_arg[0], + new_arg[1], new_arg[2] ); tape[i_var].new_var = rec->num_op_rec(); @@ -2481,8 +2740,8 @@ new_arg[2] = rec->PutPar( play->GetPar(arg[2]) ); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); rec->PutArg( - new_arg[0], - new_arg[1], + new_arg[0], + new_arg[1], new_arg[2] ); rec->PutOp(op); @@ -2497,8 +2756,8 @@ CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[1]) < num_var ); rec->PutArg( - new_arg[0], - new_arg[1], + new_arg[0], + new_arg[1], new_arg[2] ); rec->PutOp(op); @@ -2514,8 +2773,8 @@ CPPAD_ASSERT_UNKNOWN( size_t(new_arg[1]) < num_var ); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[2]) < num_var ); rec->PutArg( - new_arg[0], - new_arg[1], + new_arg[0], + new_arg[1], new_arg[2] ); rec->PutOp(op); @@ -2531,8 +2790,8 @@ CPPAD_ASSERT_UNKNOWN( size_t(new_arg[1]) < num_var ); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[2]) < num_var ); rec->PutArg( - new_arg[0], - new_arg[1], + new_arg[0], + new_arg[1], new_arg[2] ); rec->PutOp(op); @@ -2578,7 +2837,7 @@ else { // This argument does not affect the result and // has been optimized out so use nan in its place. - new_arg[0] = rec->PutPar( nan(Base(0)) ); + new_arg[0] = rec->PutPar( base_nan ); rec->PutArg(new_arg[0]); rec->PutOp(UsrapOp); } @@ -2593,7 +2852,7 @@ rec->PutOp(UsrrpOp); } break; - + case UsrrvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); if( user_info[user_curr].connect_type != not_connected ) @@ -2609,7 +2868,7 @@ } if( replace_hash ) - { // The old variable index i_var corresponds to the + { // The old variable index i_var corresponds to the // new variable index tape[i_var].new_var. In addition // this is the most recent variable that has this code. hash_table_var[code] = i_var; @@ -2630,14 +2889,15 @@ // Move skip information from user_info to cskip_info for(i = 0; i < user_info.size(); i++) - { if( user_info[i].connect_type == cexp_connected ) + { if( user_info[i].connect_type == cexp_connected && + ! user_info[i].cexp_set.empty() ) { std::set::const_iterator itr = user_info[i].cexp_set.begin(); while( itr != user_info[i].cexp_set.end() ) - { j = itr->index_; + { j = itr->index(); k = user_info[i].op_begin; while(k < user_info[i].op_end) - { if( itr->compare_ == true ) + { if( itr->compare() == true ) cskip_info[j].skip_op_false.push_back(k++); else cskip_info[j].skip_op_true.push_back(k++); } @@ -2653,9 +2913,9 @@ if( info.i_arg > 0 ) { CPPAD_ASSERT_UNKNOWN( info.n_op_true==info.skip_op_true.size() ); CPPAD_ASSERT_UNKNOWN(info.n_op_false==info.skip_op_false.size()); - size_t n_true = + size_t n_true = info.skip_var_true.size() + info.skip_op_true.size(); - size_t n_false = + size_t n_false = info.skip_var_false.size() + info.skip_op_false.size(); size_t i_arg = info.i_arg; rec->ReplaceArg(i_arg++, info.cop ); @@ -2667,36 +2927,38 @@ for(j = 0; j < info.skip_var_true.size(); j++) { i_var = info.skip_var_true[j]; if( tape[i_var].match ) - { // the operation for this argument has been removed + { // The operation for this argument has been removed, + // so use an operator index that never comes up. rec->ReplaceArg(i_arg++, rec->num_op_rec()); } else { CPPAD_ASSERT_UNKNOWN( tape[i_var].new_op > 0 ); rec->ReplaceArg(i_arg++, tape[i_var].new_op ); } - } + } for(j = 0; j < info.skip_op_true.size(); j++) { i_op = info.skip_op_true[j]; rec->ReplaceArg(i_arg++, i_op); - } + } for(j = 0; j < info.skip_var_false.size(); j++) { i_var = info.skip_var_false[j]; if( tape[i_var].match ) - { // the operation for this argument has been removed + { // The operation for this argument has been removed, + // so use an operator index that never comes up. rec->ReplaceArg(i_arg++, rec->num_op_rec()); } else { CPPAD_ASSERT_UNKNOWN( tape[i_var].new_op > 0 ); rec->ReplaceArg(i_arg++, tape[i_var].new_op ); } - } + } for(j = 0; j < info.skip_op_false.size(); j++) { i_op = info.skip_op_false[j]; rec->ReplaceArg(i_arg++, i_op); - } + } rec->ReplaceArg(i_arg++, n_true + n_false); # ifndef NDEBUG - size_t n_arg = 7 + n_true + n_false; + size_t n_arg = 7 + n_true + n_false; CPPAD_ASSERT_UNKNOWN( info.i_arg + n_arg == i_arg ); # endif } @@ -2713,12 +2975,17 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. +\param options +The default value for this option is the empty string. +The only other possible value is "no_conditional_skip". +If this option is present, no conditional skip operators will be generated. + */ template -void ADFun::optimize(void) +void ADFun::optimize(const std::string& options) { // place to store the optimized version of the recording recorder rec; @@ -2752,7 +3019,7 @@ # endif // create the optimized recording - CppAD::optimize::optimize_run(n, dep_taddr_, &play_, &rec); + CppAD::optimize::optimize_run(options, n, dep_taddr_, &play_, &rec); // number of variables in the recording num_var_tape_ = rec.num_var_rec(); @@ -2760,6 +3027,9 @@ // now replace the recording play_.get(rec); + // set flag so this function knows it has been optimized + has_been_optimized_ = true; + // free memory allocated for sparse Jacobian calculation // (the results are no longer valid) for_jac_sparse_pack_.resize(0, 0); @@ -2782,13 +3052,13 @@ check = Forward(0, x); // check results - Base eps = 10. * epsilon(); - for(i = 0; i < m; i++) CPPAD_ASSERT_KNOWN( + Base eps = 10. * CppAD::numeric_limits::epsilon(); + for(i = 0; i < m; i++) CPPAD_ASSERT_KNOWN( abs_geq( eps * max_taylor , check[i] - y[i] ) , "Error during check of f.optimize()." ); - // Erase memory that this calculation was done so NDEBUG gives + // Erase memory that this calculation was done so NDEBUG gives // same final state for this object (from users perspective) num_order_taylor_ = 0; } diff -Nru cppad-2015.00.00.9/cppad/local/opt_val_hes.hpp cppad-2016.00.00.1/cppad/local/opt_val_hes.hpp --- cppad-2015.00.00.9/cppad/local/opt_val_hes.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/opt_val_hes.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: opt_val_hes.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_OPT_VAL_HES_INCLUDED -# define CPPAD_OPT_VAL_HES_INCLUDED +// $Id: opt_val_hes.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_OPT_VAL_HES_HPP +# define CPPAD_OPT_VAL_HES_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,16 +27,12 @@ $$ -$index Jacobian$$ -$index Hessian$$ -$index optimal value$$ -$index value$$ -$index opt_val_hes$$ $section Jacobian and Hessian of Optimal Values$$ +$mindex opt_val_hes$$ $head Syntax$$ -$icode%signdet% = opt_val_hes(%x%, %y%, %fun%, %jac%, %hes%)%$$ +$icode%signdet% = opt_val_hes(%x%, %y%, %fun%, %jac%, %hes%)%$$ $head See Also$$ $cref BenderQuad$$ @@ -47,26 +43,26 @@ 2008, Springer. $head Purpose$$ -We are given a function +We are given a function $latex S : \B{R}^n \times \B{R}^m \rightarrow \B{R}^\ell$$ and we define $latex F : \B{R}^n \times \B{R}^m \rightarrow \B{R}$$ and $latex V : \B{R}^n \rightarrow \B{R} $$ by $latex \[ \begin{array}{rcl} - F(x, y) & = & \sum_{k=0}^{\ell-1} S_k ( x , y) + F(x, y) & = & \sum_{k=0}^{\ell-1} S_k ( x , y) \\ - V(x) & = & F [ x , Y(x) ] + V(x) & = & F [ x , Y(x) ] \\ 0 & = & \partial_y F [x , Y(x) ] \end{array} \] $$ -We wish to compute the Jacobian +We wish to compute the Jacobian and possibly also the Hessian, of $latex V (x)$$. $head BaseVector$$ -The type $icode BaseVector$$ must be a -$cref SimpleVector$$ class. -We use $icode Base$$ to refer to the type of the elements of +The type $icode BaseVector$$ must be a +$cref SimpleVector$$ class. +We use $icode Base$$ to refer to the type of the elements of $icode BaseVector$$; i.e., $codei% %BaseVector%::value_type @@ -78,7 +74,7 @@ const %BaseVector%& %x% %$$ and its size must be equal to $icode n$$. -It specifies the point at which we evaluating +It specifies the point at which we evaluating the Jacobian $latex V^{(1)} (x)$$ (and possibly the Hessian $latex V^{(2)} (x)$$). @@ -89,14 +85,14 @@ const %BaseVector%& %y% %$$ and its size must be equal to $icode m$$. -It must be equal to $latex Y(x)$$; i.e., +It must be equal to $latex Y(x)$$; i.e., it must solve the implicit equation $latex \[ - 0 = \partial_y F ( x , y) + 0 = \partial_y F ( x , y) \] $$ $head Fun$$ -The argument $icode fun$$ is an object of type $icode Fun$$ +The argument $icode fun$$ is an object of type $icode Fun$$ which must support the member functions listed below. CppAD will may be recording operations of the type $codei%AD<%Base%>%$$ when these member functions are called. @@ -104,7 +100,7 @@ they must not call $cref/AD::abort_recording/abort_recording/$$. $subhead Fun::ad_vector$$ -The type $icode%Fun%::ad_vector%$$ must be a +The type $icode%Fun%::ad_vector%$$ must be a $cref SimpleVector$$ class with elements of type $codei%AD<%Base%>%$$; i.e. $codei% %Fun%::ad_vector::value_type @@ -125,9 +121,9 @@ $pre $$ -One can choose $icode ell$$ equal to one, and have +One can choose $icode ell$$ equal to one, and have $latex S(x,y)$$ the same as $latex F(x, y)$$. -Each of the functions $latex S_k (x , y)$$, +Each of the functions $latex S_k (x , y)$$, (in the summation defining $latex F(x, y)$$) is differentiated separately using AD. For very large problems, breaking $latex F(x, y)$$ into the sum @@ -195,7 +191,7 @@ The input values of its elements do not matter. If it has size zero, it is not affected. Otherwise, on output it contains the Jacobian of $latex V (x)$$; i.e., -for $latex j = 0 , \ldots , n-1$$, +for $latex j = 0 , \ldots , n-1$$, $latex \[ jac[ j ] = V^{(1)} (x)_j \] $$ @@ -211,7 +207,7 @@ If it has size zero, it is not affected. Otherwise, on output it contains the Hessian of $latex V (x)$$; i.e., for $latex i = 0 , \ldots , n-1$$, and -$latex j = 0 , \ldots , n-1$$, +$latex j = 0 , \ldots , n-1$$, $latex \[ hes[ i * n + j ] = V^{(2)} (x)_{i,j} \] $$ @@ -222,7 +218,7 @@ Otherwise the return value $icode signdet$$ is the sign of the determinant for $latex \partial_{yy}^2 F(x , y) $$. -If it is zero, then the matrix is singular and +If it is zero, then the matrix is singular and the Hessian is not computed ($icode hes$$ is not changed). $head Example$$ @@ -231,7 +227,7 @@ %$$ The file $cref opt_val_hes.cpp$$ -contains an example and test of this operation. +contains an example and test of this operation. It returns true if it succeeds and false otherwise. $end @@ -247,41 +243,41 @@ /*! Computing Jabobians and Hessians of Optimal Values -We are given a function +We are given a function \f$ S : {\rm R}^n \times {\rm R}^m \rightarrow {\rm R}^\ell \f$ -and we define \f$ F : {\rm R}^n \times {\rm R}^m \rightarrow {\rm R} \f$ +and we define \f$ F : {\rm R}^n \times {\rm R}^m \rightarrow {\rm R} \f$ and \f$ V : {\rm R}^n \rightarrow {\rm R} \f$ by \f[ \begin{array}{rcl} - F(x, y) & = & \sum_{k=0}^{\ell-1} S_k ( x , y) + F(x, y) & = & \sum_{k=0}^{\ell-1} S_k ( x , y) \\ - V(x) & = & F [ x , Y(x) ] + V(x) & = & F [ x , Y(x) ] \\ 0 & = & \partial_y F [x , Y(x) ] \end{array} \f] -We wish to compute the Jacobian +We wish to compute the Jacobian and possibly also the Hessian, of \f$ V (x) \f$. \tparam BaseVector -The type \c BaseVector must be a SimpleVector class. -We use \c Base to refer to the type of the elements of +The type \c BaseVector must be a SimpleVector class. +We use \c Base to refer to the type of the elements of \c BaseVector; i.e., BaseVector::value_type. \param x is a vector with size \c n. -It specifies the point at which we evaluating +It specifies the point at which we evaluating the Jacobian \f$ V^{(1)} (x) \f$ (and possibly the Hessian \f$ V^{(2)} (x) \f$). \param y is a vector with size \c m. -It must be equal to \f$ Y(x) \f$; i.e., +It must be equal to \f$ Y(x) \f$; i.e., it must solve the implicit equation \f[ - 0 = \partial_y F ( x , y) + 0 = \partial_y F ( x , y) \f] \param fun @@ -293,7 +289,7 @@ they must not call \c AD::abort_recording. \par Fun::ad_vector -The type Fun::ad_vector must be a +The type Fun::ad_vector must be a SimpleVector class with elements of type \c AD; i.e. Fun::ad_vector::value_type is equal to \c AD. @@ -338,7 +334,7 @@ The input values of its elements do not matter. If it has size zero, it is not affected. Otherwise, on output it contains the Jacobian of \f$ V (x) \f$; i.e., -for \f$ j = 0 , \ldots , n-1 \f$, +for \f$ j = 0 , \ldots , n-1 \f$, \f[ jac[ j ] = V^{(1)} (x)_j \f] $$ @@ -350,7 +346,7 @@ If it has size zero, it is not affected. Otherwise, on output it contains the Hessian of \f$ V (x) \f$; i.e., for \f$ i = 0 , \ldots , n-1 \f$, and -\f$ j = 0 , \ldots , n-1 \f$, +\f$ j = 0 , \ldots , n-1 \f$, \f[ hes[ i * n + j ] = V^{(2)} (x)_{i,j} \f] @@ -367,9 +363,9 @@ template int opt_val_hes( - const BaseVector& x , - const BaseVector& y , - Fun fun , + const BaseVector& x , + const BaseVector& y , + Fun fun , BaseVector& jac , BaseVector& hes ) { // determine the base type @@ -410,14 +406,14 @@ // ADFun version of S_k(x, y) ADFun S_k; - // AD version of x + // AD version of x ad_vector a_x(n); // AD version of y ad_vector a_y(n); if( jac.size() > 0 ) - { // this is the easy part, computing the V^{(1)} (x) which is equal + { // this is the easy part, computing the V^{(1)} (x) which is equal // to \partial_x F (x, y) (see Thoerem 2 of the reference). // copy x and y to AD version @@ -442,7 +438,7 @@ BaseVector jac_k = S_k.Jacobian(x); // add \partial_x S_k (x, y) to jac for(j = 0; j < n; j++) - jac[j] += jac_k[j]; + jac[j] += jac_k[j]; } } // check if we are done @@ -454,22 +450,22 @@ reference: Y^{(1)}(x) = - F_yy (x, y)^{-1} F_yx (x, y) Using Theorem 2 of the reference: - V^{(2)}(x) = F_xx (x, y) + F_xy (x, y) Y^{(1)}(x) + V^{(2)}(x) = F_xx (x, y) + F_xy (x, y) Y^{(1)}(x) */ // Base and AD version of xy BaseVector xy(n + m); ad_vector a_xy(n + m); for(j = 0; j < n; j++) - a_xy[j] = xy[j] = x[j]; + a_xy[j] = xy[j] = x[j]; for(j = 0; j < m; j++) - a_xy[n+j] = xy[n+j] = y[j]; + a_xy[n+j] = xy[n+j] = y[j]; // Initialization summation for Hessian of F size_t nm_sq = (n + m) * (n + m); BaseVector F_hes(nm_sq); for(j = 0; j < nm_sq; j++) F_hes[j] = Base(0.); - BaseVector hes_k(nm_sq); + BaseVector hes_k(nm_sq); // add in Hessian of S_k to hes for(k = 0; k < ell; k++) @@ -487,24 +483,24 @@ S_k.Dependent(a_xy, s_k); // when computing the Hessian it pays to optimize the tape S_k.optimize(); - // compute Hessian of S_k + // compute Hessian of S_k hes_k = S_k.Hessian(xy, 0); // add \partial_x S_k (x, y) to jac for(j = 0; j < nm_sq; j++) - F_hes[j] += hes_k[j]; + F_hes[j] += hes_k[j]; } // Extract F_yx BaseVector F_yx(m * n); for(i = 0; i < m; i++) { for(j = 0; j < n; j++) F_yx[i * n + j] = F_hes[ (i+n)*(n+m) + j ]; - } + } // Extract F_yy BaseVector F_yy(n * m); for(i = 0; i < m; i++) { for(j = 0; j < m; j++) F_yy[i * m + j] = F_hes[ (i+n)*(n+m) + j + n ]; - } + } // compute - Y^{(1)}(x) = F_yy (x, y)^{-1} F_yx (x, y) BaseVector neg_Y_x(m * n); @@ -513,7 +509,7 @@ if( signdet == 0 ) return signdet; - // compute hes = F_xx (x, y) + F_xy (x, y) Y^{(1)}(x) + // compute hes = F_xx (x, y) + F_xy (x, y) Y^{(1)}(x) for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { hes[i * n + j] = F_hes[ i*(n+m) + j ]; diff -Nru cppad-2015.00.00.9/cppad/local/ordered.hpp cppad-2016.00.00.1/cppad/local/ordered.hpp --- cppad-2015.00.00.9/cppad/local/ordered.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/ordered.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ordered.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_ORDERED_INCLUDED -# define CPPAD_ORDERED_INCLUDED +// $Id: ordered.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ORDERED_HPP +# define CPPAD_ORDERED_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -89,7 +89,7 @@ value we are checking if it is less than other. \return -returns true iff the absolute value of \c x is greater than or equal +returns true iff the absolute value of \c x is greater than or equal absolute value of \c y. */ template diff -Nru cppad-2015.00.00.9/cppad/local/parallel_ad.hpp cppad-2016.00.00.1/cppad/local/parallel_ad.hpp --- cppad-2015.00.00.9/cppad/local/parallel_ad.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/parallel_ad.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: parallel_ad.hpp 3619 2015-01-28 14:11:13Z bradbell $ */ -# ifndef CPPAD_PARALLEL_AD_INCLUDED -# define CPPAD_PARALLEL_AD_INCLUDED +// $Id: parallel_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_PARALLEL_AD_HPP +# define CPPAD_PARALLEL_AD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -29,18 +29,18 @@ $codei%parallel_ad<%Base%>()%$$ must be called before any $codei%AD<%Base>%$$ objects are used in $cref/parallel/ta_in_parallel/$$ mode. -In addition, if this routine is called after one is done using -parallel mode, it will free extra memory used to keep track of +In addition, if this routine is called after one is done using +parallel mode, it will free extra memory used to keep track of the multiple $codei%AD<%Base%>%$$ tapes required for parallel execution. $head Discussion$$ -By default, for each $codei%AD<%Base%>%$$ class there is only one +By default, for each $codei%AD<%Base%>%$$ class there is only one tape that records $cref/AD of Base/glossary/AD of Base/$$ operations. This tape is a global variable and hence it cannot be used -by multiple threads at the same time. +by multiple threads at the same time. The $cref/parallel_setup/ta_parallel_setup/$$ function informs CppAD of the maximum number of threads that can be active in parallel mode. -This routine does extra setup +This routine does extra setup (and teardown) for the particular $icode Base$$ type. $head CheckSimpleVector$$ @@ -51,11 +51,11 @@ where $icode Type$$ is $icode Base$$ and $codei%AD<%Base%>%$$. $head Example$$ -The files -$cref team_openmp.cpp$$, +The files +$cref team_openmp.cpp$$, $cref team_bthread.cpp$$, and -$cref team_pthread.cpp$$, -contain examples and tests that implement this function. +$cref team_pthread.cpp$$, +contain examples and tests that implement this function. $head Restriction$$ This routine cannot be called in parallel mode or while @@ -71,13 +71,13 @@ namespace CppAD { /*! -Enable parallel execution mode with AD by initializing +Enable parallel execution mode with AD by initializing static variables that my be used. */ template void parallel_ad(void) -{ CPPAD_ASSERT_KNOWN( +{ CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "parallel_ad must be called before entering parallel execution mode." ); @@ -105,7 +105,7 @@ // statics that depend on the value of Base AD::tape_id_handle(0); - AD::tape_handle(0); + AD::tape_handle(0); AD::tape_manage(tape_manage_clear); discrete::List(); CheckSimpleVector< Base, CppAD::vector >(); diff -Nru cppad-2015.00.00.9/cppad/local/parameter_op.hpp cppad-2016.00.00.1/cppad/local/parameter_op.hpp --- cppad-2015.00.00.9/cppad/local/parameter_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/parameter_op.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: parameter_op.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_PARAMETER_OP_INCLUDED -# define CPPAD_PARAMETER_OP_INCLUDED +// $Id: parameter_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_PARAMETER_OP_HPP +# define CPPAD_PARAMETER_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -33,13 +33,13 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param i_z -variable index corresponding to the result for this operation; +variable index corresponding to the result for this operation; i.e. the row index in \a taylor corresponding to the component of y -that is a parameter. +that is a parameter. \param arg \a arg[0] @@ -51,19 +51,19 @@ \param parameter \b Input: \a parameter[ \a arg[0] ] is the value of a component -of y that is a parameter. +of y that is a parameter. \param cap_order number of colums in the matrix containing all the Taylor coefficients. \param taylor -\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] -is the zero order Taylor coefficient corresponding to z. +\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. \par Checked Assertions where op is the unary operator with one result: \li NumArg(op) == 1 \li NumRes(op) == 1 -\li \a size_t(arg[0]) < num_par +\li \a size_t(arg[0]) < num_par \li \a 0 < \a cap_order */ template @@ -72,9 +72,9 @@ const addr_t* arg , size_t num_par , const Base* parameter , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ParOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(ParOp) == 1 ); diff -Nru cppad-2015.00.00.9/cppad/local/par_var.hpp cppad-2016.00.00.1/cppad/local/par_var.hpp --- cppad-2015.00.00.9/cppad/local/par_var.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/par_var.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: par_var.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_PAR_VAR_INCLUDED -# define CPPAD_PAR_VAR_INCLUDED +// $Id: par_var.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_PAR_VAR_HPP +# define CPPAD_PAR_VAR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,8 +22,6 @@ bool $$ -$index Parameter$$ -$index Variable$$ $section Is an AD Object a Parameter or Variable$$ $head Syntax$$ @@ -34,9 +32,9 @@ $head Purpose$$ -Determine if $icode x$$ is a -$cref/parameter/glossary/Parameter/$$ or -$cref/variable/glossary/Variable/$$. +Determine if $icode x$$ is a +$cref/parameter/glossary/Parameter/$$ or +$cref/variable/glossary/Variable/$$. $head x$$ The argument $icode x$$ has prototype @@ -84,7 +82,7 @@ { if( x.tape_id_ == 0 ) return true; size_t thread = size_t(x.tape_id_ % CPPAD_MAX_NUM_THREADS); - return x.tape_id_ != *AD::tape_id_ptr(thread); + return x.tape_id_ != *AD::tape_id_ptr(thread); } template @@ -93,7 +91,7 @@ { if( x.tape_id_ == 0 ) return true; size_t thread = size_t(x.tape_id_ % CPPAD_MAX_NUM_THREADS); - return x.tape_id_ != *AD::tape_id_ptr(thread); + return x.tape_id_ != *AD::tape_id_ptr(thread); } // Variable @@ -103,7 +101,7 @@ { if( x.tape_id_ == 0 ) return false; size_t thread = size_t(x.tape_id_ % CPPAD_MAX_NUM_THREADS); - return x.tape_id_ == *AD::tape_id_ptr(thread); + return x.tape_id_ == *AD::tape_id_ptr(thread); } template @@ -112,9 +110,9 @@ { if( x.tape_id_ == 0 ) return false; size_t thread = size_t(x.tape_id_ % CPPAD_MAX_NUM_THREADS); - return x.tape_id_ == *AD::tape_id_ptr(thread); + return x.tape_id_ == *AD::tape_id_ptr(thread); } -} +} // END CppAD namespace diff -Nru cppad-2015.00.00.9/cppad/local/player.hpp cppad-2016.00.00.1/cppad/local/player.hpp --- cppad-2015.00.00.9/cppad/local/player.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/player.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: player.hpp 3372 2014-09-28 18:42:37Z bradbell $ */ -# ifndef CPPAD_PLAYER_INCLUDED -# define CPPAD_PLAYER_INCLUDED +// $Id: player.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_PLAYER_HPP +# define CPPAD_PLAYER_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -61,7 +61,7 @@ // --------------- Functions used to create and maniplate a recording ------- public: /// Default constructor - player(void) : + player(void) : num_var_rec_(0) , num_load_op_rec_(0) , op_rec_( std::numeric_limits::max() ) , @@ -76,21 +76,21 @@ { } // =============================================================== - /*! - Moving an operation sequence from a recorder to a player - + /*! + Moving an operation sequence from a recorder to a player + \param rec - the object that was used to record the operation sequence. After this + the object that was used to record the operation sequence. After this operation, the state of the recording is no longer defined. For example, the \c pod_vector member variables in \c this have been swapped with \c rec . - */ + */ void get(recorder& rec) { size_t i; // just set size_t values num_var_rec_ = rec.num_var_rec_; - num_load_op_rec_ = rec.num_load_op_rec_; + num_load_op_rec_ = rec.num_load_op_rec_; // op_rec_ op_rec_.swap(rec.op_rec_); @@ -117,14 +117,14 @@ CPPAD_ASSERT_UNKNOWN( i == vecad_ind_rec_.size() ); } // =============================================================== - /*! - Copying an operation sequence from one player to another - + /*! + Copying an operation sequence from one player to another + \param play the object that contains the operatoion sequence to copy. - */ + */ void operator=(const player& play) - { + { num_var_rec_ = play.num_var_rec_; num_load_op_rec_ = play.num_load_op_rec_; op_rec_ = play.op_rec_; @@ -138,7 +138,7 @@ /// Erase all information in an operation sequence player. void Erase(void) - { + { num_var_rec_ = 0; num_load_op_rec_ = 0; num_vecad_vec_rec_ = 0; @@ -151,11 +151,11 @@ } public: - /*! - \brief + /*! + \brief Old method of fetching an operator from the recording. - \return + \return the i-th operator in the recording. \param i @@ -164,11 +164,11 @@ OpCode GetOp (size_t i) const { return OpCode(op_rec_[i]); } - /*! - \brief + /*! + \brief Fetch a VecAD index from the recording. - \return + \return the i-th VecAD index in the recording. \param i @@ -177,11 +177,11 @@ size_t GetVecInd (size_t i) const { return vecad_ind_rec_[i]; } - /*! - \brief + /*! + \brief Fetch a parameter from the recording. - \return + \return the i-th parameter in the recording. \param i @@ -190,26 +190,26 @@ Base GetPar(size_t i) const { return par_rec_[i]; } - /*! - \brief + /*! + \brief Fetch entire parameter vector from the recording. - \return + \return the entire parameter vector. */ const Base* GetPar(void) const { return par_rec_.data(); } - /*! - \brief + /*! + \brief Fetch a '\\0' terminated string from the recording. - \return + \return the beginning of the string. \param i - the index where the string begins. + the index where the string begins. */ const char *GetTxt(size_t i) const { CPPAD_ASSERT_UNKNOWN(i < text_rec_.size() ); @@ -249,9 +249,9 @@ { return text_rec_.size(); } /// Fetch a rough measure of amount of memory used to store recording - /// (just lengths, not capacities). + /// (just lengths, not capacities). size_t Memory(void) const - { return op_rec_.size() * sizeof(OpCode) + { return op_rec_.size() * sizeof(OpCode) + op_arg_rec_.size() * sizeof(addr_t) + par_rec_.size() * sizeof(Base) + text_rec_.size() * sizeof(char) @@ -267,7 +267,7 @@ /// Index in recording corresponding to current operator size_t op_index_; - /// Current offset of the argument indices in op_arg_rec_ + /// Current offset of the argument indices in op_arg_rec_ const addr_t* op_arg_; /// Index for primary (last) variable corresponding to current operator @@ -301,7 +301,7 @@ void forward_start( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { - op = op_ = OpCode( op_rec_[0] ); + op = op_ = OpCode( op_rec_[0] ); op_arg = op_arg_ = op_arg_rec_.data(); op_index = op_index_ = 0; var_index = var_index_ = 0; @@ -316,36 +316,36 @@ Fetch the next operator during a forward sweep. Use forward_start to initialize to the first operator; i.e., - the BeginOp at the beginning of the recording. + the BeginOp at the beginning of the recording. We use the notation forward_routine to denote the set forward_start, forward_next, forward_csum, forward_cskip. \param op [in,out] - The input value of \c op must be its output value from the + The input value of \c op must be its output value from the previous call to a forward_routine. Its output value is the next operator in the recording. For speed, \c forward_next does not check for the special cases - where op == CSumOp or op == CSkipOp. In these cases, - the other return values from \c forward_next must be corrected by a call + where op == CSumOp or op == CSkipOp. In these cases, + the other return values from \c forward_next must be corrected by a call to \c forward_csum or \c forward_cskip respectively. \param op_arg [in,out] The input value of \c op_arg must be its output value form the - previous call to a forward routine. + previous call to a forward routine. Its output value is the beginning of the vector of argument indices for this operation. \param op_index [in,out] The input value of \c op_index must be its output value form the - previous call to a forward routine. - Its output value is the index of the next operator in the recording. + previous call to a forward routine. + Its output value is the index of the next operator in the recording. Thus the ouput value following the previous call to forward_start is one. In addition, - the output value increases by one with each call to forward_next. + the output value increases by one with each call to forward_next. \param var_index [in,out] The input value of \c var_index must be its output value form the - previous call to a forward routine. + previous call to a forward routine. Its output value is the index of the primary (last) result corresponding to the operator op. */ @@ -358,10 +358,10 @@ CPPAD_ASSERT_UNKNOWN( op_index == op_index_ ); CPPAD_ASSERT_UNKNOWN( var_index == var_index_ ); - // index for the next operator + // index for the next operator op_index = ++op_index_; - // first argument for next operator + // first argument for next operator op_arg = op_arg_ += NumArg(op_); // next operator @@ -369,11 +369,11 @@ // index for last result for next operator var_index = var_index_ += NumRes(op); - + CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); - CPPAD_ASSERT_UNKNOWN( - op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() + CPPAD_ASSERT_UNKNOWN( + op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() ); CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_rec_ ); } @@ -385,7 +385,7 @@ call to \c forward_next and must be \c CSumOp. It is not modified. \param op_arg [in,out] - The input value of \c op_arg must be the return value from the + The input value of \c op_arg must be the return value from the previous call to \c forward_next. Its output value is the beginning of the vector of argument indices for the next operation. @@ -415,13 +415,13 @@ The only thing that really needs fixing is op_arg_. Actual number of arugments for this operator is op_arg[0] + op_arg[1] + 4. - We must change op_arg_ so that when you add NumArg(CSumOp) + We must change op_arg_ so that when you add NumArg(CSumOp) you get first argument for next operator in sequence. */ op_arg = op_arg_ += op_arg[0] + op_arg[1] + 4; CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); - CPPAD_ASSERT_UNKNOWN( + CPPAD_ASSERT_UNKNOWN( op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() ); CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_rec_ ); @@ -434,7 +434,7 @@ call to \c forward_next and must be \c CSkipOp. It is not modified. \param op_arg [in,out] - The input value of \c op_arg must be the return value from the + The input value of \c op_arg must be the return value from the previous call to \c forward_next. Its output value is the beginning of the vector of argument indices for the next operation. @@ -464,13 +464,13 @@ The only thing that really needs fixing is op_arg_. Actual number of arugments for this operator is 7 + op_arg[4] + op_arg[5] - We must change op_arg_ so that when you add NumArg(CSkipOp) + We must change op_arg_ so that when you add NumArg(CSkipOp) you get first argument for next operator in sequence. */ op_arg = op_arg_ += 7 + op_arg[4] + op_arg[5]; CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); - CPPAD_ASSERT_UNKNOWN( + CPPAD_ASSERT_UNKNOWN( op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() ); CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_rec_ ); @@ -504,7 +504,7 @@ OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { op_arg = op_arg_ = op_arg_rec_.data() + op_arg_rec_.size(); - op_index = op_index_ = op_rec_.size() - 1; + op_index = op_index_ = op_rec_.size() - 1; var_index = var_index_ = num_var_rec_ - 1; op = op_ = OpCode( op_rec_[ op_index_ ] ); CPPAD_ASSERT_UNKNOWN( op_ == EndOp ); @@ -516,43 +516,43 @@ Fetch the next operator during a reverse sweep. Use reverse_start to initialize to reverse play back. - The first call to reverse_next (after reverse_start) will give the + The first call to reverse_next (after reverse_start) will give the last operator in the recording. We use the notation reverse_routine to denote the set reverse_start, reverse_next, reverse_csum, reverse_cskip. \param op [in,out] - The input value of \c op must be its output value from the + The input value of \c op must be its output value from the previous call to a reverse_routine. Its output value is the next operator in the recording (in reverse order). The last operator sets op equal to EndOp. \param op_arg [in,out] - The input value of \c op_arg must be its output value from the + The input value of \c op_arg must be its output value from the previous call to a reverse_routine. Its output value is the beginning of the vector of argument indices for this operation. - The last operator sets op_arg equal to the beginning of the + The last operator sets op_arg equal to the beginning of the argument indices for the entire recording. For speed, \c reverse_next does not check for the special cases op == CSumOp or op == CSkipOp. In these cases, the other - return values from \c reverse_next must be corrected by a call to + return values from \c reverse_next must be corrected by a call to \c reverse_csum or \c reverse_cskip respectively. \param op_index [in,out] - The input value of \c op_index must be its output value from the + The input value of \c op_index must be its output value from the previous call to a reverse_routine. Its output value is the index of this operator in the recording. Thus the output - value following the previous call to reverse_start is equal to + value following the previous call to reverse_start is equal to the number of variables in the recording minus one. In addition, the output value decreases by one with each call to reverse_next. The last operator sets op_index equal to 0. \param var_index [in,out] - The input value of \c var_index must be its output value from the + The input value of \c var_index must be its output value from the previous call to a reverse_routine. Its output value is the index of the primary (last) result corresponding to the operator op. @@ -580,8 +580,8 @@ // first argument for next operator op_arg = op_arg_ -= NumArg(op); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); - CPPAD_ASSERT_UNKNOWN( - op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() + CPPAD_ASSERT_UNKNOWN( + op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() ); } /*! @@ -592,7 +592,7 @@ call to \c reverse_next and must be \c CSumOp. It is not modified. \param op_arg [in,out] - The input value of \c op_arg must be the return value from the + The input value of \c op_arg must be the return value from the previous call to \c reverse_next. Its output value is the beginning of the vector of argument indices for this operation. @@ -601,7 +601,7 @@ previous call to \c reverse_next. It is not modified. \param var_index [in] - The input value of \c var_index must be the return value from the + The input value of \c var_index must be the return value from the previous call to \c reverse_next. It is not modified. */ @@ -617,7 +617,7 @@ CPPAD_ASSERT_UNKNOWN( op == CSumOp ); CPPAD_ASSERT_UNKNOWN( NumArg(CSumOp) == 0 ); /* - The variables that need fixing are op_arg_ and op_arg. Currently, + The variables that need fixing are op_arg_ and op_arg. Currently, op_arg points to the last argument for the previous operator. */ // last argument for this csum operation @@ -643,7 +643,7 @@ call to \c reverse_next and must be \c CSkipOp. It is not modified. \param op_arg [in,out] - The input value of \c op_arg must be the return value from the + The input value of \c op_arg must be the return value from the previous call to \c reverse_next. Its output value is the beginning of the vector of argument indices for this operation. @@ -652,7 +652,7 @@ previous call to \c reverse_next. It is not modified. \param var_index [in] - The input value of \c var_index must be the return value from the + The input value of \c var_index must be the return value from the previous call to \c reverse_next. It is not modified. */ @@ -668,7 +668,7 @@ CPPAD_ASSERT_UNKNOWN( op == CSkipOp ); CPPAD_ASSERT_UNKNOWN( NumArg(CSkipOp) == 0 ); /* - The variables that need fixing are op_arg_ and op_arg. Currently, + The variables that need fixing are op_arg_ and op_arg. Currently, op_arg points to the last arugment for the previous operator. */ // last argument for this cskip operation diff -Nru cppad-2015.00.00.9/cppad/local/pod_vector.hpp cppad-2016.00.00.1/cppad/local/pod_vector.hpp --- cppad-2015.00.00.9/cppad/local/pod_vector.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/pod_vector.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: pod_vector.hpp 3491 2014-12-21 13:15:12Z bradbell $ -# ifndef CPPAD_POD_VECTOR_INCLUDED -# define CPPAD_POD_VECTOR_INCLUDED +// $Id: pod_vector.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_POD_VECTOR_HPP +# define CPPAD_POD_VECTOR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,7 +17,7 @@ # include # endif # include -# include +# include # include # include @@ -31,21 +31,21 @@ A list of which Types pod_vector consideres to be plain old data */ /// default value is false -template inline bool is_pod(void) { return false; } +template inline bool is_pod(void) { return false; } /// system pod types so far: template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } # if CPPAD_CSTDINT_HAS_8_TO_64 -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } // -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } -template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } +template <> inline bool is_pod(void) { return true; } # else // CPPAD_CSTDINT_HAS_8_TO_64 template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } @@ -59,7 +59,7 @@ # endif # endif // CPPAD_CSTDINT_HAS_8_TO_64 -/// CppAD pod types so far: +/// CppAD pod types so far: template <> inline bool is_pod(void) { return true; } // --------------------------------------------------------------------------- @@ -76,7 +76,7 @@ size_t length_; /// maximum number of Type elements current allocation can hold size_t capacity_; - /// pointer to the first type elements + /// pointer to the first type elements /// (not defined and should not be used when capacity_ = 0) Type *data_; /// do not use the copy constructor @@ -89,12 +89,12 @@ /// value for maximum number of elements in this vector. inline pod_vector( size_t max_length = std::numeric_limits::max() - ) + ) : max_length_(max_length), length_(0), capacity_(0), data_(CPPAD_NULL) { } // ---------------------------------------------------------------------- - /// Destructor: returns allocated memory to \c thread_alloc; - /// see \c extend. If this is not plain old data, + /// Destructor: returns allocated memory to \c thread_alloc; + /// see \c extend. If this is not plain old data, /// the destructor for each element is called. ~pod_vector(void) { if( capacity_ > 0 ) @@ -105,7 +105,7 @@ for(i = 0; i < capacity_; i++) (data_ + i)->~Type(); } - thread_alloc::return_memory(v_ptr); + thread_alloc::return_memory(v_ptr); } } // ---------------------------------------------------------------------- @@ -116,7 +116,7 @@ inline size_t capacity(void) const { return capacity_; } /// current data pointer, no longer valid after any of the following: - /// extend, erase, operator=, and ~pod_vector. + /// extend, erase, operator=, and ~pod_vector. /// Take extreem care when using this function. inline Type* data(void) { return data_; } @@ -125,7 +125,7 @@ { return data_; } // ---------------------------------------------------------------------- /*! - Increase the number of elements the end of this vector. + Increase the number of elements the end of this vector. \param n is the number of elements to add to end of this vector. @@ -133,7 +133,7 @@ \return is the number of elements in the vector before \c extend was extended. - - If \c Type is plain old data, new elements are not initialized; + - If \c Type is plain old data, new elements are not initialized; i.e., their constructor is not called. Otherwise, the constructor is called for each new element. @@ -174,7 +174,7 @@ for(i = 0; i < capacity_; i++) new(data_ + i) Type(); } - + // copy old data to new data for(i = 0; i < old_length; i++) data_[i] = old_data[i]; @@ -185,8 +185,8 @@ if( ! is_pod() ) { for(i = 0; i < old_capacity; i++) (old_data + i)->~Type(); - } - thread_alloc::return_memory(v_ptr); + } + thread_alloc::return_memory(v_ptr); } // return value for extend(n) is the old length @@ -199,7 +199,7 @@ size_t i ) { CPPAD_ASSERT_UNKNOWN( i < length_ ); - return data_[i]; + return data_[i]; } // ---------------------------------------------------------------------- /// constant element access; i.e., we cannot change this element value @@ -208,21 +208,21 @@ size_t i ) const { CPPAD_ASSERT_UNKNOWN( i < length_ ); - return data_[i]; + return data_[i]; } // ---------------------------------------------------------------------- /*! - Remove all the elements from this vector but leave the capacity + Remove all the elements from this vector but leave the capacity and data pointer as is. */ void erase(void) { length_ = 0; return; - } + } // ---------------------------------------------------------------------- /*! - Remove all the elements from this vector and delete its memory. + Remove all the elements from this vector and delete its memory. */ void free(void) { if( capacity_ > 0 ) @@ -233,22 +233,22 @@ for(i = 0; i < capacity_; i++) (data_ + i)->~Type(); } - thread_alloc::return_memory(v_ptr); + thread_alloc::return_memory(v_ptr); } data_ = CPPAD_NULL; capacity_ = 0; length_ = 0; } /// vector assignment operator - /// If the resulting length of the vector would be more than - /// \c max_length_, and \c NDEBUG is not defined, + /// If the resulting length of the vector would be more than + /// \c max_length_, and \c NDEBUG is not defined, /// a CPPAD_ASSERT is generated. void operator=( /// right hand size of the assingment operation const pod_vector& x ) { size_t i; - + if( x.length_ <= capacity_ ) { // use existing allocation for this vector length_ = x.length_; @@ -267,7 +267,7 @@ for(i = 0; i < capacity_; i++) (data_ + i)->~Type(); } - thread_alloc::return_memory(v_ptr); + thread_alloc::return_memory(v_ptr); } length_ = capacity_ = 0; extend( x.length_ ); @@ -281,7 +281,7 @@ \param other is the other vector that we are swapping this vector with. - */ + */ void swap(pod_vector& other) { std::swap(capacity_, other.capacity_); std::swap(length_, other.length_); diff -Nru cppad-2015.00.00.9/cppad/local/pow.hpp cppad-2016.00.00.1/cppad/local/pow.hpp --- cppad-2015.00.00.9/cppad/local/pow.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/pow.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: pow.hpp 2939 2013-10-14 11:06:18Z bradbell $ */ -# ifndef CPPAD_POW_INCLUDED -# define CPPAD_POW_INCLUDED +// $Id: pow.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_POW_HPP +# define CPPAD_POW_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,10 +23,9 @@ const $$ -$index pow, AD$$ -$index exponent, AD function$$ $section The AD Power Function$$ +$mindex pow exponent$$ $head Syntax$$ $icode%z% = pow(%x%, %y%)%$$ @@ -43,9 +42,9 @@ This version of the $code pow$$ function may use logarithms and exponentiation to compute derivatives. This will not work if $icode x$$ is less than or equal zero. -If the value of $icode y$$ is an integer, -the $cref pow_int$$ function is used to compute this value -using only multiplication (and division if $icode y$$ is negative). +If the value of $icode y$$ is an integer, +the $cref pow_int$$ function is used to compute this value +using only multiplication (and division if $icode y$$ is negative). (This will work even if $icode x$$ is less than or equal zero.) $head x$$ @@ -85,7 +84,7 @@ %$$ The file $cref pow.cpp$$ -is an examples and tests of this function. +is an examples and tests of this function. It returns true if it succeeds and false otherwise. $end @@ -94,9 +93,9 @@ // BEGIN CppAD namespace namespace CppAD { - + // case where x and y are AD ----------------------------------------- -template AD +template AD pow(const AD& x, const AD& y) { // compute the Base part @@ -134,7 +133,7 @@ { // result = variable^0 } else - { // result = variable^parameter + { // result = variable^parameter CPPAD_ASSERT_UNKNOWN( NumRes(PowvpOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumArg(PowvpOp) == 2 ); @@ -151,10 +150,10 @@ } else if( var_y ) { if( IdenticalZero(x.value_) ) - { // result = 0^variable + { // result = 0^variable } else - { // result = variable^parameter + { // result = parameter^variable CPPAD_ASSERT_UNKNOWN( NumRes(PowpvOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumArg(PowpvOp) == 2 ); @@ -180,8 +179,8 @@ pow(const AD& x, const VecAD_reference& y) { return pow(x, y.ADBase()); } -template AD -pow(const VecAD_reference& x, const VecAD_reference& y) +template AD +pow(const VecAD_reference& x, const VecAD_reference& y) { return pow(x.ADBase(), y.ADBase()); } template AD @@ -243,7 +242,7 @@ { return pow(x.ADBase(), AD(y)); } // ========================================================================= -// Fold operations for the cases where x is an int, +// Fold operations for the cases where x is an int, // but let cppad/pow_int.hpp handle the cases where y is an int. // ------------------------------------------------------------------------- template AD pow @@ -256,4 +255,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/pow_op.hpp cppad-2016.00.00.1/cppad/local/pow_op.hpp --- cppad-2015.00.00.9/cppad/local/pow_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/pow_op.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: pow_op.hpp 3321 2014-09-12 09:50:39Z bradbell $ */ -# ifndef CPPAD_POW_OP_INCLUDED -# define CPPAD_POW_OP_INCLUDED +// $Id: pow_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_POW_OP_HPP +# define CPPAD_POW_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -32,8 +32,8 @@ template inline void forward_powvv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -87,8 +87,8 @@ template inline void forward_powvv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -174,7 +174,7 @@ template inline void reverse_powvv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -227,8 +227,8 @@ template inline void forward_powpv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -259,11 +259,11 @@ // z_1 = z_0 * y addr_t adr[2]; // offset of z_i in taylor (as if it were a parameter); i.e., log(x) - adr[0] = i_z * cap_order; + adr[0] = i_z * cap_order; // offset of y in taylor (as a variable) adr[1] = arg[1]; - // Trick: use taylor both for the parameter vector and variable values + // Trick: use taylor both for the parameter vector and variable values forward_mulpv_op(p, q, i_z+1, adr, taylor, cap_order, taylor); // z_2 = exp(z_1) @@ -292,14 +292,14 @@ template inline void forward_powpv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) -{ +{ // convert from final result to first result i_z -= 2; // 2 = NumRes(PowpvOp) - 1; @@ -325,7 +325,7 @@ // ofset of y in taylor (as a variable) adr[1] = arg[1]; - // Trick: use taylor both for the parameter vector and variable values + // Trick: use taylor both for the parameter vector and variable values forward_mulpv_op_dir(q, r, i_z+1, adr, taylor, cap_order, taylor); // z_2 = exp(z_1) @@ -394,7 +394,7 @@ template inline void reverse_powpv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -419,7 +419,7 @@ // z_1 = z_0 * y addr_t adr[2]; - adr[0] = i_z * cap_order; // offset of z_0[0] in taylor + adr[0] = i_z * cap_order; // offset of z_0[0] in taylor adr[1] = arg[1]; // index of y in taylor and partial // use taylor both for parameter and variable values reverse_mulpv_op( @@ -446,8 +446,8 @@ template inline void forward_powvp_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -499,8 +499,8 @@ template inline void forward_powvp_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -592,7 +592,7 @@ template inline void reverse_powvp_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , diff -Nru cppad-2015.00.00.9/cppad/local/print_for.hpp cppad-2016.00.00.1/cppad/local/print_for.hpp --- cppad-2015.00.00.9/cppad/local/print_for.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/print_for.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: print_for.hpp 3170 2014-03-09 14:33:53Z bradbell $ */ -# ifndef CPPAD_PRINT_FOR_INCLUDED -# define CPPAD_PRINT_FOR_INCLUDED +// $Id: print_for.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_PRINT_FOR_HPP +# define CPPAD_PRINT_FOR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,14 +24,9 @@ const $$ -$index print, forward mode$$ -$index forward, mode print$$ -$index text, output$$ -$index output, text$$ -$index debug, forward mode$$ -$index forward, debug$$ -$section Printing AD Values During Forward Mode$$ +$section Printing AD Values During Forward Mode$$ +$mindex print text output debug$$ $head Syntax$$ $icode%f%.Forward(0, %x%) @@ -46,10 +41,10 @@ $codei% %f%.Forward(0, %x%) %$$ -assigns the +assigns the $cref/independent variable/glossary/Tape/Independent Variable/$$ vector equal to $icode x$$. -It then computes a value for all of the dependent variables in the +It then computes a value for all of the dependent variables in the $cref/operation sequence/glossary/Operation/Sequence/$$ corresponding to $icode f$$. Putting a $code PrintFor$$ in the operation sequence will @@ -75,7 +70,7 @@ $codei% const char* %before% %$$ -This text is written to $code std::cout$$ before $icode var$$. +This text is written to $code std::cout$$ before $icode var$$. $head var$$ The argument $icode var$$ has one of the following prototypes @@ -84,14 +79,14 @@ const VecAD<%Base%>::reference& %var% %$$ The value of $icode var$$, that corresponds to $icode x$$, -is written to $code std::cout$$ during the execution of +is written to $code std::cout$$ during the execution of $codei% %f%.Forward(0, %x%) %$$ Note that $icode var$$ may be a -$cref/variable/glossary/Variable/$$ or +$cref/variable/glossary/Variable/$$ or $cref/parameter/glossary/Parameter/$$. -(A parameters value does not depend on the value of +(A parameters value does not depend on the value of the independent variable vector $icode x$$.) $head after$$ @@ -99,8 +94,8 @@ $codei% const char* %after% %$$ -This text is written to $code std::cout$$ after $icode var$$. - +This text is written to $code std::cout$$ after $icode var$$. + $head Discussion$$ This is helpful for understanding why tape evaluations have trouble. @@ -109,7 +104,7 @@ the corresponding result will be $cref nan$$. $head Alternative$$ -The $cref ad_output$$ section describes the normal +The $cref ad_output$$ section describes the normal printing of values; i.e., printing when the corresponding code is executed. @@ -134,9 +129,9 @@ # include -namespace CppAD { +namespace CppAD { template - void PrintFor(const AD& pos, + void PrintFor(const AD& pos, const char *before, const AD& var, const char* after) { CPPAD_ASSERT_NARG_NRES(PriOp, 5, 0); @@ -154,7 +149,7 @@ "PrintFor: length of after is greater than 1000 characters" ); size_t ind0, ind1, ind2, ind3, ind4; - + // ind[0] = base 2 representation of the value [Var(pos), Var(var)] ind0 = 0; @@ -196,7 +191,7 @@ template void PrintFor( const VecAD_reference& pos , - const char *before , + const char *before , const VecAD_reference& var , const char *after ) { PrintFor(pos.ADBase(), before, var.ADBase(), after); } @@ -204,7 +199,7 @@ template void PrintFor( const VecAD_reference& pos , - const char *before , + const char *before , const AD& var , const char *after ) { PrintFor(pos.ADBase(), before, var, after); } @@ -212,7 +207,7 @@ template void PrintFor( const AD& pos , - const char *before , + const char *before , const VecAD_reference& var , const char *after ) { PrintFor(pos, before, var.ADBase(), after); } diff -Nru cppad-2015.00.00.9/cppad/local/print_op.hpp cppad-2016.00.00.1/cppad/local/print_op.hpp --- cppad-2015.00.00.9/cppad/local/print_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/print_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: print_op.hpp 3323 2014-09-12 12:10:54Z bradbell $ */ -# ifndef CPPAD_PRINT_OP_INCLUDED -# define CPPAD_PRINT_OP_INCLUDED +// $Id: print_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_PRINT_OP_HPP +# define CPPAD_PRINT_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -29,7 +29,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param s_out diff -Nru cppad-2015.00.00.9/cppad/local/prototype_op.hpp cppad-2016.00.00.1/cppad/local/prototype_op.hpp --- cppad-2015.00.00.9/cppad/local/prototype_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/prototype_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: prototype_op.hpp 3321 2014-09-12 09:50:39Z bradbell $ */ -# ifndef CPPAD_PROTOTYPE_OP_INCLUDED -# define CPPAD_PROTOTYPE_OP_INCLUDED +// $Id: prototype_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_PROTOTYPE_OP_HPP +# define CPPAD_PROTOTYPE_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,7 +28,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param p @@ -38,8 +38,8 @@ highest order of the Taylor coefficient that we are computing. \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in \a taylor corresponding to z. \param i_x variable index corresponding to the argument for this operator; @@ -49,17 +49,17 @@ maximum number of orders that will fit in the \c taylor array. \param taylor -\b Input: taylor [ i_x * cap_order + k ], +\b Input: taylor [ i_x * cap_order + k ], for k = 0 , ... , q, is the k-th order Taylor coefficient corresponding to x. \n -\b Input: taylor [ i_z * cap_order + k ], +\b Input: taylor [ i_z * cap_order + k ], for k = 0 , ... , p-1, is the k-th order Taylor coefficient corresponding to z. \n -\b Output: taylor [ i_z * cap_order + k ], +\b Output: taylor [ i_z * cap_order + k ], for k = p , ... , q, -is the k-th order Taylor coefficient corresponding to z. +is the k-th order Taylor coefficient corresponding to z. \par Checked Assertions \li NumArg(op) == 1 @@ -73,7 +73,7 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -86,7 +86,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param q @@ -96,8 +96,8 @@ number of directions for Taylor coefficients that we are computing. \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \param i_x @@ -113,34 +113,34 @@ which is the number of Taylor coefficients per variable \param taylor -\b Input: If x is a variable, -taylor [ arg[0] * tpv + 0 ], +\b Input: If x is a variable, +taylor [ arg[0] * tpv + 0 ], is the zero order Taylor coefficient for all directions and -taylor [ arg[0] * tpv + (k-1)*r + ell + 1 ], +taylor [ arg[0] * tpv + (k-1)*r + ell + 1 ], for k = 1 , ... , q, ell = 0, ..., r-1, -is the k-th order Taylor coefficient +is the k-th order Taylor coefficient corresponding to x and the ell-th direction. \n -\b Input: taylor [ i_z * tpv + 0 ], +\b Input: taylor [ i_z * tpv + 0 ], is the zero order Taylor coefficient for all directions and -taylor [ i_z * tpv + (k-1)*r + ell + 1 ], +taylor [ i_z * tpv + (k-1)*r + ell + 1 ], for k = 1 , ... , q-1, ell = 0, ..., r-1, -is the k-th order Taylor coefficient +is the k-th order Taylor coefficient corresponding to z and the ell-th direction. \n -\b Output: -taylor [ i_z * tpv + (q-1)*r + ell + 1], +\b Output: +taylor [ i_z * tpv + (q-1)*r + ell + 1], ell = 0, ..., r-1, -is the q-th order Taylor coefficient -corresponding to z and the ell-th direction. +is the q-th order Taylor coefficient +corresponding to z and the ell-th direction. -\par Checked Assertions +\par Checked Assertions \li NumArg(op) == 1 \li NumRes(op) == 2 -\li i_x < i_z -\li 0 < q +\li i_x < i_z +\li 0 < q \li q < cap_order */ template @@ -149,7 +149,7 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -157,15 +157,15 @@ } /*! -Prototype for zero order forward mode unary operator with one result (not used). +Prototype for zero order forward mode unary operator with one result (not used). \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in \a taylor corresponding to z. \param i_x variable index corresponding to the argument for this operator; @@ -175,23 +175,23 @@ maximum number of orders that will fit in the \c taylor array. \param taylor -\b Input: \a taylor [ \a i_x * \a cap_order + 0 ] -is the zero order Taylor coefficient corresponding to x. +\b Input: \a taylor [ \a i_x * \a cap_order + 0 ] +is the zero order Taylor coefficient corresponding to x. \n -\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] -is the zero order Taylor coefficient corresponding to z. +\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. -\par Checked Assertions +\par Checked Assertions \li NumArg(op) == 1 \li NumRes(op) == 1 -\li \a i_x < \a i_z +\li \a i_x < \a i_z \li \a 0 < \a cap_order */ template inline void forward_unary1_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -201,16 +201,16 @@ /*! Prototype for reverse mode unary operator with one result (not used). -This routine is given the partial derivatives of a function +This routine is given the partial derivatives of a function G(z , x , w, u ... ) -and it uses them to compute the partial derivatives of +and it uses them to compute the partial derivatives of \verbatim H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] \endverbatim \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param d @@ -218,8 +218,8 @@ we are computing the partial derivatives with respect to. \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in \a taylor to z. +variable index corresponding to the result for this operation; +i.e. the row index in \a taylor to z. \param i_x variable index corresponding to the argument for this operation; @@ -229,11 +229,11 @@ maximum number of orders that will fit in the \c taylor array. \param taylor -\a taylor [ \a i_x * \a cap_order + k ] +\a taylor [ \a i_x * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to x. \n -\a taylor [ \a i_z * \a cap_order + k ] +\a taylor [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to z. @@ -241,30 +241,30 @@ number of colums in the matrix containing all the partial derivatives. \param partial -\b Input: \a partial [ \a i_x * \a nc_partial + k ] +\b Input: \a partial [ \a i_x * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of G( z , x , w , u , ... ) with respect to +is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n -\b Input: \a partial [ \a i_z * \a nc_partial + k ] +\b Input: \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of G( z , x , w , u , ... ) with respect to +is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for z. \n \b Output: \a partial [ \a i_x * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of H( x , w , u , ... ) with respect to +is the partial derivative of H( x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Output: \a partial [ \a i_z * \a nc_partial + k ] -for k = 0 , ... , \a d +for k = 0 , ... , \a d may be used as work space; i.e., may change in an unspecified manner. \par Checked Assumptions \li NumArg(op) == 1 \li NumRes(op) == 1 -\li \a i_x < \a i_z +\li \a i_x < \a i_z \li \a d < \a cap_order \li \a d < \a nc_partial */ @@ -273,7 +273,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -289,7 +289,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param p @@ -299,8 +299,8 @@ highest order of the Taylor coefficients that we are computing. \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \param i_x @@ -311,33 +311,33 @@ maximum number of orders that will fit in the \c taylor array. \param taylor -\b Input: taylor [ i_x * cap_order + k ] +\b Input: taylor [ i_x * cap_order + k ] for k = 0 , ... , q, is the k-th order Taylor coefficient corresponding to x. \n -\b Input: taylor [ i_z * cap_order + k ] +\b Input: taylor [ i_z * cap_order + k ] for k = 0 , ... , p - 1, is the k-th order Taylor coefficient corresponding to z. \n -\b Input: taylor [ ( i_z - 1) * cap_order + k ] +\b Input: taylor [ ( i_z - 1) * cap_order + k ] for k = 0 , ... , p-1, is the k-th order Taylor coefficient corresponding to the auxillary result y. \n \b Output: taylor [ i_z * cap_order + k ], for k = p , ... , q, -is the k-th order Taylor coefficient corresponding to z. +is the k-th order Taylor coefficient corresponding to z. \n -\b Output: taylor [ ( i_z - 1 ) * cap_order + k ], +\b Output: taylor [ ( i_z - 1 ) * cap_order + k ], for k = p , ... , q, -is the k-th order Taylor coefficient corresponding to +is the k-th order Taylor coefficient corresponding to the autillary result y. -\par Checked Assertions +\par Checked Assertions \li NumArg(op) == 1 \li NumRes(op) == 2 -\li i_x + 1 < i_z +\li i_x + 1 < i_z \li q < cap_order -\li p <= q +\li p <= q */ template inline void forward_unary2_op( @@ -345,7 +345,7 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -353,23 +353,23 @@ } /*! -Prototype for multiple direction forward mode unary operator with two results +Prototype for multiple direction forward mode unary operator with two results (not used). \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param q order of the Taylor coefficients that we are computing. -\param r +\param r number of directions for Taylor coefficients that we are computing. \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \param i_x @@ -385,41 +385,41 @@ which is the number of Taylor coefficients per variable \param taylor -\b Input: taylor [ i_x * tpv + 0 ] +\b Input: taylor [ i_x * tpv + 0 ] is the zero order Taylor coefficient for all directions and taylor [ i_x * tpv + (k-1)*r + ell + 1 for k = 1 , ... , q, ell = 0 , ..., r-1, -is the k-th order Taylor coefficient +is the k-th order Taylor coefficient corresponding to x and the ell-th direction. \n -\b Input: taylor [ i_z * tpv + 0 ], +\b Input: taylor [ i_z * tpv + 0 ], is the zero order Taylor coefficient for all directions and -taylor [ i_z * tpv + (k-1)*r + ell + 1 ], +taylor [ i_z * tpv + (k-1)*r + ell + 1 ], for k = 1 , ... , q-1, ell = 0, ..., r-1, -is the k-th order Taylor coefficient +is the k-th order Taylor coefficient corresponding to z and the ell-th direction. \n -\b Input: taylor [ (i_z-1) * tpv + 0 ], +\b Input: taylor [ (i_z-1) * tpv + 0 ], is the zero order Taylor coefficient for all directions and -taylor [ (i_z-1) * tpv + (k-1)*r + ell + 1 ], +taylor [ (i_z-1) * tpv + (k-1)*r + ell + 1 ], for k = 1 , ... , q-1, ell = 0, ..., r-1, -is the k-th order Taylor coefficient +is the k-th order Taylor coefficient corresponding to the auxillary result y and the ell-th direction. \n -\b Output: -taylor [ i_z * tpv + (q-1)*r + ell + 1], +\b Output: +taylor [ i_z * tpv + (q-1)*r + ell + 1], ell = 0, ..., r-1, -is the q-th order Taylor coefficient -corresponding to z and the ell-th direction. +is the q-th order Taylor coefficient +corresponding to z and the ell-th direction. -\par Checked Assertions +\par Checked Assertions \li NumArg(op) == 1 \li NumRes(op) == 2 -\li i_x + 1 < i_z -\li 0 < q +\li i_x + 1 < i_z +\li 0 < q \li q < cap_order */ template @@ -428,7 +428,7 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -436,15 +436,15 @@ } /*! -Prototype for zero order forward mode unary operator with two results (not used). +Prototype for zero order forward mode unary operator with two results (not used). \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor corresponding to z. The auxillary result is called y and has index \a i_z - 1. \param i_x @@ -455,27 +455,27 @@ maximum number of orders that will fit in the \c taylor array. \param taylor -\b Input: \a taylor [ \a i_x * \a cap_order + 0 ] -is the zero order Taylor coefficient corresponding to x. +\b Input: \a taylor [ \a i_x * \a cap_order + 0 ] +is the zero order Taylor coefficient corresponding to x. \n -\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] -is the zero order Taylor coefficient corresponding to z. +\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. \n -\b Output: \a taylor [ ( \a i_z - 1 ) * \a cap_order + j ] -is the j-th order Taylor coefficient corresponding to -the autillary result y. +\b Output: \a taylor [ ( \a i_z - 1 ) * \a cap_order + j ] +is the j-th order Taylor coefficient corresponding to +the autillary result y. \par Checked Assertions \li NumArg(op) == 1 \li NumRes(op) == 2 -\li \a i_x + 1 < \a i_z +\li \a i_x + 1 < \a i_z \li \a j < \a cap_order */ template inline void forward_unary2_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -485,16 +485,16 @@ /*! Prototype for reverse mode unary operator with two results (not used). -This routine is given the partial derivatives of a function +This routine is given the partial derivatives of a function G( z , y , x , w , ... ) -and it uses them to compute the partial derivatives of +and it uses them to compute the partial derivatives of \verbatim H( x , w , u , ... ) = G[ z(x) , y(x), x , w , u , ... ] \endverbatim \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param d @@ -502,8 +502,8 @@ we are computing the partial derivatives with respect to. \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor to z. The auxillary result is called y and has index \a i_z - 1. \param i_x @@ -514,53 +514,53 @@ maximum number of orders that will fit in the \c taylor array. \param taylor -\a taylor [ \a i_x * \a cap_order + k ] +\a taylor [ \a i_x * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to x. \n -\a taylor [ \a i_z * \a cap_order + k ] +\a taylor [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to z. \n -\a taylor [ ( \a i_z - 1) * \a cap_order + k ] +\a taylor [ ( \a i_z - 1) * \a cap_order + k ] for k = 0 , ... , \a d -is the k-th order Taylor coefficient corresponding to +is the k-th order Taylor coefficient corresponding to the auxillary variable y. \param nc_partial number of colums in the matrix containing all the partial derivatives. \param partial -\b Input: \a partial [ \a i_x * \a nc_partial + k ] +\b Input: \a partial [ \a i_x * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of -G( z , y , x , w , u , ... ) +is the partial derivative of +G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n -\b Input: \a partial [ \a i_z * \a nc_partial + k ] +\b Input: \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of G( z , y , x , w , u , ... ) with respect to +is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for z. \n -\b Input: \a partial [ ( \a i_z - 1) * \a nc_partial + k ] +\b Input: \a partial [ ( \a i_z - 1) * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of G( z , x , w , u , ... ) with respect to +is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for the auxillary variable y. \n \b Output: \a partial [ \a i_x * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of H( x , w , u , ... ) with respect to +is the partial derivative of H( x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Output: \a partial [ \a ( i_z - j ) * \a nc_partial + k ] -for j = 0 , 1 , and for k = 0 , ... , \a d +for j = 0 , 1 , and for k = 0 , ... , \a d may be used as work space; i.e., may change in an unspecified manner. \par Checked Assumptions \li NumArg(op) == 1 \li NumRes(op) == 2 -\li \a i_x + 1 < \a i_z +\li \a i_x + 1 < \a i_z \li \a d < \a cap_order \li \a d < \a nc_partial */ @@ -569,7 +569,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -584,7 +584,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param p @@ -594,8 +594,8 @@ highest order of the Taylor coefficient that we are computing. \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in \a taylor corresponding to z. \param arg \a arg[0] @@ -607,33 +607,33 @@ i.e. the index corresponding to y. \param parameter -If x is a parameter, \a parameter [ \a arg[0] ] +If x is a parameter, \a parameter [ \a arg[0] ] is the value corresponding to x. \n -If y is a parameter, \a parameter [ \a arg[1] ] +If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor -\b Input: If x is a variable, -taylor [ arg[0] * cap_order + k ], +\b Input: If x is a variable, +taylor [ arg[0] * cap_order + k ], for k = 0 , ... , q, is the k-th order Taylor coefficient corresponding to x. \n -\b Input: If y is a variable, -taylor [ arg[1] * cap_order + k ], +\b Input: If y is a variable, +taylor [ arg[1] * cap_order + k ], for k = 0 , ... , q, is the k-th order Taylor coefficient corresponding to y. \n -\b Input: taylor [ i_z * cap_order + k ], +\b Input: taylor [ i_z * cap_order + k ], for k = 0 , ... , p-1, is the k-th order Taylor coefficient corresponding to z. \n -\b Output: taylor [ i_z * cap_order + k ], +\b Output: taylor [ i_z * cap_order + k ], for k = p, ... , q, -is the k-th order Taylor coefficient corresponding to z. +is the k-th order Taylor coefficient corresponding to z. \par Checked Assertions \li NumArg(op) == 2 @@ -648,7 +648,7 @@ size_t i_z , const addr_t* arg , const Base* parameter , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -660,7 +660,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param q @@ -670,8 +670,8 @@ number of directions for Taylor coefficients that we are computing \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in \a taylor corresponding to z. \param arg \a arg[0] @@ -683,10 +683,10 @@ i.e. the index corresponding to y. \param parameter -If x is a parameter, \a parameter [ \a arg[0] ] +If x is a parameter, \a parameter [ \a arg[0] ] is the value corresponding to x. \n -If y is a parameter, \a parameter [ \a arg[1] ] +If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order @@ -698,37 +698,37 @@ which is the number of Taylor coefficients per variable \param taylor -\b Input: If x is a variable, -taylor [ arg[0] * tpv + 0 ], +\b Input: If x is a variable, +taylor [ arg[0] * tpv + 0 ], is the zero order Taylor coefficient for all directions and -taylor [ arg[0] * tpv + (k-1)*r + ell + 1 ], +taylor [ arg[0] * tpv + (k-1)*r + ell + 1 ], for k = 1 , ... , q, ell = 0, ..., r-1, -is the k-th order Taylor coefficient +is the k-th order Taylor coefficient corresponding to x and the ell-th direction. \n -\b Input: If y is a variable, -taylor [ arg[1] * tpv + 0 ], +\b Input: If y is a variable, +taylor [ arg[1] * tpv + 0 ], is the zero order Taylor coefficient for all directions and -taylor [ arg[1] * tpv + (k-1)*r + ell + 1 ], +taylor [ arg[1] * tpv + (k-1)*r + ell + 1 ], for k = 1 , ... , q, ell = 0, ..., r-1, -is the k-th order Taylor coefficient +is the k-th order Taylor coefficient corresponding to y and the ell-th direction. \n -\b Input: taylor [ i_z * tpv + 0 ], +\b Input: taylor [ i_z * tpv + 0 ], is the zero order Taylor coefficient for all directions and -taylor [ i_z * tpv + (k-1)*r + ell + 1 ], +taylor [ i_z * tpv + (k-1)*r + ell + 1 ], for k = 1 , ... , q-1, ell = 0, ..., r-1, -is the k-th order Taylor coefficient +is the k-th order Taylor coefficient corresponding to z and the ell-th direction. \n -\b Output: -taylor [ i_z * tpv + (q-1)*r + ell + 1], +\b Output: +taylor [ i_z * tpv + (q-1)*r + ell + 1], ell = 0, ..., r-1, -is the q-th order Taylor coefficient -corresponding to z and the ell-th direction. +is the q-th order Taylor coefficient +corresponding to z and the ell-th direction. \par Checked Assertions \li NumArg(op) == 2 @@ -742,7 +742,7 @@ size_t i_z , const addr_t* arg , const Base* parameter , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -755,12 +755,12 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in \a taylor corresponding to z. \param arg \a arg[0] @@ -772,24 +772,24 @@ i.e. the index corresponding to y. \param parameter -If x is a parameter, \a parameter [ \a arg[0] ] +If x is a parameter, \a parameter [ \a arg[0] ] is the value corresponding to x. \n -If y is a parameter, \a parameter [ \a arg[1] ] +If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor -\b Input: If x is a variable, \a taylor [ \a arg[0] * \a cap_order + 0 ] +\b Input: If x is a variable, \a taylor [ \a arg[0] * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to x. \n -\b Input: If y is a variable, \a taylor [ \a arg[1] * \a cap_order + 0 ] +\b Input: If y is a variable, \a taylor [ \a arg[1] * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to y. \n -\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] -is the zero order Taylor coefficient corresponding to z. +\b Output: \a taylor [ \a i_z * \a cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. \par Checked Assertions \li NumArg(op) == 2 @@ -800,7 +800,7 @@ size_t i_z , const addr_t* arg , const Base* parameter , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -810,16 +810,16 @@ /*! Prototype for reverse mode binary operator x op y (not used). -This routine is given the partial derivatives of a function +This routine is given the partial derivatives of a function G( z , y , x , w , ... ) -and it uses them to compute the partial derivatives of +and it uses them to compute the partial derivatives of \verbatim H( y , x , w , u , ... ) = G[ z(x , y) , y , x , w , u , ... ] \endverbatim \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param d @@ -827,8 +827,8 @@ we are computing the partial derivatives with respect to. \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in \a taylor corresponding to z. \param arg \a arg[0] @@ -840,25 +840,25 @@ i.e. the index corresponding to y. \param parameter -If x is a parameter, \a parameter [ \a arg[0] ] +If x is a parameter, \a parameter [ \a arg[0] ] is the value corresponding to x. \n -If y is a parameter, \a parameter [ \a arg[1] ] +If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor -\a taylor [ \a i_z * \a cap_order + k ] +\a taylor [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to z. \n -If x is a variable, \a taylor [ \a arg[0] * \a cap_order + k ] +If x is a variable, \a taylor [ \a arg[0] * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to x. \n -If y is a variable, \a taylor [ \a arg[1] * \a cap_order + k ] +If y is a variable, \a taylor [ \a arg[1] * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to y. @@ -866,41 +866,41 @@ number of colums in the matrix containing all the partial derivatives. \param partial -\b Input: \a partial [ \a i_z * \a nc_partial + k ] +\b Input: \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of -G( z , y , x , w , u , ... ) +is the partial derivative of +G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for z. \n -\b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] +\b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of G( z , y , x , w , u , ... ) with respect to +is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n -\b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] +\b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of G( z , x , w , u , ... ) with respect to +is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for the auxillary variable y. \n \b Output: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of H( y , x , w , u , ... ) with respect to +is the partial derivative of H( y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Output: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] -for k = 0 , ... , \a d -is the partial derivative of H( y , x , w , u , ... ) with respect to +for k = 0 , ... , \a d +is the partial derivative of H( y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for y. \n \b Output: \a partial [ \a i_z * \a nc_partial + k ] -for k = 0 , ... , \a d +for k = 0 , ... , \a d may be used as work space; i.e., may change in an unspecified manner. \par Checked Assumptions \li NumArg(op) == 2 \li NumRes(op) == 1 -\li \a If x is a variable, arg[0] < \a i_z -\li \a If y is a variable, arg[1] < \a i_z +\li \a If x is a variable, arg[0] < \a i_z +\li \a If y is a variable, arg[1] < \a i_z \li \a d < \a cap_order \li \a d < \a nc_partial */ @@ -910,7 +910,7 @@ size_t i_z , addr_t* arg , const Base* parameter , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -924,7 +924,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param p @@ -934,8 +934,8 @@ highest order of the Taylor coefficient that we are computing. \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor corresponding to z. Note that there are three results for this operation, below they are referred to as z_0, z_1, z_2 and correspond to \verbatim @@ -943,7 +943,7 @@ z_1 = z0 * y z_2 = exp(z1) \endverbatim -It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). +It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). \param arg \a arg[0] @@ -955,23 +955,23 @@ i.e. the index corresponding to y. \param parameter -If x is a parameter, \a parameter [ \a arg[0] ] +If x is a parameter, \a parameter [ \a arg[0] ] is the value corresponding to x. \n -If y is a parameter, \a parameter [ \a arg[1] ] +If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor -\b Input: If x is a variable, -taylor [ arg[0] * cap_order + k ] +\b Input: If x is a variable, +taylor [ arg[0] * cap_order + k ] for k = 0 , ... , q, is the k-th order Taylor coefficient corresponding to x. \n -\b Input: If y is a variable, -taylor [ arg[1] * cap_order + k ] +\b Input: If y is a variable, +taylor [ arg[1] * cap_order + k ] for k = 0 , ... , q is the k-th order Taylor coefficient corresponding to y. \n @@ -979,13 +979,13 @@ for j = 0, 1, 2 , for k = 0 , ... , p-1, is the k-th order Taylor coefficient corresponding to z_j. \n -\b Output: taylor [ (i_z-2+j) * cap_order + k ], +\b Output: taylor [ (i_z-2+j) * cap_order + k ], is the k-th order Taylor coefficient corresponding to z_j. \par Checked Assertions \li NumArg(op) == 2 \li NumRes(op) == 3 -\li If x is a variable, arg[0] < i_z - 2 +\li If x is a variable, arg[0] < i_z - 2 \li If y is a variable, arg[1] < i_z - 2 \li q < cap_order \li p <= q @@ -997,7 +997,7 @@ size_t i_z , const addr_t* arg , const Base* parameter , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -1008,7 +1008,7 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param q @@ -1018,8 +1018,8 @@ is the number of Taylor coefficient directions that we are computing \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor corresponding to z. Note that there are three results for this operation, below they are referred to as z_0, z_1, z_2 and correspond to \verbatim @@ -1027,7 +1027,7 @@ z_1 = z0 * y z_2 = exp(z1) \endverbatim -It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). +It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). \param arg \a arg[0] @@ -1039,10 +1039,10 @@ i.e. the index corresponding to y. \param parameter -If x is a parameter, \a parameter [ \a arg[0] ] +If x is a parameter, \a parameter [ \a arg[0] ] is the value corresponding to x. \n -If y is a parameter, \a parameter [ \a arg[1] ] +If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order @@ -1054,27 +1054,27 @@ which is the number of Taylor coefficients per variable \param taylor -\b Input: If x is a variable, -taylor [ arg[0] * tpv + 0 ] +\b Input: If x is a variable, +taylor [ arg[0] * tpv + 0 ] is the zero order coefficient corresponding to x and -taylor [ arg[0] * tpv + (k-1)*r+1+ell ] +taylor [ arg[0] * tpv + (k-1)*r+1+ell ] for k = 1 , ... , q, ell = 0 , ... , r-1, is the k-th order Taylor coefficient corresponding to x for the ell-th direction. \n \n -\b Input: If y is a variable, -taylor [ arg[1] * tpv + 0 ] +\b Input: If y is a variable, +taylor [ arg[1] * tpv + 0 ] is the zero order coefficient corresponding to y and -taylor [ arg[1] * tpv + (k-1)*r+1+ell ] +taylor [ arg[1] * tpv + (k-1)*r+1+ell ] for k = 1 , ... , q, ell = 0 , ... , r-1, is the k-th order Taylor coefficient corresponding to y for the ell-th direction. \n \n -\b Input: +\b Input: taylor [ (i_z-2+j) * tpv + 0 ], is the zero order coefficient corresponding to z_j and taylor [ (i_z-2+j) * tpv + (k-1)*r+1+ell ], @@ -1083,7 +1083,7 @@ for the ell-th direction. \n \n -\b Output: +\b Output: taylor [ (i_z-2+j) * tpv + (q-1)*r+1+ell ], for j = 0, 1, 2 , ell = 0, ... , r-1, is the q-th order Taylor coefficient corresponding to z_j @@ -1092,7 +1092,7 @@ \par Checked Assertions \li NumArg(op) == 2 \li NumRes(op) == 3 -\li If x is a variable, arg[0] < i_z - 2 +\li If x is a variable, arg[0] < i_z - 2 \li If y is a variable, arg[1] < i_z - 2 \li 0 < q \li q < cap_order @@ -1104,7 +1104,7 @@ size_t i_z , const addr_t* arg , const Base* parameter , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -1115,12 +1115,12 @@ \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor corresponding to z. Note that there are three results for this operation, below they are referred to as z_0, z_1, z_2 and correspond to \verbatim @@ -1128,7 +1128,7 @@ z_1 = z0 * y z_2 = exp(z1) \endverbatim -It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). +It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). \param arg \a arg[0] @@ -1140,29 +1140,29 @@ i.e. the index corresponding to y. \param parameter -If x is a parameter, \a parameter [ \a arg[0] ] +If x is a parameter, \a parameter [ \a arg[0] ] is the value corresponding to x. \n -If y is a parameter, \a parameter [ \a arg[1] ] +If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor -\b Input: If x is a variable, \a taylor [ \a arg[0] * \a cap_order + 0 ] +\b Input: If x is a variable, \a taylor [ \a arg[0] * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to x. \n -\b Input: If y is a variable, \a taylor [ \a arg[1] * \a cap_order + 0 ] +\b Input: If y is a variable, \a taylor [ \a arg[1] * \a cap_order + 0 ] is the k-th order Taylor coefficient corresponding to y. \n -\b Output: \a taylor [ \a (i_z - 2 + j) * \a cap_order + 0 ] +\b Output: \a taylor [ \a (i_z - 2 + j) * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to z_j. \par Checked Assertions \li NumArg(op) == 2 \li NumRes(op) == 3 -\li If x is a variable, \a arg[0] < \a i_z - 2 +\li If x is a variable, \a arg[0] < \a i_z - 2 \li If y is a variable, \a arg[1] < \a i_z - 2 */ template @@ -1170,7 +1170,7 @@ size_t i_z , const addr_t* arg , const Base* parameter , - size_t cap_order , + size_t cap_order , Base* taylor ) { // This routine is only for documentaiton, it should not be used @@ -1179,16 +1179,16 @@ /*! Prototype for reverse mode z = pow(x, y) (not used). -This routine is given the partial derivatives of a function +This routine is given the partial derivatives of a function G( z , y , x , w , ... ) -and it uses them to compute the partial derivatives of +and it uses them to compute the partial derivatives of \verbatim H( y , x , w , u , ... ) = G[ pow(x , y) , y , x , w , u , ... ] \endverbatim \tparam Base base type for the operator; i.e., this operation was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base . \param d @@ -1196,8 +1196,8 @@ we are computing the partial derivatives with respect to. \param i_z -variable index corresponding to the last (primary) result for this operation; -i.e. the row index in \a taylor corresponding to z. +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in \a taylor corresponding to z. Note that there are three results for this operation, below they are referred to as z_0, z_1, z_2 and correspond to \verbatim @@ -1205,7 +1205,7 @@ z_1 = z0 * y z_2 = exp(z1) \endverbatim -It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). +It follows that the final result is equal to z; i.e., z = z_2 = pow(x, y). \param arg \a arg[0] @@ -1217,25 +1217,25 @@ i.e. the index corresponding to y. \param parameter -If x is a parameter, \a parameter [ \a arg[0] ] +If x is a parameter, \a parameter [ \a arg[0] ] is the value corresponding to x. \n -If y is a parameter, \a parameter [ \a arg[1] ] +If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor -\a taylor [ \a (i_z - 2 + j) * \a cap_order + k ] +\a taylor [ \a (i_z - 2 + j) * \a cap_order + k ] for j = 0, 1, 2 and k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to z_j. \n -If x is a variable, \a taylor [ \a arg[0] * \a cap_order + k ] +If x is a variable, \a taylor [ \a arg[0] * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to x. \n -If y is a variable, \a taylor [ \a arg[1] * \a cap_order + k ] +If y is a variable, \a taylor [ \a arg[1] * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to y. @@ -1243,34 +1243,34 @@ number of colums in the matrix containing all the partial derivatives. \param partial -\b Input: \a partial [ \a (i_z - 2 + j) * \a nc_partial + k ] +\b Input: \a partial [ \a (i_z - 2 + j) * \a nc_partial + k ] for j = 0, 1, 2, and k = 0 , ... , \a d -is the partial derivative of -G( z , y , x , w , u , ... ) +is the partial derivative of +G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for z_j. \n -\b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] +\b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of G( z , y , x , w , u , ... ) with respect to +is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n -\b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] +\b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of G( z , x , w , u , ... ) with respect to +is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for the auxillary variable y. \n \b Output: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] for k = 0 , ... , \a d -is the partial derivative of H( y , x , w , u , ... ) with respect to +is the partial derivative of H( y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Output: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] -for k = 0 , ... , \a d -is the partial derivative of H( y , x , w , u , ... ) with respect to +for k = 0 , ... , \a d +is the partial derivative of H( y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for y. \n \b Output: \a partial [ \a ( i_z - j ) * \a nc_partial + k ] -for j = 0 , 1 , 2 and for k = 0 , ... , \a d +for j = 0 , 1 , 2 and for k = 0 , ... , \a d may be used as work space; i.e., may change in an unspecified manner. \par Checked Assumptions @@ -1287,7 +1287,7 @@ size_t i_z , addr_t* arg , const Base* parameter , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -1304,7 +1304,7 @@ It is also given the reverse mode dependence of G on z. In addition, it is given the revese mode Hessian sparsity for the quanity of interest G(z , y , ... ) -and it uses them to compute the sparsity patterns for +and it uses them to compute the sparsity patterns for \verbatim H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] \endverbatim @@ -1314,28 +1314,28 @@ \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in sparsity corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in sparsity corresponding to z. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in sparsity corresponding to x. \param rev_jacobian -\a rev_jacobian[i_z] -is all false (true) if the Jacobian of G with respect to z must be zero +\a rev_jacobian[i_z] +is all false (true) if the Jacobian of G with respect to z must be zero (may be non-zero). \n \n -\a rev_jacobian[i_x] -is all false (true) if the Jacobian with respect to x must be zero +\a rev_jacobian[i_x] +is all false (true) if the Jacobian with respect to x must be zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \param for_jac_sparsity The set with index \a i_x in for_jac_sparsity -is the forward mode Jacobian sparsity pattern for the variable x. +is the forward mode Jacobian sparsity pattern for the variable x. \param rev_hes_sparsity The set with index \a i_z in in \a rev_hes_sparsity @@ -1344,13 +1344,13 @@ \n \n The set with index \a i_x in \a rev_hes_sparsity -is the Hessian sparsity pattern +is the Hessian sparsity pattern where one of the partials derivative is with respect to x. On input, it corresponds to the function G, and on output it corresponds to the function H. \par Checked Assertions: -\li \a i_x < \a i_z +\li \a i_x < \a i_z */ template @@ -1360,7 +1360,7 @@ bool* rev_jacobian , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) -{ +{ // This routine is only for documentaiton, it should not be used CPPAD_ASSERT_UNKNOWN( false ); } @@ -1368,9 +1368,9 @@ /*! Prototype for reverse mode Hessian sparsity binary operators. -This routine is given the sparsity patterns the Hessian +This routine is given the sparsity patterns the Hessian of a function G(z, y, x, ... ) -and it uses them to compute the sparsity patterns for the Hessian of +and it uses them to compute the sparsity patterns for the Hessian of \verbatim H( y, x, w , u , ... ) = G[ z(x,y) , y , x , w , u , ... ] \endverbatim @@ -1380,8 +1380,8 @@ \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in sparsity corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in sparsity corresponding to z. \param arg \a arg[0] @@ -1394,20 +1394,20 @@ i.e. the row index in sparsity patterns corresponding to y. \param jac_reverse -\a jac_reverse[i_z] +\a jac_reverse[i_z] is false (true) if the Jacobian of G with respect to z is always zero (may be non-zero). \n \n -\a jac_reverse[ \a arg[0] ] -is false (true) if the Jacobian with respect to x is always zero +\a jac_reverse[ \a arg[0] ] +is false (true) if the Jacobian with respect to x is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \n \n -\a jac_reverse[ \a arg[1] ] -is false (true) if the Jacobian with respect to y is always zero +\a jac_reverse[ \a arg[1] ] +is false (true) if the Jacobian with respect to y is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. @@ -1421,27 +1421,27 @@ is the forward sparsity pattern for y. \param rev_hes_sparsity -The set wiht index \a i_x in \a rev_hes_sparsity +The set wiht index \a i_x in \a rev_hes_sparsity is the Hessian sparsity pattern for the function G where one of the partial derivatives is with respect to z. \n \n -The set with index \a arg[0] in \a rev_hes_sparsity -is the Hessian sparsity pattern where one of the +The set with index \a arg[0] in \a rev_hes_sparsity +is the Hessian sparsity pattern where one of the partial derivatives is with respect to x. On input, it corresponds to the function G, and on output it correspondst to H. \n \n -The set with index \a arg[1] in \a rev_hes_sparsity -is the Hessian sparsity pattern where one of the +The set with index \a arg[1] in \a rev_hes_sparsity +is the Hessian sparsity pattern where one of the partial derivatives is with respect to y. On input, it corresponds to the function G, and on output it correspondst to H. \par Checked Assertions: -\li \a arg[0] < \a i_z -\li \a arg[1] < \a i_z +\li \a arg[0] < \a i_z +\li \a arg[1] < \a i_z */ template inline void reverse_sparse_hessian_binary_op( @@ -1450,7 +1450,7 @@ bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) -{ +{ // This routine is only for documentaiton, it should not be used CPPAD_ASSERT_UNKNOWN( false ); } diff -Nru cppad-2015.00.00.9/cppad/local/recorder.hpp cppad-2016.00.00.1/cppad/local/recorder.hpp --- cppad-2015.00.00.9/cppad/local/recorder.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/recorder.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: recorder.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_RECORDER_INCLUDED -# define CPPAD_RECORDER_INCLUDED +// $Id: recorder.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_RECORDER_HPP +# define CPPAD_RECORDER_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -33,6 +33,10 @@ friend class player; private: + /// operator index at which to abort recording with an error + /// (do not abort when zero) + size_t abort_op_index_; + /// offset for this thread in the static hash table const size_t thread_offset_; @@ -60,7 +64,7 @@ // ---------------------- Public Functions ----------------------------------- public: /// Default constructor - recorder(void) : + recorder(void) : thread_offset_( thread_alloc::thread_num() * CPPAD_HASH_TABLE_SIZE ) , num_var_rec_(0) , num_load_op_rec_(0) , @@ -69,7 +73,17 @@ op_arg_rec_( std::numeric_limits::max() ) , par_rec_( std::numeric_limits::max() ) , text_rec_( std::numeric_limits::max() ) - { } + { + abort_op_index_ = 0; + } + + /// Set the abort index + void set_abort_op_index(size_t abort_op_index) + { abort_op_index_ = abort_op_index; } + + /// Get the abort index + size_t get_abort_op_index(void) + { return abort_op_index_; } /// Destructor ~recorder(void) @@ -78,7 +92,7 @@ /*! Frees all information in recording. - Frees the operation sequence store in this recording + Frees the operation sequence store in this recording (the operation sequence is empty after this operation). The buffers used to store the current recording are returned to the system (so as to conserve on memory). @@ -101,13 +115,13 @@ /// Find or add a parameter to the current vector of parameters. inline size_t PutPar(const Base &par); /// Put one operation argument index in the recording - inline void PutArg(addr_t arg0); + inline void PutArg(addr_t arg0); /// Put two operation argument index in the recording - inline void PutArg(addr_t arg0, addr_t arg1); + inline void PutArg(addr_t arg0, addr_t arg1); /// Put three operation argument index in the recording - inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2); + inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2); /// Put four operation argument index in the recording - inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3); + inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3); /// Put five operation argument index in the recording inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, addr_t arg4); @@ -136,9 +150,9 @@ size_t num_op_rec(void) const { return op_rec_.size(); } - /// Approximate amount of memory used by the recording + /// Approximate amount of memory used by the recording size_t Memory(void) const - { return op_rec_.capacity() * sizeof(CPPAD_OP_CODE_TYPE) + { return op_rec_.capacity() * sizeof(CPPAD_OP_CODE_TYPE) + vecad_ind_rec_.capacity() * sizeof(size_t) + op_arg_rec_.capacity() * sizeof(addr_t) + par_rec_.capacity() * sizeof(Base) @@ -150,7 +164,7 @@ Put next operator in the operation sequence. This sets the op code for the next operation in this recording. -This call must be followed by putting the corresponding +This call must be followed by putting the corresponding \verbatim NumArg(op) \endverbatim @@ -161,8 +175,8 @@ recorded (which must not be LdpOp or LdvOp). \return -The return value is the index of the primary (last) variable -corresponding to the result of this operation. +The return value is the index of the primary (last) variable +corresponding to the result of this operation. The number of variables corresponding to the operation is given by \verbatim NumRes(op) @@ -176,6 +190,10 @@ template inline size_t recorder::PutOp(OpCode op) { size_t i = op_rec_.extend(1); + CPPAD_ASSERT_KNOWN( + (abort_op_index_ == 0) || (abort_op_index_ != i), + "Operator index equals abort_op_index in Independent" + ); op_rec_[i] = static_cast(op); CPPAD_ASSERT_UNKNOWN( op_rec_.size() == i + 1 ); CPPAD_ASSERT_UNKNOWN( (op != LdpOp) & (op != LdvOp) ); @@ -191,7 +209,7 @@ Put next LdpOp or LdvOp operator in operation sequence (special cases). This sets the op code for the next operation in this recording. -This call must be followed by putting the corresponding +This call must be followed by putting the corresponding \verbatim NumArg(op) \endverbatim @@ -202,8 +220,8 @@ recorded (which must be LdpOp or LdvOp). \return -The return value is the index of the primary (last) variable -corresponding to the result of this operation. +The return value is the index of the primary (last) variable +corresponding to the result of this operation. The number of variables corresponding to the operation is given by \verbatim NumRes(op) @@ -216,13 +234,18 @@ and after each call to Erase. \par num_load_op_rec() -The return value for num_load_op_rec() +The return value for num_load_op_rec() increases by one after each call to this function (and starts at zero after the default constructor or Erase). */ template inline size_t recorder::PutLoadOp(OpCode op) { size_t i = op_rec_.extend(1); + CPPAD_ASSERT_KNOWN( + (abort_op_index_ == 0) || (abort_op_index_ != i), + "This is the abort operator index specified by " + "Independent(x, abort_op_index)." + ); op_rec_[i] = static_cast(op); CPPAD_ASSERT_UNKNOWN( op_rec_.size() == i + 1 ); CPPAD_ASSERT_UNKNOWN( (op == LdpOp) | (op == LdvOp) ); @@ -281,10 +304,10 @@ size_t i; size_t code; - CPPAD_ASSERT_UNKNOWN( + CPPAD_ASSERT_UNKNOWN( thread_offset_ / CPPAD_HASH_TABLE_SIZE - == - thread_alloc::thread_num() + == + thread_alloc::thread_num() ); // get hash code for this value @@ -295,7 +318,7 @@ i = hash_table[code + thread_offset_]; if( i < par_rec_.size() && IdenticalEqualPar(par_rec_[i], par) ) return i; - + // place a new value in the table i = par_rec_.extend(1); par_rec_[i] = par; @@ -323,7 +346,7 @@ places the values passed to PutArg at the current end of the operation argument indices for the recording. \a arg0 comes before \a arg1, etc. -The proper number of operation argument indices +The proper number of operation argument indices corresponding to the operation code op is given by \verbatim NumArg(op) @@ -342,11 +365,11 @@ \param arg0 The operation argument index -\copydetails prototype_put_arg +\copydetails prototype_put_arg */ template inline void recorder::PutArg(addr_t arg0) -{ +{ size_t i = op_arg_rec_.extend(1); op_arg_rec_[i] = static_cast( arg0 ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.size() == i + 1 ); @@ -360,11 +383,11 @@ \param arg1 Second operation argument index. -\copydetails prototype_put_arg +\copydetails prototype_put_arg */ template inline void recorder::PutArg(addr_t arg0, addr_t arg1) -{ +{ size_t i = op_arg_rec_.extend(2); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i] = static_cast( arg1 ); @@ -382,11 +405,11 @@ \param arg2 Third operation argument index. -\copydetails prototype_put_arg +\copydetails prototype_put_arg */ template inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2) -{ +{ size_t i = op_arg_rec_.extend(3); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i++] = static_cast( arg1 ); @@ -408,12 +431,12 @@ \param arg3 Fourth operation argument index. -\copydetails prototype_put_arg +\copydetails prototype_put_arg */ template inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3) -{ +{ size_t i = op_arg_rec_.extend(4); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i++] = static_cast( arg1 ); @@ -440,12 +463,12 @@ \param arg4 Fifth operation argument index. -\copydetails prototype_put_arg +\copydetails prototype_put_arg */ template inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, addr_t arg4) -{ +{ size_t i = op_arg_rec_.extend(5); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i++] = static_cast( arg1 ); @@ -476,12 +499,12 @@ \param arg5 Sixth operation argument index. -\copydetails prototype_put_arg +\copydetails prototype_put_arg */ template -inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, +inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, addr_t arg4, addr_t arg5) -{ +{ size_t i = op_arg_rec_.extend(6); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i++] = static_cast( arg1 ); @@ -504,7 +527,7 @@ */ template inline size_t recorder::ReserveArg(size_t n_arg) -{ +{ size_t i = op_arg_rec_.extend(n_arg); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.size() == i + n_arg ); return i; @@ -512,7 +535,7 @@ /*! \brief -Replace an argument value in the recording +Replace an argument value in the recording (intended to fill in reserved values). \param i_arg @@ -544,12 +567,12 @@ size_t n = 0; while( text[n] != '\0' ) n++; - CPPAD_ASSERT_UNKNOWN( n <= 1000 ); + CPPAD_ASSERT_UNKNOWN( n <= 1000 ); n++; CPPAD_ASSERT_UNKNOWN( text[n-1] == '\0' ); // copy text including terminating '\0' - size_t i = text_rec_.extend(n); + size_t i = text_rec_.extend(n); size_t j; for(j = 0; j < n; j++) text_rec_[i + j] = text[j]; diff -Nru cppad-2015.00.00.9/cppad/local/reverse.hpp cppad-2016.00.00.1/cppad/local/reverse.hpp --- cppad-2015.00.00.9/cppad/local/reverse.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/reverse.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: reverse.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_REVERSE_INCLUDED -# define CPPAD_REVERSE_INCLUDED +// $Id: reverse.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_REVERSE_HPP +# define CPPAD_REVERSE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,28 +26,28 @@ /*! Use reverse mode to compute derivative of forward mode Taylor coefficients. -The function -\f$ X : {\rm R} \times {\rm R}^{n \times q} \rightarrow {\rm R} \f$ +The function +\f$ X : {\rm R} \times {\rm R}^{n \times q} \rightarrow {\rm R} \f$ is defined by \f[ X(t , u) = \sum_{k=0}^{q-1} u^{(k)} t^k \f] -The function -\f$ Y : {\rm R} \times {\rm R}^{n \times q} \rightarrow {\rm R} \f$ +The function +\f$ Y : {\rm R} \times {\rm R}^{n \times q} \rightarrow {\rm R} \f$ is defined by \f[ Y(t , u) = F[ X(t, u) ] \f] -The function +The function \f$ W : {\rm R}^{n \times q} \rightarrow {\rm R} \f$ is defined by \f[ -W(u) = \sum_{k=0}^{q-1} ( w^{(k)} )^{\rm T} +W(u) = \sum_{k=0}^{q-1} ( w^{(k)} )^{\rm T} \frac{1}{k !} \frac{ \partial^k } { t^k } Y(0, u) \f] \tparam Base base type for the operator; i.e., this operation sequence was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \tparam VectorBase @@ -79,7 +79,7 @@ Is a vector \f$ dw \f$ such that for \f$ j = 0 , \ldots , n-1 \f$ and \f$ k = 0 , \ldots , q-1 \f$ -\f[ +\f[ dw[ j * q + k ] = W^{(1)} ( x )_{j,k} \f] where the matrix \f$ x \f$ is the value for \f$ u \f$ @@ -89,7 +89,7 @@ */ template template -VectorBase ADFun::Reverse(size_t q, const VectorBase &w) +VectorBase ADFun::Reverse(size_t q, const VectorBase &w) { // constants const Base zero(0); @@ -106,8 +106,8 @@ Partial.extend(num_var_tape_ * q); // update maximum memory requirement - // memoryMax = std::max( memoryMax, - // Memory() + num_var_tape_ * q * sizeof(Base) + // memoryMax = std::max( memoryMax, + // Memory() + num_var_tape_ * q * sizeof(Base) // ); // check VectorBase is Simple Vector class with Base type elements @@ -121,12 +121,12 @@ CPPAD_ASSERT_KNOWN( q > 0, "The first argument to Reverse must be greater than zero." - ); + ); CPPAD_ASSERT_KNOWN( num_order_taylor_ >= q, "Less that q taylor_ coefficients are currently stored" " in this ADFun object." - ); + ); // special case where multiple forward directions have been computed, // but we are only using the one direction zero order results if( (q == 1) & (num_direction_taylor_ > 1) ) @@ -179,15 +179,15 @@ for(j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] < num_var_tape_ ); - // independent variable taddr equals its operator taddr + // independent variable taddr equals its operator taddr CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == InvOp ); - // by the Reverse Identity Theorem + // by the Reverse Identity Theorem // partial of y^{(k)} w.r.t. u^{(0)} is equal to // partial of y^{(q-1)} w.r.t. u^{(q - 1 - k)} if( size_t(w.size()) == m ) { for(k = 0; k < q; k++) - value[j * q + k ] = + value[j * q + k ] = Partial[ind_taddr_[j] * q + q - 1 - k]; } else @@ -203,7 +203,7 @@ return value; } - + } // END_CPPAD_NAMESPACE # endif diff -Nru cppad-2015.00.00.9/cppad/local/reverse_sweep.hpp cppad-2016.00.00.1/cppad/local/reverse_sweep.hpp --- cppad-2015.00.00.9/cppad/local/reverse_sweep.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/reverse_sweep.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: reverse_sweep.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_REVERSE_SWEEP_INCLUDED -# define CPPAD_REVERSE_SWEEP_INCLUDED +// $Id: reverse_sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_REVERSE_SWEEP_HPP +# define CPPAD_REVERSE_SWEEP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -31,7 +31,7 @@ \code user_ok = user_atom->reverse \endcode -This maco is undefined at the end of this file to facillitate is +This maco is undefined at the end of this file to facillitate is use with a different definition in other files. */ # ifdef NDEBUG @@ -42,7 +42,7 @@ /*! \def CPPAD_REVERSE_SWEEP_TRACE -This value is either zero or one. +This value is either zero or one. Zero is the normal operational value. If it is one, a trace of every reverse_sweep computation is printed. */ @@ -53,11 +53,11 @@ \tparam Base base type for the operator; i.e., this operation sequence was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \param d -is the highest order Taylor coefficients that +is the highest order Taylor coefficients that we are computing the derivative of. \param n @@ -81,27 +81,27 @@ f.Forward(k, x_k) -We define +We define \f$ X : {\bf R}^{n \times d} \rightarrow {\bf R}^n \f$ by \f[ X(t, u) = u^{(0)} + u^{(1)} t + \cdots + u^{(d)} t^d \f] -We define +We define \f$ Y : {\bf R}^{n \times d} \rightarrow {\bf R}^m \f$ by \f[ Y(t, u) = F[ X(t, u) ] \f] -We define the function +We define the function \f$ W : {\bf R}^{n \times d} \rightarrow {\bf R} \f$ by \f[ -W(u) -= -\sum_{k=0}^{d} ( w^{(k)} )^{\rm T} +W(u) += +\sum_{k=0}^{d} ( w^{(k)} )^{\rm T} \frac{1}{k !} \frac{\partial^k}{\partial t^k} Y(0, u) \f] (The matrix \f$ w \in {\bf R}^m \f$, is defined below under the heading Partial.) -Note that the scale factor 1 / k converts +Note that the scale factor 1 / k converts the k-th partial derivative to the k-th order Taylor coefficient. This routine computes the derivative of \f$ W(u) \f$ with respect to all the Taylor coefficients @@ -112,7 +112,7 @@ There is an exception to this, while palying back the tape the object \a play holds information about the current location -with in the tape and this changes during palyback. +with in the tape and this changes during palyback. \param J Is the number of columns in the coefficient matrix \a Taylor. @@ -121,7 +121,7 @@ \param Taylor For i = 1 , ... , \a numvar, and for k = 0 , ... , \a d, \a Taylor [ i * J + k ] -is the k-th order Taylor coefficient corresponding to +is the k-th order Taylor coefficient corresponding to variable with index i on the tape. The value \f$ u \in {\bf R}^{n \times d} \f$, at which the derivative is computed, @@ -137,22 +137,22 @@ \b Input: The last \f$ m \f$ rows of \a Partial are inputs. The matrix \f$ w \f$, used to define \f$ W(u) \f$, -is specified by these rows. -For i = 0 , ... , m - 1, +is specified by these rows. +For i = 0 , ... , m - 1, for k = 0 , ... , d, Partial [ (numvar - m + i ) * K + k ] = w[i,k]. \n \n \b Temporary: -For i = n+1 , ... , \a numvar - 1 and for k = 0 , ... , d, +For i = n+1 , ... , \a numvar - 1 and for k = 0 , ... , d, the value of \a Partial [ i * K + k ] is used for temporary work space -and its output value is not defined. +and its output value is not defined. \n \n \b Output: -For j = 1 , ... , n and for k = 0 , ... , d, -\a Partial [ j * K + k ] -is the partial derivative of \f$ W( u ) \f$ with +For j = 1 , ... , n and for k = 0 , ... , d, +\a Partial [ j * K + k ] +is the partial derivative of \f$ W( u ) \f$ with respect to \f$ u_j^{(k)} \f$. \param cskip_op @@ -169,7 +169,7 @@ \par Assumptions The first operator on the tape is a BeginOp, -and the next \a n operators are InvOp operations for the +and the next \a n operators are InvOp operations for the corresponding independent variables. */ template @@ -253,7 +253,7 @@ CPPAD_ASSERT_UNKNOWN( op != CSkipOp ); // if( op == CSkipOp ) // { // CSkip has a variable number of arguments - // play->reverse_cskip(op, arg, i_op, i_var); + // play->reverse_cskip(op, arg, i_op, i_var); // } CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); play->reverse_next(op, arg, i_op, i_var); @@ -273,19 +273,19 @@ const Base* Z_tmp = Taylor + i_var * J; const Base* pZ_tmp = Partial + i_var * K; printOp( - std::cout, + std::cout, play, i_op, i_tmp, - op, + op, arg ); if( NumRes(op) > 0 && op != BeginOp ) printOpResult( - std::cout, - d + 1, - Z_tmp, - d + 1, - pZ_tmp + std::cout, + d + 1, + Z_tmp, + d + 1, + pZ_tmp ); std::cout << std::endl; # endif @@ -299,6 +299,26 @@ break; // -------------------------------------------------- + case AcosOp: + // sqrt(1 - x * x), acos(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_acos_op( + d, i_var, arg[0], J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case AcoshOp: + // sqrt(x * x - 1), acosh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_acosh_op( + d, i_var, arg[0], J, Taylor, K, Partial + ); + break; +# endif + // -------------------------------------------------- + case AddvvOp: reverse_addvv_op( d, i_var, arg, parameter, J, Taylor, K, Partial @@ -314,26 +334,28 @@ break; // -------------------------------------------------- - case AcosOp: - // sqrt(1 - x * x), acos(x) + case AsinOp: + // sqrt(1 - x * x), asin(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); - reverse_acos_op( + reverse_asin_op( d, i_var, arg[0], J, Taylor, K, Partial ); break; // -------------------------------------------------- - case AsinOp: - // sqrt(1 - x * x), asin(x) +# if CPPAD_USE_CPLUSPLUS_2011 + case AsinhOp: + // sqrt(1 + x * x), asinh(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); - reverse_asin_op( + reverse_asinh_op( d, i_var, arg[0], J, Taylor, K, Partial ); break; +# endif // -------------------------------------------------- case AtanOp: - // 1 + x * x, atan(x) + // 1 + x * x, atan(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); reverse_atan_op( d, i_var, arg[0], J, Taylor, K, Partial @@ -341,6 +363,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AtanhOp: + // 1 - x * x, atanh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_atanh_op( + d, i_var, arg[0], J, Taylor, K, Partial + ); + break; +# endif + // ------------------------------------------------- + case BeginOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); more_operators = false; @@ -373,23 +406,19 @@ case CExpOp: reverse_cond_op( - d, - i_var, - arg, - num_par, - parameter, - J, + d, + i_var, + arg, + num_par, + parameter, + J, Taylor, - K, + K, Partial ); break; // -------------------------------------------------- - case ComOp: - break; - // -------------------------------------------------- - case CosOp: CPPAD_ASSERT_UNKNOWN( i_var < numvar ); reverse_cos_op( @@ -408,7 +437,7 @@ case DisOp: // Derivative of discrete operation is zero so no - // contribution passes through this operation. + // contribution passes through this operation. break; // -------------------------------------------------- @@ -435,7 +464,7 @@ break; // -------------------------------------------------- -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 case ErfOp: reverse_erf_op( d, i_var, arg, parameter, J, Taylor, K, Partial @@ -450,23 +479,46 @@ ); break; // -------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + reverse_expm1_op( + d, i_var, arg[0], J, Taylor, K, Partial + ); + break; +# endif + // -------------------------------------------------- + + case InvOp: + break; + // -------------------------------------------------- + case LdpOp: reverse_load_op( - op, d, i_var, arg, J, Taylor, K, Partial, var_by_load_op.data() + op, d, i_var, arg, J, Taylor, K, Partial, var_by_load_op.data() ); break; // ------------------------------------------------- case LdvOp: reverse_load_op( - op, d, i_var, arg, J, Taylor, K, Partial, var_by_load_op.data() + op, d, i_var, arg, J, Taylor, K, Partial, var_by_load_op.data() ); break; - // ------------------------------------------------- + // -------------------------------------------------- - case InvOp: + case EqpvOp: + case EqvvOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NepvOp: + case NevvOp: break; - // -------------------------------------------------- + // ------------------------------------------------- case LogOp: reverse_log_op( @@ -475,11 +527,13 @@ break; // -------------------------------------------------- - case MulvvOp: - reverse_mulvv_op( - d, i_var, arg, parameter, J, Taylor, K, Partial +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + reverse_log1p_op( + d, i_var, arg[0], J, Taylor, K, Partial ); break; +# endif // -------------------------------------------------- case MulpvOp: @@ -490,6 +544,13 @@ break; // -------------------------------------------------- + case MulvvOp: + reverse_mulvv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + case ParOp: break; // -------------------------------------------------- @@ -620,7 +681,7 @@ user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); @@ -654,7 +715,7 @@ ); # ifndef NDEBUG if( ! user_ok ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.reverse: returned false"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); @@ -680,7 +741,7 @@ user_tx[user_j * user_k1 + 0] = parameter[ arg[0]]; for(ell = 1; ell < user_k1; ell++) user_tx[user_j * user_k1 + ell] = Base(0.); - + if( user_j == 0 ) user_state = user_start; break; @@ -732,6 +793,29 @@ break; // ------------------------------------------------------------ + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + reverse_zmulpv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + reverse_zmulvp_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case ZmulvvOp: + reverse_zmulvv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + default: CPPAD_ASSERT_UNKNOWN(false); } diff -Nru cppad-2015.00.00.9/cppad/local/rev_hes_sweep.hpp cppad-2016.00.00.1/cppad/local/rev_hes_sweep.hpp --- cppad-2015.00.00.9/cppad/local/rev_hes_sweep.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/rev_hes_sweep.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: rev_hes_sweep.hpp 3639 2015-02-11 02:01:35Z bradbell $ */ -# ifndef CPPAD_REV_HES_SWEEP_INCLUDED -# define CPPAD_REV_HES_SWEEP_INCLUDED +// $Id: rev_hes_sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_REV_HES_SWEEP_HPP +# define CPPAD_REV_HES_SWEEP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,7 +21,7 @@ /*! \def CPPAD_REV_HES_SWEEP_TRACE -This value is either zero or one. +This value is either zero or one. Zero is the normal operational value. If it is one, a trace of every rev_hes_sweep computation is printed. */ @@ -30,12 +30,12 @@ /*! Given the forward Jacobian sparsity pattern for all the variables, and the reverse Jacobian sparsity pattern for the dependent variables, -RevHesSweep computes the Hessian sparsity pattern for all the independent +RevHesSweep computes the Hessian sparsity pattern for all the independent variables. \tparam Base base type for the operator; i.e., this operation sequence was recorded -using AD< \a Base > and computations by this routine are done using type +using AD< \a Base > and computations by this routine are done using type \a Base. \tparam Vector_set @@ -48,7 +48,7 @@ \param numvar is the total number of variables on the tape; i.e., \a play->num_var_rec(). -This is also the number of rows in the entire sparsity pattern +This is also the number of rows in the entire sparsity pattern \a rev_hes_sparse. \param play @@ -65,17 +65,17 @@ with in the tape and this changes during playback. \param for_jac_sparse -For i = 0 , ... , \a numvar - 1, +For i = 0 , ... , \a numvar - 1, (for all the variables on the tape), the forward Jacobian sparsity pattern for the variable with index i corresponds to the set with index i in \a for_jac_sparse. \param RevJac \b Input: -For i = 0, ... , \a numvar - 1 +For i = 0, ... , \a numvar - 1 the if the variable with index i on the tape is an dependent variable and included in the Hessian, \a RevJac[ i ] is equal to true, -otherwise it is equal to false. +otherwise it is equal to false. \n \n \b Output: The values in \a RevJac upon return are not specified; i.e., @@ -86,14 +86,14 @@ corresponds to the set with index i in \a rev_hes_sparse. \n \n -\b Input: For i = 0 , ... , \a numvar - 1 +\b Input: For i = 0 , ... , \a numvar - 1 the reverse Hessian sparsity pattern for the variable with index i is empty. \n \n \b Output: For j = 1 , ... , \a n, -the reverse Hessian sparsity pattern for the independent dependent variable +the reverse Hessian sparsity pattern for the independent dependent variable with index (j-1) is given by the set with index j -in \a rev_hes_sparse. +in \a rev_hes_sparse. The values in the rest of \a rev_hes_sparse are not specified; i.e., they are used for temporary work space. */ @@ -130,12 +130,12 @@ CPPAD_ASSERT_UNKNOWN( for_jac_sparse.end() == limit ); // check number of sets match - CPPAD_ASSERT_UNKNOWN( + CPPAD_ASSERT_UNKNOWN( for_jac_sparse.n_set() == rev_hes_sparse.n_set() ); // vecad_sparsity contains a sparsity pattern for each VecAD object. - // vecad_ind maps a VecAD index (beginning of the VecAD object) + // vecad_ind maps a VecAD index (beginning of the VecAD object) // to the index for the corresponding set in vecad_sparsity. size_t num_vecad_ind = play->num_vec_ind_rec(); size_t num_vecad_vec = play->num_vecad_vec_rec(); @@ -152,13 +152,13 @@ { // length of this VecAD length = play->GetVecInd(j); // set vecad_ind to proper index for this VecAD - vecad_ind[j] = i; + vecad_ind[j] = i; // make all other values for this vector invalid for(k = 1; k <= length; k++) vecad_ind[j+k] = num_vecad_vec; // start of next VecAD j += length + 1; - // initialize this vector's reverse jacobian value + // initialize this vector's reverse jacobian value vecad_jac[i] = false; } CPPAD_ASSERT_UNKNOWN( j == play->num_vec_ind_rec() ); @@ -177,6 +177,10 @@ vector bool_u; // bool reverse Hessian sparsity for y vector bool_v; // bool reverse Hessian sparsity for x // + vectorBool pack_r; // pack forward Jacobian sparsity for x + vectorBool pack_u; // pack reverse Hessian sparsity for y + vectorBool pack_v; // pack reverse Hessian sparsity for x + // vector user_vx; // which components of x are variables vector user_s; // reverse Jacobian sparsity for y vector user_t; // reverse Jacobian sparsity for x @@ -189,7 +193,9 @@ size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator - bool user_bool = false; // use bool or set sparsity ? + bool user_pack = false; // sparsity pattern type is pack + bool user_bool = false; // sparsity pattern type is bool + bool user_set = false; // sparsity pattern type is set # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif @@ -253,6 +259,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AcoshOp: + // sqrt(x * x - 1), acosh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse + ); + break; +# endif + // ------------------------------------------------- + case AsinOp: // sqrt(1 - x * x), asin(x) CPPAD_ASSERT_NARG_NRES(op, 1, 2) @@ -262,6 +279,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AsinhOp: + // sqrt(1 + x * x), asinh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse + ); + break; +# endif + // ------------------------------------------------- + case AtanOp: // 1 + x * x, atan(x) CPPAD_ASSERT_NARG_NRES(op, 1, 2) @@ -271,6 +299,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AtanhOp: + // 1 - x * x, atanh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse + ); + break; +# endif + // ------------------------------------------------- + case BeginOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1) more_operators = false; @@ -303,12 +342,6 @@ break; // --------------------------------------------------- - case ComOp: - CPPAD_ASSERT_NARG_NRES(op, 4, 0) - CPPAD_ASSERT_UNKNOWN( arg[1] > 1 ); - break; - // -------------------------------------------------- - case CosOp: // sin(x), cos(x) CPPAD_ASSERT_NARG_NRES(op, 1, 2) @@ -358,7 +391,9 @@ // ------------------------------------------------- case ErfOp: - CPPAD_ASSERT_NARG_NRES(op, 3, 5) + // arg[1] is always the parameter 0 + // arg[0] is always the parameter 2 / sqrt(pi) + CPPAD_ASSERT_NARG_NRES(op, 3, 5); reverse_sparse_hessian_nonlinear_unary_op( i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse ); @@ -373,6 +408,16 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + CPPAD_ASSERT_NARG_NRES(op, 1, 1) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse + ); + break; +# endif + // ------------------------------------------------- + case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1) // Z is already defined @@ -409,6 +454,20 @@ break; // ------------------------------------------------- + case EqpvOp: + case EqvvOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NepvOp: + case NevvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + break; + // ------------------------------------------------- + case LogOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1) reverse_sparse_hessian_nonlinear_unary_op( @@ -417,12 +476,14 @@ break; // ------------------------------------------------- - case MulvvOp: - CPPAD_ASSERT_NARG_NRES(op, 2, 1) - reverse_sparse_hessian_mul_op( - i_var, arg, RevJac, for_jac_sparse, rev_hes_sparse +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse ); break; +# endif // ------------------------------------------------- case MulpvOp: @@ -433,6 +494,14 @@ break; // ------------------------------------------------- + case MulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_mul_op( + i_var, arg, RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + case ParOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1) @@ -594,14 +663,19 @@ user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif + user_pack = user_atom->sparsity() == + atomic_base::pack_sparsity_enum; user_bool = user_atom->sparsity() == atomic_base::bool_sparsity_enum; + user_set = user_atom->sparsity() == + atomic_base::set_sparsity_enum; + CPPAD_ASSERT_UNKNOWN( user_pack || user_bool || user_set ); user_ix.resize(user_n); user_vx.resize(user_n); user_s.resize(user_m); @@ -612,6 +686,24 @@ user_s[i] = false; for(i = 0; i < user_n; i++) user_t[i] = false; + if( user_pack ) + { pack_r.resize(user_n * user_q); + pack_u.resize(user_m * user_q); + pack_v.resize(user_n * user_q); + // simpler to initialize all patterns as empty + for(i = 0; i < user_m; i++) + { + for(j = 0; j < user_q; j++) + pack_u[ i * user_q + j] = false; + } + for(i = 0; i < user_n; i++) + { + for(j = 0; j < user_q; j++) + { pack_r[ i * user_q + j] = false; + pack_v[ i * user_q + j] = false; + } + } + } if( user_bool ) { bool_r.resize(user_n * user_q); bool_u.resize(user_m * user_q); @@ -630,7 +722,7 @@ } } } - else + if( user_set ) { set_r.resize(user_n); set_u.resize(user_m); set_v.resize(user_n); @@ -656,27 +748,41 @@ // call users function for this operation user_atom->set_id(user_id); # ifdef NDEBUG - if( user_bool ) + if( user_pack ) + user_atom->rev_sparse_hes(user_vx, + user_s, user_t, user_q, pack_r, pack_u, pack_v + ); + if( user_bool ) user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, bool_r, bool_u, bool_v ); - else + if( user_set ) user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, set_r, set_u, set_v ); # else - if( user_bool ) + if( user_pack ) + user_ok = user_atom->rev_sparse_hes(user_vx, + user_s, user_t, user_q, pack_r, pack_u, pack_v + ); + if( user_bool ) user_ok = user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, bool_r, bool_u, bool_v ); - else + if( user_set ) user_ok = user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, set_r, set_u, set_v ); if( ! user_ok ) - { std::string msg = + { std::string msg = atomic_base::class_name(user_index) - + ": atomic_base.rev_sparse_hes: returned false"; + + ": atomic_base.rev_sparse_hes: returned false\n"; + if( user_pack ) + msg += "sparsity = pack_sparsity_enum"; + if( user_bool ) + msg += "sparsity = bool_sparsity_enum"; + if( user_set ) + msg += "sparsity = set_sparsity_enum"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif @@ -685,13 +791,19 @@ size_t i_x = user_ix[i]; if( user_t[i] ) RevJac[i_x] = true; + if( user_pack ) + { + for(j = 0; j < user_q; j++) + if( pack_v[ i * user_q + j ] ) + rev_hes_sparse.add_element(i_x, j); + } if( user_bool ) { for(j = 0; j < user_q; j++) if( bool_v[ i * user_q + j ] ) rev_hes_sparse.add_element(i_x, j); } - else + if( user_set ) { set_itr = set_v[i].begin(); set_end = set_v[i].end(); @@ -728,9 +840,11 @@ for_jac_sparse.begin(arg[0]); i = for_jac_sparse.next_element(); while( i < user_q ) - { if( user_bool ) + { if( user_pack ) + pack_r[ user_j * user_q + i ] = true; + if( user_bool ) bool_r[ user_j * user_q + i ] = true; - else + if( user_set ) set_r[user_j].insert(i); i = for_jac_sparse.next_element(); } @@ -761,15 +875,41 @@ rev_hes_sparse.begin(i_var); j = rev_hes_sparse.next_element(); while( j < user_q ) - { if( user_bool ) + { if( user_pack ) + pack_u[user_i * user_q + j] = true; + if( user_bool ) bool_u[user_i * user_q + j] = true; - else + if( user_set ) set_u[user_i].insert(j); j = rev_hes_sparse.next_element(); } if( user_i == 0 ) user_state = user_arg; break; + // ------------------------------------------------- + + case ZmulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, arg[1], RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case ZmulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_mul_op( + i_var, arg, RevJac, for_jac_sparse, rev_hes_sparse + ); + break; // ------------------------------------------------- @@ -794,20 +934,20 @@ j = rev_hes_sparse.next_element(); } printOp( - std::cout, + std::cout, play, i_op, i_var, - op, + op, arg ); // should also print RevJac[i_var], but printOpResult does not // yet allow for this if( NumRes(op) > 0 && op != BeginOp ) printOpResult( - std::cout, - 1, - &zf_value, - 1, + std::cout, + 1, + &zf_value, + 1, &zh_value ); std::cout << std::endl; diff -Nru cppad-2015.00.00.9/cppad/local/rev_jac_sweep.hpp cppad-2016.00.00.1/cppad/local/rev_jac_sweep.hpp --- cppad-2015.00.00.9/cppad/local/rev_jac_sweep.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/rev_jac_sweep.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rev_jac_sweep.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_REV_JAC_SWEEP_INCLUDED -# define CPPAD_REV_JAC_SWEEP_INCLUDED +// $Id: rev_jac_sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_REV_JAC_SWEEP_HPP +# define CPPAD_REV_JAC_SWEEP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -60,7 +60,7 @@ is the type used for vectors of sets. It can be either \c sparse_pack, \c sparse_set, or \c sparse_list. -\param nz_compare +\param dependency Are the derivatives with respect to left and right of the expression below considered to be non-zero: \code @@ -110,7 +110,7 @@ template void RevJacSweep( - bool nz_compare, + bool dependency, size_t n, size_t numvar, player *play, @@ -171,6 +171,9 @@ vector bool_r; // bool sparsity pattern for the argument x vector bool_s; // bool sparisty pattern for the result y // + vectorBool pack_r; // pack sparsity pattern for the argument x + vectorBool pack_s; // pack sparisty pattern for the result y + // const size_t user_q = limit; // maximum element plus one size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator @@ -180,7 +183,9 @@ size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator - bool user_bool = false; // use bool or set sparsity ? + bool user_pack = false; // sparsity pattern type is pack + bool user_bool = false; // sparsity pattern type is bool + bool user_set = false; // sparsity pattern type is set # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif @@ -242,6 +247,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AcoshOp: + // sqrt(x * x - 1), acosh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; +# endif + // ------------------------------------------------- + case AsinOp: // sqrt(1 - x * x), asin(x) CPPAD_ASSERT_NARG_NRES(op, 1, 2); @@ -251,6 +267,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AsinhOp: + // sqrt(1 + x * x), asinh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; +# endif + // ------------------------------------------------- + case AtanOp: // 1 + x * x, atan(x) CPPAD_ASSERT_NARG_NRES(op, 1, 2); @@ -260,6 +287,17 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case AtanhOp: + // 1 - x * x, atanh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; +# endif + // ------------------------------------------------- + case BeginOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); more_operators = false; @@ -287,17 +325,11 @@ case CExpOp: reverse_sparse_jacobian_cond_op( - nz_compare, i_var, arg, num_par, var_sparsity + dependency, i_var, arg, num_par, var_sparsity ); break; // --------------------------------------------------- - case ComOp: - CPPAD_ASSERT_NARG_NRES(op, 4, 0); - CPPAD_ASSERT_UNKNOWN( arg[1] > 1 ); - break; - // -------------------------------------------------- - case CosOp: // sin(x), cos(x) CPPAD_ASSERT_NARG_NRES(op, 1, 2); @@ -318,7 +350,10 @@ case DisOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); - // derivative is identically zero + // derivative is identically zero but dependency is not + if( dependency ) reverse_sparse_jacobian_unary_op( + i_var, arg[1], var_sparsity + ); break; // ------------------------------------------------- @@ -347,7 +382,9 @@ // ------------------------------------------------- case ErfOp: - CPPAD_ASSERT_NARG_NRES(op, 1, 1); + // arg[1] is always the parameter 0 + // arg[0] is always the parameter 2 / sqrt(pi) + CPPAD_ASSERT_NARG_NRES(op, 3, 5); reverse_sparse_jacobian_unary_op( i_var, arg[0], var_sparsity ); @@ -362,6 +399,16 @@ break; // ------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + reverse_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; +# endif + // ------------------------------------------------- + case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); break; @@ -369,6 +416,7 @@ case LdpOp: reverse_sparse_jacobian_load_op( + dependency, op, i_var, arg, @@ -382,6 +430,7 @@ case LdvOp: reverse_sparse_jacobian_load_op( + dependency, op, i_var, arg, @@ -393,6 +442,20 @@ break; // ------------------------------------------------- + case EqpvOp: + case EqvvOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NepvOp: + case NevvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + break; + // ------------------------------------------------- + case LogOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); reverse_sparse_jacobian_unary_op( @@ -401,12 +464,14 @@ break; // ------------------------------------------------- - case MulvvOp: - CPPAD_ASSERT_NARG_NRES(op, 2, 1); - reverse_sparse_jacobian_binary_op( - i_var, arg, var_sparsity +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + reverse_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity ); break; +# endif // ------------------------------------------------- case MulpvOp: @@ -417,6 +482,14 @@ break; // ------------------------------------------------- + case MulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + case ParOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); @@ -447,13 +520,16 @@ // ------------------------------------------------- case PriOp: - CPPAD_ASSERT_NARG_NRES(op, 5, 0); + CPPAD_ASSERT_NARG_NRES(op, 5, 0); break; // ------------------------------------------------- case SignOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); - // derivative is identically zero + // derivative is identically zero but dependency is not + if( dependency ) reverse_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); break; // ------------------------------------------------- @@ -484,13 +560,14 @@ // ------------------------------------------------- case StppOp: - // sparsity cannot proagate through a parameter + // does not affect sparsity or dependency when both are parameters CPPAD_ASSERT_NARG_NRES(op, 3, 0); break; // ------------------------------------------------- case StpvOp: reverse_sparse_jacobian_store_op( + dependency, op, arg, num_vecad_ind, @@ -503,11 +580,22 @@ case StvpOp: CPPAD_ASSERT_NARG_NRES(op, 3, 0); + // storing a parameter only affects dependency + reverse_sparse_jacobian_store_op( + dependency, + op, + arg, + num_vecad_ind, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); break; // ------------------------------------------------- case StvvOp: reverse_sparse_jacobian_store_op( + dependency, op, arg, num_vecad_ind, @@ -578,8 +666,22 @@ CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif + user_pack = user_atom->sparsity() == + atomic_base::pack_sparsity_enum; user_bool = user_atom->sparsity() == atomic_base::bool_sparsity_enum; + user_set = user_atom->sparsity() == + atomic_base::set_sparsity_enum; + CPPAD_ASSERT_UNKNOWN( user_pack || user_bool || user_set ); + if( user_pack ) + { if( pack_r.size() != user_m * user_q ) + pack_r.resize( user_m * user_q ); + if( pack_s.size() != user_n * user_q ) + pack_s.resize( user_n * user_q ); + for(i = 0; i < user_m; i++) + for(j = 0; j < user_q; j++) + pack_r[ i * user_q + j] = false; + } if( user_bool ) { if( bool_r.size() != user_m * user_q ) bool_r.resize( user_m * user_q ); @@ -589,7 +691,7 @@ for(j = 0; j < user_q; j++) bool_r[ i * user_q + j] = false; } - else + if( user_set ) { if(set_r.size() != user_m ) set_r.resize(user_m); if(set_s.size() != user_n ) @@ -611,7 +713,13 @@ if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) - + ": atomic_base.rev_sparse_jac: returned false"; + + ": atomic_base.rev_sparse_jac: returned false\n"; + if( user_pack ) + msg += "sparsity = pack_sparsity_enum"; + if( user_bool ) + msg += "sparsity = bool_sparsity_enum"; + if( user_set ) + msg += "sparsity = set_sparsity_enum"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif @@ -638,18 +746,23 @@ CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); --user_j; - // It might be faster if we add set union to var_sparsity + // 2DO: It might be faster if we add set union to var_sparsity // where one of the sets is not in var_sparsity. + if( user_pack ) + { for(j = 0; j < user_q; j++) + if( pack_s[ user_j * user_q + j ] ) + var_sparsity.add_element(arg[0], j); + } if( user_bool ) { for(j = 0; j < user_q; j++) - if( bool_s[ user_j * user_q + j ] ) - var_sparsity.add_element(arg[0], j); + if( bool_s[ user_j * user_q + j ] ) + var_sparsity.add_element(arg[0], j); } - else + if( user_set ) { set_itr = set_s[user_j].begin(); set_end = set_s[user_j].end(); while( set_itr != set_end ) - var_sparsity.add_element(arg[0], *set_itr++); + var_sparsity.add_element(arg[0], *set_itr++); } if( user_j == 0 ) user_state = user_start; @@ -665,14 +778,12 @@ if( user_i == 0 ) { // call users function for this operation user_atom->set_id(user_id); - if( user_bool) - CPPAD_ATOMIC_CALL( - user_q, bool_r, bool_s - ); - else - CPPAD_ATOMIC_CALL( - user_q, set_r, set_s - ); + if( user_pack ) + CPPAD_ATOMIC_CALL( user_q, pack_r, pack_s); + if( user_bool ) + CPPAD_ATOMIC_CALL( user_q, bool_r, bool_s); + if( user_set ) + CPPAD_ATOMIC_CALL( user_q, set_r, set_s); user_state = user_arg; } break; @@ -685,28 +796,52 @@ var_sparsity.begin(i_var); i = var_sparsity.next_element(); while( i < user_q ) - { if( user_bool ) + { if( user_pack ) + pack_r[ user_i * user_q + i ] = true; + if( user_bool ) bool_r[ user_i * user_q + i ] = true; - else - set_r[user_i].insert(i); + if( user_set ) + set_r[user_i].insert(i); i = var_sparsity.next_element(); } if( user_i == 0 ) { // call users function for this operation user_atom->set_id(user_id); - if( user_bool) - CPPAD_ATOMIC_CALL( - user_q, bool_r, bool_s - ); - else - CPPAD_ATOMIC_CALL( - user_q, set_r, set_s - ); + if( user_pack ) + CPPAD_ATOMIC_CALL( user_q, pack_r, pack_s); + if( user_bool ) + CPPAD_ATOMIC_CALL( user_q, bool_r, bool_s); + if( user_set ) + CPPAD_ATOMIC_CALL( user_q, set_r, set_s); user_state = user_arg; } break; // ------------------------------------------------- + case ZmulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, arg[1], var_sparsity + ); + break; + // ------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, arg[0], var_sparsity + ); + break; + // ------------------------------------------------- + + case ZmulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + default: CPPAD_ASSERT_UNKNOWN(0); } diff -Nru cppad-2015.00.00.9/cppad/local/rev_one.hpp cppad-2016.00.00.1/cppad/local/rev_one.hpp --- cppad-2015.00.00.9/cppad/local/rev_one.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/rev_one.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: rev_one.hpp 2683 2012-12-30 18:17:03Z bradbell $ */ -# ifndef CPPAD_REV_ONE_INCLUDED -# define CPPAD_REV_ONE_INCLUDED +// $Id: rev_one.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_REV_ONE_HPP +# define CPPAD_REV_ONE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,15 +22,10 @@ $$ -$index derivative, first order driver$$ -$index first, order derivative driver$$ -$index driver, first order derivative$$ - -$index easy, derivative$$ -$index driver, easy derivative$$ -$index derivative, easy$$ + $section First Order Derivative: Driver Routine$$ +$mindex derivative easy$$ $head Syntax$$ $icode%dw% = %f%.RevOne(%x%, %i%)%$$ @@ -43,9 +38,9 @@ derivative of $latex F_i$$ with respect to $latex x$$; i.e., $latex \[ dw = -F_i^{(1)} (x) -= \left[ - \D{ F_i }{ x_0 } (x) , \cdots , \D{ F_i }{ x_{n-1} } (x) +F_i^{(1)} (x) += \left[ + \D{ F_i }{ x_0 } (x) , \cdots , \D{ F_i }{ x_{n-1} } (x) \right] \] $$ @@ -63,7 +58,7 @@ const %Vector% &%x% %$$ (see $cref/Vector/RevOne/Vector/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. It specifies @@ -87,9 +82,9 @@ (see $cref/Vector/RevOne/Vector/$$ below) and its size is $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. -The value of $icode dw$$ is the derivative of $latex F_i$$ +The value of $icode dw$$ is the derivative of $latex F_i$$ evaluated at $icode x$$; i.e., -for $latex j = 0 , \ldots , n - 1 $$ +for $latex j = 0 , \ldots , n - 1 $$ $latex \[. dw[ j ] = \D{ F_i }{ x_j } ( x ) \] $$ @@ -103,7 +98,7 @@ $head RevOne Uses Forward$$ After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After a call to $code RevOne$$, the zero order Taylor coefficients correspond to @@ -114,7 +109,7 @@ $children% example/rev_one.cpp %$$ -The routine +The routine $cref/RevOne/rev_one.cpp/$$ is both an example and test. It returns $code true$$, if it succeeds and $code false$$ otherwise. @@ -139,7 +134,7 @@ CPPAD_ASSERT_KNOWN( x.size() == n, "RevOne: Length of x not equal domain dimension for f" - ); + ); CPPAD_ASSERT_KNOWN( i < m, "RevOne: the index i is not less than range dimension for f" diff -Nru cppad-2015.00.00.9/cppad/local/rev_sparse_hes.hpp cppad-2016.00.00.1/cppad/local/rev_sparse_hes.hpp --- cppad-2015.00.00.9/cppad/local/rev_sparse_hes.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/rev_sparse_hes.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: rev_sparse_hes.hpp 3441 2014-12-03 14:46:44Z bradbell $ */ -# ifndef CPPAD_REV_SPARSE_HES_INCLUDED -# define CPPAD_REV_SPARSE_HES_INCLUDED +// $Id: rev_sparse_hes.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_REV_SPARSE_HES_HPP +# define CPPAD_REV_SPARSE_HES_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,14 +27,10 @@ Dep proportional var + cpp $$ -$section Hessian Sparsity Pattern: Reverse Mode$$ - -$index RevSparseHes$$ -$index reverse, sparse Hessian$$ -$index sparse, reverse Hessian$$ -$index pattern, reverse Hessian$$ +$section Hessian Sparsity Pattern: Reverse Mode$$ $head Syntax$$ $icode%h% = %f%.RevSparseHes(%q%, %s%) @@ -45,22 +41,22 @@ $head Purpose$$ We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. -For a fixed matrix $latex R \in \B{R}^{n \times q}$$ +For a fixed matrix $latex R \in \B{R}^{n \times q}$$ and a fixed vector $latex S \in \B{R}^{1 \times m}$$, -we define +we define $latex \[ \begin{array}{rcl} -H(x) +H(x) & = & \partial_x \left[ \partial_u S * F[ x + R * u ] \right]_{u=0} \\ & = & R^\R{T} * (S * F)^{(2)} ( x ) \\ -H(x)^\R{T} +H(x)^\R{T} & = & (S * F)^{(2)} ( x ) * R \end{array} \] $$ Given a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex R$$ and the vector $latex S$$, $code RevSparseHes$$ returns a sparsity pattern for the $latex H(x)$$. @@ -82,7 +78,7 @@ %$$ It specifies the number of columns in $latex R \in \B{R}^{n \times q}$$ and the number of rows in $latex H(x) \in \B{R}^{q \times n}$$. -It must be the same value as in the previous $cref ForSparseJac$$ call +It must be the same value as in the previous $cref ForSparseJac$$ call $codei% %f%.ForSparseJac(%q%, %r%, %r_transpose%) %$$ @@ -104,7 +100,7 @@ %$$ see $cref/r/ForSparseJac/r/$$. The type of the elements of -$cref/VectorSet/RevSparseHes/VectorSet/$$ must be the +$cref/VectorSet/RevSparseHes/VectorSet/$$ must be the same as the type of the elements of $icode r$$. $head s$$ @@ -118,8 +114,8 @@ If it has elements of type $code std::set$$, its size is one and all the elements of $icode%s%[0]%$$ are between zero and $latex m - 1$$. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the vector $icode S$$. $head h$$ @@ -135,8 +131,8 @@ If it has elements of type $code std::set$$, its size is $latex q$$ and all the set elements are between zero and $icode%n%-1%$$ inclusive. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex H(x)$$. $subhead transpose true$$ @@ -145,8 +141,8 @@ If it has elements of type $code std::set$$, its size is $latex n$$ and all the set elements are between zero and $icode%q%-1%$$ inclusive. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex H(x)^\R{T}$$. $head VectorSet$$ @@ -156,7 +152,7 @@ see $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for a discussion of the difference. The type of the elements of -$cref/VectorSet/RevSparseHes/VectorSet/$$ must be the +$cref/VectorSet/RevSparseHes/VectorSet/$$ must be the same as the type of the elements of $icode r$$. $head Entire Sparsity Pattern$$ @@ -166,24 +162,29 @@ $cref/elementary vector/glossary/Elementary Vector/$$; i.e. $latex \[ S_j = \left\{ \begin{array}{ll} - 1 & {\rm if} \; j = k + 1 & {\rm if} \; j = k \\ 0 & {\rm otherwise} -\end{array} \right. +\end{array} \right. \] $$ In this case, -the corresponding value $icode h$$ is a +the corresponding value $icode h$$ is a sparsity pattern for the Hessian matrix $latex F_k^{(2)} (x) \in \B{R}^{n \times n}$$. $head Example$$ $children% example/rev_sparse_hes.cpp + %example/sparsity_sub.cpp %$$ The file $cref rev_sparse_hes.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. +The file +$cref/sparsity_sub.cpp/sparsity_sub.cpp/RevSparseHes/$$ +contains an example and test of using $code RevSparseHes$$ +to compute the sparsity pattern for a subset of the Hessian. $end ----------------------------------------------------------------------------- @@ -198,6 +199,8 @@ Reverse mode Hessian sparsity patterns. */ +// =========================================================================== +// RevSparseHesBool /*! Calculate Hessian sparsity patterns using reverse mode. @@ -222,8 +225,8 @@ and \a x is any argument value. \param q -is the value of \a q in the -by the previous call of the form +is the value of \a q in the +by the previous call of the form \verbatim f.ForSparseJac(q, r) \endverbatim @@ -233,7 +236,7 @@ is a vector with size \c m that specifies the sparsity pattern for the vector \f$ S \f$, where \c m is the number of dependent variables -corresponding to the operation sequence stored in \a play. +corresponding to the operation sequence stored in \a play. \param h the input value of \a h must be a vector with size \c q*n. @@ -253,13 +256,13 @@ to the corresponding variable in the tape. \param play -is the recording that defines the function we are computing the sparsity +is the recording that defines the function we are computing the sparsity pattern for. \param for_jac_sparsity -is a vector of sets containing the -the forward Jacobian sparsity pattern corresponding to -$latex R$$ for all of the variables on the tape. +is a vector of sets containing the +the forward Jacobian sparsity pattern corresponding to +$latex R$$ for all of the variables on the tape. */ template @@ -298,7 +301,7 @@ // Array that will hold reverse Jacobian dependency flag. // Initialize as true for the dependent variables. pod_vector RevJac; - RevJac.extend(num_var); + RevJac.extend(num_var); for(i = 0; i < num_var; i++) RevJac[i] = false; for(i = 0; i < m; i++) @@ -315,7 +318,7 @@ n, num_var, &play, - for_jac_sparsity, + for_jac_sparsity, RevJac.data(), rev_hes_sparsity ); @@ -323,7 +326,7 @@ // return values corresponding to independent variables CPPAD_ASSERT_UNKNOWN( size_t(h.size()) == n * q ); for(j = 0; j < n; j++) - { for(i = 0; i < q; i++) + { for(i = 0; i < q; i++) { if( transpose ) h[ j * q + i ] = false; else h[ i * n + j ] = false; @@ -353,6 +356,8 @@ return; } +// =========================================================================== +// RevSparseHesSet /*! Calculate Hessian sparsity patterns using reverse mode. @@ -377,8 +382,8 @@ and \a x is any argument value. \param q -is the value of \a q in the -by the previous call of the form +is the value of \a q in the +by the previous call of the form \verbatim f.ForSparseJac(q, r) \endverbatim @@ -388,7 +393,7 @@ is a vector with size \c m that specifies the sparsity pattern for the vector \f$ S \f$, where \c m is the number of dependent variables -corresponding to the operation sequence stored in \a play. +corresponding to the operation sequence stored in \a play. \param h If \c transpose, the input value of \a h must be a vector with size \a q. @@ -409,13 +414,13 @@ to the corresponding variable in the tape. \param play -is the recording that defines the function we are computing the sparsity +is the recording that defines the function we are computing the sparsity pattern for. \param for_jac_sparsity -is a vector of sets containing the -the forward Jacobian sparsity pattern corresponding to -$latex R$$ for all of the variables on the tape. +is a vector of sets containing the +the forward Jacobian sparsity pattern corresponding to +$latex R$$ for all of the variables on the tape. */ template @@ -458,7 +463,7 @@ // Array that will hold reverse Jacobian dependency flag. // Initialize as true for the dependent variables. pod_vector RevJac; - RevJac.extend(num_var); + RevJac.extend(num_var); for(i = 0; i < num_var; i++) RevJac[i] = false; itr = s[0].begin(); @@ -483,7 +488,7 @@ n, num_var, &play, - for_jac_sparsity, + for_jac_sparsity, RevJac.data(), rev_hes_sparsity ); @@ -513,7 +518,8 @@ return; } - +// =========================================================================== +// RevSparseHes /*! User API for Hessian sparsity patterns using reverse mode. @@ -540,8 +546,8 @@ and \a x is any argument value. \param q -is the value of \a q in the -by the previous call of the form +is the value of \a q in the +by the previous call of the form \verbatim f.ForSparseJac(q, r, packed) \endverbatim @@ -553,10 +559,10 @@ is a vector with size \c m that specifies the sparsity pattern for the vector \f$ S \f$, where \c m is the number of dependent variables -corresponding to the operation sequence stored in \a play. +corresponding to the operation sequence stored in \a play. \return -If \c transpose is false (true), +If \c transpose is false (true), the return vector is a sparsity pattern for \f$ H(x) \f$ (\f$ H(x)^T \f$). \f[ H(x) = R^T ( S * F)^{(2)} (x) @@ -585,7 +591,8 @@ return h; } - +// =========================================================================== +// RevSparseHesCase /*! Private helper function for RevSparseHes(q, s). @@ -612,23 +619,23 @@ template void ADFun::RevSparseHesCase( bool set_type , - bool transpose , - size_t q , + bool transpose , + size_t q , const VectorSet& s , VectorSet& h ) -{ size_t n = Domain(); +{ size_t n = Domain(); h.resize(q * n ); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( for_jac_sparse_pack_.n_set() > 0, "RevSparseHes: previous stored call to ForSparseJac did not " "use bool for the elements of r." ); CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.n_set() == 0 ); CPPAD_ASSERT_UNKNOWN( for_jac_sparse_pack_.n_set() == num_var_tape_ ); - + // use sparse_pack for the calculation - CppAD::RevSparseHesBool( + CppAD::RevSparseHesBool( transpose , q , s , @@ -637,10 +644,9 @@ dep_taddr_ , ind_taddr_ , play_ , - for_jac_sparse_pack_ + for_jac_sparse_pack_ ); } - /*! Private helper function for RevSparseHes(q, s). @@ -648,7 +654,7 @@ applies. \param set_type -is a \c std::set value. +is a \c std::set value. This argument is used to dispatch to the proper source code depending on the vlaue of \c VectorSet::value_type. @@ -668,8 +674,8 @@ template void ADFun::RevSparseHesCase( const std::set& set_type , - bool transpose , - size_t q , + bool transpose , + size_t q , const VectorSet& s , VectorSet& h ) { size_t n = Domain(); @@ -677,16 +683,16 @@ h.resize(n); else h.resize(q); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( for_jac_sparse_set_.n_set() > 0, "RevSparseHes: previous stored call to ForSparseJac did not " "use std::set for the elements of r." ); CPPAD_ASSERT_UNKNOWN( for_jac_sparse_pack_.n_set() == 0 ); CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.n_set() == num_var_tape_ ); - + // use sparse_pack for the calculation - CppAD::RevSparseHesSet( + CppAD::RevSparseHesSet( transpose , q , s , @@ -695,9 +701,114 @@ dep_taddr_ , ind_taddr_ , play_ , - for_jac_sparse_set_ + for_jac_sparse_set_ ); } +// =========================================================================== +// RevSparseHesCheckpoint +/*! +Hessian sparsity patterns calculation used by checkpoint functions. + +\tparam Base +is the base type for this recording. + +\param transpose +is true (false) h is equal to \f$ H(x) \f$ (\f$ H(x)^T \f$) +where +\f[ + H(x) = R^T (S * F)^{(2)} (x) +\f] +where \f$ F \f$ is the function corresponding to the operation sequence +and \f$ x \f$ is any argument value. + +\param q +is the value of q in the by the previous call of the form +\verbatim + f.ForSparseJac(q, r) +\endverbatim +The value r in this call is a sparsity pattern for the matrix \f$ R \f$. + +\param s +is a vector with size m that specifies the sparsity pattern +for the vector \f$ S \f$, +where m is the number of dependent variables +corresponding to the operation sequence stored in play_. + +\param h +The input size and elements of h do not matter. +On output, h is the sparsity pattern for the matrix \f$ H(x) \f$ +or \f$ H(x)^T \f$ depending on transpose. + +\par Assumptions +The forward jacobian sparsity pattern must be currently stored +in this ADFUN object. +*/ +template +void ADFun::RevSparseHesCheckpoint( + size_t q , + vector& s , + bool transpose , + CPPAD_INTERNAL_SPARSE_SET& h ) +{ size_t n = Domain(); + size_t m = Range(); + + // checkpoint functions should get this right + CPPAD_ASSERT_UNKNOWN( for_jac_sparse_pack_.n_set() == 0 ); + CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.n_set() == num_var_tape_ ); + CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.end() == q ); + CPPAD_ASSERT_UNKNOWN( s.size() == m ); + + // Array that holds the reverse Jacobiain dependcy flags. + // Initialize as true for dependent variables, flase for others. + pod_vector RevJac; + RevJac.extend(num_var_tape_); + for(size_t i = 0; i < num_var_tape_; i++) + RevJac[i] = false; + for(size_t i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ) + RevJac[ dep_taddr_[i] ] = s[i]; + } + + // holds reverse Hessian sparsity pattern for all variables + CPPAD_INTERNAL_SPARSE_SET rev_hes_sparsity; + rev_hes_sparsity.resize(num_var_tape_, q); + + // compute Hessian sparsity pattern for all variables + RevHesSweep( + n, + num_var_tape_, + &play_, + for_jac_sparse_set_, + RevJac.data(), + rev_hes_sparsity + ); + + // dimension the return value + if( transpose ) + h.resize(n, q); + else + h.resize(q, n); + + // j is index corresponding to reverse mode partial + for(size_t j = 0; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] < num_var_tape_ ); + + // ind_taddr_[j] is operator taddr for j-th independent variable + CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == j + 1 ); + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == InvOp ); + + // extract the result from rev_hes_sparsity + CPPAD_ASSERT_UNKNOWN( rev_hes_sparsity.end() == q ); + rev_hes_sparsity.begin(j + 1); + size_t i = rev_hes_sparsity.next_element(); + while( i < q ) + { if( transpose ) + h.add_element(j, i); + else h.add_element(i, j); + i = rev_hes_sparsity.next_element(); + } + } +} } // END_CPPAD_NAMESPACE # endif diff -Nru cppad-2015.00.00.9/cppad/local/rev_sparse_jac.hpp cppad-2016.00.00.1/cppad/local/rev_sparse_jac.hpp --- cppad-2015.00.00.9/cppad/local/rev_sparse_jac.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/rev_sparse_jac.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: rev_sparse_jac.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_REV_SPARSE_JAC_INCLUDED -# define CPPAD_REV_SPARSE_JAC_INCLUDED +// $Id: rev_sparse_jac.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_REV_SPARSE_JAC_HPP +# define CPPAD_REV_SPARSE_JAC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,17 +30,14 @@ proportional $$ -$section Jacobian Sparsity Pattern: Reverse Mode$$ +$section Jacobian Sparsity Pattern: Reverse Mode$$ +$mindex RevSparseJac sparse$$ -$index RevSparseJac$$ -$index reverse, sparse Jacobian$$ -$index sparse, reverse Jacobian$$ -$index pattern, reverse Jacobian$$ $head Syntax$$ $icode%s% = %f%.RevSparseJac(%q%, %r%) %$$ -$icode%s% = %f%.RevSparseJac(%q%, %r%, %transpose%)%$$ +$icode%s% = %f%.RevSparseJac(%q%, %r%, %transpose%, %dependency%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the @@ -52,7 +49,7 @@ S(x) = R * F^{(1)} ( x ) \] $$ Given a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R$$, $code RevSparseJac$$ returns a sparsity pattern for the $latex S(x)$$. @@ -63,7 +60,7 @@ %$$ $head x$$ -the sparsity pattern is valid for all values of the independent +the sparsity pattern is valid for all values of the independent variables in $latex x \in B^n$$ (even if it has $cref CondExp$$ or $cref VecAD$$ operations). @@ -73,8 +70,8 @@ size_t %q% %$$ It specifies the number of rows in -$latex R \in B^{q \times m}$$ and the -Jacobian $latex S(x) \in B^{q \times n}$$. +$latex R \in B^{q \times m}$$ and the +Jacobian $latex S(x) \in B^{q \times n}$$. $head transpose$$ The argument $icode transpose$$ has prototype @@ -83,22 +80,14 @@ %$$ The default value $code false$$ is used when $icode transpose$$ is not present. -$head nz_compare$$ -The argument $icode nz_compare$$ has prototype +$head dependency$$ +The argument $icode dependency$$ has prototype $codei% - bool %nz_compare% + bool %dependency% %$$ -If $icode nz_compare$$ is true, -the derivatives with respect to left and right of the -$cref CondExp$$ below are considered to be non-zero: -$codei% - %CondExp%Rel%(%left%, %right%, %if_true%, %if_false%) -%$$ -This is used by the -$cref/optimizer/optimize/$$ with $cref checkpoint$$ functions -to obtain the correct dependency relations. -The default value $icode%nz_compare% = false%$$ is used when -$icode nz_compare$$ is not present. +If $icode dependency$$ is true, +the $cref/dependency pattern/dependency.cpp/Dependency Pattern/$$ +(instead of sparsity pattern) is computed. $head r$$ The argument $icode s$$ has prototype @@ -113,8 +102,8 @@ If it has elements of type $code std::set$$, its size is $icode q$$ and all its set elements are between zero and $latex m - 1$$. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex R \in B^{q \times m}$$. $subhead transpose true$$ @@ -123,8 +112,8 @@ If it has elements of type $code std::set$$, its size is $icode m$$ and all its set elements are between zero and $latex q - 1$$. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex R^\R{T} \in B^{m \times q}$$. $head s$$ @@ -140,8 +129,8 @@ If it has elements of type $code std::set$$, its size is $icode q$$ and all its set elements are between zero and $latex n - 1$$. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex S(x) \in {q \times n}$$. $subhead transpose true$$ @@ -150,8 +139,8 @@ If it has elements of type $code std::set$$, its size is $icode n$$ and all its set elements are between zero and $latex q - 1$$. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the matrix $latex S(x)^\R{T} \in {n \times q}$$. $head VectorSet$$ @@ -164,8 +153,8 @@ $head Entire Sparsity Pattern$$ Suppose that $latex q = m$$ and $latex R$$ is the $latex m \times m$$ identity matrix. -In this case, -the corresponding value for $icode s$$ is a +In this case, +the corresponding value for $icode s$$ is a sparsity pattern for the Jacobian $latex S(x) = F^{(1)} ( x )$$. $head Example$$ @@ -189,7 +178,8 @@ Reverse mode Jacobian sparsity patterns. */ -// ------------------------------------------------------------------------- +// ========================================================================= +// RevSparseJacBool /*! Calculate Jacobian vector of bools sparsity patterns using reverse mode. @@ -207,7 +197,7 @@ \param transpose are the sparsity patterns transposed. -\param nz_compare +\param dependency Are the derivatives with respect to left and right of the expression below considered to be non-zero: \code @@ -224,7 +214,7 @@ \param s the input value of \a s must be a vector with size p*n where \c n is the number of independent variables -corresponding to the operation sequence stored in \a play. +corresponding to the operation sequence stored in \a play. The input value of the components of \c s does not matter. On output, \a s is the sparsity pattern for the matrix \f[ @@ -245,15 +235,15 @@ to the corresponding variable in the tape. \param play -is the recording that defines the function we are computing the sparsity +is the recording that defines the function we are computing the sparsity pattern for. */ -template +template void RevSparseJacBool( bool transpose , - bool nz_compare , - size_t q , + bool dependency , + size_t q , const VectorSet& r , VectorSet& s , size_t total_num_var , @@ -289,18 +279,18 @@ for(i = 0; i < m; i++) { CPPAD_ASSERT_UNKNOWN( dep_taddr[i] < total_num_var ); if( transpose ) - { for(j = 0; j < q; j++) if( r[ j * m + i ] ) + { for(j = 0; j < q; j++) if( r[ i * q + j ] ) var_sparsity.add_element( dep_taddr[i], j ); } else - { for(j = 0; j < q; j++) if( r[ i * q + j ] ) + { for(j = 0; j < q; j++) if( r[ j * m + i ] ) var_sparsity.add_element( dep_taddr[i], j ); } } // evaluate the sparsity patterns RevJacSweep( - nz_compare, + dependency, n, total_num_var, &play, @@ -321,7 +311,7 @@ s[ j * q + i ] = false; } else - { for(i = 0; i < q; i++) + { for(i = 0; i < q; i++) s[ i * n + j ] = false; } CPPAD_ASSERT_UNKNOWN( var_sparsity.end() == q ); @@ -335,6 +325,8 @@ } } } +// ========================================================================= +// RevSparseJacSet /*! Calculate Jacobian vector of sets sparsity patterns using reverse mode. @@ -352,7 +344,7 @@ \param transpose see \c RevSparseJacBool. -\param nz_compare +\param dependency see \c RevSparseJacBool. \param q @@ -376,11 +368,11 @@ \param play see \c RevSparseJacBool. */ -template +template void RevSparseJacSet( bool transpose , - bool nz_compare , - size_t q , + bool dependency , + size_t q , const VectorSet& r , VectorSet& s , size_t total_num_var , @@ -423,7 +415,7 @@ { for(i = 0; i < m; i++) { itr = r[i].begin(); while(itr != r[i].end()) - { j = *itr++; + { j = *itr++; CPPAD_ASSERT_KNOWN( j < q, "RevSparseJac: transpose is true and element of the set\n" @@ -438,7 +430,7 @@ { for(i = 0; i < q; i++) { itr = r[i].begin(); while(itr != r[i].end()) - { j = *itr++; + { j = *itr++; CPPAD_ASSERT_KNOWN( j < m, "RevSparseJac: transpose is false and element of the set\n" @@ -451,7 +443,7 @@ } // evaluate the sparsity patterns RevJacSweep( - nz_compare, + dependency, n, total_num_var, &play, @@ -478,12 +470,13 @@ } } } -// -------------------------------------------------------------------------- +// ========================================================================= +// RevSparseJacCase /*! Private helper function for \c RevSparseJac(q, r, transpose). -All of the description in the public member function +All of the description in the public member function \c RevSparseJac(q, r, transpose) apply. \param set_type @@ -492,19 +485,19 @@ depending on the value of \c VectorSet::value_type. \param transpose -See \c RevSparseJac(q, r, transpose, nz_compare) +See \c RevSparseJac(q, r, transpose, dependency) -\param nz_compare -See \c RevSparseJac(q, r, transpose, nz_compare) +\param dependency +See \c RevSparseJac(q, r, transpose, dependency) \param q -See \c RevSparseJac(q, r, transpose, nz_compare) +See \c RevSparseJac(q, r, transpose, dependency) \param r -See \c RevSparseJac(q, r, transpose, nz_compare) +See \c RevSparseJac(q, r, transpose, dependency) \param s -is the return value for the corresponding call to +is the return value for the corresponding call to RevSparseJac(q, r, transpose). */ @@ -513,7 +506,7 @@ void ADFun::RevSparseJacCase( bool set_type , bool transpose , - bool nz_compare , + bool dependency , size_t q , const VectorSet& r , VectorSet& s ) @@ -525,7 +518,7 @@ // store results in s RevSparseJacBool( transpose , - nz_compare , + dependency , q , r , s , @@ -539,7 +532,7 @@ /*! Private helper function for \c RevSparseJac(q, r, transpose). -All of the description in the public member function +All of the description in the public member function \c RevSparseJac(q, r, transpose) apply. \param set_type @@ -548,16 +541,16 @@ depending on the value of \c VectorSet::value_type. \param transpose -See \c RevSparseJac(q, r, transpose, nz_compare) +See \c RevSparseJac(q, r, transpose, dependency) -\param nz_compare -See \c RevSparseJac(q, r, transpose, nz_compare) +\param dependency +See \c RevSparseJac(q, r, transpose, dependency) \param q -See \c RevSparseJac(q, r, transpose, nz_compare) +See \c RevSparseJac(q, r, transpose, dependency) \param r -See \c RevSparseJac(q, r, transpose, nz_compare) +See \c RevSparseJac(q, r, transpose, dependency) \param s is the return value for the corresponding call to RevSparseJac(q, r, transpose) @@ -568,7 +561,7 @@ void ADFun::RevSparseJacCase( const std::set& set_type , bool transpose , - bool nz_compare , + bool dependency , size_t q , const VectorSet& r , VectorSet& s ) @@ -580,7 +573,7 @@ // store results in r RevSparseJacSet( transpose , - nz_compare , + dependency , q , r , s , @@ -590,13 +583,14 @@ play_ ); } -// -------------------------------------------------------------------------- +// ========================================================================= +// RevSparseJac /*! User API for Jacobian sparsity patterns using reverse mode. The C++ source code corresponding to this operation is \verbatim - s = f.RevSparseJac(q, r, transpose, nz_compare) + s = f.RevSparseJac(q, r, transpose, dependency) \endverbatim \tparam Base @@ -615,7 +609,7 @@ \param transpose are the sparsity patterns for \f$ R \f$ and \f$ S(x) \f$ transposed. -\param nz_compare +\param dependency Are the derivatives with respect to left and right of the expression below considered to be non-zero: \code @@ -641,10 +635,10 @@ template template VectorSet ADFun::RevSparseJac( - size_t q , + size_t q , const VectorSet& r , bool transpose , - bool nz_compare ) + bool dependency ) { VectorSet s; typedef typename VectorSet::value_type Set_type; @@ -652,13 +646,138 @@ RevSparseJacCase( Set_type() , transpose , - nz_compare , + dependency , q , r , s ); return s; } +// =========================================================================== +// RevSparseJacCheckpoint +/*! +Reverse mode Jacobian sparsity calculation used by checkpoint functions. + +\tparam Base +is the base type for this recording. + +\param transpose +is true (false) s is equal to \f$ S(x) \f$ (\f$ S(x)^T \f$) +where +\f[ + S(x) = R * F^{(1)} (x) +\f] +where \f$ F \f$ is the function corresponding to the operation sequence +and \f$ x \f$ is any argument value. + +\param q +is the number of rows in the matrix \f$ R \f$. + +\param r +is a sparsity pattern for the matrix \f$ R \f$. + +\param transpose +are the sparsity patterns for \f$ R \f$ and \f$ S(x) \f$ transposed. + +\param dependency +Are the derivatives with respect to left and right of the expression below +considered to be non-zero: +\code + CondExpRel(left, right, if_true, if_false) +\endcode +This is used by the optimizer to obtain the correct dependency relations. + +\param s +The input size and elements of s do not matter. +On output, s is the sparsity pattern for the matrix \f$ S(x) \f$ +or \f$ S(x)^T \f$ depending on transpose. + +*/ +template +void ADFun::RevSparseJacCheckpoint( + size_t q , + CPPAD_INTERNAL_SPARSE_SET& r , + bool transpose , + bool dependency , + CPPAD_INTERNAL_SPARSE_SET& s ) +{ size_t n = Domain(); + size_t m = Range(); + +# ifndef NDEBUG + if( transpose ) + { CPPAD_ASSERT_UNKNOWN( r.n_set() == m ); + CPPAD_ASSERT_UNKNOWN( r.end() == q ); + } + else + { CPPAD_ASSERT_UNKNOWN( r.n_set() == q ); + CPPAD_ASSERT_UNKNOWN( r.end() == m ); + } + for(size_t i = 0; i < m; i++) + CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); +# endif + + // holds reverse Jacobian sparsity pattern for all variables + CPPAD_INTERNAL_SPARSE_SET var_sparsity; + var_sparsity.resize(num_var_tape_, q); + + // set sparsity pattern for dependent variables + if( transpose ) + { for(size_t i = 0; i < m; i++) + { r.begin(i); + size_t j = r.next_element(); + while( j < q ) + { var_sparsity.add_element( dep_taddr_[i], j ); + j = r.next_element(); + } + } + } + else + { for(size_t j = 0; j < q; j++) + { r.begin(j); + size_t i = r.next_element(); + while( i < m ) + { var_sparsity.add_element( dep_taddr_[i], j ); + i = r.next_element(); + } + } + } + + // evaluate the sparsity pattern for all variables + RevJacSweep( + dependency, + n, + num_var_tape_, + &play_, + var_sparsity + ); + + // dimension the return value + if( transpose ) + s.resize(n, m); + else + s.resize(m, n); + + // return values corresponding to independent variables + for(size_t j = 0; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == (j+1) ); + + // ind_taddr_[j] is operator taddr for j-th independent variable + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == InvOp ); + + // extract the result from var_sparsity + CPPAD_ASSERT_UNKNOWN( var_sparsity.end() == q ); + var_sparsity.begin(j+1); + size_t i = var_sparsity.next_element(); + while( i < q ) + { if( transpose ) + s.add_element(j, i); + else + s.add_element(i, j); + i = var_sparsity.next_element(); + } + } + +} } // END_CPPAD_NAMESPACE # endif diff -Nru cppad-2015.00.00.9/cppad/local/rev_two.hpp cppad-2016.00.00.1/cppad/local/rev_two.hpp --- cppad-2015.00.00.9/cppad/local/rev_two.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/rev_two.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: rev_two.hpp 2683 2012-12-30 18:17:03Z bradbell $ */ -# ifndef CPPAD_REV_TWO_INCLUDED -# define CPPAD_REV_TWO_INCLUDED +// $Id: rev_two.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_REV_TWO_HPP +# define CPPAD_REV_TWO_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,16 +23,11 @@ $$ -$index partial, second order driver$$ -$index second, order partial driver$$ -$index driver, second order partial$$ - -$index easy, partial$$ -$index driver, easy partial$$ -$index partial, easy$$ + $section Reverse Mode Second Partial Derivative Driver$$ +$mindex order easy$$ $head Syntax$$ $icode%ddw% = %f%.RevTwo(%x%, %i%, %j%)%$$ @@ -41,11 +36,11 @@ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. -The syntax above sets +The syntax above sets $latex \[ ddw [ k * p + \ell ] = - \DD{ F_{i[ \ell ]} }{ x_{j[ \ell ]} }{ x_k } (x) + \DD{ F_{i[ \ell ]} }{ x_{j[ \ell ]} }{ x_k } (x) \] $$ for $latex k = 0 , \ldots , n-1$$ and $latex \ell = 0 , \ldots , p$$, @@ -65,7 +60,7 @@ const %VectorBase% &%x% %$$ (see $cref/VectorBase/RevTwo/VectorBase/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. It specifies @@ -78,7 +73,7 @@ %$$ (see $cref/VectorSize_t/RevTwo/VectorSize_t/$$ below) We use $icode p$$ to denote the size of the vector $icode i$$. -All of the indices in $icode i$$ +All of the indices in $icode i$$ must be less than $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$; i.e., for $latex \ell = 0 , \ldots , p-1$$, $latex i[ \ell ] < m$$. @@ -91,7 +86,7 @@ (see $cref/VectorSize_t/RevTwo/VectorSize_t/$$ below) and its size must be equal to $icode p$$, the size of the vector $icode i$$. -All of the indices in $icode j$$ +All of the indices in $icode j$$ must be less than $icode n$$; i.e., for $latex \ell = 0 , \ldots , p-1$$, $latex j[ \ell ] < n$$. @@ -103,12 +98,12 @@ (see $cref/VectorBase/RevTwo/VectorBase/$$ below) and its size is $latex n * p$$. It contains the requested partial derivatives; to be specific, -for $latex k = 0 , \ldots , n - 1 $$ +for $latex k = 0 , \ldots , n - 1 $$ and $latex \ell = 0 , \ldots , p - 1$$ $latex \[ ddw [ k * p + \ell ] = - \DD{ F_{i[ \ell ]} }{ x_{j[ \ell ]} }{ x_k } (x) + \DD{ F_{i[ \ell ]} }{ x_{j[ \ell ]} }{ x_k } (x) \] $$ $head VectorBase$$ @@ -125,7 +120,7 @@ $head RevTwo Uses Forward$$ After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After a call to $code RevTwo$$, the zero order Taylor coefficients correspond to @@ -136,7 +131,7 @@ $children% example/rev_two.cpp %$$ -The routine +The routine $cref/RevTwo/rev_two.cpp/$$ is both an example and test. It returns $code true$$, if it succeeds and $code false$$ otherwise. @@ -171,7 +166,7 @@ CPPAD_ASSERT_KNOWN( x.size() == n, "RevTwo: Length of x not equal domain dimension for f." - ); + ); CPPAD_ASSERT_KNOWN( i.size() == j.size(), "RevTwo: Lenght of the i and j vectors are not equal." @@ -209,9 +204,9 @@ ); } - // loop over all forward directions - for(j1 = 0; j1 < n; j1++) - { // first order forward mode calculation done + // loop over all forward directions + for(j1 = 0; j1 < n; j1++) + { // first order forward mode calculation done bool first_done = false; for(l = 0; l < p; l++) if( j[l] == j1 ) { if( ! first_done ) diff -Nru cppad-2015.00.00.9/cppad/local/set_get_in_parallel.hpp cppad-2016.00.00.1/cppad/local/set_get_in_parallel.hpp --- cppad-2015.00.00.9/cppad/local/set_get_in_parallel.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/set_get_in_parallel.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,67 @@ +// $Id$ +# ifndef CPPAD_SET_GET_IN_PARALLEL_HPP +# define CPPAD_SET_GET_IN_PARALLEL_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include +# include +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +\file set_get_in_parallel.hpp +File used to set and get user in_parallel routine. +*/ +/*! +Set and call the routine that determine if we are in parallel execution mode. + +\return +value retuned by most recent setting for in_parallel_new. +If set is true, +or the most recent setting is CPPAD_NULL (its initial value), +the return value is false. +Otherwise the function corresponding to the most recent setting +is called and its value returned by set_get_in_parallel. + +\param in_parallel_new [in] +If set is false, in_parallel_new it is not used. +Otherwise, the current value of in_parallel_new becomes the +most recent setting for in_parallel_user. + +\param set +If set is true, then parallel_new is becomes the most +recent setting for this set_get_in_parallel. +In this case, it is assumed that we are currently in sequential execution mode. +*/ +static bool set_get_in_parallel( + bool (*in_parallel_new)(void) , + bool set = false ) +{ static bool (*in_parallel_user)(void) = CPPAD_NULL; + + if( set ) + { in_parallel_user = in_parallel_new; + // Doing a raw assert in this case because set_get_in_parallel is used + // by ErrorHandler and hence cannot use ErrorHandler. + // CPPAD_ASSERT_UNKNOWN( in_parallel_user() == false ) + assert(in_parallel_user == CPPAD_NULL || in_parallel_user() == false); + return false; + } + // + if( in_parallel_user == CPPAD_NULL ) + return false; + // + return in_parallel_user(); +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/sign.hpp cppad-2016.00.00.1/cppad/local/sign.hpp --- cppad-2015.00.00.9/cppad/local/sign.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sign.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sign.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_SIGN_INCLUDED -# define CPPAD_SIGN_INCLUDED +// $Id: sign.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SIGN_HPP +# define CPPAD_SIGN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,31 +14,20 @@ -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------- $begin sign$$ $spell + CppAD Dirac - Vec - std - faq - Taylor - Cpp - namespace - const $$ - -$index sign, AD$$ - -$section Sign Function$$ +$section The Sign: sign$$ $head Syntax$$ $icode%y% = sign(%x%)%$$ - -$head Purpose$$ +$head Description$$ Evaluates the $code sign$$ function which is defined by $latex \[ -{\rm sign} (x ) = +{\rm sign} (x) = \left\{ \begin{array}{rl} +1 & {\rm if} \; x > 0 \\ 0 & {\rm if} \; x = 0 \\ @@ -46,31 +35,12 @@ \end{array} \right. \] $$ +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. -$head x$$ -The argument $icode x$$ has one of the following prototypes -$codei% - const AD<%Base%> &%x% - const VecAD<%Base%>::reference &%x% -%$$ - -$head y$$ -The result $icode y$$ has prototype -$codei% - AD<%Base%> %y% -%$$ - -$head Operation Sequence$$ -This is an AD of $icode Base$$ -$cref/atomic operation/glossary/Operation/Atomic/$$ -and hence is part of the current -AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$. - -$head Complex Types$$ -The $code sign$$ function is not defined for the AD type sequences -above $code std::complex$$ or $code std::complex$$ -because these are not $cref/ordered types/base_ordered/Ordered Type/$$. +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ CppAD computes the derivative of the $code sign$$ function as zero for all @@ -78,7 +48,7 @@ The correct mathematical derivative is different and is given by $latex \[ - {\rm sign}{(1)} (x) = 2 \delta (x) + {\rm sign}^{(1)} (x) = 2 \delta (x) \] $$ where $latex \delta (x)$$ is the Dirac Delta function. @@ -88,7 +58,7 @@ %$$ The file $cref sign.cpp$$ -contains an example and test of this function. +contains an example and test of this function. It returns true if it succeeds and false otherwise. $end @@ -100,12 +70,12 @@ template AD AD::Sign (void) const -{ +{ AD result; result.value_ = sign(value_); CPPAD_ASSERT_UNKNOWN( Parameter(result) ); - if( Variable(*this) ) + if( Variable(*this) ) { // add this operation to the tape CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 ); @@ -131,4 +101,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/sign_op.hpp cppad-2016.00.00.1/cppad/local/sign_op.hpp --- cppad-2015.00.00.9/cppad/local/sign_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sign_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sign_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_SIGN_OP_INCLUDED -# define CPPAD_SIGN_OP_INCLUDED +// $Id: sign_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SIGN_OP_HPP +# define CPPAD_SIGN_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,7 +36,7 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -72,7 +72,7 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -104,7 +104,7 @@ inline void forward_sign_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { @@ -135,11 +135,11 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 ); diff -Nru cppad-2015.00.00.9/cppad/local/sinh_op.hpp cppad-2016.00.00.1/cppad/local/sinh_op.hpp --- cppad-2015.00.00.9/cppad/local/sinh_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sinh_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sinh_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_SINH_OP_INCLUDED -# define CPPAD_SINH_OP_INCLUDED +// $Id: sinh_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SINH_OP_HPP +# define CPPAD_SINH_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,9 +43,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SinhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 2 ); @@ -101,9 +101,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SinhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 2 ); @@ -152,7 +152,7 @@ inline void forward_sinh_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -189,7 +189,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -212,6 +212,7 @@ const Base* c = s - cap_order; // called y in documentation Base* pc = ps - nc_partial; + // rest of this routine is identical for the following cases: // reverse_sin_op, reverse_cos_op, reverse_sinh_op, reverse_cosh_op. size_t j = d; @@ -222,17 +223,17 @@ pc[j] /= Base(j); for(k = 1; k <= j; k++) { - px[k] += ps[j] * Base(k) * c[j-k]; - px[k] += pc[j] * Base(k) * s[j-k]; - - ps[j-k] += pc[j] * Base(k) * x[k]; - pc[j-k] += ps[j] * Base(k) * x[k]; + px[k] += Base(k) * azmul(ps[j], c[j-k]); + px[k] += Base(k) * azmul(pc[j], s[j-k]); + + ps[j-k] += Base(k) * azmul(pc[j], x[k]); + pc[j-k] += Base(k) * azmul(ps[j], x[k]); } --j; } - px[0] += ps[0] * c[0]; - px[0] += pc[0] * s[0]; + px[0] += azmul(ps[0], c[0]); + px[0] += azmul(pc[0], s[0]); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/sin_op.hpp cppad-2016.00.00.1/cppad/local/sin_op.hpp --- cppad-2015.00.00.9/cppad/local/sin_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sin_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sin_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_SIN_OP_INCLUDED -# define CPPAD_SIN_OP_INCLUDED +// $Id: sin_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SIN_OP_HPP +# define CPPAD_SIN_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,9 +43,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SinOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SinOp) == 2 ); @@ -100,9 +100,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SinOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SinOp) == 2 ); @@ -152,7 +152,7 @@ inline void forward_sin_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -190,7 +190,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -213,6 +213,7 @@ const Base* c = s - cap_order; // called y in documentation Base* pc = ps - nc_partial; + // rest of this routine is identical for the following cases: // reverse_sin_op, reverse_cos_op, reverse_sinh_op, reverse_cosh_op. size_t j = d; @@ -223,17 +224,17 @@ pc[j] /= Base(j); for(k = 1; k <= j; k++) { - px[k] += ps[j] * Base(k) * c[j-k]; - px[k] -= pc[j] * Base(k) * s[j-k]; - - ps[j-k] -= pc[j] * Base(k) * x[k]; - pc[j-k] += ps[j] * Base(k) * x[k]; + px[k] += Base(k) * azmul(ps[j], c[j-k]); + px[k] -= Base(k) * azmul(pc[j], s[j-k]); + + ps[j-k] -= Base(k) * azmul(pc[j], x[k]); + pc[j-k] += Base(k) * azmul(ps[j], x[k]); } --j; } - px[0] += ps[0] * c[0]; - px[0] -= pc[0] * s[0]; + px[0] += azmul(ps[0], c[0]); + px[0] -= azmul(pc[0], s[0]); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/sparse_binary_op.hpp cppad-2016.00.00.1/cppad/local/sparse_binary_op.hpp --- cppad-2015.00.00.9/cppad/local/sparse_binary_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse_binary_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: sparse_binary_op.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_SPARSE_BINARY_OP_INCLUDED -# define CPPAD_SPARSE_BINARY_OP_INCLUDED +// $Id: sparse_binary_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_BINARY_OP_HPP +# define CPPAD_SPARSE_BINARY_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,13 +20,13 @@ /*! -Forward mode Jacobian sparsity pattern for all binary operators. +Forward mode Jacobian sparsity pattern for all binary operators. The C++ source code corresponding to a binary operation has the form \verbatim z = fun(x, y) \endverbatim -where fun is a C++ binary function and both x and y are variables, +where fun is a C++ binary function and both x and y are variables, or it has the form \verbatim z = x op y @@ -38,8 +38,8 @@ \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z -variable index corresponding to the result for this operation; -i.e., z. +variable index corresponding to the result for this operation; +i.e., z. \param arg \a arg[0] @@ -51,29 +51,29 @@ i.e., y. \param sparsity -\b Input: +\b Input: The set with index \a arg[0] in \a sparsity is the sparsity bit pattern for x. This identifies which of the independent variables the variable x -depends on. +depends on. \n \n -\b Input: +\b Input: The set with index \a arg[1] in \a sparsity is the sparsity bit pattern for y. This identifies which of the independent variables the variable y -depends on. +depends on. \n \n -\b Output: +\b Output: The set with index \a i_z in \a sparsity is the sparsity bit pattern for z. This identifies which of the independent variables the variable z -depends on. +depends on. \par Checked Assertions: -\li \a arg[0] < \a i_z -\li \a arg[1] < \a i_z +\li \a arg[0] < \a i_z +\li \a arg[1] < \a i_z */ template @@ -81,7 +81,7 @@ size_t i_z , const addr_t* arg , Vector_set& sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); @@ -89,16 +89,16 @@ sparsity.binary_union(i_z, arg[0], arg[1], sparsity); return; -} +} /*! -Reverse mode Jacobian sparsity pattern for all binary operators. +Reverse mode Jacobian sparsity pattern for all binary operators. The C++ source code corresponding to a unary operation has the form \verbatim z = fun(x, y) \endverbatim -where fun is a C++ unary function and x and y are variables, +where fun is a C++ unary function and x and y are variables, or it has the form \verbatim z = x op y @@ -107,7 +107,7 @@ This routine is given the sparsity patterns for a function G(z, y, x, ... ) -and it uses them to compute the sparsity patterns for +and it uses them to compute the sparsity patterns for \verbatim H( y, x, w , u , ... ) = G[ z(x,y) , y , x , w , u , ... ] \endverbatim @@ -117,7 +117,7 @@ \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z -variable index corresponding to the result for this operation; +variable index corresponding to the result for this operation; i.e., z. \param arg @@ -131,17 +131,17 @@ i.e., y. \param sparsity -The set with index \a i_z in \a sparsity +The set with index \a i_z in \a sparsity is the sparsity pattern for z corresponding ot the function G. \n \n -The set with index \a arg[0] in \a sparsity +The set with index \a arg[0] in \a sparsity is the sparsity pattern for x. On input, it corresponds to the function G, and on output it corresponds to H. \n \n -The set with index \a arg[1] in \a sparsity +The set with index \a arg[1] in \a sparsity is the sparsity pattern for y. On input, it corresponds to the function G, and on output it corresponds to H. @@ -149,15 +149,15 @@ \n \par Checked Assertions: -\li \a arg[0] < \a i_z -\li \a arg[1] < \a i_z +\li \a arg[0] < \a i_z +\li \a arg[1] < \a i_z */ template inline void reverse_sparse_jacobian_binary_op( size_t i_z , const addr_t* arg , Vector_set& sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); @@ -166,10 +166,10 @@ sparsity.binary_union(arg[1], arg[1], i_z, sparsity); return; -} +} /*! -Reverse mode Hessian sparsity pattern for add and subtract operators. +Reverse mode Hessian sparsity pattern for add and subtract operators. The C++ source code corresponding to a unary operation has the form \verbatim @@ -186,7 +186,7 @@ bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); @@ -198,10 +198,10 @@ jac_reverse[arg[1]] |= jac_reverse[i_z]; return; -} +} /*! -Reverse mode Hessian sparsity pattern for multiplication operator. +Reverse mode Hessian sparsity pattern for multiplication operator. The C++ source code corresponding to a unary operation has the form \verbatim @@ -218,7 +218,7 @@ bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); @@ -228,18 +228,18 @@ if( jac_reverse[i_z] ) { rev_hes_sparsity.binary_union( - arg[0], arg[0], arg[1], for_jac_sparsity); + arg[0], arg[0], arg[1], for_jac_sparsity); rev_hes_sparsity.binary_union( - arg[1], arg[1], arg[0], for_jac_sparsity); + arg[1], arg[1], arg[0], for_jac_sparsity); } jac_reverse[arg[0]] |= jac_reverse[i_z]; jac_reverse[arg[1]] |= jac_reverse[i_z]; return; -} +} /*! -Reverse mode Hessian sparsity pattern for division operator. +Reverse mode Hessian sparsity pattern for division operator. The C++ source code corresponding to a unary operation has the form \verbatim @@ -256,7 +256,7 @@ bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); @@ -266,20 +266,20 @@ if( jac_reverse[i_z] ) { rev_hes_sparsity.binary_union( - arg[0], arg[0], arg[1], for_jac_sparsity); + arg[0], arg[0], arg[1], for_jac_sparsity); rev_hes_sparsity.binary_union( - arg[1], arg[1], arg[0], for_jac_sparsity); + arg[1], arg[1], arg[0], for_jac_sparsity); rev_hes_sparsity.binary_union( - arg[1], arg[1], arg[1], for_jac_sparsity); + arg[1], arg[1], arg[1], for_jac_sparsity); } jac_reverse[arg[0]] |= jac_reverse[i_z]; jac_reverse[arg[1]] |= jac_reverse[i_z]; return; -} +} /*! -Reverse mode Hessian sparsity pattern for power function. +Reverse mode Hessian sparsity pattern for power function. The C++ source code corresponding to a unary operation has the form \verbatim @@ -296,7 +296,7 @@ bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); @@ -307,14 +307,14 @@ if( jac_reverse[i_z] ) { rev_hes_sparsity.binary_union( - arg[0], arg[0], arg[0], for_jac_sparsity); + arg[0], arg[0], arg[0], for_jac_sparsity); rev_hes_sparsity.binary_union( - arg[0], arg[0], arg[1], for_jac_sparsity); + arg[0], arg[0], arg[1], for_jac_sparsity); rev_hes_sparsity.binary_union( - arg[1], arg[1], arg[0], for_jac_sparsity); + arg[1], arg[1], arg[0], for_jac_sparsity); rev_hes_sparsity.binary_union( - arg[1], arg[1], arg[1], for_jac_sparsity); + arg[1], arg[1], arg[1], for_jac_sparsity); } // I cannot think of a case where this is necessary, but it including @@ -322,7 +322,7 @@ jac_reverse[arg[0]] |= jac_reverse[i_z]; jac_reverse[arg[1]] |= jac_reverse[i_z]; return; -} +} } // END_CPPAD_NAMESPACE # endif diff -Nru cppad-2015.00.00.9/cppad/local/sparse_hessian.hpp cppad-2016.00.00.1/cppad/local/sparse_hessian.hpp --- cppad-2015.00.00.9/cppad/local/sparse_hessian.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse_hessian.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sparse_hessian.hpp 3239 2014-04-28 23:00:17Z bradbell $ */ -# ifndef CPPAD_SPARSE_HESSIAN_INCLUDED -# define CPPAD_SPARSE_HESSIAN_INCLUDED +// $Id: sparse_hessian.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_HESSIAN_HPP +# define CPPAD_SPARSE_HESSIAN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,6 +16,7 @@ /* $begin sparse_hessian$$ $spell + jacobian recomputed CppAD valarray @@ -24,11 +25,13 @@ hes const Taylor + cppad + cmake + colpack $$ $section Sparse Hessian: Easy Driver$$ -$index SparseHessian$$ -$index hessian, sparse$$ +$mindex SparseHessian$$ $head Syntax$$ $icode%hes% = %f%.SparseHessian(%x%, %w%) @@ -41,10 +44,10 @@ and $latex m$$ for the $cref/range/seq_property/Range/$$ size of $icode f$$. We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ do denote the $cref/AD function/glossary/AD Function/$$ -corresponding to $icode f$$. -The syntax above sets $icode hes$$ to the Hessian +corresponding to $icode f$$. +The syntax above sets $icode hes$$ to the Hessian $latex \[ - H(x) = \dpow{2}{x} \sum_{i=1}^m w_i F_i (x) + H(x) = \dpow{2}{x} \sum_{i=1}^m w_i F_i (x) \] $$ This routine takes advantage of the sparsity of the Hessian in order to reduce the amount of computation necessary. @@ -69,7 +72,7 @@ const %VectorBase%& %x% %$$ (see $cref/VectorBase/sparse_hessian/VectorBase/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. It specifies @@ -81,7 +84,7 @@ const %VectorBase%& %w% %$$ and size $latex m$$. -It specifies the value of $latex w_i$$ in the expression +It specifies the value of $latex w_i$$ in the expression for $icode hes$$. The more components of $latex w$$ that are identically zero, the more sparse the resulting Hessian may be (and hence the more efficient @@ -99,14 +102,20 @@ its size is $latex n$$ and all its set elements are between zero and $latex n - 1$$. It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the Hessian $latex H(x)$$. $pre $$ -If this sparsity pattern does not change between calls to +If this sparsity pattern does not change between calls to $codei SparseHessian$$, it should be faster to calculate $icode p$$ once and pass this argument to $codei SparseHessian$$. +Furthermore, if you specify $icode work$$ in the calling sequence, +it is not necessary to keep the sparsity pattern; see the heading +$cref/p/sparse_hessian/work/p/$$ under the $icode work$$ description. +$pre + +$$ In addition, if you specify $icode p$$, CppAD will use the same type of sparsity representation @@ -129,7 +138,7 @@ Furthermore, for $latex k = 0 , \ldots , K-1$$, it must hold that $latex row[k] < n$$ and $latex col[k] < n$$. -In addition, +In addition, all of the $latex (row[k], col[k])$$ pairs must correspond to a true value in the sparsity pattern $icode p$$. @@ -141,7 +150,7 @@ In the case where $icode row$$ and $icode col$$ are not present, the size of $icode hes$$ is $latex n * n$$ and its size is $latex n * n$$. -In this case, for $latex i = 0 , \ldots , n - 1 $$ +In this case, for $latex i = 0 , \ldots , n - 1 $$ and $latex ell = 0 , \ldots , n - 1$$ $latex \[ hes [ j * n + \ell ] = \DD{ w^{\rm T} F }{ x_j }{ x_\ell } ( x ) @@ -150,7 +159,7 @@ $$ In the case where the arguments $icode row$$ and $icode col$$ are present, -we use $latex K$$ to denote the size of $icode hes$$. +we use $latex K$$ to denote the size of $icode hes$$. The input value of its elements does not matter. Upon return, for $latex k = 0 , \ldots , K - 1$$, $latex \[ @@ -169,24 +178,64 @@ %$$ This object can only be used with the routines $code SparseHessian$$. During its the first use, information is stored in $icode work$$. -This is used to reduce the work done by future calls to $code SparseHessian$$ +This is used to reduce the work done by future calls to $code SparseHessian$$ with the same $icode f$$, $icode p$$, $icode row$$, and $icode col$$. -If a future call is make where any of these values have changed, +If a future call is made where any of these values have changed, you must first call $icode%work%.clear()%$$ to inform CppAD that this information needs to be recomputed. +$subhead color_method$$ +The coloring algorithm determines which rows and columns +can be computed during the same sweep. +This field has prototype +$codei% + std::string %work%.color_method +%$$ +This value only matters on the first call to $code sparse_hessian$$ that +follows the $icode work$$ constructor or a call to +$icode%work%.clear()%$$. +$codei% + +"cppad.symmetric" +%$$ +This is the default coloring method (after a constructor or $code clear()$$). +It takes advantage of the fact that the Hessian matrix +is symmetric to find a coloring that requires fewer +$cref/sweeps/sparse_hessian/n_sweep/$$. +$codei% + +"cppad.general" +%$$ +This is the same as the $code "cppad"$$ method for the +$cref/sparse_jacobian/sparse_jacobian/work/color_method/$$ calculation. +$codei% + +"colpack.star" +%$$ +This method requires that +$cref colpack_prefix$$ was specified on the +$cref/cmake command/cmake/CMake Command/$$ line. +It also takes advantage of the fact that the Hessian matrix is symmetric. + +$subhead p$$ +If $icode work$$ is present, and it is not the first call after +its construction or a clear, +the sparsity pattern $icode p$$ is not used. +This enables one to free the sparsity pattern +and still compute corresponding sparse Hessians. + $head n_sweep$$ The return value $icode n_sweep$$ has prototype $codei% size_t %n_sweep% %$$ -It is the number of first order forward sweeps +It is the number of first order forward sweeps used to compute the requested Hessian values. -Each first forward sweep is followed by a second order reverse sweep +Each first forward sweep is followed by a second order reverse sweep so it is also the number of reverse sweeps. -This is proportional to the total work that $code SparseHessian$$ does, -not counting the zero order forward sweep, -or the work to combine multiple columns into a single +This is proportional to the total work that $code SparseHessian$$ does, +not counting the zero order forward sweep, +or the work to combine multiple columns into a single forward-reverse sweep pair. $head VectorBase$$ @@ -207,11 +256,11 @@ $subhead Restrictions$$ If $icode VectorSet$$ has elements of $code std::set$$, -then $icode%p%[%i%]%$$ must return a reference (not a copy) to the +then $icode%p%[%i%]%$$ must return a reference (not a copy) to the corresponding set. According to section 26.3.2.3 of the 1998 C++ standard, $code std::valarray< std::set >$$ does not satisfy -this condition. +this condition. $head VectorSize$$ The type $icode VectorSize$$ must be a $cref SimpleVector$$ class with @@ -222,27 +271,38 @@ $head Uses Forward$$ After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After a call to any of the sparse Hessian routines, the zero order Taylor coefficients correspond to $icode%f%.Forward(0, %x%)%$$ and the other coefficients are unspecified. -$head Example$$ $children% - example/sparse_hessian.cpp + example/sparse_hessian.cpp% + example/sub_sparse_hes.cpp% + example/sparse_sub_hes.cpp %$$ + +$head Example$$ The routine -$cref sparse_hessian.cpp$$ +$cref sparse_hessian.cpp$$ is examples and tests of $code sparse_hessian$$. It return $code true$$, if it succeeds and $code false$$ otherwise. +$head Subset Hessian$$ +The routines +$cref sub_sparse_hes.cpp$$ and $cref sparse_sub_hes.cpp$$ +are examples and tests that compute a sparse Hessian +for a subset of the variables. +They return $code true$$, if they succeed and $code false$$ otherwise. $end ----------------------------------------------------------------------------- */ # include +# include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -251,18 +311,32 @@ */ // =========================================================================== /*! -class used by SparseHessian to hold information +class used by SparseHessian to hold information so it does not need to be recomputed. */ class sparse_hessian_work { public: + /// Coloring method: "cppad", or "colpack" + /// (this field is set by user) + std::string color_method; + /// row and column indicies for return values + /// (some may be reflected by star coloring algorithm) + CppAD::vector row; + CppAD::vector col; /// indices that sort the user row and col arrays by color CppAD::vector order; /// results of the coloring algorithm CppAD::vector color; + + /// constructor + sparse_hessian_work(void) : color_method("cppad.symmetric") + { } /// inform CppAD that this information needs to be recomputed void clear(void) - { order.clear(); + { color_method = "cppad.symmetric"; + row.clear(); + col.clear(); + order.clear(); color.clear(); } }; @@ -277,7 +351,7 @@ is a simple vector class with elements of type \a Base. \tparam VectorSet -is a simple vector class with elements of type +is a simple vector class with elements of type \c bool or \c std::set. \tparam VectorSize @@ -294,24 +368,24 @@ \param sparsity [in] is the sparsity pattern for the Hessian that we are calculating. -\param row [in] +\param user_row [in] is the vector of row indices for the returned Hessian values. -\param col [in] +\param user_col [in] is the vector of columns indices for the returned Hessian values. -It must have the same size are r. +It must have the same size as user_row. \param hes [out] is the vector of Hessian values. -It must have the same size are r. -The return value hes[k] is the second partial of +It must have the same size as user_row. +The return value hes[k] is the second partial of \f$ w^{\rm T} F(x)\f$ with respect to the row[k] and col[k] component of \f$ x\f$. \param work This structure contains information that is computed by \c SparseHessianCompute. If the sparsity pattern, \c row vector, or \c col vectors -are not the same between calls to \c SparseHessianCompute, +are not the same between calls to \c SparseHessianCompute, \c work.clear() must be called to reinitialize \c work. \return @@ -328,14 +402,16 @@ const VectorBase& x , const VectorBase& w , VectorSet& sparsity , - const VectorSize& row , - const VectorSize& col , + const VectorSize& user_row , + const VectorSize& user_col , VectorBase& hes , sparse_hessian_work& work ) { using CppAD::vectorBool; size_t i, k, ell; + CppAD::vector& row(work.row); + CppAD::vector& col(work.col); CppAD::vector& color(work.color); CppAD::vector& order(work.order); @@ -348,13 +424,16 @@ // check VectorBase is Simple Vector class with Base type elements CheckSimpleVector(); + // number of components of Hessian that are required + size_t K = hes.size(); + CPPAD_ASSERT_UNKNOWN( size_t( user_row.size() ) == K ); + CPPAD_ASSERT_UNKNOWN( size_t( user_col.size() ) == K ); + CPPAD_ASSERT_UNKNOWN( size_t(x.size()) == n ); CPPAD_ASSERT_UNKNOWN( color.size() == 0 || color.size() == n ); + CPPAD_ASSERT_UNKNOWN( row.size() == 0 || row.size() == K ); + CPPAD_ASSERT_UNKNOWN( col.size() == 0 || col.size() == K ); - // number of components of Hessian that are required - size_t K = hes.size(); - CPPAD_ASSERT_UNKNOWN( row.size() == K ); - CPPAD_ASSERT_UNKNOWN( col.size() == K ); // Point at which we are evaluating the Hessian Forward(0, x); @@ -370,9 +449,38 @@ CPPAD_ASSERT_UNKNOWN( sparsity.n_set() == n ); CPPAD_ASSERT_UNKNOWN( sparsity.end() == n ); + // copy user rwo and col to work space + row.resize(K); + col.resize(K); + for(k = 0; k < K; k++) + { row[k] = user_row[k]; + col[k] = user_col[k]; + } + // execute coloring algorithm color.resize(n); - color_general_cppad(sparsity, row, col, color); + if( work.color_method == "cppad.general" ) + color_general_cppad(sparsity, row, col, color); + else if( work.color_method == "cppad.symmetric" ) + color_symmetric_cppad(sparsity, row, col, color); + else if( work.color_method == "colpack.star" ) + { +# if CPPAD_HAS_COLPACK + color_symmetric_colpack(sparsity, row, col, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "SparseHessian: work.color_method = colpack.star" + "and colpack_prefix missing from cmake command line." + ); +# endif + } + else + { CPPAD_ASSERT_KNOWN( + false, + "SparseHessian: work.color_method is not valid." + ); + } // put sorting indices in color order VectorSize key(K); @@ -414,7 +522,7 @@ ddw = Reverse(2, w); // set the corresponding components of the result - while( k < K && color[ row[ order[k] ] ] == ell ) + while( k < K && color[ row[ order[k] ] ] == ell ) { hes[ order[k] ] = ddw[ col[ order[k] ] * 2 + 1 ]; k++; } @@ -439,7 +547,7 @@ is a simple vector class with elements of type \a Base. \tparam VectorSet -is a simple vector class with elements of type +is a simple vector class with elements of type \c bool or \c std::set. \tparam VectorSize @@ -465,15 +573,15 @@ \param hes [out] is the vector of Hessian values. -It must have the same size are r. -The return value hes[k] is the second partial of +It must have the same size are r. +The return value hes[k] is the second partial of \f$ w^{\rm T} F(x)\f$ with respect to the row[k] and col[k] component of \f$ x\f$. \param work This structure contains information that is computed by \c SparseHessianCompute. If the sparsity pattern, \c row vector, or \c col vectors -are not the same between calls to \c SparseHessian, +are not the same between calls to \c SparseHessian, \c work.clear() must be called to reinitialize \c work. \return @@ -496,16 +604,17 @@ sparse_hessian_work& work ) { size_t n = Domain(); + size_t K = hes.size(); # ifndef NDEBUG - size_t k, K = hes.size(); + size_t k; CPPAD_ASSERT_KNOWN( size_t(x.size()) == n , "SparseHessian: size of x not equal domain dimension for f." - ); + ); CPPAD_ASSERT_KNOWN( size_t(row.size()) == K && size_t(col.size()) == K , "SparseHessian: either r or c does not have the same size as ehs." - ); + ); CPPAD_ASSERT_KNOWN( work.color.size() == 0 || work.color.size() == n, "SparseHessian: invalid value in work." @@ -526,6 +635,11 @@ "SparseHessian: invalid value in work." ); # endif + // check for case where there is nothing to compute + size_t n_sweep = 0; + if( K == 0 ) + return n_sweep; + typedef typename VectorSet::value_type Set_type; typedef typename internal_sparsity::pattern_type Pattern_type; Pattern_type s; @@ -533,7 +647,7 @@ { bool transpose = false; sparsity_user2internal(s, p, n, n, transpose); } - size_t n_sweep = SparseHessianCompute(x, w, s, row, col, hes, work); + n_sweep = SparseHessianCompute(x, w, s, row, col, hes, work); return n_sweep; } /*! @@ -569,7 +683,7 @@ is a sparsity pattern for the Hessian. \return -Will be a vector of size \c n * n containing the Hessian of +Will be a vector of size \c n * n containing the Hessian of at the point specified by \a x (where \c n is the domain dimension for this ADFun object). */ @@ -600,7 +714,7 @@ // arguments to SparseHessianCompute Pattern_type s; CppAD::vector row; - CppAD::vector col; + CppAD::vector col; sparse_hessian_work work; bool transpose = false; sparsity_user2internal(s, p, n, n, transpose); @@ -653,7 +767,7 @@ It must have size equal to the range dimension for this ADFun object. \return -Will be a vector of size \c n * n containing the Hessian of +Will be a vector of size \c n * n containing the Hessian of at the point specified by \a x (where \c n is the domain dimension for this ADFun object). */ diff -Nru cppad-2015.00.00.9/cppad/local/sparse.hpp cppad-2016.00.00.1/cppad/local/sparse.hpp --- cppad-2015.00.00.9/cppad/local/sparse.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sparse.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_SPARSE_INCLUDED -# define CPPAD_SPARSE_INCLUDED +// $Id: sparse.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_HPP +# define CPPAD_SPARSE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,15 @@ $spell $$ -$index sparsity, pattern$$ -$index pattern, sparsity$$ $section Calculating Sparsity Patterns$$ $childtable% cppad/local/for_sparse_jac.hpp% cppad/local/rev_sparse_jac.hpp% - cppad/local/rev_sparse_hes.hpp + example/dependency.cpp% + cppad/local/rev_sparse_hes.hpp% + example/bool_sparsity.cpp %$$ $end diff -Nru cppad-2015.00.00.9/cppad/local/sparse_jacobian.hpp cppad-2016.00.00.1/cppad/local/sparse_jacobian.hpp --- cppad-2015.00.00.9/cppad/local/sparse_jacobian.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse_jacobian.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sparse_jacobian.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_SPARSE_JACOBIAN_INCLUDED -# define CPPAD_SPARSE_JACOBIAN_INCLUDED +// $Id: sparse_jacobian.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_JACOBIAN_HPP +# define CPPAD_SPARSE_JACOBIAN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -31,13 +31,13 @@ Bool jac Jacobian + Jacobians const Taylor $$ $section Sparse Jacobian: Easy Driver$$ -$index SparseJacobian$$ -$index jacobian, sparse$$ +$mindex SparseJacobian$$ $head Syntax$$ $icode%jac% = %f%.SparseJacobian(%x%) @@ -51,10 +51,10 @@ and $latex m$$ for the $cref/range/seq_property/Range/$$ size of $icode f$$. We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ do denote the $cref/AD function/glossary/AD Function/$$ -corresponding to $icode f$$. -The syntax above sets $icode jac$$ to the Jacobian +corresponding to $icode f$$. +The syntax above sets $icode jac$$ to the Jacobian $latex \[ - jac = F^{(1)} (x) + jac = F^{(1)} (x) \] $$ This routine takes advantage of the sparsity of the Jacobian in order to reduce the amount of computation necessary. @@ -79,7 +79,7 @@ const %VectorBase%& %x% %$$ (see $cref/VectorBase/sparse_jacobian/VectorBase/$$ below) -and its size +and its size must be equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. It specifies @@ -96,19 +96,25 @@ If it has elements of type $code std::set$$, its size is $latex m$$ and all its set elements are between zero and $latex n - 1$$. -It specifies a -$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the Jacobian $latex F^{(1)} (x)$$. $pre $$ -If this sparsity pattern does not change between calls to -$codei SparseJacobian$$, it should be faster to calculate $icode p$$ once +If this sparsity pattern does not change between calls to +$codei SparseJacobian$$, it should be faster to calculate $icode p$$ once (using $cref ForSparseJac$$ or $cref RevSparseJac$$) and then pass $icode p$$ to $codei SparseJacobian$$. +Furthermore, if you specify $icode work$$ in the calling sequence, +it is not necessary to keep the sparsity pattern; see the heading +$cref/p/sparse_jacobian/work/p/$$ under the $icode work$$ description. +$pre + +$$ In addition, if you specify $icode p$$, CppAD will use the same -type of sparsity representation +type of sparsity representation (vectors of $code bool$$ or vectors of $code std::set$$) for its internal calculations. Otherwise, the representation @@ -148,7 +154,7 @@ $$ In the case where the arguments $icode row$$ and $icode col$$ are present, -we use $latex K$$ to denote the size of $icode jac$$. +we use $latex K$$ to denote the size of $icode jac$$. The input value of its elements does not matter. Upon return, for $latex k = 0 , \ldots , K - 1$$, $latex \[ @@ -165,11 +171,11 @@ $codei% sparse_jacobian_work& %work% %$$ -This object can only be used with the routines +This object can only be used with the routines $code SparseJacobianForward$$ and $code SparseJacobianReverse$$. During its the first use, information is stored in $icode work$$. This is used to reduce the work done by future calls to the same mode -(forward or reverse), +(forward or reverse), the same $icode f$$, $icode p$$, $icode row$$, and $icode col$$. If a future call is for a different mode, or any of these values have changed, @@ -183,26 +189,34 @@ $codep% std::string %work%.color_method %$$ -and its default value (after a constructor or $code clear()$$) +and its default value (after a constructor or $code clear()$$) is $code "cppad"$$. If $cref colpack_prefix$$ is specified on the $cref/cmake command/cmake/CMake Command/$$ line, you can set this method to $code "colpack"$$. This value only matters on the first call to $code sparse_jacobian$$ -after the $icode work$$ constructor or a call to $code clear$$. +that follows the $icode work$$ constructor or a call to +$icode%work%.clear()%$$. + +$subhead p$$ +If $icode work$$ is present, and it is not the first call after +its construction or a clear, +the sparsity pattern $icode p$$ is not used. +This enables one to free the sparsity pattern +and still compute corresponding sparse Jacobians. $head n_sweep$$ The return value $icode n_sweep$$ has prototype $codei% size_t %n_sweep% %$$ -If $code SparseJacobianForward$$ ($code SparseJacobianReverse$$) is used, -$icode n_sweep$$ is the number of first order forward (reverse) sweeps -used to compute the requested Jacobian values. +If $code SparseJacobianForward$$ ($code SparseJacobianReverse$$) is used, +$icode n_sweep$$ is the number of first order forward (reverse) sweeps +used to compute the requested Jacobian values. (This is also the number of colors determined by the coloring method mentioned above). -This is proportional to the total work that $code SparseJacobian$$ does, -not counting the zero order forward sweep, +This is proportional to the total work that $code SparseJacobian$$ does, +not counting the zero order forward sweep, or the work to combine multiple columns (rows) into a single sweep. $head VectorBase$$ @@ -223,11 +237,11 @@ $subhead Restrictions$$ If $icode VectorSet$$ has elements of $code std::set$$, -then $icode%p%[%i%]%$$ must return a reference (not a copy) to the +then $icode%p%[%i%]%$$ must return a reference (not a copy) to the corresponding set. According to section 26.3.2.3 of the 1998 C++ standard, $code std::valarray< std::set >$$ does not satisfy -this condition. +this condition. $head VectorSize$$ The type $icode VectorSize$$ must be a $cref SimpleVector$$ class with @@ -238,7 +252,7 @@ $head Uses Forward$$ After each call to $cref Forward$$, -the object $icode f$$ contains the corresponding +the object $icode f$$ contains the corresponding $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. After a call to any of the sparse Jacobian routines, the zero order Taylor coefficients correspond to @@ -270,19 +284,19 @@ */ // =========================================================================== /*! -class used by SparseJacobian to hold information so it does not need to be +class used by SparseJacobian to hold information so it does not need to be recomputed. */ class sparse_jacobian_work { public: - /// Coloring method: color_general_cppad or color_general_colpack + /// Coloring method: "cppad", or "colpack" /// (this field is set by user) std::string color_method; - /// indices that sort the user row and col arrays by color + /// indices that sort the user row and col arrays by color CppAD::vector order; /// results of the coloring algorithm CppAD::vector color; - + /// constructor sparse_jacobian_work(void) : color_method("cppad") { } @@ -315,7 +329,7 @@ is a vector specifing the point at which to compute the Jacobian. \param p_transpose [in] -If work.color.size() != 0, +If work.color.size() != 0, then \c p_transpose is not used. Otherwise, it is a sparsity pattern for the transpose of the Jacobian of this ADFun object. @@ -339,7 +353,7 @@ work.color_method is an input. The rest of this structure contains information that is computed by \c SparseJacobainFor. If the sparsity pattern, \c row vector, or \c col vectors -are not the same between calls to \c SparseJacobianFor, +are not the same between calls to \c SparseJacobianFor, \c work.clear() must be called to reinitialize \c work. \return @@ -378,8 +392,8 @@ // number of components of Jacobian that are required size_t K = size_t(jac.size()); - CPPAD_ASSERT_UNKNOWN( row.size() == K ); - CPPAD_ASSERT_UNKNOWN( col.size() == K ); + CPPAD_ASSERT_UNKNOWN( size_t( row.size() ) == K ); + CPPAD_ASSERT_UNKNOWN( size_t( col.size() ) == K ); // Point at which we are evaluating the Jacobian Forward(0, x); @@ -448,7 +462,7 @@ dy = Forward(1, dx); // set the corresponding components of the result - while( k < K && color[ col[order[k]] ] == ell ) + while( k < K && color[ col[order[k]] ] == ell ) { jac[ order[k] ] = dy[row[order[k]]]; k++; } @@ -468,7 +482,7 @@ VectorBase dx(n * r), dy(m * r); // loop over colors we will do this tme - for(ell = 0; ell < r; ell++) + for(ell = 0; ell < r; ell++) { // combine all columns with this color for(j = 0; j < n; j++) { dx[j * r + ell] = zero; @@ -480,9 +494,9 @@ dy = Forward(q, r, dx); // store results - for(ell = 0; ell < r; ell++) + for(ell = 0; ell < r; ell++) { // set the components of the result for this color - while( k < K && color[ col[order[k]] ] == ell + count_color ) + while( k < K && color[ col[order[k]] ] == ell + count_color ) { jac[ order[k] ] = dy[ row[order[k]] * r + ell ]; k++; } @@ -527,7 +541,7 @@ \param jac [out] is the vector of Jacobian values. -It must have the same size as \c row. +It must have the same size as \c row. The return value jac[k] is the partial of the row[k] range component of the function with respect the the col[k] domain component of its argument. @@ -536,7 +550,7 @@ work.color_method is an input. The rest of This structure contains information that is computed by \c SparseJacobainRev. If the sparsity pattern, \c row vector, or \c col vectors -are not the same between calls to \c SparseJacobianRev, +are not the same between calls to \c SparseJacobianRev, \c work.clear() must be called to reinitialize \c work. \return @@ -575,8 +589,8 @@ // number of components of Jacobian that are required size_t K = size_t(jac.size()); - CPPAD_ASSERT_UNKNOWN( row.size() == K ); - CPPAD_ASSERT_UNKNOWN( col.size() == K ); + CPPAD_ASSERT_UNKNOWN( size_t( size_t( row.size() ) ) == K ); + CPPAD_ASSERT_UNKNOWN( size_t( size_t( col.size() ) ) == K ); // Point at which we are evaluating the Jacobian Forward(0, x); @@ -619,7 +633,7 @@ index_sort(key, order); } size_t n_color = 1; - for(i = 0; i < m; i++) if( color[i] < m ) + for(i = 0; i < m; i++) if( color[i] < m ) n_color = std::max(n_color, color[i] + 1); // weighting vector for calls to reverse @@ -647,7 +661,7 @@ dw = Reverse(1, w); // set the corresponding components of the result - while( k < K && color[ row[order[k]] ] == ell ) + while( k < K && color[ row[order[k]] ] == ell ) { jac[ order[k] ] = dw[col[order[k]]]; k++; } @@ -673,7 +687,7 @@ is a simple vector class with elements of type \a Base. \tparam VectorSet -is a simple vector class with elements of type +is a simple vector class with elements of type \c bool or \c std::set. \tparam VectorSize @@ -694,15 +708,15 @@ \param jac [out] is the vector of Jacobian values. -It must have the same size as \c row. +It must have the same size as \c row. The return value jac[k] is the partial of the row[k] range component of the function with respect the the col[k] domain component of its argument. \param work [in,out] -this structure contains information that depends on the function object, +this structure contains information that depends on the function object, sparsity pattern, \c row vector, and \c col vector. -If they are not the same between calls to \c SparseJacobianForward, +If they are not the same between calls to \c SparseJacobianForward, \c work.clear() must be called to reinitialize them. \return @@ -723,17 +737,18 @@ { size_t n = Domain(); size_t m = Range(); + size_t K = jac.size(); # ifndef NDEBUG - size_t k, K = jac.size(); + size_t k; CPPAD_ASSERT_KNOWN( size_t(x.size()) == n , "SparseJacobianForward: size of x not equal domain dimension for f." - ); + ); CPPAD_ASSERT_KNOWN( size_t(row.size()) == K && size_t(col.size()) == K , "SparseJacobianForward: either r or c does not have " "the same size as jac." - ); + ); CPPAD_ASSERT_KNOWN( work.color.size() == 0 || work.color.size() == n, "SparseJacobianForward: invalid value in work." @@ -754,6 +769,10 @@ "SparseJacobianForward: invalid value in work." ); # endif + // check for case where there is nothing to compute + size_t n_sweep = 0; + if( K == 0 ) + return n_sweep; typedef typename VectorSet::value_type Set_type; typedef typename internal_sparsity::pattern_type Pattern_type; @@ -762,7 +781,7 @@ { bool transpose = true; sparsity_user2internal(s_transpose, p, m, n, transpose); } - size_t n_sweep = SparseJacobianFor(x, s_transpose, row, col, jac, work); + n_sweep = SparseJacobianFor(x, s_transpose, row, col, jac, work); return n_sweep; } /*! @@ -781,7 +800,7 @@ is a simple vector class with elements of type \a Base. \tparam VectorSet -is a simple vector class with elements of type +is a simple vector class with elements of type \c bool or \c std::set. \tparam VectorSize @@ -802,15 +821,15 @@ \param jac [out] is the vector of Jacobian values. -It must have the same size as \c row. +It must have the same size as \c row. The return value jac[k] is the partial of the row[k] range component of the function with respect the the col[k] domain component of its argument. \param work [in,out] -this structure contains information that depends on the function object, +this structure contains information that depends on the function object, sparsity pattern, \c row vector, and \c col vector. -If they are not the same between calls to \c SparseJacobianReverse, +If they are not the same between calls to \c SparseJacobianReverse, \c work.clear() must be called to reinitialize them. \return @@ -831,17 +850,18 @@ { size_t m = Range(); size_t n = Domain(); + size_t K = jac.size(); # ifndef NDEBUG - size_t k, K = jac.size(); + size_t k; CPPAD_ASSERT_KNOWN( size_t(x.size()) == n , "SparseJacobianReverse: size of x not equal domain dimension for f." - ); + ); CPPAD_ASSERT_KNOWN( size_t(row.size()) == K && size_t(col.size()) == K , "SparseJacobianReverse: either r or c does not have " "the same size as jac." - ); + ); CPPAD_ASSERT_KNOWN( work.color.size() == 0 || work.color.size() == m, "SparseJacobianReverse: invalid value in work." @@ -862,7 +882,11 @@ "SparseJacobianReverse: invalid value in work." ); # endif - + // check for case where there is nothing to compute + size_t n_sweep = 0; + if( K == 0 ) + return n_sweep; + typedef typename VectorSet::value_type Set_type; typedef typename internal_sparsity::pattern_type Pattern_type; Pattern_type s; @@ -870,7 +894,7 @@ { bool transpose = false; sparsity_user2internal(s, p, m, n, transpose); } - size_t n_sweep = SparseJacobianRev(x, s, row, col, jac, work); + n_sweep = SparseJacobianRev(x, s, row, col, jac, work); return n_sweep; } /*! @@ -889,7 +913,7 @@ is a simple vector class with elements of type \a Base. \tparam VectorSet -is a simple vector class with elements of type +is a simple vector class with elements of type \c bool or \c std::set. \param x [in] @@ -948,10 +972,10 @@ k++; i = s_transpose.next_element(); } - } + } size_t K = k; VectorBase J(K); - + // now we have folded this into the following case SparseJacobianFor(x, s_transpose, row, col, J, work); @@ -976,7 +1000,7 @@ k++; j = s.next_element(); } - } + } size_t K = k; VectorBase J(K); @@ -989,7 +1013,7 @@ } return jac; -} +} /*! Compute a sparse Jacobian. @@ -1027,7 +1051,7 @@ if( n <= m ) { size_t j, k; - // use forward mode + // use forward mode VectorBool r(n * n); for(j = 0; j < n; j++) { for(k = 0; k < n; k++) @@ -1039,7 +1063,7 @@ else { size_t i, k; - // use reverse mode + // use reverse mode VectorBool s(m * m); for(i = 0; i < m; i++) { for(k = 0; k < m; k++) diff -Nru cppad-2015.00.00.9/cppad/local/sparse_list.hpp cppad-2016.00.00.1/cppad/local/sparse_list.hpp --- cppad-2015.00.00.9/cppad/local/sparse_list.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse_list.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sparse_list.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_SPARSE_LIST_INCLUDED -# define CPPAD_SPARSE_LIST_INCLUDED +// $Id: sparse_list.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_LIST_HPP +# define CPPAD_SPARSE_LIST_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,47 +26,122 @@ linked list. */ class sparse_list { -private: +public: /// type used for each set in the vector of sets /// (note that next is index in data_ for next element in this set). - struct Element { size_t value; size_t next; }; + struct pair_size_t { size_t value; size_t next; }; +private: + // ----------------------------------------------------------------- /// Number of sets that we are representing /// (set by constructor and resize). size_t n_set_; + /// Possible elements in each set are 0, 1, ..., end_ - 1; size_t end_; + /// The data for all the elements in all the sets - CppAD::pod_vector data_; + CppAD::pod_vector data_; + /// next element - Element next_element_; + pair_size_t next_pair_; + + /// number of elements in data_ that are no longer being used. + size_t data_not_used_; + + /// temporary data vector used for garbage collection + CppAD::pod_vector data_tmp_; + // ----------------------------------------------------------------- + /*! Private member function that counts number of elements in a set. + + \param index + is the index of the set we are counting. + + \par Checked Assertions + \li index < n_set_ + */ + size_t number_elements(size_t index) const + { CPPAD_ASSERT_UNKNOWN(index < n_set_ ); + + size_t count = 0; + size_t i = index; + size_t value = data_[i].value; + while( value < end_ ) + { count++; + i = data_[i].next; + value = data_[i].value; + } + return count; + } + // ----------------------------------------------------------------- + /// Private member functions that does garbage collection. + void collect_garbage(void) + { CPPAD_ASSERT_UNKNOWN( 2 * data_not_used_ > data_.size() ); + // + CPPAD_ASSERT_UNKNOWN( + number_elements() + n_set_ + data_not_used_ == data_.size() + ); + + // copy the sets to a temporary data vector + data_tmp_.erase(); + data_tmp_.extend(n_set_); + for(size_t i = 0; i < n_set_; i++) + { size_t next = i; + size_t next_tmp = i; + // + size_t value = data_[next].value; + while( value < end_ ) + { data_tmp_[next_tmp].value = value; + // data_tmp_[next_tmp].next = data_tmp_.extend(1); + // does not seem to work ? + size_t index_tmp = data_tmp_.extend(1); + data_tmp_[next_tmp].next = index_tmp; + // + next = data_[next].next; + next_tmp = data_tmp_[next_tmp].next; + // + value = data_[next].value; + } + data_tmp_[next_tmp].value = end_; + } + CPPAD_ASSERT_UNKNOWN( + data_tmp_.size() + data_not_used_ == data_.size() + ); + + // swap the tmp and old data vectors + data_.swap(data_tmp_); + + // all of the elements are used in this new version of data_ + data_not_used_ = 0; + } public: // ----------------------------------------------------------------- /*! Default constructor (no sets) */ - sparse_list(void) : - n_set_(0) , - end_(0) - { next_element_.value = end_; } + sparse_list(void) : + n_set_(0) , + end_(0) , + data_not_used_(0) + { next_pair_.value = end_; } // ----------------------------------------------------------------- - /*! Make use of copy constructor an error - + /*! Using copy constructor is a programing (not user) error + \param v vector that we are attempting to make a copy of. - */ + */ sparse_list(const sparse_list& v) - { // Error: + { // Error: // Probably a sparse_list argument has been passed by value - CPPAD_ASSERT_UNKNOWN(false); + CPPAD_ASSERT_UNKNOWN(false); } // ----------------------------------------------------------------- - /*! Destructor + /*! Destructor */ ~sparse_list(void) - { } + { } // ----------------------------------------------------------------- /*! Change number of sets, end marker, and initialize all sets as empty - If \c n_set_in is zero, any memory currently allocated for this object + If \c n_set_in is zero, any memory currently allocated for this object is freed. Otherwise, new memory may be allocated for the sets (if needed). \param n_set_in @@ -75,10 +150,11 @@ \param end_in is the maximum element plus one (the minimum element is 0). */ - void resize(size_t n_set_in, size_t end_in) + void resize(size_t n_set_in, size_t end_in) { n_set_ = n_set_in; end_ = end_in; - next_element_.value = end_in; + next_pair_.value = end_in; + data_not_used_ = 0; if( n_set_in == 0 ) { // free all memory connected with this object data_.free(); @@ -118,17 +194,17 @@ return; } - // search list for place to insert + // search list for place to insert size_t previous = index; size_t current = data_[previous].next; value = data_[current].value; while( value < element ) { previous = current; current = data_[previous].next; - value = data_[current].value; + value = data_[current].value; } if( element != value ) - { CPPAD_ASSERT_UNKNOWN( element < value ); + { CPPAD_ASSERT_UNKNOWN( element < value ); size_t insert = data_.extend(1); // data_[insert].next = data_[previous].next; @@ -137,13 +213,13 @@ } } // ----------------------------------------------------------------- - /*! Is an element of a set. + /*! Is an element in a set. \param index is the index for this set in the vector of sets. \param element - is the element we are adding to the set. + is the element we are checking to see if it is in set. \par Checked Assertions \li index < n_set_ @@ -164,7 +240,7 @@ } // ----------------------------------------------------------------- /*! Begin retrieving elements from one of the sets. - + \param index is the index for the set that is going to be retrieved. The elements of the set are retrieved in increasing order. @@ -176,25 +252,26 @@ void begin(size_t index) { // initialize element to search for in this set CPPAD_ASSERT_UNKNOWN( index < n_set_ ); - next_element_ = data_[index]; + next_pair_ = data_[index]; return; } // ----------------------------------------------------------------- /*! Get the next element from the current retrieval set. - + \return is the next element in the set with index specified by the previous call to \c begin. If no such element exists, \c this->end() is returned. \par Assumption - There is no call to \c add_element since the previvious \c begin + There is no call to \c add_element or \c binary_union + since the previvious \c begin */ size_t next_element(void) - { size_t element = next_element_.value; + { size_t element = next_pair_.value; if( element != end_ ) - next_element_ = data_[next_element_.next]; + next_pair_ = data_[next_pair_.next]; return element; } @@ -204,12 +281,26 @@ \param target is the index of the set we are setting to the empty set. + \par data_not_used_ + increments this value by number of elements lost. + \par Checked Assertions \li target < n_set_ */ void clear(size_t target) { CPPAD_ASSERT_UNKNOWN( target < n_set_ ); + + // number of elements that will be deleted by this operation + size_t number_delete = number_elements(target); + + // delete the elements from the set data_[target].value = end_; + + // adjust data_not_used_ + data_not_used_ += number_delete; + + if( 2 * data_not_used_ > data_.size() ) + collect_garbage(); } // ----------------------------------------------------------------- /*! Assign one set equal to another set. @@ -218,25 +309,35 @@ is the index (in this \c sparse_list object) of the set being assinged. \param other_source - is the index (in the other \c sparse_list object) of the + is the index (in the other \c sparse_list object) of the that we are using as the value to assign to the target set. \param other is the other \c sparse_list object (which may be the same as this \c sparse_list object). + \par data_not_used_ + increments this value by number of elements lost. + \par Checked Assertions \li this_target < n_set_ \li other_index < other.n_set_ */ void assignment( - size_t this_target , - size_t other_source , + size_t this_target , + size_t other_source , const sparse_list& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( other_source < other.n_set_ ); CPPAD_ASSERT_UNKNOWN( end_ == other.end() ); + // check if we are assigning a set to itself + if( (this == &other) & (this_target == other_source) ) + return; + + // number of elements that will be deleted by this operation + size_t number_delete = number_elements(this_target); + size_t this_index = this_target; size_t other_index = other_source; size_t value = other.data_[other_index].value; @@ -249,6 +350,12 @@ value = other.data_[other_index].value; } data_[this_index].value = end_; + + // adjust data_not_used_ + data_not_used_ += number_delete; + + if( 2 * data_not_used_ > data_.size() ) + collect_garbage(); } // ----------------------------------------------------------------- /*! Assign a set equal to the union of two other sets. @@ -257,12 +364,12 @@ is the index (in this \c sparse_list object) of the set being assinged. \param this_left - is the index (in this \c sparse_list object) of the + is the index (in this \c sparse_list object) of the left operand for the union operation. It is OK for \a this_target and \a this_left to be the same value. \param other_right - is the index (in the other \c sparse_list object) of the + is the index (in the other \c sparse_list object) of the right operand for the union operation. It is OK for \a this_target and \a other_right to be the same value. @@ -276,21 +383,32 @@ \li other_right < other.n_set_ */ void binary_union( - size_t this_target , - size_t this_left , - size_t other_right , + size_t this_target , + size_t this_left , + size_t other_right , const sparse_list& other ) - { + { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( this_left < n_set_ ); CPPAD_ASSERT_UNKNOWN( other_right < other.n_set_ ); CPPAD_ASSERT_UNKNOWN( end_ == other.end() ); - // merge left and right into target set + // determine if we will delete the original version of the target + size_t number_delete = 0; + bool delete_target = this_target == this_left; + delete_target |= (this == &other) & (this_target == other_right); + if( delete_target ) + { // number of elements that will be deleted by this operation + number_delete = number_elements(this_target); + } + + // value and next for left and right sets size_t left_value = data_[this_left].value; size_t left_next = data_[this_left].next; size_t right_value = other.data_[other_right].value; size_t right_next = other.data_[other_right].next; + + // merge left and right sets to form new target set size_t current = this_target; while( (left_value < end_) | (right_value < end_) ) { if( left_value == right_value ) @@ -312,44 +430,49 @@ current = next; } data_[current].value = end_; + + // adjust data_not_used_ + data_not_used_ += number_delete; + + if( 2 * data_not_used_ > data_.size() ) + collect_garbage(); } // ----------------------------------------------------------------- /*! Sum over all sets of the number of elements - + /return The the total number of elements - */ + */ size_t number_elements(void) const { size_t i, count; count = 0; for(i = 0; i < n_set_; i++) - { size_t index = i; - while( data_[index].value != end_ ) - { count++; - index = data_[index].next; - } - } + count += number_elements(i); return count; } // ----------------------------------------------------------------- /*! Fetch n_set for vector of sets object. - + \return Number of from sets for this vector of sets object */ size_t n_set(void) const { return n_set_; } // ----------------------------------------------------------------- - /*! Fetch end for this vector of sets object. - + /*! Fetch end for this vector of sets object. + \return is the maximum element value plus one (the minimum element value is 0). */ size_t end(void) const { return end_; } }; +// Tell pod_vector class that each pair_size_t is plain old data and hence +// the corresponding constructor need not be called. +template <> inline bool is_pod(void) +{ return true; } -/*! +/*! Copy a user vector of sets sparsity pattern to an internal sparse_list object. \tparam VectorSet @@ -373,21 +496,20 @@ \param transpose if true, the sparsity pattern in \c internal is the transpose -of the one in \c user. +of the one in \c user. Otherwise it is the same sparsity pattern. */ template void sparsity_user2internal( - sparse_list& internal , + sparse_list& internal , const VectorSet& user , size_t n_row , size_t n_col , bool transpose ) -{ CPPAD_ASSERT_UNKNOWN( n_row == size_t(user.size()) ); - +{ CPPAD_ASSERT_KNOWN( size_t( user.size() ) == n_row, - "Size of this vector of lists sparsity pattern is not equal " + "Size of this vector of sets sparsity pattern is not equal\n" "the range dimension for the corresponding function." ); @@ -401,7 +523,12 @@ { itr = user[i].begin(); while(itr != user[i].end()) { j = *itr++; - CPPAD_ASSERT_UNKNOWN( j < n_col ); + CPPAD_ASSERT_KNOWN( + j < n_col, + "An element in this vector of sets sparsity pattern " + "is greater than or equal\n" + "the domain dimension for the corresponding function." + ); internal.add_element(j, i); } } diff -Nru cppad-2015.00.00.9/cppad/local/sparse_pack.hpp cppad-2016.00.00.1/cppad/local/sparse_pack.hpp --- cppad-2015.00.00.9/cppad/local/sparse_pack.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse_pack.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: sparse_pack.hpp 3301 2014-05-24 05:20:21Z bradbell $ -# ifndef CPPAD_SPARSE_PACK_INCLUDED -# define CPPAD_SPARSE_PACK_INCLUDED +// $Id: sparse_pack.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_PACK_HPP +# define CPPAD_SPARSE_PACK_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -32,7 +32,7 @@ typedef size_t Pack; /// Number of bits per Pack value static const size_t n_bit_ = std::numeric_limits::digits; - /// Number of sets that we are representing + /// Number of sets that we are representing /// (set by constructor and resize). size_t n_set_; /// Possible elements in each set are 0, 1, ..., end_ - 1 @@ -46,40 +46,40 @@ /// index for which we were retrieving next_element /// (use n_set_ if no such index exists). size_t next_index_; - /// Next element to start search at + /// Next element to start search at /// (use end_ for no such element exists; i.e., past end of the set). size_t next_element_; public: // ----------------------------------------------------------------- /*! Default constructor (no sets) */ - sparse_pack(void) : - n_set_(0) , - end_(0) , + sparse_pack(void) : + n_set_(0) , + end_(0) , n_pack_(0) , next_index_(0) , next_element_(0) { } // ----------------------------------------------------------------- /*! Make use of copy constructor an error - + \param v vector that we are attempting to make a copy of. - */ + */ sparse_pack(const sparse_pack& v) - { // Error: + { // Error: // Probably a sparse_pack argument has been passed by value - CPPAD_ASSERT_UNKNOWN(0); + CPPAD_ASSERT_UNKNOWN(0); } // ----------------------------------------------------------------- - /*! Destructor + /*! Destructor */ ~sparse_pack(void) { } // ----------------------------------------------------------------- /*! Change number of sets, set end, and initialize all sets as empty - If \c n_set_in is zero, any memory currently allocated for this object + If \c n_set_in is zero, any memory currently allocated for this object is freed. Otherwise, new memory may be allocated for the sets (if needed). \param n_set_in @@ -88,7 +88,7 @@ \param end_in is the maximum element plus one (the minimum element is 0). */ - void resize(size_t n_set_in, size_t end_in) + void resize(size_t n_set_in, size_t end_in) { n_set_ = n_set_in; end_ = end_in; @@ -160,7 +160,7 @@ } // ----------------------------------------------------------------- /*! Begin retrieving elements from one of the sets. - + \param index is the index for the set that is going to be retrieved. The elements of the set are retrieved in increasing order. @@ -172,10 +172,10 @@ { // initialize element to search for in this set CPPAD_ASSERT_UNKNOWN( index < n_set_ ); next_index_ = index; - next_element_ = 0; + next_element_ = 0; } /*! Get the next element from the current retrieval set. - + \return is the next element in the set with index specified by the previous call to \c begin. @@ -206,7 +206,7 @@ // check if no more elements in the set if( next_element_ == end_ ) return end_; - // increment bit index in Pack value so corresponds to + // increment bit index in Pack value so corresponds to // next element k++; CPPAD_ASSERT_UNKNOWN( k <= n_bit_ ); @@ -248,7 +248,7 @@ is the index (in this \c sparse_pack object) of the set being assinged. \param other_value - is the index (in the other \c sparse_pack object) of the + is the index (in the other \c sparse_pack object) of the that we are using as the value to assign to the target set. \param other @@ -258,11 +258,11 @@ \par Checked Assertions \li this_target < n_set_ \li other_value < other.n_set_ - \li n_pack_ == other.n_pack_ + \li n_pack_ == other.n_pack_ */ void assignment( - size_t this_target , - size_t other_value , + size_t this_target , + size_t other_value , const sparse_pack& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( other_value < other.n_set_ ); @@ -282,12 +282,12 @@ is the index (in this \c sparse_pack object) of the set being assinged. \param this_left - is the index (in this \c sparse_pack object) of the + is the index (in this \c sparse_pack object) of the left operand for the union operation. It is OK for \a this_target and \a this_left to be the same value. \param other_right - is the index (in the other \c sparse_pack object) of the + is the index (in the other \c sparse_pack object) of the right operand for the union operation. It is OK for \a this_target and \a other_right to be the same value. @@ -299,12 +299,12 @@ \li this_target < n_set_ \li this_left < n_set_ \li other_right < other.n_set_ - \li n_pack_ == other.n_pack_ + \li n_pack_ == other.n_pack_ */ void binary_union( - size_t this_target , - size_t this_left , - size_t other_right , + size_t this_target , + size_t this_left , + size_t other_right , const sparse_pack& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( this_left < n_set_ ); @@ -321,24 +321,24 @@ } // ----------------------------------------------------------------- /*! Amount of memory used by this vector of sets - + \return The amount of memory in units of type unsigned char memory. - */ + */ size_t memory(void) const { return n_set_ * n_pack_ * sizeof(Pack); } // ----------------------------------------------------------------- /*! Fetch n_set for vector of sets object. - + \return Number of from sets for this vector of sets object */ size_t n_set(void) const { return n_set_; } // ----------------------------------------------------------------- - /*! Fetch end for this vector of sets object. - + /*! Fetch end for this vector of sets object. + \return is the maximum element value plus one (the minimum element value is 0). */ @@ -346,7 +346,7 @@ { return end_; } }; -/*! +/*! Copy a user vector of bools sparsity pattern to an internal sparse_pack object. \tparam VectorBool @@ -370,23 +370,23 @@ \param transpose if true, the sparsity pattern in \c internal is the transpose -of the one in \c user. +of the one in \c user. Otherwise it is the same sparsity pattern. */ template void sparsity_user2internal( - sparse_pack& internal , + sparse_pack& internal , const VectorBool& user , size_t n_row , size_t n_col , bool transpose ) -{ CPPAD_ASSERT_UNKNOWN( n_row * n_col == size_t(user.size()) ); +{ size_t i, j; CPPAD_ASSERT_KNOWN( size_t( user.size() ) == n_row * n_col, - "Size of this vector of bools sparsity pattern is not equal product " - "of the domain and range dimensions for corresponding function." + "Size of this vector of bools sparsity pattern is not equal\n" + "product of domain and range dimensions for corresponding function." ); // transposed pattern case diff -Nru cppad-2015.00.00.9/cppad/local/sparse_pattern.hpp cppad-2016.00.00.1/cppad/local/sparse_pattern.hpp --- cppad-2015.00.00.9/cppad/local/sparse_pattern.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse_pattern.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sparse_pattern.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_SPARSE_PATTERN_INCLUDED -# define CPPAD_SPARSE_PATTERN_INCLUDED +// $Id: sparse_pattern.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_PATTERN_HPP +# define CPPAD_SPARSE_PATTERN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -40,19 +40,19 @@ /*! Specilization for \c bool elements. */ -template <> -struct internal_sparsity +template <> +struct internal_sparsity { typedef sparse_pack pattern_type; }; /*! Specilization for std::set elements. */ -template <> -struct internal_sparsity< std::set > +template <> +struct internal_sparsity< std::set > { typedef CPPAD_INTERNAL_SPARSE_SET pattern_type; -}; +}; } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/sparse_set.hpp cppad-2016.00.00.1/cppad/local/sparse_set.hpp --- cppad-2015.00.00.9/cppad/local/sparse_set.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse_set.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: sparse_set.hpp 3301 2014-05-24 05:20:21Z bradbell $ -# ifndef CPPAD_SPARSE_SET_INCLUDED -# define CPPAD_SPARSE_SET_INCLUDED +// $Id: sparse_set.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_SET_HPP +# define CPPAD_SPARSE_SET_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -32,7 +32,7 @@ private: /// type used for each set in the vector sets typedef std::set Set; - /// Number of sets that we are representing + /// Number of sets that we are representing /// (set by constructor and resize). size_t n_set_; /// Possible elements in each set are 0, 1, ..., end_ - 1 @@ -50,32 +50,32 @@ // ----------------------------------------------------------------- /*! Default constructor (no sets) */ - sparse_set(void) : - n_set_(0) , - end_(0) , + sparse_set(void) : + n_set_(0) , + end_(0) , next_index_(0) { } // ----------------------------------------------------------------- /*! Make use of copy constructor an error - + \param v vector that we are attempting to make a copy of. - */ + */ sparse_set(const sparse_set& v) - { // Error: + { // Error: // Probably a sparse_set argument has been passed by value - CPPAD_ASSERT_UNKNOWN(false); + CPPAD_ASSERT_UNKNOWN(false); } // ----------------------------------------------------------------- - /*! Destructor + /*! Destructor */ ~sparse_set(void) - { } + { } // ----------------------------------------------------------------- /*! Change number of sets, set end, and initialize all sets as empty - If \c n_set_in is zero, any memory currently allocated for this object + If \c n_set_in is zero, any memory currently allocated for this object is freed. Otherwise, new memory may be allocated for the sets (if needed). \param n_set_in @@ -84,7 +84,7 @@ \param end_in is the maximum element plus one (the minimum element is 0). */ - void resize(size_t n_set_in, size_t end_in) + void resize(size_t n_set_in, size_t end_in) { n_set_ = n_set_in; end_ = end_in; if( n_set_ == 0 ) @@ -145,7 +145,7 @@ } // ----------------------------------------------------------------- /*! Begin retrieving elements from one of the sets. - + \param index is the index for the set that is going to be retrieved. The elements of the set are retrieved in increasing order. @@ -157,13 +157,13 @@ { // initialize element to search for in this set CPPAD_ASSERT_UNKNOWN( index < n_set_ ); next_index_ = index; - next_element_ = data_[index].begin(); + next_element_ = data_[index].begin(); return; } // ----------------------------------------------------------------- /*! Get the next element from the current retrieval set. - + \return is the next element in the set with index specified by the previous call to \c begin. @@ -196,7 +196,7 @@ is the index (in this \c sparse_set object) of the set being assinged. \param other_value - is the index (in the other \c sparse_set object) of the + is the index (in the other \c sparse_set object) of the that we are using as the value to assign to the target set. \param other @@ -208,8 +208,8 @@ \li other_value < other.n_set_ */ void assignment( - size_t this_target , - size_t other_value , + size_t this_target , + size_t other_value , const sparse_set& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( other_value < other.n_set_ ); @@ -224,12 +224,12 @@ is the index (in this \c sparse_set object) of the set being assinged. \param this_left - is the index (in this \c sparse_set object) of the + is the index (in this \c sparse_set object) of the left operand for the union operation. It is OK for \a this_target and \a this_left to be the same value. \param other_right - is the index (in the other \c sparse_set object) of the + is the index (in the other \c sparse_set object) of the right operand for the union operation. It is OK for \a this_target and \a other_right to be the same value. @@ -243,9 +243,9 @@ \li other_right < other.n_set_ */ void binary_union( - size_t this_target , - size_t this_left , - size_t other_right , + size_t this_target , + size_t this_left , + size_t other_right , const sparse_set& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( this_left < n_set_ ); @@ -264,14 +264,14 @@ // move results to the target set with out copying elements data_[this_target].swap(temp); - + } // ----------------------------------------------------------------- /*! Sum over all sets of the number of elements - + /return The the total number of elements - */ + */ size_t number_elements(void) const { size_t i, count; count = 0; @@ -281,15 +281,15 @@ } // ----------------------------------------------------------------- /*! Fetch n_set for vector of sets object. - + \return Number of from sets for this vector of sets object */ size_t n_set(void) const { return n_set_; } // ----------------------------------------------------------------- - /*! Fetch end for this vector of sets object. - + /*! Fetch end for this vector of sets object. + \return is the maximum element value plus one (the minimum element value is 0). */ @@ -297,7 +297,7 @@ { return end_; } }; -/*! +/*! Copy a user vector of sets sparsity pattern to an internal sparse_set object. \tparam VectorSet @@ -321,21 +321,20 @@ \param transpose if true, the sparsity pattern in \c internal is the transpose -of the one in \c user. +of the one in \c user. Otherwise it is the same sparsity pattern. */ template void sparsity_user2internal( - sparse_set& internal , + sparse_set& internal , const VectorSet& user , size_t n_row , size_t n_col , bool transpose ) -{ CPPAD_ASSERT_UNKNOWN( n_row == size_t(user.size()) ); - +{ CPPAD_ASSERT_KNOWN( size_t( user.size() ) == n_row, - "Size of this vector of sets sparsity pattern is not equal " + "Size of this vector of sets sparsity pattern is not equal\n" "the range dimension for the corresponding function." ); @@ -349,7 +348,12 @@ { itr = user[i].begin(); while(itr != user[i].end()) { j = *itr++; - CPPAD_ASSERT_UNKNOWN( j < n_col ); + CPPAD_ASSERT_KNOWN( + j < n_col, + "An element in this vector of sets sparsity pattern " + "is greater than or equal\n" + "the domain dimension for the corresponding function." + ); internal.add_element(j, i); } } diff -Nru cppad-2015.00.00.9/cppad/local/sparse_unary_op.hpp cppad-2016.00.00.1/cppad/local/sparse_unary_op.hpp --- cppad-2015.00.00.9/cppad/local/sparse_unary_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sparse_unary_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: sparse_unary_op.hpp 3301 2014-05-24 05:20:21Z bradbell $ */ -# ifndef CPPAD_SPARSE_UNARY_OP_INCLUDED -# define CPPAD_SPARSE_UNARY_OP_INCLUDED +// $Id: sparse_unary_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_UNARY_OP_HPP +# define CPPAD_SPARSE_UNARY_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ /*! -Forward mode Jacobian sparsity pattern for all unary operators. +Forward mode Jacobian sparsity pattern for all unary operators. The C++ source code corresponding to a unary operation has the form \verbatim @@ -37,8 +37,8 @@ \c sparse_pack, \c sparse_set or \c sparse_list. \param i_z -variable index corresponding to the result for this operation; -i.e., z. +variable index corresponding to the result for this operation; +i.e., z. \param i_x variable index corresponding to the argument for this operator; @@ -49,17 +49,17 @@ \b Input: The set with index \a arg[0] in \a sparsity is the sparsity bit pattern for x. This identifies which of the independent variables the variable x -depends on. +depends on. \n \n \b Output: The set with index \a i_z in \a sparsity is the sparsity bit pattern for z. This identifies which of the independent variables the variable z -depends on. +depends on. \n \par Checked Assertions: -\li \a i_x < \a i_z +\li \a i_x < \a i_z */ template @@ -67,15 +67,15 @@ size_t i_z , size_t i_x , Vector_set& sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( i_x < i_z ); sparsity.assignment(i_z, i_x, sparsity); -} +} /*! -Reverse mode Jacobian sparsity pattern for all unary operators. +Reverse mode Jacobian sparsity pattern for all unary operators. The C++ source code corresponding to a unary operation has the form \verbatim @@ -89,7 +89,7 @@ This routine is given the sparsity patterns for a function G(z, y, ... ) -and it uses them to compute the sparsity patterns for +and it uses them to compute the sparsity patterns for \verbatim H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] \endverbatim @@ -100,28 +100,28 @@ \param i_z -variable index corresponding to the result for this operation; -i.e. the row index in sparsity corresponding to z. +variable index corresponding to the result for this operation; +i.e. the row index in sparsity corresponding to z. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in sparsity corresponding to x. \param sparsity -\b Input: -The set with index \a i_z in \a sparsity -is the sparsity bit pattern for G with respect to the variable z. +\b Input: +The set with index \a i_z in \a sparsity +is the sparsity bit pattern for G with respect to the variable z. \n -\b Input: +\b Input: The set with index \a i_x in \a sparsity -is the sparsity bit pattern for G with respect to the variable x. +is the sparsity bit pattern for G with respect to the variable x. \n -\b Output: -The set with index \a i_x in \a sparsity +\b Output: +The set with index \a i_x in \a sparsity is the sparsity bit pattern for H with respect to the variable x. \par Checked Assertions: -\li \a i_x < \a i_z +\li \a i_x < \a i_z */ template @@ -129,14 +129,14 @@ size_t i_z , size_t i_x , Vector_set& sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( i_x < i_z ); sparsity.binary_union(i_x, i_x, i_z, sparsity); return; -} +} /*! Reverse mode Hessian sparsity pattern for linear unary operators. @@ -160,7 +160,7 @@ bool* rev_jacobian , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( i_x < i_z ); @@ -193,7 +193,7 @@ bool* rev_jacobian , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( i_x < i_z ); diff -Nru cppad-2015.00.00.9/cppad/local/sqrt_op.hpp cppad-2016.00.00.1/cppad/local/sqrt_op.hpp --- cppad-2015.00.00.9/cppad/local/sqrt_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sqrt_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sqrt_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_SQRT_OP_INCLUDED -# define CPPAD_SQRT_OP_INCLUDED +// $Id: sqrt_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SQRT_OP_HPP +# define CPPAD_SQRT_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -37,9 +37,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SqrtOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SqrtOp) == 1 ); @@ -57,10 +57,6 @@ } for(size_t j = p; j <= q; j++) { - CPPAD_ASSERT_KNOWN( - x[0] != Base(0), - "Forward: attempt to take derivatve of square root of zero" - ) z[j] = Base(0); for(k = 1; k < j; k++) z[j] -= Base(k) * z[k] * z[j-k]; @@ -86,9 +82,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SqrtOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SqrtOp) == 1 ); @@ -99,10 +95,6 @@ size_t num_taylor_per_var = (cap_order-1) * r + 1; Base* z = taylor + i_z * num_taylor_per_var; Base* x = taylor + i_x * num_taylor_per_var; - CPPAD_ASSERT_KNOWN( - x[0] != Base(0), - "Forward: attempt to take derivatve of square root of zero" - ) size_t m = (q-1) * r + 1; for(size_t ell = 0; ell < r; ell++) @@ -112,7 +104,7 @@ z[m+ell] /= Base(q); z[m+ell] += x[m+ell] / Base(2); z[m+ell] /= z[0]; - } + } } /*! @@ -129,7 +121,7 @@ inline void forward_sqrt_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -159,7 +151,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -177,10 +169,8 @@ const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; - CPPAD_ASSERT_KNOWN( - z[0] != Base(0), - "Reverse: attempt to take derivatve of square root of zero" - ) + + Base inv_z0 = Base(1) / z[0]; // number of indices to access size_t j = d; @@ -189,15 +179,15 @@ { // scale partial w.r.t. z[j] - pz[j] /= z[0]; + pz[j] = azmul(pz[j], inv_z0); - pz[0] -= pz[j] * z[j]; + pz[0] -= azmul(pz[j], z[j]); px[j] += pz[j] / Base(2); for(k = 1; k < j; k++) - pz[k] -= pz[j] * z[j-k]; + pz[k] -= azmul(pz[j], z[j-k]); --j; } - px[0] += pz[0] / (Base(2) * z[0]); + px[0] += azmul(pz[0], inv_z0) / Base(2); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/standard_math.hpp cppad-2016.00.00.1/cppad/local/standard_math.hpp --- cppad-2015.00.00.9/cppad/local/standard_math.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/standard_math.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -0,0 +1,132 @@ +// $Id$ +# ifndef CPPAD_STANDARD_MATH_HPP +# define CPPAD_STANDARD_MATH_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin unary_standard_math$$ +$spell + const + VecAD + fabs +$$ + +$section The Unary Standard Math Functions$$ + +$head Syntax$$ +$icode%y% = %fun%(%x%)%$$ + +$head Purpose$$ +Evaluates the standard math function $icode fun$$. + +$head Possible Types$$ + +$subhead Base$$ +If $icode Base$$ satisfies the +$cref/base type requirements/base_require/$$ +and argument $icode x$$ has prototype +$codei% + const %Base%& %x% +%$$ +then the result $icode y$$ has prototype +$codei% + %Base% %y% +%$$ + +$subhead AD$$ +If the argument $icode x$$ has prototype +$codei% + const AD<%Base%>& %x% +%$$ +then the result $icode y$$ has prototype +$codei% + AD<%Base%> %y% +%$$ + +$subhead VecAD$$ +If the argument $icode x$$ has prototype +$codei% + const VecAD<%Base%>::reference& %x% +%$$ +then the result $icode y$$ has prototype +$codei% + AD<%Base%> %y% +%$$ + +$children%cppad/local/std_math_98.hpp + %cppad/local/abs.hpp + %cppad/local/acosh.hpp + %cppad/local/asinh.hpp + %cppad/local/atanh.hpp + %cppad/local/erf.hpp + %cppad/local/expm1.hpp + %cppad/local/log1p.hpp + %cppad/local/sign.hpp +%$$ + +$head fun$$ +The possible values for $icode fun$$ are +$table +$icode fun$$ $pre $$ $cnext Description $rnext +$cref abs$$ $cnext $title abs$$ $rnext +$cref acos$$ $cnext $title acos$$ $rnext +$cref acosh$$ $cnext $title acosh$$ $rnext +$cref asin$$ $cnext $title asin$$ $rnext +$cref asinh$$ $cnext $title asinh$$ $rnext +$cref atan$$ $cnext $title atan$$ $rnext +$cref atanh$$ $cnext $title atanh$$ $rnext +$cref cos$$ $cnext $title cos$$ $rnext +$cref cosh$$ $cnext $title cosh$$ $rnext +$cref erf$$ $cnext $title erf$$ $rnext +$cref exp$$ $cnext $title exp$$ $rnext +$cref expm1$$ $cnext $title expm1$$ $rnext +$cref/fabs/abs/$$ $cnext $title abs$$ $rnext +$cref log10$$ $cnext $title log10$$ $rnext +$cref log1p$$ $cnext $title log1p$$ $rnext +$cref log$$ $cnext $title log$$ $rnext +$cref sign$$ $cnext $title sign$$ $rnext +$cref sin$$ $cnext $title sin$$ $rnext +$cref sinh$$ $cnext $title sinh$$ $rnext +$cref sqrt$$ $cnext $title sqrt$$ $rnext +$cref tan$$ $cnext $title tan$$ $rnext +$cref tanh$$ $cnext $title tanh$$ +$tend + +$end +*/ +# include +# include +# include +# include +# include +# include +# include +# include +# include + +/* +$begin binary_math$$ + +$section The Binary Math Functions$$ + +$childtable%cppad/local/atan2.hpp + %cppad/local/pow.hpp + %cppad/local/azmul.hpp +%$$ + +$end +*/ +# include +# include + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/std_math_98.hpp cppad-2016.00.00.1/cppad/local/std_math_98.hpp --- cppad-2015.00.00.9/cppad/local/std_math_98.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/std_math_98.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,601 @@ +// $Id$ +# ifndef CPPAD_STD_MATH_98_HPP +# define CPPAD_STD_MATH_98_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +------------------------------------------------------------------------------- +$begin acos$$ +$spell + acos +$$ + +$section Inverse Sine Function: acos$$ + +$head Syntax$$ +$icode%y% = acos(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{acos}^{(1)} (x) & = & - (1 - x * x)^{-1/2} +\end{array} +\] $$ + +$head Example$$ +$children% + example/acos.cpp +%$$ +The file +$cref acos.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin asin$$ +$spell + asin +$$ + +$section Inverse Sine Function: asin$$ + +$head Syntax$$ +$icode%y% = asin(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{asin}^{(1)} (x) & = & (1 - x * x)^{-1/2} +\end{array} +\] $$ + +$head Example$$ +$children% + example/asin.cpp +%$$ +The file +$cref asin.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin atan$$ +$spell + atan +$$ + +$section Inverse Tangent Function: atan$$ + +$head Syntax$$ +$icode%y% = atan(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{atan}^{(1)} (x) & = & \frac{1}{1 + x^2} +\end{array} +\] $$ + +$head Example$$ +$children% + example/atan.cpp +%$$ +The file +$cref atan.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin cos$$ +$spell + cos +$$ + +$section The Cosine Function: cos$$ + +$head Syntax$$ +$icode%y% = cos(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{cos}^{(1)} (x) & = & - \sin(x) +\end{array} +\] $$ + +$head Example$$ +$children% + example/cos.cpp +%$$ +The file +$cref cos.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin cosh$$ +$spell + cosh +$$ + +$section The Hyperbolic Cosine Function: cosh$$ + +$head Syntax$$ +$icode%y% = cosh(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{cosh}^{(1)} (x) & = & \sinh(x) +\end{array} +\] $$ + +$head Example$$ +$children% + example/cosh.cpp +%$$ +The file +$cref cosh.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin exp$$ +$spell + exp +$$ + +$section The Exponential Function: exp$$ + +$head Syntax$$ +$icode%y% = exp(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{exp}^{(1)} (x) & = & \exp(x) +\end{array} +\] $$ + +$head Example$$ +$children% + example/exp.cpp +%$$ +The file +$cref exp.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin log$$ +$spell +$$ + +$section The Exponential Function: log$$ + +$head Syntax$$ +$icode%y% = log(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{log}^{(1)} (x) & = & \frac{1}{x} +\end{array} +\] $$ + +$head Example$$ +$children% + example/log.cpp +%$$ +The file +$cref log.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin log10$$ +$spell + CppAD +$$ + +$section The Base 10 Logarithm Function: log10$$ + +$head Syntax$$ +$icode%y% = log10(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Method$$ +CppAD uses the representation +$latex \[ +\begin{array}{lcr} + {\rm log10} (x) & = & \log(x) / \log(10) +\end{array} +\] $$ + +$head Example$$ +$children% + example/log10.cpp +%$$ +The file +$cref log10.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin sin$$ +$spell + sin +$$ + +$section The Sine Function: sin$$ + +$head Syntax$$ +$icode%y% = sin(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{sin}^{(1)} (x) & = & \cos(x) +\end{array} +\] $$ + +$head Example$$ +$children% + example/sin.cpp +%$$ +The file +$cref sin.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin sinh$$ +$spell + sinh +$$ + +$section The Hyperbolic Sine Function: sinh$$ + +$head Syntax$$ +$icode%y% = sinh(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{sinh}^{(1)} (x) & = & \cosh(x) +\end{array} +\] $$ + +$head Example$$ +$children% + example/sinh.cpp +%$$ +The file +$cref sinh.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin sqrt$$ +$spell + sqrt +$$ + +$section The Square Root Function: sqrt$$ + +$head Syntax$$ +$icode%y% = sqrt(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{sqrt}^{(1)} (x) & = & \frac{1}{2 \R{sqrt} (x) } +\end{array} +\] $$ + +$head Example$$ +$children% + example/sqrt.cpp +%$$ +The file +$cref sqrt.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin tan$$ +$spell + tan +$$ + +$section The Tangent Function: tan$$ + +$head Syntax$$ +$icode%y% = tan(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{tan}^{(1)} (x) & = & 1 + \tan (x)^2 +\end{array} +\] $$ + +$head Example$$ +$children% + example/tan.cpp +%$$ +The file +$cref tan.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +$begin tanh$$ +$spell + tanh +$$ + +$section The Hyperbolic Tangent Function: tanh$$ + +$head Syntax$$ +$icode%y% = tanh(%x%)%$$ + +$head x, y$$ +See the $cref/possible types/unary_standard_math/Possible Types/$$ +for a unary standard math function. + +$head Atomic$$ +This is an $cref/atomic operation/glossary/Operation/Atomic/$$. + +$head Derivative$$ +$latex \[ +\begin{array}{lcr} + \R{tanh}^{(1)} (x) & = & 1 - \tanh (x)^2 +\end{array} +\] $$ + +$head Example$$ +$children% + example/tanh.cpp +%$$ +The file +$cref tanh.cpp$$ +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------- +*/ + +/*! +\file std_math_98.hpp +Define AD standard math functions (using their Base versions) +*/ + +/*! +\def CPPAD_STANDARD_MATH_UNARY_AD(Name, Op) +Defines function Name with argument type AD and tape operation Op + +The macro defines the function x.Name() where x has type AD. +It then uses this funciton to define Name(x) where x has type +AD or VecAD_reference. + +If x is a variable, the tape unary operator Op is used +to record the operation and the result is identified as correspoding +to this operation; i.e., Name(x).taddr_ idendifies the operation and +Name(x).tape_id_ identifies the tape. + +This macro is used to define AD versions of +acos, asin, atan, cos, cosh, exp, fabs, log, sin, sinh, sqrt, tan, tanh. +*/ + +# define CPPAD_STANDARD_MATH_UNARY_AD(Name, Op) \ + template \ + inline AD Name(const AD &x) \ + { return x.Name(); } \ + template \ + inline AD AD::Name (void) const \ + { \ + AD result; \ + result.value_ = CppAD::Name(value_); \ + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); \ + \ + if( Variable(*this) ) \ + { CPPAD_ASSERT_UNKNOWN( NumArg(Op) == 1 ); \ + ADTape *tape = tape_this(); \ + tape->Rec_.PutArg(taddr_); \ + result.taddr_ = tape->Rec_.PutOp(Op); \ + result.tape_id_ = tape->id_; \ + } \ + return result; \ + } \ + template \ + inline AD Name(const VecAD_reference &x) \ + { return Name( x.ADBase() ); } + +// BEGIN CppAD namespace +namespace CppAD { + + CPPAD_STANDARD_MATH_UNARY_AD(acos, AcosOp) + CPPAD_STANDARD_MATH_UNARY_AD(asin, AsinOp) + CPPAD_STANDARD_MATH_UNARY_AD(atan, AtanOp) + CPPAD_STANDARD_MATH_UNARY_AD(cos, CosOp) + CPPAD_STANDARD_MATH_UNARY_AD(cosh, CoshOp) + CPPAD_STANDARD_MATH_UNARY_AD(exp, ExpOp) + CPPAD_STANDARD_MATH_UNARY_AD(fabs, AbsOp) + CPPAD_STANDARD_MATH_UNARY_AD(log, LogOp) + CPPAD_STANDARD_MATH_UNARY_AD(sin, SinOp) + CPPAD_STANDARD_MATH_UNARY_AD(sinh, SinhOp) + CPPAD_STANDARD_MATH_UNARY_AD(sqrt, SqrtOp) + CPPAD_STANDARD_MATH_UNARY_AD(tan, TanOp) + CPPAD_STANDARD_MATH_UNARY_AD(tanh, TanhOp) + +# if CPPAD_USE_CPLUSPLUS_2011 + CPPAD_STANDARD_MATH_UNARY_AD(asinh, AsinhOp) + CPPAD_STANDARD_MATH_UNARY_AD(acosh, AcoshOp) + CPPAD_STANDARD_MATH_UNARY_AD(atanh, AtanhOp) + CPPAD_STANDARD_MATH_UNARY_AD(expm1, Expm1Op) + CPPAD_STANDARD_MATH_UNARY_AD(log1p, Log1pOp) +# endif + +# if CPPAD_USE_CPLUSPLUS_2011 + // Error function is a special case + template + inline AD erf(const AD &x) + { return x.erf(); } + template + inline AD AD::erf (void) const + { + AD result; + result.value_ = CppAD::erf(value_); + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + if( Variable(*this) ) + { CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); + ADTape *tape = tape_this(); + // arg[0] = argument to erf function + tape->Rec_.PutArg(taddr_); + // arg[1] = zero + addr_t p = tape->Rec_.PutPar( Base(0) ); + tape->Rec_.PutArg(p); + // arg[2] = 2 / sqrt(pi) + p = tape->Rec_.PutPar(Base( + 1.0 / std::sqrt( std::atan(1.0) ) + )); + tape->Rec_.PutArg(p); + // + result.taddr_ = tape->Rec_.PutOp(ErfOp); + result.tape_id_ = tape->id_; + } + return result; + } + template + inline AD erf(const VecAD_reference &x) + { return erf( x.ADBase() ); } +# endif + + /*! + Compute the log of base 10 of x where has type AD + + \tparam Base + is the base type (different from base for log) + for this AD type, see base_require. + + \param x + is the argument for the log10 function. + + \result + if the result is y, then \f$ x = 10^y \f$. + */ + template + inline AD log10(const AD &x) + { return CppAD::log(x) / CppAD::log( Base(10) ); } + template + inline AD log10(const VecAD_reference &x) + { return CppAD::log(x.ADBase()) / CppAD::log( Base(10) ); } +} + +# undef CPPAD_STANDARD_MATH_UNARY_AD + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/std_math_ad.hpp cppad-2016.00.00.1/cppad/local/std_math_ad.hpp --- cppad-2015.00.00.9/cppad/local/std_math_ad.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/std_math_ad.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,376 +0,0 @@ -/* $Id: std_math_ad.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_STD_MATH_AD_INCLUDED -# define CPPAD_STD_MATH_AD_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------------- -$begin std_math_ad$$ -$spell - Vec - std - atan - const - acos - asin - atan - cos - exp - fabs - sqrt - CppAD - namespace - tanh -$$ - -$index standard, AD math unary$$ -$index math, AD unary$$ -$index unary, AD math$$ - -$index acos, AD$$ -$index asin, AD$$ -$index atan, AD$$ -$index cos, AD$$ -$index cosh, AD$$ -$index exp, AD$$ -$index fabs, AD$$ -$index log, AD$$ -$index log10, AD$$ -$index sin, AD$$ -$index sinh, AD$$ -$index sqrt, AD$$ -$index tan, AD$$ -$index tanh, AD$$ - -$section AD Standard Math Unary Functions$$ - -$head Syntax$$ -$icode%y% = %fun%(%x%)%$$ - - -$head Purpose$$ -Evaluates the one argument standard math function -$icode fun$$ where its argument is an -$cref/AD of/glossary/AD of Base/$$ $icode Base$$ object. - -$head x$$ -The argument $icode x$$ has one of the following prototypes -$codei% - const AD<%Base%> &%x% - const VecAD<%Base%>::reference &%x% -%$$ - -$head y$$ -The result $icode y$$ has prototype -$codei% - AD<%Base%> %y% -%$$ - - -$head Operation Sequence$$ -Most of these functions are AD of $icode Base$$ -$cref/atomic operations/glossary/Operation/Atomic/$$. -In all cases, -The AD of $icode Base$$ -operation sequence used to calculate $icode y$$ is -$cref/independent/glossary/Operation/Independent/$$ -of $icode x$$. - -$head fun$$ -A definition of $icode fun$$ is included -for each of the following functions: -$code acos$$, -$code asin$$, -$code atan$$, -$code cos$$, -$code cosh$$, -$code exp$$, -$code fabs$$, -$code log$$, -$code log10$$, -$code sin$$, -$code sinh$$, -$code sqrt$$, -$code tan$$, -$code tanh$$. - - -$head Examples$$ -The following files -contain examples and tests of these functions. -Each test returns true if it succeeds and false otherwise. -$children% - example/acos.cpp% - example/asin.cpp% - example/atan.cpp% - example/cos.cpp% - example/cosh.cpp% - example/exp.cpp% - example/log.cpp% - example/log10.cpp% - example/sin.cpp% - example/sinh.cpp% - example/sqrt.cpp% - example/tan.cpp% - example/tanh.cpp -%$$ -$table -$rref abs.cpp$$ -$rref Acos.cpp$$ -$rref Asin.cpp$$ -$rref atan.cpp$$ -$rref cos.cpp$$ -$rref cosh.cpp$$ -$rref exp.cpp$$ -$rref log.cpp$$ -$rref log10.cpp$$ -$rref sin.cpp$$ -$rref sinh.cpp$$ -$rref sqrt.cpp$$ -$rref tan.cpp$$ -$rref tanh.cpp$$ -$tend - - -$head Derivatives$$ -Each of these functions satisfy a standard math function differential equation. -Calculating derivatives using this differential equation -is discussed for -both $cref/forward/ForwardTheory/Standard Math Functions/$$ -and $cref/reverse/ReverseTheory/Standard Math Functions/$$ mode. -The exact form of the differential equation -for each of these functions is listed below: - -$subhead acos$$ -$latex \[ -\begin{array}{lcr} - \D{[ {\rm acos} (x) ]}{x} & = & - (1 - x * x)^{-1/2} -\end{array} -\] $$ - -$subhead asin$$ -$latex \[ -\begin{array}{lcr} - \D{[ {\rm asin} (x) ]}{x} & = & (1 - x * x)^{-1/2} -\end{array} -\] $$ - -$subhead atan$$ -$latex \[ -\begin{array}{lcr} - \D{[ {\rm atan} (x) ]}{x} & = & \frac{1}{1 + x^2} -\end{array} -\] $$ - -$subhead cos$$ -$latex \[ -\begin{array}{lcr} - \D{[ \cos (x) ]}{x} & = & - \sin (x) \\ - \D{[ \sin (x) ]}{x} & = & \cos (x) -\end{array} -\] $$ - -$subhead cosh$$ -$latex \[ -\begin{array}{lcr} - \D{[ \cosh (x) ]}{x} & = & \sinh (x) \\ - \D{[ \sin (x) ]}{x} & = & \cosh (x) -\end{array} -\] $$ - -$subhead exp$$ -$latex \[ -\begin{array}{lcr} - \D{[ \exp (x) ]}{x} & = & \exp (x) -\end{array} -\] $$ - -$subhead log$$ -$latex \[ -\begin{array}{lcr} - \D{[ \log (x) ]}{x} & = & \frac{1}{x} -\end{array} -\] $$ - -$subhead log10$$ -This function is special in that it's derivatives are calculated -using the relation -$latex \[ -\begin{array}{lcr} - {\rm log10} (x) & = & \log(x) / \log(10) -\end{array} -\] $$ - -$subhead sin$$ -$latex \[ -\begin{array}{lcr} - \D{[ \sin (x) ]}{x} & = & \cos (x) \\ - \D{[ \cos (x) ]}{x} & = & - \sin (x) -\end{array} -\] $$ - -$subhead sinh$$ -$latex \[ -\begin{array}{lcr} - \D{[ \sinh (x) ]}{x} & = & \cosh (x) \\ - \D{[ \cosh (x) ]}{x} & = & \sinh (x) -\end{array} -\] $$ - -$subhead sqrt$$ -$latex \[ -\begin{array}{lcr} - \D{[ {\rm sqrt} (x) ]}{x} & = & \frac{1}{2 {\rm sqrt} (x) } -\end{array} -\] $$ - -$subhead tan$$ -$latex \[ -\begin{array}{lcr} - \D{[ \tan (x) ]}{x} & = & 1 + \tan (x)^2 -\end{array} -\] $$ - -$subhead tanh$$ -$latex \[ -\begin{array}{lcr} - \D{[ \tanh (x) ]}{x} & = & 1 - \tanh (x)^2 -\end{array} -\] $$ - -$end -------------------------------------------------------------------------------- -*/ - -/*! -\file std_math_ad.hpp -Define AD standard math functions (using their Base versions) -*/ - -/*! -\def CPPAD_STANDARD_MATH_UNARY_AD(Name, Op) -Defines function Name with argument type AD and tape operation Op - -The macro defines the function x.Name() where x has type AD. -It then uses this funciton to define Name(x) where x has type -AD or VecAD_reference. - -If x is a variable, the tape unary operator Op is used -to record the operation and the result is identified as correspoding -to this operation; i.e., Name(x).taddr_ idendifies the operation and -Name(x).tape_id_ identifies the tape. - -This macro is used to define AD versions of -acos, asin, atan, cos, cosh, exp, fabs, log, sin, sinh, sqrt, tan, tanh. -*/ - -# define CPPAD_STANDARD_MATH_UNARY_AD(Name, Op) \ - template \ - inline AD Name(const AD &x) \ - { return x.Name(); } \ - template \ - inline AD AD::Name (void) const \ - { \ - AD result; \ - result.value_ = CppAD::Name(value_); \ - CPPAD_ASSERT_UNKNOWN( Parameter(result) ); \ - \ - if( Variable(*this) ) \ - { CPPAD_ASSERT_UNKNOWN( NumArg(Op) == 1 ); \ - ADTape *tape = tape_this(); \ - tape->Rec_.PutArg(taddr_); \ - result.taddr_ = tape->Rec_.PutOp(Op); \ - result.tape_id_ = tape->id_; \ - } \ - return result; \ - } \ - template \ - inline AD Name(const VecAD_reference &x) \ - { return Name( x.ADBase() ); } - -// BEGIN CppAD namespace -namespace CppAD { - - CPPAD_STANDARD_MATH_UNARY_AD(acos, AcosOp) - CPPAD_STANDARD_MATH_UNARY_AD(asin, AsinOp) - CPPAD_STANDARD_MATH_UNARY_AD(atan, AtanOp) - CPPAD_STANDARD_MATH_UNARY_AD(cos, CosOp) - CPPAD_STANDARD_MATH_UNARY_AD(cosh, CoshOp) - CPPAD_STANDARD_MATH_UNARY_AD(exp, ExpOp) - CPPAD_STANDARD_MATH_UNARY_AD(fabs, AbsOp) - CPPAD_STANDARD_MATH_UNARY_AD(log, LogOp) - CPPAD_STANDARD_MATH_UNARY_AD(sin, SinOp) - CPPAD_STANDARD_MATH_UNARY_AD(sinh, SinhOp) - CPPAD_STANDARD_MATH_UNARY_AD(sqrt, SqrtOp) - CPPAD_STANDARD_MATH_UNARY_AD(tan, TanOp) - CPPAD_STANDARD_MATH_UNARY_AD(tanh, TanhOp) - -# if CPPAD_COMPILER_HAS_ERF - // Error function is a special case - template - inline AD erf(const AD &x) - { return x.erf(); } - template - inline AD AD::erf (void) const - { - AD result; - result.value_ = CppAD::erf(value_); - CPPAD_ASSERT_UNKNOWN( Parameter(result) ); - - if( Variable(*this) ) - { CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); - ADTape *tape = tape_this(); - // arg[0] = argument to erf function - tape->Rec_.PutArg(taddr_); - // arg[1] = zero - addr_t p = tape->Rec_.PutPar( Base(0) ); - tape->Rec_.PutArg(p); - // arg[2] = 2 / sqrt(pi) - p = tape->Rec_.PutPar(Base( - 1.0 / std::sqrt( std::atan(1.0) ) - )); - tape->Rec_.PutArg(p); - // - result.taddr_ = tape->Rec_.PutOp(ErfOp); - result.tape_id_ = tape->id_; - } - return result; - } - template - inline AD erf(const VecAD_reference &x) - { return erf( x.ADBase() ); } -# endif - - /*! - Compute the log of base 10 of x where has type AD - - \tparam Base - is the base type (different from base for log) - for this AD type, see base_require. - - \param x - is the argument for the log10 function. - - \result - if the result is y, then \f$ x = 10^y \f$. - */ - template - inline AD log10(const AD &x) - { return CppAD::log(x) / CppAD::log( Base(10) ); } - template - inline AD log10(const VecAD_reference &x) - { return CppAD::log(x.ADBase()) / CppAD::log( Base(10) ); } -} - -# undef CPPAD_STANDARD_MATH_UNARY_AD - -# endif diff -Nru cppad-2015.00.00.9/cppad/local/std_set.hpp cppad-2016.00.00.1/cppad/local/std_set.hpp --- cppad-2015.00.00.9/cppad/local/std_set.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/std_set.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: std_set.hpp 3232 2014-04-27 15:38:21Z bradbell $ -# ifndef CPPAD_STD_SET_INCLUDED -# define CPPAD_STD_SET_INCLUDED +// $Id: std_set.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_STD_SET_HPP +# define CPPAD_STD_SET_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,7 +16,7 @@ # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -34,7 +34,7 @@ if( one.empty() ) one.insert(1); return one; -} +} /*! A standard set with a two elements. */ @@ -47,7 +47,7 @@ two.insert(2); } return two; -} +} } // END_CPPAD_NAMESPACE # endif diff -Nru cppad-2015.00.00.9/cppad/local/store_op.hpp cppad-2016.00.00.1/cppad/local/store_op.hpp --- cppad-2015.00.00.9/cppad/local/store_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/store_op.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: store_op.hpp 3322 2014-09-12 10:29:34Z bradbell $ */ -# ifndef CPPAD_STORE_OP_INCLUDED -# define CPPAD_STORE_OP_INCLUDED +// $Id: store_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_STORE_OP_HPP +# define CPPAD_STORE_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,21 +18,40 @@ \file store_op.hpp Changing the current value of a VecAD element. */ +/* +============================================================================== + +The C++ source code corresponding to this operation is +\verbatim + v[x] = y +\endverbatim +where v is a VecAD vector, x is an AD object, +and y is AD or Base objects. +We define the index corresponding to v[x] by +\verbatim + i_v_x = index_by_ind[ arg[0] + i_vec ] +\endverbatim +where i_vec is defined under the heading arg[1] below: + +============================================================================== +*/ /*! -Shared documentation for zero order forward implementation of +Shared documentation for zero order forward implementation of op = StppOp, StpvOp, StvpOp, or StvvOp (not called). + The C++ source code corresponding to this operation is \verbatim v[x] = y \endverbatim where v is a VecAD vector, x is an AD object, -and y is AD or Base objects. +and y is AD or Base objects. We define the index corresponding to v[x] by \verbatim i_v_x = index_by_ind[ arg[0] + i_vec ] \endverbatim where i_vec is defined under the heading arg[1] below: + \tparam Base base type for the operator; i.e., this operation was recorded @@ -46,13 +65,13 @@ \n arg[0] \n -is the offset of this VecAD vector relative to the beginning +is the offset of this VecAD vector relative to the beginning of the isvar_by_ind and index_by_ind arrays. \n -\n -arg[1] \n -If this is a StppOp or StpvOp operation (if x is a parameter), +arg[1] +\n +If this is a StppOp or StpvOp operation (if x is a parameter), i_vec is defined by \verbatim i_vec = arg[1] @@ -82,9 +101,9 @@ is used to compute the index in the definition of i_vec above. \param isvar_by_ind -If y is a varable (StpvOp and StvvOp cases), +If y is a varable (StpvOp and StvvOp cases), isvar_by_ind[ arg[0] + i_vec ] is set to true. -Otherwise y is a paraemter (StppOp and StvpOp cases) and +Otherwise y is a paraemter (StppOp and StvpOp cases) and isvar_by_ind[ arg[0] + i_vec ] is set to false. \param index_by_ind @@ -96,11 +115,11 @@ \par Check User Errors \li Check that the index is with in range; i.e. i_vec < index_by_ind[ arg[0] - 1 ] -Note that, if x is a parameter, +Note that, if x is a parameter, the corresponding vector index and it does not change. In this case, the error above should be detected during tape recording. -\par Checked Assertions +\par Checked Assertions \li NumArg(op) == 3 \li NumRes(op) == 0 \li 0 < arg[0] @@ -109,7 +128,7 @@ template inline void forward_store_op_0( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , size_t cap_order , Base* taylor , @@ -120,41 +139,28 @@ CPPAD_ASSERT_UNKNOWN( false ); } /*! -Shared documnetation for sparsity operations corresponding to +Shared documnetation for sparsity operations corresponding to op = StpvOp or StvvOp (not called). - -The C++ source code corresponding to this operation is -\verbatim - v[x] = y -\endverbatim -where v is a VecAD vector, x is an AD object, -and y is AD or Base objects. -We define the index corresponding to v[x] by -\verbatim - i_v_x = combined[ arg[0] + i_vec ] -\endverbatim -where i_vec is defined under the heading \a arg[1] below: - \tparam Vector_set is the type used for vectors of sets. It can be either \c sparse_pack, \c sparse_set, or \c sparse_list. \param op -is the code corresponding to this operator; i.e., StpvOp or StvvOp -(only used for error checking). +is the code corresponding to this operator; +i.e., StpvOp, StvpOp, or StvvOp. \param arg \n \a arg[0] is the offset corresponding to this VecAD vector in the combined array. \n -\n +\n \a arg[2] \n -The set with index \a arg[2] in \a var_sparsity +The set with index \a arg[2] in \a var_sparsity is the sparsity pattern corresponding to y. -(Note that \a arg[2] > 0 because y is a variable.) +(Note that \a arg[2] > 0 because y is a variable.) \param num_combined is the total number of elements in the VecAD address array. @@ -169,32 +175,31 @@ \endverbatim \param var_sparsity -The set with index \a arg[2] in \a var_sparsity +The set with index \a arg[2] in \a var_sparsity is the sparsity pattern for y. This is an input for forward mode operations. For reverse mode operations: The sparsity pattern for v is added to the spartisy pattern for y. \param vecad_sparsity -The set with index \a i_v in \a vecad_sparsity +The set with index \a i_v in \a vecad_sparsity is the sparsity pattern for v. This is an input for reverse mode operations. For forward mode operations, the sparsity pattern for y is added to the sparsity pattern for the vector v. -\par Checked Assertions +\par Checked Assertions \li NumArg(op) == 3 \li NumRes(op) == 0 \li 0 < \a arg[0] \li \a arg[0] < \a num_combined \li \a arg[2] < \a var_sparsity.n_set() \li i_v < \a vecad_sparsity.n_set() - */ template inline void sparse_store_op( OpCode op , - const addr_t* arg , + const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , @@ -213,7 +218,7 @@ template inline void forward_store_pp_op_0( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , size_t cap_order , Base* taylor , @@ -221,7 +226,7 @@ size_t* index_by_ind ) { size_t i_vec = arg[1]; - // Because the index is a parameter, this indexing error should be + // Because the index is a parameter, this indexing error should be // caught and reported to the user when the tape is recording. CPPAD_ASSERT_UNKNOWN( i_vec < index_by_ind[ arg[0] - 1 ] ); @@ -242,7 +247,7 @@ template inline void forward_store_pv_op_0( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , size_t cap_order , Base* taylor , @@ -250,7 +255,7 @@ size_t* index_by_ind ) { size_t i_vec = arg[1]; - // Because the index is a parameter, this indexing error should be + // Because the index is a parameter, this indexing error should be // caught and reported to the user when the tape is recording. CPPAD_ASSERT_UNKNOWN( i_vec < index_by_ind[ arg[0] - 1 ] ); @@ -270,15 +275,15 @@ template inline void forward_store_vp_op_0( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , size_t cap_order , Base* taylor , bool* isvar_by_ind , size_t* index_by_ind ) -{ +{ size_t i_vec = Integer( taylor[ arg[1] * cap_order + 0 ] ); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( i_vec < index_by_ind[ arg[0] - 1 ] , "VecAD: index during zero order forward sweep is out of range" ); @@ -300,15 +305,15 @@ template inline void forward_store_vv_op_0( size_t i_z , - const addr_t* arg , + const addr_t* arg , size_t num_par , size_t cap_order , Base* taylor , bool* isvar_by_ind , size_t* index_by_ind ) -{ +{ size_t i_vec = Integer( taylor[ arg[1] * cap_order + 0 ] ); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( i_vec < index_by_ind[ arg[0] - 1 ] , "VecAD: index during zero order forward sweep is out of range" ); @@ -324,12 +329,30 @@ /*! Forward mode sparsity operations for StpvOp and StvvOp + +The C++ source code corresponding to this operation is +\verbatim + v[x] = y +\endverbatim +where v is a VecAD vector, x is an AD object, +and y is AD or Base objects. +We define the index corresponding to v[x] by +\verbatim + i_v_x = index_by_ind[ arg[0] + i_vec ] +\endverbatim +where i_vec is defined under the heading arg[1] below: + + +\param dependency +is this a dependency (or sparsity) calculation. + \copydetails sparse_store_op */ template inline void forward_sparse_store_op( + bool dependency , OpCode op , - const addr_t* arg , + const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , @@ -343,93 +366,49 @@ CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < var_sparsity.n_set() ); - vecad_sparsity.binary_union(i_v, i_v, arg[2], var_sparsity); + if( dependency & ( (op == StvvOp) | (op == StvpOp) ) ) + vecad_sparsity.binary_union(i_v, i_v, arg[1], var_sparsity); + + if( (op == StpvOp) | (op == StvvOp ) ) + vecad_sparsity.binary_union(i_v, i_v, arg[2], var_sparsity); return; } /*! -Reverse mode sparsity operations for StpvOp and StvvOp +Reverse mode sparsity operations for StpvOp, StvpOp, and StvvOp -This routine is given the sparsity patterns for -G(v[x], y , w , u ... ) and it uses them to compute the -sparsity patterns for -\verbatim - H(y , w , u , ... ) = G[ v[x], y , w , u , ... ] -\endverbatim - - + The C++ source code corresponding to this operation is \verbatim v[x] = y \endverbatim where v is a VecAD vector, x is an AD object, -and y is AD or Base objects. +and y is AD or Base objects. We define the index corresponding to v[x] by \verbatim - i_v_x = combined[ arg[0] + i_vec ] + i_v_x = index_by_ind[ arg[0] + i_vec ] \endverbatim -where i_vec is defined under the heading \a arg[1] below: - -\tparam Vector_set -is the type used for vectors of sets. It can be either -\c sparse_pack, \c sparse_set, or \c sparse_list. - -\param op -is the code corresponding to this operator; i.e., StpvOp or StvvOp -(only used for error checking). - -\param arg -\n -\a arg[0] -is the offset corresponding to this VecAD vector in the combined array. -\n -\n -\a arg[2] -\n -The set with index \a arg[2] in \a var_sparsity -is the sparsity pattern corresponding to y. -(Note that \a arg[2] > 0 because y is a variable.) - -\param num_combined -is the total number of elements in the VecAD address array. +where i_vec is defined under the heading arg[1] below: + -\param combined -\a combined [ arg[0] - 1 ] -is the index of the set in \a vecad_sparsity corresponding -to the sparsity pattern for the vector v. -We use the notation i_v below which is defined by +This routine is given the sparsity patterns for +G(v[x], y , w , u ... ) and it uses them to compute the +sparsity patterns for \verbatim - i_v = combined[ \a arg[0] - 1 ] + H(y , w , u , ... ) = G[ v[x], y , w , u , ... ] \endverbatim -\param var_sparsity -The set with index \a arg[2] in \a var_sparsity -is the sparsity pattern for y. -This is an input for forward mode operations. -For reverse mode operations: -The sparsity pattern for v is added to the spartisy pattern for y. +\param dependency +is this a dependency (or sparsity) calculation. -\param vecad_sparsity -The set with index \a i_v in \a vecad_sparsity -is the sparsity pattern for v. -This is an input for reverse mode operations. -For forward mode operations, the sparsity pattern for y is added -to the sparsity pattern for the vector v. - -\par Checked Assertions -\li NumArg(op) == 3 -\li NumRes(op) == 0 -\li 0 < \a arg[0] -\li \a arg[0] < \a num_combined -\li \a arg[2] < \a var_sparsity.n_set() -\li i_v < \a vecad_sparsity.n_set() - +\copydetails sparse_store_op */ template inline void reverse_sparse_jacobian_store_op( + bool dependency , OpCode op , - const addr_t* arg , + const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , @@ -443,7 +422,10 @@ CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < var_sparsity.n_set() ); - var_sparsity.binary_union(arg[2], arg[2], i_v, vecad_sparsity); + if( dependency & ( (op == StvpOp) | (op == StvvOp) ) ) + var_sparsity.binary_union(arg[1], arg[1], i_v, vecad_sparsity); + if( (op == StpvOp) | (op == StvvOp) ) + var_sparsity.binary_union(arg[2], arg[2], i_v, vecad_sparsity); return; } @@ -451,89 +433,37 @@ /*! Reverse mode sparsity operations for StpvOp and StvvOp -This routine is given the sparsity patterns for -G(v[x], y , w , u ... ) -and it uses them to compute the sparsity patterns for -\verbatim - H(y , w , u , ... ) = G[ v[x], y , w , u , ... ] -\endverbatim - - + The C++ source code corresponding to this operation is \verbatim v[x] = y \endverbatim where v is a VecAD vector, x is an AD object, -and y is AD or Base objects. +and y is AD or Base objects. We define the index corresponding to v[x] by \verbatim - i_v_x = combined[ arg[0] + i_vec ] + i_v_x = index_by_ind[ arg[0] + i_vec ] \endverbatim -where i_vec is defined under the heading \a arg[1] below: - -\tparam Vector_set -is the type used for vectors of sets. It can be either -\c sparse_pack, \c sparse_set, or \c sparse_list. - -\param op -is the code corresponding to this operator; i.e., StpvOp or StvvOp -(only used for error checking). - -\param arg -\n -\a arg[0] -is the offset corresponding to this VecAD vector in the combined array. -\n -\n -\a arg[2] -\n -The set with index \a arg[2] in \a var_sparsity -is the sparsity pattern corresponding to y. -(Note that \a arg[2] > 0 because y is a variable.) - -\param num_combined -is the total number of elements in the VecAD address array. +where i_vec is defined under the heading arg[1] below: + -\param combined -\a combined [ arg[0] - 1 ] -is the index of the set in \a vecad_sparsity corresponding -to the sparsity pattern for the vector v. -We use the notation i_v below which is defined by +This routine is given the sparsity patterns for +G(v[x], y , w , u ... ) +and it uses them to compute the sparsity patterns for \verbatim - i_v = combined[ \a arg[0] - 1 ] + H(y , w , u , ... ) = G[ v[x], y , w , u , ... ] \endverbatim -\param var_sparsity -The set with index \a arg[2] in \a var_sparsity -is the sparsity pattern for y. -This is an input for forward mode operations. -For reverse mode operations: -The sparsity pattern for v is added to the spartisy pattern for y. - -\param vecad_sparsity -The set with index \a i_v in \a vecad_sparsity -is the sparsity pattern for v. -This is an input for reverse mode operations. -For forward mode operations, the sparsity pattern for y is added -to the sparsity pattern for the vector v. - -\par Checked Assertions -\li NumArg(op) == 3 -\li NumRes(op) == 0 -\li 0 < \a arg[0] -\li \a arg[0] < \a num_combined -\li \a arg[2] < \a var_sparsity.n_set() -\li i_v < \a vecad_sparsity.n_set() - +\copydetails sparse_store_op \param var_jacobian -\a var_jacobian[ \a arg[2] ] -is false (true) if the Jacobian of G with respect to y is always zero +\a var_jacobian[ \a arg[2] ] +is false (true) if the Jacobian of G with respect to y is always zero (may be non-zero). \param vecad_jacobian -\a vecad_jacobian[i_v] -is false (true) if the Jacobian with respect to x is always zero +\a vecad_jacobian[i_v] +is false (true) if the Jacobian with respect to x is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. @@ -541,7 +471,7 @@ template inline void reverse_sparse_hessian_store_op( OpCode op , - const addr_t* arg , + const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , diff -Nru cppad-2015.00.00.9/cppad/local/sub_eq.hpp cppad-2016.00.00.1/cppad/local/sub_eq.hpp --- cppad-2015.00.00.9/cppad/local/sub_eq.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sub_eq.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sub_eq.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_SUB_EQ_INCLUDED -# define CPPAD_SUB_EQ_INCLUDED +// $Id: sub_eq.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SUB_EQ_HPP +# define CPPAD_SUB_EQ_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -85,4 +85,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/sub.hpp cppad-2016.00.00.1/cppad/local/sub.hpp --- cppad-2015.00.00.9/cppad/local/sub.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sub.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sub.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_SUB_INCLUDED -# define CPPAD_SUB_INCLUDED +// $Id: sub.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SUB_HPP +# define CPPAD_SUB_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -87,4 +87,4 @@ } // END CppAD namespace -# endif +# endif diff -Nru cppad-2015.00.00.9/cppad/local/sub_op.hpp cppad-2016.00.00.1/cppad/local/sub_op.hpp --- cppad-2015.00.00.9/cppad/local/sub_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/sub_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sub_op.hpp 3321 2014-09-12 09:50:39Z bradbell $ */ -# ifndef CPPAD_SUB_OP_INCLUDED -# define CPPAD_SUB_OP_INCLUDED +// $Id: sub_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SUB_OP_HPP +# define CPPAD_SUB_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,8 +36,8 @@ template inline void forward_subvv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -74,8 +74,8 @@ template inline void forward_subvv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -149,7 +149,7 @@ template inline void reverse_subvv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -194,8 +194,8 @@ template inline void forward_subpv_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -236,8 +236,8 @@ template inline void forward_subpv_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -310,7 +310,7 @@ template inline void reverse_subpv_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , @@ -353,8 +353,8 @@ template inline void forward_subvp_op( - size_t p , - size_t q , + size_t p , + size_t q , size_t i_z , const addr_t* arg , const Base* parameter , @@ -395,8 +395,8 @@ template inline void forward_subvp_op_dir( - size_t q , - size_t r , + size_t q , + size_t r , size_t i_z , const addr_t* arg , const Base* parameter , @@ -470,7 +470,7 @@ template inline void reverse_subvp_op( - size_t d , + size_t d , size_t i_z , const addr_t* arg , const Base* parameter , diff -Nru cppad-2015.00.00.9/cppad/local/tanh_op.hpp cppad-2016.00.00.1/cppad/local/tanh_op.hpp --- cppad-2015.00.00.9/cppad/local/tanh_op.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/tanh_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: tanh_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_TANH_OP_INCLUDED -# define CPPAD_TANH_OP_INCLUDED +// $Id: tanh_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_TANH_OP_HPP +# define CPPAD_TANH_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,9 +43,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(TanOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 2 ); @@ -98,9 +98,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(TanOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 2 ); @@ -146,7 +146,7 @@ inline void forward_tanh_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -184,7 +184,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -207,6 +207,7 @@ const Base* y = z - cap_order; // called y in documentation Base* py = pz - nc_partial; + size_t j = d; size_t k; Base base_two(2); @@ -215,15 +216,15 @@ px[j] += pz[j]; pz[j] /= Base(j); for(k = 1; k <= j; k++) - { px[k] -= pz[j] * y[j-k] * Base(k); - py[j-k] -= pz[j] * x[k] * Base(k); + { px[k] -= azmul(pz[j], y[j-k]) * Base(k); + py[j-k] -= azmul(pz[j], x[k]) * Base(k); } for(k = 0; k < j; k++) - pz[k] += py[j-1] * z[j-k-1] * base_two; - + pz[k] += azmul(py[j-1], z[j-k-1]) * base_two; + --j; } - px[0] += pz[0] * (Base(1) - y[0]); + px[0] += azmul(pz[0], Base(1) - y[0]); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/tan_op.hpp cppad-2016.00.00.1/cppad/local/tan_op.hpp --- cppad-2015.00.00.9/cppad/local/tan_op.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/tan_op.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: tan_op.hpp 3320 2014-09-11 23:06:21Z bradbell $ */ -# ifndef CPPAD_TAN_OP_INCLUDED -# define CPPAD_TAN_OP_INCLUDED +// $Id: tan_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_TAN_OP_HPP +# define CPPAD_TAN_OP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,9 +43,9 @@ size_t q , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(TanOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 2 ); @@ -98,9 +98,9 @@ size_t r , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) -{ +{ // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(TanOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 2 ); @@ -147,7 +147,7 @@ inline void forward_tan_op_0( size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , Base* taylor ) { // check assumptions @@ -185,7 +185,7 @@ size_t d , size_t i_z , size_t i_x , - size_t cap_order , + size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) @@ -208,6 +208,7 @@ const Base* y = z - cap_order; // called y in documentation Base* py = pz - nc_partial; + size_t j = d; size_t k; Base base_two(2); @@ -216,15 +217,15 @@ px[j] += pz[j]; pz[j] /= Base(j); for(k = 1; k <= j; k++) - { px[k] += pz[j] * y[j-k] * Base(k); - py[j-k] += pz[j] * x[k] * Base(k); + { px[k] += azmul(pz[j], y[j-k]) * Base(k); + py[j-k] += azmul(pz[j], x[k]) * Base(k); } for(k = 0; k < j; k++) - pz[k] += py[j-1] * z[j-k-1] * base_two; - + pz[k] += azmul(py[j-1], z[j-k-1]) * base_two; + --j; } - px[0] += pz[0] * (Base(1) + y[0]); + px[0] += azmul(pz[0], Base(1) + y[0]); } } // END_CPPAD_NAMESPACE diff -Nru cppad-2015.00.00.9/cppad/local/tape_link.hpp cppad-2016.00.00.1/cppad/local/tape_link.hpp --- cppad-2015.00.00.9/cppad/local/tape_link.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/tape_link.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: tape_link.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_TAPE_LINK_INCLUDED -# define CPPAD_TAPE_LINK_INCLUDED +// $Id: tape_link.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_TAPE_LINK_HPP +# define CPPAD_TAPE_LINK_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,11 +14,11 @@ -------------------------------------------------------------------------- */ # include -# include +# include # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include +# include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! @@ -50,7 +50,7 @@ { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; static tape_id_t* tape_id_table[CPPAD_MAX_NUM_THREADS]; CPPAD_ASSERT_UNKNOWN( - (! thread_alloc::in_parallel()) || thread == thread_alloc::thread_num() + (! thread_alloc::in_parallel()) || thread == thread_alloc::thread_num() ); return tape_id_table + thread; @@ -80,8 +80,8 @@ */ template inline tape_id_t* AD::tape_id_ptr(size_t thread) -{ CPPAD_ASSERT_UNKNOWN( *tape_id_handle(thread) != CPPAD_NULL ) - return *tape_id_handle(thread); +{ CPPAD_ASSERT_UNKNOWN( *tape_id_handle(thread) != CPPAD_NULL ) + return *tape_id_handle(thread); } /*! @@ -130,11 +130,11 @@ template inline ADTape* AD::tape_ptr(void) { size_t thread = thread_alloc::thread_num(); - return *tape_handle(thread); + return *tape_handle(thread); } /*! -Pointer for the tape for this AD class and the specified tape +Pointer for the tape for this AD class and the specified tape identifier. \tparam Base @@ -147,9 +147,9 @@ \code thread = size_t( tape_id % CPPAD_MAX_NUM_THREADS ) \endcode -and that there is a tape recording AD operations +and that there is a tape recording AD operations for this thread. -If this is not the currently executing thread, +If this is not the currently executing thread, a variable from a different thread is being recorded on the tape for this thread which is a user error. @@ -170,7 +170,7 @@ ); CPPAD_ASSERT_UNKNOWN( tape_id == *tape_id_ptr(thread) ); CPPAD_ASSERT_UNKNOWN( *tape_handle(thread) != CPPAD_NULL ); - return *tape_handle(thread); + return *tape_handle(thread); } /*! @@ -189,7 +189,7 @@ This argument determines if we are creating a new tape, or deleting an old one. - \c tape_manage_new : -Creates and a new tape. +Creates and a new tape. It is assumed that there is no tape recording AD operations for this thread when \c tape_manage is called. It the input value of *tape_id_handle(thread) is \c CPPAD_NULL, @@ -209,46 +209,73 @@ */ template ADTape* AD::tape_manage(tape_manage_job job) -{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL - static ADTape* tape_table[CPPAD_MAX_NUM_THREADS]; +{ // this routine has static variables so first call cannot be in parallel + CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL + + // The tape for the master thread static ADTape tape_zero; + + // Pointer to the tape for each thread + static ADTape* tape_table[CPPAD_MAX_NUM_THREADS]; + + // The id current being used for each of the tapes static tape_id_t tape_id_save[CPPAD_MAX_NUM_THREADS]; + // Thread corresponding to this call size_t thread = thread_alloc::thread_num(); + + // tape_manage_clear if( job == tape_manage_clear ) - { CPPAD_ASSERT_UNKNOWN(thread == 0 && (! thread_alloc::in_parallel())); + { // This operation cannot be done in parallel + CPPAD_ASSERT_UNKNOWN(thread == 0 && (! thread_alloc::in_parallel())); for(thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++) - { if( tape_table[thread] != CPPAD_NULL ) - { tape_id_save[thread] = tape_table[thread]->id_; + { // if this thread has a tape + if( tape_table[thread] != CPPAD_NULL ) + { // id corresponding to this thread + tape_id_save[thread] = tape_table[thread]->id_; *tape_id_handle(thread) = &tape_id_save[thread]; + // delete all but the master thread if( thread != 0 ) delete( tape_table[thread] ); + + // set the tape pointer to null tape_table[thread] = CPPAD_NULL; } - } + } return CPPAD_NULL; } + + // id and tape fpor this thread tape_id_t** tape_id = tape_id_handle(thread); ADTape** tape = tape_handle(thread); + // check if there is no tape currently attached to this thread if( tape_table[thread] == CPPAD_NULL ) { // allocate separate memroy to avoid false sharing if( thread == 0 ) + { // mastert tape is a static in this routine tape_table[thread] = &tape_zero; - else tape_table[thread] = new ADTape(); + } + else + { // other tapes are allocated + tape_table[thread] = new ADTape(); + } + // current id and pointer to this tape tape_table[thread]->id_ = tape_id_save[thread]; *tape_id = &tape_table[thread]->id_; - // init tape id > 0 and thread == tape id % CPPAD_MAX_NUM_THREADS + // if id is zero, initialize it so that + // thread == tape id % CPPAD_MAX_NUM_THREADS if( **tape_id == 0 ) **tape_id = thread + CPPAD_MAX_NUM_THREADS; } // make sure tape_id_handle(thread) is pointing to the proper place CPPAD_ASSERT_UNKNOWN( *tape_id == &tape_table[thread]->id_ ); + // make sure tape_id value is valid for this thread - CPPAD_ASSERT_UNKNOWN( - size_t( **tape_id % CPPAD_MAX_NUM_THREADS ) == thread + CPPAD_ASSERT_UNKNOWN( + size_t( **tape_id % CPPAD_MAX_NUM_THREADS ) == thread ); switch(job) @@ -268,7 +295,7 @@ ); // advance tape identfier so all AD variables become parameters **tape_id += CPPAD_MAX_NUM_THREADS; - // free memory corresponding to recording in the old tape + // free memory corresponding to recording in the old tape tape_table[thread]->Rec_.free(); // inform rest of CppAD that no tape recording for this thread *tape = CPPAD_NULL; @@ -301,7 +328,7 @@ template inline ADTape *AD::tape_this(void) const -{ +{ size_t thread = size_t( tape_id_ % CPPAD_MAX_NUM_THREADS ); CPPAD_ASSERT_UNKNOWN( tape_id_ == *tape_id_ptr(thread) ); CPPAD_ASSERT_UNKNOWN( *tape_handle(thread) != CPPAD_NULL ); diff -Nru cppad-2015.00.00.9/cppad/local/test_vector.hpp cppad-2016.00.00.1/cppad/local/test_vector.hpp --- cppad-2015.00.00.9/cppad/local/test_vector.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/test_vector.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: test_vector.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_TEST_VECTOR_INCLUDED -# define CPPAD_TEST_VECTOR_INCLUDED +// $Id: test_vector.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_TEST_VECTOR_HPP +# define CPPAD_TEST_VECTOR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -29,14 +29,11 @@ stdvector $$ -$index CPPAD_TEST_VECTOR$$ -$index vector, test$$ -$index test, vector$$ $section Choosing The Vector Testing Template Class$$ +$mindex CPPAD_TEST_VECTOR test$$ -$head Deprecated$$ -$index deprecated, test vector$$ +$head Deprecated 2012-07-03$$ The $code CPPAD_TEST_VECTOR$$ macro has been deprecated, use $cref/CPPAD_TESTVECTOR/testvector/$$ instead. @@ -45,7 +42,7 @@ %$$ $head Introduction$$ -Many of the CppAD $cref/examples/example/$$ and tests use +Many of the CppAD $cref/examples/example/$$ and tests use the $code CPPAD_TEST_VECTOR$$ template class to pass information. The default definition for this template class is $cref/CppAD::vector/CppAD_vector/$$. @@ -75,8 +72,8 @@ # define CPPAD_TEST_VECTOR CppAD::vector # endif /* $$ -If you specify $code --with-eigenvector$$ on the -$cref/configure/InstallUnix/Configure/$$ command line, +If you specify $code --with-eigenvector$$ on the +$cref/configure/auto_tools/Configure/$$ command line, $code CPPAD_EIGENVECTOR$$ is true. This vector type cannot be supported by $code CPPAD_TEST_VECTOR$$ (use $cref/CPPAD_TESTVECTOR/testvector/$$ for this support) @@ -90,8 +87,8 @@ $head std::vector$$ -If you specify $code --with-stdvector$$ on the -$cref/configure/InstallUnix/Configure/$$ +If you specify $code --with-stdvector$$ on the +$cref/configure/auto_tools/Configure/$$ command line during CppAD installation, $code CPPAD_STDVECTOR$$ is true and $code CPPAD_TEST_VECTOR$$ is defined by the following source code @@ -106,12 +103,12 @@ Use of $code CppAD::vector$$, $code std::vector$$, and $code std::valarray$$ with CppAD is always tested to some degree. Specifying $code --with-stdvector$$ will increase the amount of -$code std::vector$$ testing. +$code std::vector$$ testing. $head boost::numeric::ublas::vector$$ If you specify a value for $icode boost_dir$$ on the configure command line during CppAD installation, -$code CPPAD_BOOSTVECTOR$$ is true +$code CPPAD_BOOSTVECTOR$$ is true and $code CPPAD_TEST_VECTOR$$ is defined by the following source code $codep */ // The next 4 lines are C++ source code. @@ -124,16 +121,16 @@ Use of $code CppAD::vector$$, $code std::vector$$, and $code std::valarray$$ with CppAD is always tested to some degree. Specifying $icode boost_dir$$ will increase the amount of -Ublas vector testing. +Ublas vector testing. -$head CppADvector$$ +$head CppADvector Deprecated 2007-07-28$$ The preprocessor symbol $code CppADvector$$ is defined to have the same value as $code CPPAD_TEST_VECTOR$$ but its use is deprecated: $codep */ # define CppADvector CPPAD_TEST_VECTOR /* $$ $end ------------------------------------------------------------------------- +------------------------------------------------------------------------ */ # endif diff -Nru cppad-2015.00.00.9/cppad/local/testvector.hpp cppad-2016.00.00.1/cppad/local/testvector.hpp --- cppad-2015.00.00.9/cppad/local/testvector.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/testvector.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: testvector.hpp 2576 2012-11-17 13:44:48Z bradbell $ */ -# ifndef CPPAD_TESTVECTOR_INCLUDED -# define CPPAD_TESTVECTOR_INCLUDED +// $Id: testvector.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_TESTVECTOR_HPP +# define CPPAD_TESTVECTOR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,18 +28,16 @@ ublas $$ -$index CPPAD_TESTVECTOR$$ -$index vector, test$$ -$index test, vector$$ $section Using The CppAD Test Vector Template Class$$ +$mindex CPPAD_TESTVECTOR$$ $head Syntax$$ $codei%CPPAD_TESTVECTOR(%Scalar%) %$$ $head Introduction$$ -Many of the CppAD $cref/examples/example/$$ and tests use +Many of the CppAD $cref/examples/example/$$ and tests use the $code CPPAD_TESTVECTOR$$ template class to pass information to CppAD. This is not a true template class because it's syntax uses $codei%(%Scalar%)%$$ instead of $codei%<%Scalar%>%$$. @@ -60,7 +58,7 @@ # define CPPAD_TESTVECTOR(Scalar) CppAD::vector< Scalar > # endif /* $$ -In this case CppAD will use its own vector for +In this case CppAD will use its own vector for many of its examples and tests. $head std::vector$$ @@ -75,7 +73,7 @@ # define CPPAD_TESTVECTOR(Scalar) std::vector< Scalar > # endif /* $$ -In this case CppAD will use standard vector for +In this case CppAD will use standard vector for many of its examples and tests. $head boost::numeric::ublas::vector$$ @@ -90,7 +88,7 @@ # define CPPAD_TESTVECTOR(Scalar) boost::numeric::ublas::vector< Scalar > # endif /* $$ -In this case CppAD will use this boost vector for +In this case CppAD will use this boost vector for many of its examples and tests. $head Eigen Vectors$$ @@ -105,11 +103,11 @@ # define CPPAD_TESTVECTOR(Scalar) Eigen::Matrix< Scalar , Eigen::Dynamic, 1> # endif /* $$ -In this case CppAD will use the Eigen vector +In this case CppAD will use the Eigen vector for many of its examples and tests. $end ------------------------------------------------------------------------- +------------------------------------------------------------------------ */ # endif diff -Nru cppad-2015.00.00.9/cppad/local/unary_minus.hpp cppad-2016.00.00.1/cppad/local/unary_minus.hpp --- cppad-2015.00.00.9/cppad/local/unary_minus.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/unary_minus.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: unary_minus.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_UNARY_MINUS_INCLUDED -# define CPPAD_UNARY_MINUS_INCLUDED +// $Id: unary_minus.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_UNARY_MINUS_HPP +# define CPPAD_UNARY_MINUS_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,12 +21,9 @@ inline $$ -$index unary, AD minus operator$$ -$index AD, unary minus operator$$ -$index minus, AD unary operator$$ -$index -, AD unary operator$$ $section AD Unary Minus Operator$$ +$mindex -$$ $head Syntax$$ @@ -62,7 +59,7 @@ $cref/operation sequence/glossary/Operation/Sequence/$$. $head Derivative$$ -If $latex f$$ is a +If $latex f$$ is a $cref/Base function/glossary/Base Function/$$, $latex \[ \D{[ - f(x) ]}{x} = - \D{f(x)}{x} @@ -85,7 +82,7 @@ // Broken g++ compiler inhibits declaring unary minus a member or friend template -inline AD AD::operator - (void) const +inline AD AD::operator - (void) const { // should make a more efficient version by adding unary minus to // Operator.h (some day) AD result(0); @@ -97,7 +94,7 @@ template -inline AD operator - (const VecAD_reference &right) +inline AD operator - (const VecAD_reference &right) { return - right.ADBase(); } } diff -Nru cppad-2015.00.00.9/cppad/local/unary_plus.hpp cppad-2016.00.00.1/cppad/local/unary_plus.hpp --- cppad-2015.00.00.9/cppad/local/unary_plus.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/unary_plus.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: unary_plus.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_UNARY_PLUS_INCLUDED -# define CPPAD_UNARY_PLUS_INCLUDED +// $Id: unary_plus.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_UNARY_PLUS_HPP +# define CPPAD_UNARY_PLUS_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,12 +21,9 @@ inline $$ -$index unary, AD plus operator$$ -$index AD, unary plus operator$$ -$index plus, AD unary operator$$ -$index +, AD unary operator$$ $section AD Unary Plus Operator$$ +$mindex +$$ $head Syntax$$ @@ -60,7 +57,7 @@ $cref/operation sequence/glossary/Operation/Sequence/$$. $head Derivative$$ -If $latex f$$ is a +If $latex f$$ is a $cref/Base function/glossary/Base Function/$$, $latex \[ \D{[ + f(x) ]}{x} = \D{f(x)}{x} @@ -84,7 +81,7 @@ namespace CppAD { template -inline AD AD::operator + (void) const +inline AD AD::operator + (void) const { AD result(*this); return result; @@ -92,7 +89,7 @@ template -inline AD operator + (const VecAD_reference &right) +inline AD operator + (const VecAD_reference &right) { return right.ADBase(); } } diff -Nru cppad-2015.00.00.9/cppad/local/undef.hpp cppad-2016.00.00.1/cppad/local/undef.hpp --- cppad-2015.00.00.9/cppad/local/undef.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/undef.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -// $Id: undef.hpp 3495 2014-12-24 01:16:15Z bradbell $ -# ifndef CPPAD_UNDEF_INCLUDED -# define CPPAD_UNDEF_INCLUDED +// $Id: undef.hpp 3768 2015-12-28 18:58:35Z bradbell $ +# ifndef CPPAD_UNDEF_HPP +# define CPPAD_UNDEF_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,14 +27,17 @@ # undef CPPAD_BOOL_UNARY in user api # undef CPPAD_DISCRETE_FUNCTION in user api # undef CPPAD_EIGENVECTOR in user api -# undef CPPAD_COMPILER_HAS_ERF in user api # undef CPPAD_INTERNAL_SPARSE_SET in user api # undef CPPAD_MAX_NUM_THREADS in user api +# undef CPPAD_NUMERIC_LIMITS in user api # undef CPPAD_NULL in user api # undef CPPAD_PACKAGE_STRING in user api +# undef CPPAD_STANDARD_MATH_UNARY in user api # undef CPPAD_TAPE_ADDR_TYPE in user api # undef CPPAD_TAPE_ID_TYPE in user api # undef CPPAD_TESTVECTOR in user api +# undef CPPAD_TO_STRING in user api +# undef CPPAD_USE_CPLUSPLUS_2011 in user api # undef CPPAD_TRACK_COUNT in deprecated api # undef CPPAD_TRACK_DEL_VEC in deprecated api @@ -53,13 +56,13 @@ # undef CppADvector deprecated version of CPPAD_TEST_VECTOR // for conditional testing when implicit conversion is not present -# undef CPPAD_IMPLICIT_CTOR_FROM_ANY_TYPE +# undef CPPAD_DEPRECATED ----------------------------------------------------------------------------- */ -// Preprecessor definitions that do not presist +// Preprecessor definitions that do not presist # undef CPPAD_ASSERT_NARG_NRES -# undef CPPAD_ASSERT_NOT_PARALLEL # undef CPPAD_ASSERT_ARG_BEFORE_RESULT +# undef CPPAD_AZMUL # undef CPPAD_BOOSTVECTOR # undef CPPAD_COND_EXP # undef CPPAD_COND_EXP_BASE_REL @@ -70,11 +73,11 @@ # undef CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR # undef CPPAD_FOR_JAC_SWEEP_TRACE # undef CPPAD_HAS_COLPACK -# undef CPPAD_HAS_CSTDINT_8_TO_64 -# undef CPPAD_HAS_RVALUE # undef CPPAD_HAS_GETTIMEOFDAY -# undef CPPAD_HAS_NULLPTR +# undef CPPAD_HAS_MKSTEMP +# undef CPPAD_HAS_TMPNAM_S # undef CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +# undef CPPAD_LIB_EXPORT # undef CPPAD_MAX_NUM_CAPACITY # undef CPPAD_MIN_DOUBLE_CAPACITY # undef CPPAD_OP_CODE_TYPE @@ -82,7 +85,6 @@ # undef CPPAD_REV_HES_SWEEP_TRACE # undef CPPAD_REV_JAC_SWEEP_TRACE # undef CPPAD_SIZE_T_NOT_UNSIGNED_INT -# undef CPPAD_STANDARD_MATH_UNARY # undef CPPAD_STANDARD_MATH_UNARY_AD # undef CPPAD_STDVECTOR # undef CPPAD_TRACE_CAPACITY diff -Nru cppad-2015.00.00.9/cppad/local/user_ad.hpp cppad-2016.00.00.1/cppad/local/user_ad.hpp --- cppad-2015.00.00.9/cppad/local/user_ad.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/user_ad.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: user_ad.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_USER_AD_INCLUDED -# define CPPAD_USER_AD_INCLUDED +// $Id: user_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_USER_AD_HPP +# define CPPAD_USER_AD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,27 +24,26 @@ $$ $section AD Objects$$ +$mindex require$$ -$index AD, object$$ $head Purpose$$ -The sections listed below describe the operations +The sections listed below describe the operations that are available to $cref/AD of Base/glossary/AD of Base/$$ objects. These objects are used to $cref/tape/glossary/Tape/$$ an AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. This operation sequence can be transferred to an $cref ADFun$$ object where it -can be used to evaluate the corresponding +can be used to evaluate the corresponding function and derivative values. $head Base Type Requirements$$ -$index Base, require$$ -The $icode Base$$ requirements are provided by the CppAD package +The $icode Base$$ requirements are provided by the CppAD package for the following base types: -$code float$$, +$code float$$, $code double$$, -$code std::complex$$, +$code std::complex$$, $code std::complex$$. Otherwise, see $cref base_require$$. @@ -69,5 +68,6 @@ # include # include # include +# include # endif diff -Nru cppad-2015.00.00.9/cppad/local/value.hpp cppad-2016.00.00.1/cppad/local/value.hpp --- cppad-2015.00.00.9/cppad/local/value.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/value.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: value.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_VALUE_INCLUDED -# define CPPAD_VALUE_INCLUDED +// $Id: value.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_VALUE_HPP +# define CPPAD_VALUE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,17 +19,17 @@ const $$ -$index Value$$ -$index Base, from AD$$ -$index AD, convert to Base$$ -$index convert, AD to Base$$ $section Convert From an AD Type to its Base Type$$ +$mindex Value$$ $head Syntax$$ $icode%b% = Value(%x%)%$$ +$head See Also$$ +$cref var2par$$ + $head Purpose$$ Converts from an AD type to the corresponding @@ -48,15 +48,15 @@ %$$ $head Operation Sequence$$ -The result of this operation is not an +The result of this operation is not an $cref/AD of Base/glossary/AD of Base/$$ object. Thus it will not be recorded as part of an AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. $head Restriction$$ -If the argument $icode x$$ is a -$cref/variable/glossary/Variable/$$ its dependency information +If the argument $icode x$$ is a +$cref/variable/glossary/Variable/$$ its dependency information would not be included in the $code Value$$ result (see above). For this reason, the argument $icode x$$ must be a $cref/parameter/glossary/Parameter/$$; i.e., @@ -80,14 +80,14 @@ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION -Base Value(const AD &x) +Base Value(const AD &x) { Base result; CPPAD_ASSERT_KNOWN( Parameter(x) , - "Value: argument is a variable (not a parameter)" + "Value: argument is a variable (not a parameter)" ); - + result = x.value_; diff -Nru cppad-2015.00.00.9/cppad/local/var2par.hpp cppad-2016.00.00.1/cppad/local/var2par.hpp --- cppad-2015.00.00.9/cppad/local/var2par.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/var2par.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: var2par.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_VAR2PAR_INCLUDED -# define CPPAD_VAR2PAR_INCLUDED +// $Id: var2par.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_VAR2PAR_HPP +# define CPPAD_VAR2PAR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,28 +22,28 @@ const $$ -$index Var2Par$$ -$index variable, convert to parameter$$ -$index parameter, convert from variable$$ -$index value_, obtain during taping$$ $section Convert an AD Variable to a Parameter$$ +$mindex Var2Par from value_ obtain during taping$$ $head Syntax$$ $icode%y% = Var2Par(%x%)%$$ +$head See Also$$ +$cref value$$ + $head Purpose$$ -Returns a +Returns a $cref/parameter/glossary/Parameter/$$ $icode y$$ -with the same value as the +with the same value as the $cref/variable/glossary/Variable/$$ $icode x$$. $head x$$ The argument $icode x$$ has prototype $codei% const AD<%Base%> &x -%$$ +%$$ The argument $icode x$$ may be a variable or parameter. @@ -51,8 +51,8 @@ The result $icode y$$ has prototype $codei% AD<%Base%> &y -%$$ -The return value $icode y$$ will be a parameter. +%$$ +The return value $icode y$$ will be a parameter. $head Example$$ @@ -82,7 +82,7 @@ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION AD Var2Par(const VecAD_reference &x) -{ AD y(x.ADBase()); +{ AD y(x.ADBase()); y.id_ = 0; } diff -Nru cppad-2015.00.00.9/cppad/local/vec_ad.hpp cppad-2016.00.00.1/cppad/local/vec_ad.hpp --- cppad-2015.00.00.9/cppad/local/vec_ad.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/vec_ad.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: vec_ad.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_VEC_AD_INCLUDED -# define CPPAD_VEC_AD_INCLUDED +// $Id: vec_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_VEC_AD_HPP +# define CPPAD_VEC_AD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -31,13 +31,9 @@ Cpp $$ -$index VecAD$$ -$index vector, AD index$$ -$index record, AD index$$ -$index tape, AD index$$ -$index index, AD record$$ $section AD Vectors that Record Index Operations$$ +$mindex VecAD tape reference VecAD$$ $head Syntax$$ @@ -53,7 +49,7 @@ $icode%r% = %v%[%x%]%$$ $head Purpose$$ -If either $icode v$$ or $icode x$$ is a +If either $icode v$$ or $icode x$$ is a $cref/variable/glossary/Variable/$$, the indexing operation $codei% @@ -61,37 +57,35 @@ %$$ is recorded in the corresponding AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$ and +$cref/operation sequence/glossary/Operation/Sequence/$$ and transferred to the corresponding $cref ADFun$$ object $icode f$$. Such an index can change each time zero order $cref/f.Forward/Forward/$$ is used; i.e., -$icode f$$ is evaluated with new value for the -$cref/independent variables/glossary/Tape/Independent Variable/$$. +$icode f$$ is evaluated with new value for the +$cref/independent variables/glossary/Tape/Independent Variable/$$. Note that the value of $icode y$$ depends on the value of $icode x$$ -in a discrete fashion and CppAD computes its partial derivative with +in a discrete fashion and CppAD computes its partial derivative with respect to $icode x$$ as zero. $head Alternatives$$ -If only the values in the vector, -and not the indices, +If only the values in the vector, +and not the indices, depend on the independent variables, the class $icode%Vector%< AD<%Base%> >%$$ is much more efficient for storing AD values where $icode Vector$$ is any -$cref SimpleVector$$ template class, -If only the indices, +$cref SimpleVector$$ template class, +If only the indices, and not the values in the vector, depend on the independent variables, The $cref Discrete$$ functions are a much more efficient way to represent these vectors. $head VecAD::reference$$ -$index VecAD::reference$$ -$index reference, VecAD$$ The result $icode r$$ has type $codei% VecAD<%Base%>::reference -%$$ -which is very much like the $codei%AD<%Base%>%$$ type +%$$ +which is very much like the $codei%AD<%Base%>%$$ type with some notable exceptions: $subhead Exceptions$$ @@ -106,9 +100,9 @@ $lnext The object $icode r$$ cannot be used -with the $cref/computed assignments operators/Arithmetic/$$ -$code +=$$, -$code -=$$, +with the $cref/computed assignments operators/Arithmetic/$$ +$code +=$$, +$code -=$$, $code *=$$, or $code /=$$. For example, the following syntax is not valid: @@ -126,7 +120,7 @@ no matter what the types of $icode z$$, and $icode u$$. $lnext -The $cref CondExp$$ functions do not accept +The $cref CondExp$$ functions do not accept $codei%VecAD<%Base%>::reference%$$ arguments. For example, the following syntax is not valid: $codei% @@ -145,7 +139,7 @@ cannot be passed to $code Independent$$. $lnext -If one uses this type in a +If one uses this type in a AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$, $cref/sparsity pattern/glossary/Sparsity Pattern/$$ calculations @@ -158,11 +152,11 @@ $head Constructor$$ $subhead v$$ -The syntax +The syntax $codei% VecAD<%Base%> %v%(%n%) %$$ -creates an $code VecAD$$ object $icode v$$ with +creates an $code VecAD$$ object $icode v$$ with $icode n$$ elements. The initial value of the elements of $icode v$$ is unspecified. @@ -186,7 +180,7 @@ %b% = %v%[%i%] %$$ as $code size_t$$ indexing of a $code VecAD$$ object. -This indexing is only valid if the vector $icode v$$ is a +This indexing is only valid if the vector $icode v$$ is a $cref/parameter/ParVar/$$; i.e., it does not depend on the independent variables. @@ -197,7 +191,7 @@ %$$ It must be greater than or equal zero and less than $icode n$$; i.e., less than -the number of elements in $icode v$$. +the number of elements in $icode v$$. $subhead b$$ The result $icode b$$ has prototype @@ -229,21 +223,21 @@ %$$ The value of $icode x$$ must be greater than or equal zero and less than $icode n$$; i.e., less than -the number of elements in $icode v$$. +the number of elements in $icode v$$. $subhead r$$ The result $icode r$$ has prototype $codei% VecAD<%Base%>::reference %r% %$$ -The object $icode r$$ has an AD type and its +The object $icode r$$ has an AD type and its operations are recorded as part of the same AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ as for $codei%AD<%Base%>%$$ objects. -It acts as a reference to the +It acts as a reference to the element with index $latex {\rm floor} (x)$$ in the vector $icode v$$ -($latex {\rm floor} (x)$$ is +($latex {\rm floor} (x)$$ is the greatest integer less than or equal $icode x$$). Because it is a reference, it can be used to change the element value; for example, @@ -268,7 +262,7 @@ $head Speed and Memory$$ The $cref VecAD$$ vector type is inefficient because every -time an element of a vector is accessed, a new CppAD +time an element of a vector is accessed, a new CppAD $cref/variable/glossary/Variable/$$ is created on the tape using either the $code Ldp$$ or $code Ldv$$ operation (unless all of the elements of the vector are @@ -304,7 +298,7 @@ $lend $end ------------------------------------------------------------------------- +------------------------------------------------------------------------ */ # include @@ -322,7 +316,7 @@ computed assignments are used with the VecAD_reference class. The argument \c op is one of the following: += , -= , *= , /=. -The argument \c name, is a string literal with the name of the +The argument \c name, is a string literal with the name of the computed assignment \c op. */ # define CPPAD_VEC_AD_COMPUTED_ASSIGNMENT(op, name) \ @@ -377,7 +371,7 @@ \param ind value of ind_ */ - VecAD_reference(VecAD *vec, const AD& ind) + VecAD_reference(VecAD *vec, const AD& ind) : vec_( vec ) , ind_(ind) { } @@ -416,7 +410,7 @@ ADTape* tape = AD::tape_ptr(vec_->tape_id_); CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL ); CPPAD_ASSERT_UNKNOWN( vec_->offset_ > 0 ); - + size_t load_op_index = tape->Rec_.num_load_op_rec(); if( IdenticalPar(ind_) ) { CPPAD_ASSERT_UNKNOWN( NumRes(LdpOp) == 1 ); @@ -430,7 +424,7 @@ result.taddr_ = tape->Rec_.PutLoadOp(LdpOp); // change result to variable for this load result.tape_id_ = tape->id_; - } + } else { CPPAD_ASSERT_UNKNOWN( NumRes(LdvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(LdvOp) == 3 ); @@ -475,13 +469,13 @@ (std::ostream &os, const VecAD &vec_); private: /// size of this VecAD vector - const size_t length_; + const size_t length_; - /// elements of this vector - pod_vector data_; + /// elements of this vector + pod_vector data_; /// offset in cummulate vector corresponding to this object - size_t offset_; + size_t offset_; /// tape id corresponding to the offset tape_id_t tape_id_; @@ -491,15 +485,15 @@ /// default constructor /// initialize tape_id_ same as for default constructor; see default.hpp - VecAD(void) - : length_(0) + VecAD(void) + : length_(0) , offset_(0) , tape_id_(0) { CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); } - /// sizing constructor + /// sizing constructor /// initialize tape_id_ same as for parameters; see ad_copy.hpp - VecAD(size_t n) + VecAD(size_t n) : length_(n) , offset_(0) , tape_id_(0) @@ -510,7 +504,7 @@ // Initialize data to zero so all have same value. // This uses less memory and avoids a valgrind error - // during TapeRec::PutPar + // during TapeRec::PutPar for(i = 0; i < length_; i++) data_[i] = zero; } @@ -531,7 +525,7 @@ /// element index Base &operator[](size_t i) { - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( Parameter(*this), "VecAD: cannot use size_t indexing because this" " VecAD vector is a variable." @@ -544,15 +538,15 @@ return data_[i]; } - /*! delayed taped elemement access - + /*! delayed taped elemement access + \param x element index \par This operation may convert this vector from a parameter to a variable */ - VecAD_reference operator[](const AD &x) + VecAD_reference operator[](const AD &x) { CPPAD_ASSERT_KNOWN( 0 <= Integer(x), @@ -567,7 +561,7 @@ if( Parameter(*this) & Parameter(x) ) return VecAD_reference(this, x); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( Parameter(*this) | Parameter(x) | (tape_id_ == x.tape_id_), "VecAD: vector and index are variables for" " different tapes." @@ -575,18 +569,18 @@ if( Parameter(*this) ) { // must place a copy of vector in tape - offset_ = + offset_ = AD::tape_ptr(x.tape_id_)->AddVec(length_, data_); - // Advance pointer by one so starts at first component of this - // vector; i.e., skip lenght at begining (so is always > 0) - offset_++; + // Advance pointer by one so starts at first component of this + // vector; i.e., skip lenght at begining (so is always > 0) + offset_++; // tape id corresponding to this offest tape_id_ = x.tape_id_; } - return VecAD_reference(this, x); + return VecAD_reference(this, x); } }; @@ -608,7 +602,7 @@ } CPPAD_ASSERT_UNKNOWN( y.taddr_ > 0 ); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( Parameter(*vec_) | (vec_->tape_id_ == y.tape_id_), "VecAD assignment: vector and new element value are variables" "\nfor different tapes." @@ -621,7 +615,7 @@ vec_->offset_ = tape->AddVec(vec_->length_, vec_->data_); // advance offset to be start of vector plus one - (vec_->offset_)++; + (vec_->offset_)++; // tape id corresponding to this offest vec_->tape_id_ = y.tape_id_; @@ -633,7 +627,7 @@ size_t i = static_cast( Integer(ind_) ); CPPAD_ASSERT_UNKNOWN( i < vec_->length_ ); - // assign value for this element (as an AD object) + // assign value for this element (as an AD object) vec_->data_[i] = y.value_; // record the setting of this array element @@ -670,11 +664,11 @@ */ template void VecAD_reference::operator=(const Base &y) -{ +{ size_t i = static_cast( Integer(ind_) ); CPPAD_ASSERT_UNKNOWN( i < vec_->length_ ); - // assign value for this element + // assign value for this element vec_->data_[i] = y; // check if this ADVec object is a parameter @@ -719,7 +713,7 @@ value that element is set to. \par -this case gets folded into case where value is AD. +this case gets folded into case where value is AD. */ template inline void VecAD_reference::operator= @@ -733,7 +727,7 @@ value that element is set to. \par -this case gets folded into case where value is Base. +this case gets folded into case where value is Base. */ template inline void VecAD_reference::operator=(int y) diff -Nru cppad-2015.00.00.9/cppad/local/zdouble.hpp cppad-2016.00.00.1/cppad/local/zdouble.hpp --- cppad-2015.00.00.9/cppad/local/zdouble.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/zdouble.hpp 2016-02-09 08:31:51.000000000 +0000 @@ -0,0 +1,550 @@ +// $Id$ +# ifndef CPPAD_ZDOUBLE_HPP +# define CPPAD_ZDOUBLE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin zdouble$$ +$spell + zdouble + op + bool + inf + CppAD +$$ +$section zdouble: An AD Base Type With Absolute Zero$$ + +$head Deprecated 2015-09-26$$ +Use the function $cref azmul$$ instead. + +$head Absolute Zero$$ +The $code zdouble$$ class acts like the $code double$$ type +with the added property that zero times any value is zero. +This includes zero time $cref nan$$ and zero times infinity. +In addition, zero divided by any value and any value times zero +are also zero. + +$head Syntax$$ + +$subhead Constructor and Assignment$$ +$codei% zdouble z +%$$ +$codei% zdouble z(x) +%$$ +$icode% z1% %op% %x% +%$$ +where $icode x$$ is a $code double$$ or $code zdouble$$ object +and $icode op$$ is $code =$$, $code +=$$, $code -=$$, $code *=$$ +or $code /=-$$. + +$subhead Comparison Operators$$ +$icode% b% = %z% %op% %x% +%$$ +$icode% b% = %x% %op% %z% +%$$ +where $icode b$$ is a $code bool$$ object, +$icode z$$ is a $code zdouble$$ object, +$icode x$$ is a $code double$$ or $code zdouble$$ object, and +$icode op$$ is $code ==$$, $code !=$$, $code <=$$, $code >=$$, +$code <$$ or $code >$$. + +$subhead Arithmetic Operators$$ +$icode% z2% = %z1% %op% %x% +%$$ +$icode% z2% = %x% %op% %z1% +%$$ +where $icode z1$$, $icode z2$$ are $code zdouble$$ objects, +$icode x$$ is a $code double$$ or $code zdouble$$ object, and +$icode op$$ is $code +$$, $code -$$, $code *$$ or $code /$$. + + +$subhead Standard Math$$ +$icode% z2% = %fun%(%z1%) +%$$ +$icode% z3% = pow(%z1%, %z2%) +%$$ +where $icode z1$$, $icode z2$$, $icode z3$$ are $code zdouble$$ objects and +$icode fun$$ is a $cref unary_standard_math$$ function. + +$subhead Nan$$ +There is a specialization of $cref nan$$ so that +$icode% + z2% = nan(%z1%) +%$$ +returns 'not a number' when $icode z1$$ has type $code zdouble$$. +Note that this template function needs to be specialized because +$codei + zdouble(0.0) == zdouble(0.0) / zdouble(0.0) +$$ + + +$head Motivation$$ + +$subhead General$$ +Often during computing (and more so in parallel computing) alternative +values for an expression are computed and one of the alternatives +is chosen using some boolean variable. +This is often represented by +$codei% + %result% = %flag% * %value_if_true% + (1 - %flag%) * %value_if_false% +%$$ +where $icode flag$$ is one for true and zero for false. +This representation does not work for $code double$$ when the value +being multiplied by zero is $code +inf$$, $code -inf$$, or $code nan$$. + +$subhead CppAD$$ +In CppAD one can use +$cref/conditional expressions/CondExp/$$ to achieve the representation +$codei% + %result% = %flag% * %value_if_true% + (1 - %flag%) * %value_if_false% +%$$ +This works fine except when there are +$cref/multiple levels of AD/mul_level/$$; e.g., +when using $codei%AD< AD >%$$. +In this case the corresponding AD function objects have type +$cref/ADFun< AD >/FunConstruct/$$. +When these AD function objects compute derivatives using +$cref reverse$$ mode, the conditional expressions are represented use +zeros to multiply the expression that is not used. +Using $codei%AD< AD >%$$ instead of $code AD< AD >$$ +makes this representation work and fixes the problem. + +$head Base Type Requirements$$ +The type $code zdouble$$ satisfies all of the CppAD +$cref/base type requirements/base_require/$$. + +$children% + test_more/zdouble.cpp +%$$ +$head Example$$ +The file $cref zdouble.cpp$$ +contains an example and test of this class. +It returns true if it succeeds and false otherwise. + +$end +*/ +# include +# include + +/*! +\file zdouble.hpp +Define a class like double but with an absolute zero. +*/ + +/*! +\def CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(op) +Define a computed assignment member operator that functions the same +as corresponding double operator. +*/ +# define CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(op) \ + zdouble& operator op (const zdouble& z) \ + { dbl_ op z.dbl_; \ + return *this; \ + } \ + zdouble& operator op (const double& x) \ + { dbl_ op x; \ + return *this; \ + } + +/*! +\def CPPAD_ZDOUBLE_UNARY_OPERATOR(op) +Define a unary computed assignment member operator. +*/ +# define CPPAD_ZDOUBLE_UNARY_OPERATOR(op) \ + zdouble operator op (void) const \ + { return zdouble( op dbl_ ); } + +/*! +# define CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR(op) +Define a binary arithmetic member operator that functions the same +as corresponding double operator. +*/ +# define CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR(op) \ + zdouble operator op (const zdouble& z) const \ + { return zdouble( dbl_ op z.dbl_ ); } \ + zdouble operator op (const double& x) const \ + { return zdouble( dbl_ op x ); } + +/*! +\def CPPAD_ZDOUBLE_COMPARE_OPERATOR(op) +Define a comparison member operator. +*/ +# define CPPAD_ZDOUBLE_COMPARE_OPERATOR(op) \ + bool operator op (const zdouble& z) const \ + { return dbl_ op z.dbl_; } \ + bool operator op (const double& x) const \ + { return dbl_ op x; } + +/*! +\def CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(op) +Define a binary arithmetic operator that is not a member because +the double operand is on the left. +*/ +# define CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(op) \ + inline zdouble operator op(const double& x, const zdouble& z) \ + { return zdouble(x) op z; } + +/*! +\def CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(op, op_switch) +Define a comparison operator that is not a member because +the double operand is on the left. +Convert it to the case where the double operand is on the right by +by using op_switch instead of op. +*/ +# define CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(op, op_switch) \ + inline bool operator op(const double& x, const zdouble& z) \ + { return z op_switch x; } + +/*! +\def CPPAD_ZDOUBLE_STD_MATH_FRIEND(fun) +Declare that a standard math function is a friend. +*/ +# define CPPAD_ZDOUBLE_STD_MATH_FRIEND(fun) \ + friend zdouble fun(const zdouble& z); +/*! +\def CPPAD_ZDOUBLE_STD_MATH(fun) +Define a standard math function. +*/ +# define CPPAD_ZDOUBLE_STD_MATH(fun) \ + inline zdouble fun(const zdouble& z ) \ + { return zdouble( std::fun(z.dbl_) ); } + +namespace CppAD { // CPPAD_BEGIN_NAMESPACDE + + +/*! +Class that is like double, except that it has an absolute zero. +*/ +class zdouble { + /*! + For zdouble objects z1, z2, and std::ostream os, + declare the following friends: + \code + os << z1 + Integer(z1) + abs(z1) + pow(z1, z2) + abs_geq(z1, z2) + fun(z1) + \endcode + where fun is any of the standard math unary functions. + */ + friend std::ostream& operator << (std::ostream &os, const zdouble& z); + friend int Integer(const zdouble& z); + friend zdouble abs(const zdouble& x); + friend zdouble pow(const zdouble& x, const zdouble& y); + friend bool abs_geq(const zdouble& x, const zdouble& y); + // + CPPAD_ZDOUBLE_STD_MATH_FRIEND(acos) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(asin) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(atan) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(cos) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(cosh) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(exp) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(fabs) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(log) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(log10) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(sin) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(sinh) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(sqrt) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(tan) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(tanh) + // +# if CPPAD_USE_CPLUSPLUS_2011 + CPPAD_ZDOUBLE_STD_MATH_FRIEND(erf) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(asinh) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(acosh) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(atanh) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(expm1) + CPPAD_ZDOUBLE_STD_MATH_FRIEND(log1p) + // +# endif +private: + /// The value for this object + double dbl_; +public: + /// Default constructor + zdouble(void) + : dbl_() + { } + /// Copy constructor + zdouble(const zdouble& z) + : dbl_(z.dbl_) + { } + /// Constructor from double + zdouble(const double& dbl) + : dbl_(dbl) + { } + // + /// Destructor + ~zdouble(void) + { } + // + /// Assignment from zdouble + zdouble& operator=(const zdouble& z) + { dbl_ = z.dbl_; + return *this; + } + /// Assignment from double + zdouble& operator=(const double& dbl) + { dbl_ = dbl; + return *this; + } + // + /// Normal computed assignment + CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(+=) + /// Normal computed assignment + CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(-=) + /// Normal unary operator + CPPAD_ZDOUBLE_UNARY_OPERATOR(+) + /// Normal unary operator + CPPAD_ZDOUBLE_UNARY_OPERATOR(-) + /// Normal compare operator + CPPAD_ZDOUBLE_COMPARE_OPERATOR(==) + /// Normal compare operator + CPPAD_ZDOUBLE_COMPARE_OPERATOR(!=) + /// Normal compare operator + CPPAD_ZDOUBLE_COMPARE_OPERATOR(<=) + /// Normal compare operator + CPPAD_ZDOUBLE_COMPARE_OPERATOR(>=) + /// Normal compare operator + CPPAD_ZDOUBLE_COMPARE_OPERATOR(<) + /// Normal compare operator + CPPAD_ZDOUBLE_COMPARE_OPERATOR(>) + // + /// Normal binary arithmetic operator + CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR(+) + /// Normal binary arithmetic operator + CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR(-) + // + /// Binary arithmetic * with absolute zero + zdouble operator * (const zdouble& z) const + { bool zero = (dbl_ == 0.0) || (z.dbl_ == 0.0); + return zdouble( zero ? 0.0 : (dbl_ * z.dbl_) ); + } + /// Binary arithmetic * with absolute zero + zdouble operator * (const double& x) const + { bool zero = (dbl_ == 0.0) || (x == 0.0); + return zdouble( zero ? 0.0 : (dbl_ * x) ); + } + /// Binary arithmetic / with absolute zero + zdouble operator / (const zdouble& z) const + { bool zero = (dbl_ == 0.0); + return zdouble( zero ? 0.0 : (dbl_ / z.dbl_) ); + } + /// Binary arithmetic / with absolute zero + zdouble operator / (const double& x) const + { bool zero = (dbl_ == 0.0); + return zdouble( zero ? 0.0 : (dbl_ / x) ); + } + // + /// Compute assignmnet *= with absolute zero + zdouble& operator *= (const zdouble& z) + { bool zero = (dbl_ == 0.0) || (z.dbl_ == 0.0); + zero ? (dbl_ = 0.0) : (dbl_ *= z.dbl_); + return *this; + } + /// Compute assignmnet *= with absolute zero + zdouble& operator *= (const double& x) + { bool zero = (dbl_ == 0.0) || (x == 0.0); + zero ? (dbl_ = 0.0) : (dbl_ *= x); + return *this; + } + // + /// Compute assignmnet /= with absolute zero + zdouble& operator /= (const zdouble& z) + { bool zero = (dbl_ == 0.0); + zero ? (dbl_ = 0.0) : (dbl_ /= z.dbl_); + return *this; + } + /// Compute assignmnet /= with absolute zero + zdouble& operator /= (const double& x) + { bool zero = (dbl_ == 0.0); + zero ? (dbl_ = 0.0) : (dbl_ /= x); + return *this; + } +}; +// BEGIN nan +/// Must specialize CppAD::nan because zdouble 0/0 is not nan. +template <> +inline zdouble nan(const zdouble& zero) +{ + return zdouble( std::numeric_limits::quiet_NaN() ); +} +// END nan +// +/// Normal non-member compare operator +CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(==, ==) +/// Normal non-member compare operator +CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(!=, !=) +/// Normal non-member compare operator +CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(<=, >=) +/// Normal non-member compare operator +CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(>=, <=) +/// Normal non-member compare operator +CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(<, >) +/// Normal non-member compare operator +CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(>, <) +// +/// Normal binary arithmetic operator +CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(+) +/// Normal binary arithmetic operator +CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(-) +/// Binary arithmetic operator with absolute zero +CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(*) +/// Binary arithmetic operator with absolute zero +CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(/) +// ------------------------------------------------------------------------- +// Base type requirements +// ------------------------------------------------------------------------- + +/// Base type requirement: CondExpOp +inline zdouble CondExpOp( + enum CompareOp cop , + const zdouble& left , + const zdouble& right , + const zdouble& exp_if_true , + const zdouble& exp_if_false ) +{ return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false); +} + +/// Base type requirement: CondExpRel +CPPAD_COND_EXP_REL(zdouble) + +/// Base type requirement: EqualOpSeq +inline bool EqualOpSeq(const zdouble& x, const zdouble& y) +{ return x == y; } + +/// Base type requirement: Identical +inline bool IdenticalPar(const zdouble& x) +{ return true; } +inline bool IdenticalZero(const zdouble& x) +{ return (x == 0.0); } +inline bool IdenticalOne(const zdouble& x) +{ return (x == 1.); } +inline bool IdenticalEqualPar(const zdouble& x, const zdouble& y) +{ return (x == y); } + +/// Base type requirement: output operator +inline std::ostream& operator << (std::ostream &os, const zdouble& z) +{ os << z.dbl_; + return os; +} + +/// Base type requirement: Integer +inline int Integer(const zdouble& x) +{ return static_cast(x.dbl_); } + +/// Base type requirement: azmul +inline zdouble azmul(const zdouble& x, const zdouble& y) +{ return x * y; } + +/// Base type requirement: Ordered +inline bool GreaterThanZero(const zdouble& x) +{ return x > 0.0; } +inline bool GreaterThanOrZero(const zdouble& x) +{ return x >= 0.0; } +inline bool LessThanZero(const zdouble& x) +{ return x < 0.0; } +inline bool LessThanOrZero(const zdouble& x) +{ return x <= 0.0; } +inline bool abs_geq(const zdouble& x, const zdouble& y) +{ return std::fabs(x.dbl_) >= std::fabs(y.dbl_); } + +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(acos) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(asin) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(atan) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(cos) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(cosh) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(exp) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(fabs) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(log) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(log10) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(sin) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(sinh) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(sqrt) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(tan) +/// Normal standard math function +CPPAD_ZDOUBLE_STD_MATH(tanh) +// +# if CPPAD_USE_CPLUSPLUS_2011 +/// C++2011 standard math function +CPPAD_ZDOUBLE_STD_MATH(erf) +/// C++2011 standard math function +CPPAD_ZDOUBLE_STD_MATH(asinh) +/// C++2011 standard math function +CPPAD_ZDOUBLE_STD_MATH(acosh) +/// C++2011 standard math function +CPPAD_ZDOUBLE_STD_MATH(atanh) +/// C++2011 standard math function +CPPAD_ZDOUBLE_STD_MATH(expm1) +/// C++2011 standard math function +CPPAD_ZDOUBLE_STD_MATH(log1p) +# endif + +/// Base type requirement: abs +inline zdouble abs(const zdouble& x) +{ return std::fabs(x.dbl_); } + +/// Base type requirement: sign +inline zdouble sign(const zdouble& x) +{ if( x > 0.0 ) + return zdouble(1.); + if( x == 0.0 ) + return zdouble(0.0); + return zdouble(-1.); +} + +/// Base type requirement: pow +inline zdouble pow(const zdouble& x, const zdouble& y) +{ return std::pow(x.dbl_, y.dbl_); } + +/// Base type requirement: limits +template <> +class numeric_limits { +public: + // machine epsilon + static zdouble epsilon(void) + { return std::numeric_limits::epsilon(); } + // minimum positive normalized value + static zdouble min(void) + { return std::numeric_limits::min(); } + // maximum finite value + static zdouble max(void) + { return std::numeric_limits::max(); } +}; + +} // CPPAD_END_NAMESPACE + +/// undef all macros defined in this file +# undef CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR +# undef CPPAD_ZDOUBLE_UNARY_OPERATOR +# undef CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR +# undef CPPAD_ZDOUBLE_COMPARE_OPERATOR +# undef CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR +# undef CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR +# undef CPPAD_ZDOUBLE_STD_MATH_FRIEND +# undef CPPAD_ZDOUBLE_STD_MATH + +# endif diff -Nru cppad-2015.00.00.9/cppad/local/zmul_op.hpp cppad-2016.00.00.1/cppad/local/zmul_op.hpp --- cppad-2015.00.00.9/cppad/local/zmul_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/local/zmul_op.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,518 @@ +// $Id$ +# ifndef CPPAD_ZMUL_OP_HPP +# define CPPAD_ZMUL_OP_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file mul_op.hpp +Forward and reverse mode calculations for z = azmul(x, y). +*/ + +// --------------------------- Zmulvv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = ZmulvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument \a parameter is not used. + +\copydetails forward_binary_op +*/ + +template +inline void forward_zmulvv_op( + size_t p , + size_t q , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base* y = taylor + arg[1] * cap_order; + Base* z = taylor + i_z * cap_order; + + size_t k; + for(size_t d = p; d <= q; d++) + { z[d] = Base(0); + for(k = 0; k <= d; k++) + z[d] += azmul(x[d-k], y[k]); + } +} +/*! +Multiple directions forward mode Taylor coefficients for op = ZmulvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument \a parameter is not used. + +\copydetails forward_binary_op_dir +*/ + +template +inline void forward_zmulvv_op_dir( + size_t q , + size_t r , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + + // Taylor coefficients corresponding to arguments and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + arg[0] * num_taylor_per_var; + Base* y = taylor + arg[1] * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + + size_t k, ell, m; + for(ell = 0; ell < r; ell++) + { m = (q-1)*r + ell + 1; + z[m] = azmul(x[0], y[m]) + azmul(x[m], y[0]); + for(k = 1; k < q; k++) + z[m] += azmul(x[(q-k-1)*r + ell + 1], y[(k-1)*r + ell + 1]); + } +} + +/*! +Compute zero order forward mode Taylor coefficients for result of op = ZmulvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument \a parameter is not used. + +\copydetails forward_binary_op_0 +*/ + +template +inline void forward_zmulvv_op_0( + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base* y = taylor + arg[1] * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = azmul(x[0], y[0]); +} + +/*! +Compute reverse mode partial derivatives for result of op = ZmulvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument \a parameter is not used. + +\copydetails reverse_binary_op +*/ + +template +inline void reverse_zmulvv_op( + size_t d , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Arguments + const Base* x = taylor + arg[0] * cap_order; + const Base* y = taylor + arg[1] * cap_order; + + // Partial derivatives corresponding to arguments and result + Base* px = partial + arg[0] * nc_partial; + Base* py = partial + arg[1] * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // number of indices to access + size_t j = d + 1; + size_t k; + while(j) + { --j; + for(k = 0; k <= j; k++) + { + px[j-k] += azmul(pz[j], y[k]); + py[k] += azmul(pz[j], x[j-k]); + } + } +} +// --------------------------- Zmulpv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = ZmulpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails forward_binary_op +*/ + +template +inline void forward_zmulpv_op( + size_t p , + size_t q , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + arg[1] * cap_order; + Base* z = taylor + i_z * cap_order; + + // Paraemter value + Base x = parameter[ arg[0] ]; + + for(size_t d = p; d <= q; d++) + z[d] = azmul(x, y[d]); +} +/*! +Multiple directions forward mode Taylor coefficients for op = ZmulpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails forward_binary_op_dir +*/ + +template +inline void forward_zmulpv_op_dir( + size_t q , + size_t r , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + + // Taylor coefficients corresponding to arguments and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + size_t m = (q-1) * r + 1; + Base* y = taylor + arg[1] * num_taylor_per_var + m; + Base* z = taylor + i_z * num_taylor_per_var + m; + + // Paraemter value + Base x = parameter[ arg[0] ]; + + for(size_t ell = 0; ell < r; ell++) + z[ell] = azmul(x, y[ell]); +} +/*! +Compute zero order forward mode Taylor coefficient for result of op = ZmulpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails forward_binary_op_0 +*/ + +template +inline void forward_zmulpv_op_0( + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); + + // Paraemter value + Base x = parameter[ arg[0] ]; + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + arg[1] * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = azmul(x, y[0]); +} + +/*! +Compute reverse mode partial derivative for result of op = ZmulpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails reverse_binary_op +*/ + +template +inline void reverse_zmulpv_op( + size_t d , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Arguments + Base x = parameter[ arg[0] ]; + + // Partial derivatives corresponding to arguments and result + Base* py = partial + arg[1] * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // number of indices to access + size_t j = d + 1; + while(j) + { --j; + py[j] += azmul(pz[j], x); + } +} +// --------------------------- Zmulvp ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = ZmulvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails forward_binary_op +*/ + +template +inline void forward_zmulvp_op( + size_t p , + size_t q , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base* z = taylor + i_z * cap_order; + + // Paraemter value + Base y = parameter[ arg[1] ]; + + for(size_t d = p; d <= q; d++) + z[d] = azmul(x[d], y); +} +/*! +Multiple directions forward mode Taylor coefficients for op = ZmulvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails forward_binary_op_dir +*/ + +template +inline void forward_zmulvp_op_dir( + size_t q , + size_t r , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + + // Taylor coefficients corresponding to arguments and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + size_t m = (q-1) * r + 1; + Base* x = taylor + arg[0] * num_taylor_per_var + m; + Base* z = taylor + i_z * num_taylor_per_var + m; + + // Paraemter value + Base y = parameter[ arg[1] ]; + + for(size_t ell = 0; ell < r; ell++) + z[ell] = azmul(x[ell], y); +} +/*! +Compute zero order forward mode Taylor coefficient for result of op = ZmulvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails forward_binary_op_0 +*/ + +template +inline void forward_zmulvp_op_0( + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); + + // Paraemter value + Base y = parameter[ arg[1] ]; + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + arg[0] * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = azmul(x[0], y); +} + +/*! +Compute reverse mode partial derivative for result of op = ZmulvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = azmul(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails reverse_binary_op +*/ + +template +inline void reverse_zmulvp_op( + size_t d , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Arguments + Base y = parameter[ arg[1] ]; + + // Partial derivatives corresponding to arguments and result + Base* px = partial + arg[0] * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // number of indices to access + size_t j = d + 1; + while(j) + { --j; + px[j] += azmul(pz[j], y); + } +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2015.00.00.9/cppad/LuFactor.h cppad-2016.00.00.1/cppad/LuFactor.h --- cppad-2015.00.00.9/cppad/LuFactor.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/LuFactor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: LuFactor.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/lu_factor.hpp" diff -Nru cppad-2015.00.00.9/cppad/lu_factor.hpp cppad-2016.00.00.1/cppad/lu_factor.hpp --- cppad-2015.00.00.9/cppad/lu_factor.hpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/cppad/lu_factor.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,400 +0,0 @@ -/* $Id: lu_factor.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_LU_FACTOR_INCLUDED -# define CPPAD_LU_FACTOR_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin LuFactor$$ -$escape #$$ -$spell - cppad.hpp - Cpp - Geq - Lu - bool - const - ip - jp - namespace - std - typename -$$ - -$index LuFactor$$ -$index linear, Lu factor equation$$ -$index equation, Lu factor$$ -$index determinant, Lu factor$$ -$index solve, Lu factor$$ - -$section LU Factorization of A Square Matrix$$ - -$pre -$$ - -$head Syntax$$ $code# include $$ -$pre -$$ -$icode%sign% = LuFactor(%ip%, %jp%, %LU%)%$$ - - -$head Description$$ -Computes an LU factorization of the matrix $icode A$$ -where $icode A$$ is a square matrix. - -$head Include$$ -The file $code cppad/lu_factor.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Matrix Storage$$ -All matrices are stored in row major order. -To be specific, if $latex Y$$ is a vector -that contains a $latex p$$ by $latex q$$ matrix, -the size of $latex Y$$ must be equal to $latex p * q $$ and for -$latex i = 0 , \ldots , p-1$$, -$latex j = 0 , \ldots , q-1$$, -$latex \[ - Y_{i,j} = Y[ i * q + j ] -\] $$ - -$head sign$$ -The return value $icode sign$$ has prototype -$codei% - int %sign% -%$$ -If $icode A$$ is invertible, $icode sign$$ is plus or minus one -and is the sign of the permutation corresponding to the row ordering -$icode ip$$ and column ordering $icode jp$$. -If $icode A$$ is not invertible, $icode sign$$ is zero. - -$head ip$$ -The argument $icode ip$$ has prototype -$codei% - %SizeVector% &%ip% -%$$ -(see description of $cref/SizeVector/LuFactor/SizeVector/$$ below). -The size of $icode ip$$ is referred to as $icode n$$ in the -specifications below. -The input value of the elements of $icode ip$$ does not matter. -The output value of the elements of $icode ip$$ determine -the order of the rows in the permuted matrix. - -$head jp$$ -The argument $icode jp$$ has prototype -$codei% - %SizeVector% &%jp% -%$$ -(see description of $cref/SizeVector/LuFactor/SizeVector/$$ below). -The size of $icode jp$$ must be equal to $icode n$$. -The input value of the elements of $icode jp$$ does not matter. -The output value of the elements of $icode jp$$ determine -the order of the columns in the permuted matrix. - -$head LU$$ -The argument $icode LU$$ has the prototype -$codei% - %FloatVector% &%LU% -%$$ -and the size of $icode LU$$ must equal $latex n * n$$ -(see description of $cref/FloatVector/LuFactor/FloatVector/$$ below). - -$subhead A$$ -We define $icode A$$ as the matrix corresponding to the input -value of $icode LU$$. - -$subhead P$$ -We define the permuted matrix $icode P$$ in terms of $icode A$$ by -$codei% - %P%(%i%, %j%) = %A%[ %ip%[%i%] * %n% + %jp%[%j%] ] -%$$ - -$subhead L$$ -We define the lower triangular matrix $icode L$$ in terms of the -output value of $icode LU$$. -The matrix $icode L$$ is zero above the diagonal -and the rest of the elements are defined by -$codei% - %L%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] -%$$ -for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , i$$. - -$subhead U$$ -We define the upper triangular matrix $icode U$$ in terms of the -output value of $icode LU$$. -The matrix $icode U$$ is zero below the diagonal, -one on the diagonal, -and the rest of the elements are defined by -$codei% - %U%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] -%$$ -for $latex i = 0 , \ldots , n-2$$ and $latex j = i+1 , \ldots , n-1$$. - -$subhead Factor$$ -If the return value $icode sign$$ is non-zero, -$codei% - %L% * %U% = %P% -%$$ -If the return value of $icode sign$$ is zero, -the contents of $icode L$$ and $icode U$$ are not defined. - -$subhead Determinant$$ -$index determinant$$ -If the return value $icode sign$$ is zero, -the determinant of $icode A$$ is zero. -If $icode sign$$ is non-zero, -using the output value of $icode LU$$ -the determinant of the matrix $icode A$$ is equal to -$codei% -%sign% * %LU%[%ip%[0], %jp%[0]] * %...% * %LU%[%ip%[%n%-1], %jp%[%n%-1]] -%$$ - -$head SizeVector$$ -The type $icode SizeVector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type size_t/SimpleVector/Elements of Specified Type/$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head FloatVector$$ -The type $icode FloatVector$$ must be a -$cref/simple vector class/SimpleVector/$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head Float$$ -This notation is used to denote the type corresponding -to the elements of a $icode FloatVector$$. -The type $icode Float$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. -In addition, the following operations must be defined for any pair -of $icode Float$$ objects $icode x$$ and $icode y$$: - -$table -$bold Operation$$ $cnext $bold Description$$ $rnext -$codei%log(%x%)%$$ $cnext - returns the logarithm of $icode x$$ as a $icode Float$$ object -$tend - -$head AbsGeq$$ -Including the file $code lu_factor.hpp$$ defines the template function -$codei% - template - bool AbsGeq<%Float%>(const %Float% &%x%, const %Float% &%y%) -%$$ -in the $code CppAD$$ namespace. -This function returns true if the absolute value of -$icode x$$ is greater than or equal the absolute value of $icode y$$. -It is used by $code LuFactor$$ to choose the pivot elements. -This template function definition uses the operator -$code <=$$ to obtain the absolute value for $icode Float$$ objects. -If this operator is not defined for your use of $icode Float$$, -you will need to specialize this template so that it works for your -use of $code LuFactor$$. -$pre - -$$ -Complex numbers do not have the operation $code <=$$ defined. -The specializations -$codei% -bool AbsGeq< std::complex > - (const std::complex &%x%, const std::complex &%y%) -bool AbsGeq< std::complex > - (const std::complex &%x%, const std::complex &%y%) -%$$ -are define by including $code lu_factor.hpp$$ -These return true if the sum of the square of the real and imaginary parts -of $icode x$$ is greater than or equal the -sum of the square of the real and imaginary parts of $icode y$$. - -$children% - example/lu_factor.cpp% - omh/lu_factor_hpp.omh -%$$ -$head Example$$ -The file -$cref lu_factor.cpp$$ -contains an example and test of using $code LuFactor$$ by itself. -It returns true if it succeeds and false otherwise. -$pre - -$$ -The file $cref lu_solve.hpp$$ provides a useful example usage of -$code LuFactor$$ with $code LuInvert$$. - -$head Source$$ -The file $cref lu_factor.hpp$$ contains the -current source code that implements these specifications. - -$end --------------------------------------------------------------------------- -*/ -// BEGIN C++ - -# include -# include - -# include -# include -# include - -namespace CppAD { // BEGIN CppAD namespace - -// AbsGeq -template -inline bool AbsGeq(const Float &x, const Float &y) -{ Float xabs = x; - if( xabs <= Float(0) ) - xabs = - xabs; - Float yabs = y; - if( yabs <= Float(0) ) - yabs = - yabs; - return xabs >= yabs; -} -inline bool AbsGeq( - const std::complex &x, - const std::complex &y) -{ double xsq = x.real() * x.real() + x.imag() * x.imag(); - double ysq = y.real() * y.real() + y.imag() * y.imag(); - - return xsq >= ysq; -} -inline bool AbsGeq( - const std::complex &x, - const std::complex &y) -{ float xsq = x.real() * x.real() + x.imag() * x.imag(); - float ysq = y.real() * y.real() + y.imag() * y.imag(); - - return xsq >= ysq; -} - -// Lines that are different from code in cppad/local/lu_ratio.hpp end with // -template // -int LuFactor(SizeVector &ip, SizeVector &jp, FloatVector &LU) // -{ - // type of the elements of LU // - typedef typename FloatVector::value_type Float; // - - // check numeric type specifications - CheckNumericType(); - - // check simple vector class specifications - CheckSimpleVector(); - CheckSimpleVector(); - - size_t i, j; // some temporary indices - const Float zero( 0 ); // the value zero as a Float object - size_t imax; // row index of maximum element - size_t jmax; // column indx of maximum element - Float emax; // maximum absolute value - size_t p; // count pivots - int sign; // sign of the permutation - Float etmp; // temporary element - Float pivot; // pivot element - - // ------------------------------------------------------- - size_t n = ip.size(); - CPPAD_ASSERT_KNOWN( - size_t(jp.size()) == n, - "Error in LuFactor: jp must have size equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(LU.size()) == n * n, - "Error in LuFactor: LU must have size equal to n * m" - ); - // ------------------------------------------------------- - - // initialize row and column order in matrix not yet pivoted - for(i = 0; i < n; i++) - { ip[i] = i; - jp[i] = i; - } - // initialize the sign of the permutation - sign = 1; - // --------------------------------------------------------- - - // Reduce the matrix P to L * U using n pivots - for(p = 0; p < n; p++) - { // determine row and column corresponding to element of - // maximum absolute value in remaining part of P - imax = jmax = n; - emax = zero; - for(i = p; i < n; i++) - { for(j = p; j < n; j++) - { CPPAD_ASSERT_UNKNOWN( - (ip[i] < n) & (jp[j] < n) - ); - etmp = LU[ ip[i] * n + jp[j] ]; - - // check if maximum absolute value so far - if( AbsGeq (etmp, emax) ) - { imax = i; - jmax = j; - emax = etmp; - } - } - } - CPPAD_ASSERT_KNOWN( - (imax < n) & (jmax < n) , - "LuFactor can't determine an element with " - "maximum absolute value.\n" - "Perhaps original matrix contains not a number or infinity.\n" - "Perhaps your specialization of AbsGeq is not correct." - ); - if( imax != p ) - { // switch rows so max absolute element is in row p - i = ip[p]; - ip[p] = ip[imax]; - ip[imax] = i; - sign = -sign; - } - if( jmax != p ) - { // switch columns so max absolute element is in column p - j = jp[p]; - jp[p] = jp[jmax]; - jp[jmax] = j; - sign = -sign; - } - // pivot using the max absolute element - pivot = LU[ ip[p] * n + jp[p] ]; - - // check for determinant equal to zero - if( pivot == zero ) - { // abort the mission - return 0; - } - - // Reduce U by the elementary transformations that maps - // LU( ip[p], jp[p] ) to one. Only need transform elements - // above the diagonal in U and LU( ip[p] , jp[p] ) is - // corresponding value below diagonal in L. - for(j = p+1; j < n; j++) - LU[ ip[p] * n + jp[j] ] /= pivot; - - // Reduce U by the elementary transformations that maps - // LU( ip[i], jp[p] ) to zero. Only need transform elements - // above the diagonal in U and LU( ip[i], jp[p] ) is - // corresponding value below diagonal in L. - for(i = p+1; i < n; i++ ) - { etmp = LU[ ip[i] * n + jp[p] ]; - for(j = p+1; j < n; j++) - { LU[ ip[i] * n + jp[j] ] -= - etmp * LU[ ip[p] * n + jp[j] ]; - } - } - } - return sign; -} -} // END CppAD namespace -// END C++ -# endif diff -Nru cppad-2015.00.00.9/cppad/LuInvert.h cppad-2016.00.00.1/cppad/LuInvert.h --- cppad-2015.00.00.9/cppad/LuInvert.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/LuInvert.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: LuInvert.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/lu_invert.hpp" diff -Nru cppad-2015.00.00.9/cppad/lu_invert.hpp cppad-2016.00.00.1/cppad/lu_invert.hpp --- cppad-2015.00.00.9/cppad/lu_invert.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/lu_invert.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,243 +0,0 @@ -/* $Id: lu_invert.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_LU_INVERT_INCLUDED -# define CPPAD_LU_INVERT_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin LuInvert$$ -$escape #$$ -$spell - cppad.hpp - Lu - Cpp - jp - ip - const - namespace - typename - etmp -$$ - -$index LuInvert$$ -$index linear, invert Lu equation$$ -$index equation, Lu invert$$ - -$section Invert an LU Factored Equation$$ - -$pre -$$ - -$head Syntax$$ $code# include $$ -$pre -$$ -$codei%LuInvert(%ip%, %jp%, %LU%, %X%)%$$ - - -$head Description$$ -Solves the matrix equation $icode%A% * %X% = %B%$$ -using an LU factorization computed by $cref LuFactor$$. - -$head Include$$ -The file $code cppad/lu_invert.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Matrix Storage$$ -All matrices are stored in row major order. -To be specific, if $latex Y$$ is a vector -that contains a $latex p$$ by $latex q$$ matrix, -the size of $latex Y$$ must be equal to $latex p * q $$ and for -$latex i = 0 , \ldots , p-1$$, -$latex j = 0 , \ldots , q-1$$, -$latex \[ - Y_{i,j} = Y[ i * q + j ] -\] $$ - -$head ip$$ -The argument $icode ip$$ has prototype -$codei% - const %SizeVector% &%ip% -%$$ -(see description for $icode SizeVector$$ in -$cref/LuFactor/LuFactor/SizeVector/$$ specifications). -The size of $icode ip$$ is referred to as $icode n$$ in the -specifications below. -The elements of $icode ip$$ determine -the order of the rows in the permuted matrix. - -$head jp$$ -The argument $icode jp$$ has prototype -$codei% - const %SizeVector% &%jp% -%$$ -(see description for $icode SizeVector$$ in -$cref/LuFactor/LuFactor/SizeVector/$$ specifications). -The size of $icode jp$$ must be equal to $icode n$$. -The elements of $icode jp$$ determine -the order of the columns in the permuted matrix. - -$head LU$$ -The argument $icode LU$$ has the prototype -$codei% - const %FloatVector% &%LU% -%$$ -and the size of $icode LU$$ must equal $latex n * n$$ -(see description for $icode FloatVector$$ in -$cref/LuFactor/LuFactor/FloatVector/$$ specifications). - -$subhead L$$ -We define the lower triangular matrix $icode L$$ in terms of $icode LU$$. -The matrix $icode L$$ is zero above the diagonal -and the rest of the elements are defined by -$codei% - %L%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] -%$$ -for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , i$$. - -$subhead U$$ -We define the upper triangular matrix $icode U$$ in terms of $icode LU$$. -The matrix $icode U$$ is zero below the diagonal, -one on the diagonal, -and the rest of the elements are defined by -$codei% - %U%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] -%$$ -for $latex i = 0 , \ldots , n-2$$ and $latex j = i+1 , \ldots , n-1$$. - -$subhead P$$ -We define the permuted matrix $icode P$$ in terms of -the matrix $icode L$$ and the matrix $icode U$$ -by $icode%P% = %L% * %U%$$. - -$subhead A$$ -The matrix $icode A$$, -which defines the linear equations that we are solving, is given by -$codei% - %P%(%i%, %j%) = %A%[ %ip%[%i%] * %n% + %jp%[%j%] ] -%$$ -(Hence -$icode LU$$ contains a permuted factorization of the matrix $icode A$$.) - - -$head X$$ -The argument $icode X$$ has prototype -$codei% - %FloatVector% &%X% -%$$ -(see description for $icode FloatVector$$ in -$cref/LuFactor/LuFactor/FloatVector/$$ specifications). -The matrix $icode X$$ -must have the same number of rows as the matrix $icode A$$. -The input value of $icode X$$ is the matrix $icode B$$ and the -output value solves the matrix equation $icode%A% * %X% = %B%$$. - - -$children% - example/lu_invert.cpp% - omh/lu_invert_hpp.omh -%$$ -$head Example$$ -The file $cref lu_solve.hpp$$ is a good example usage of -$code LuFactor$$ with $code LuInvert$$. -The file -$cref lu_invert.cpp$$ -contains an example and test of using $code LuInvert$$ by itself. -It returns true if it succeeds and false otherwise. - -$head Source$$ -The file $cref lu_invert.hpp$$ contains the -current source code that implements these specifications. - -$end --------------------------------------------------------------------------- -*/ -// BEGIN C++ -# include -# include -# include - -namespace CppAD { // BEGIN CppAD namespace - -// LuInvert -template -void LuInvert( - const SizeVector &ip, - const SizeVector &jp, - const FloatVector &LU, - FloatVector &B ) -{ size_t k; // column index in X - size_t p; // index along diagonal in LU - size_t i; // row index in LU and X - - typedef typename FloatVector::value_type Float; - - // check numeric type specifications - CheckNumericType(); - - // check simple vector class specifications - CheckSimpleVector(); - CheckSimpleVector(); - - Float etmp; - - size_t n = ip.size(); - CPPAD_ASSERT_KNOWN( - size_t(jp.size()) == n, - "Error in LuInvert: jp must have size equal to n * n" - ); - CPPAD_ASSERT_KNOWN( - size_t(LU.size()) == n * n, - "Error in LuInvert: Lu must have size equal to n * m" - ); - size_t m = size_t(B.size()) / n; - CPPAD_ASSERT_KNOWN( - size_t(B.size()) == n * m, - "Error in LuSolve: B must have size equal to a multiple of n" - ); - - // temporary storage for reordered solution - FloatVector x(n); - - // loop over equations - for(k = 0; k < m; k++) - { // invert the equation c = L * b - for(p = 0; p < n; p++) - { // solve for c[p] - etmp = B[ ip[p] * m + k ] / LU[ ip[p] * n + jp[p] ]; - B[ ip[p] * m + k ] = etmp; - // subtract off effect on other variables - for(i = p+1; i < n; i++) - B[ ip[i] * m + k ] -= - etmp * LU[ ip[i] * n + jp[p] ]; - } - - // invert the equation x = U * c - p = n; - while( p > 0 ) - { --p; - etmp = B[ ip[p] * m + k ]; - x[ jp[p] ] = etmp; - for(i = 0; i < p; i++ ) - B[ ip[i] * m + k ] -= - etmp * LU[ ip[i] * n + jp[p] ]; - } - - // copy reordered solution into B - for(i = 0; i < n; i++) - B[i * m + k] = x[i]; - } - return; -} -} // END CppAD namespace -// END C++ -# endif diff -Nru cppad-2015.00.00.9/cppad/LuSolve.h cppad-2016.00.00.1/cppad/LuSolve.h --- cppad-2015.00.00.9/cppad/LuSolve.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/LuSolve.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: LuSolve.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/lu_solve.hpp" diff -Nru cppad-2015.00.00.9/cppad/lu_solve.hpp cppad-2016.00.00.1/cppad/lu_solve.hpp --- cppad-2015.00.00.9/cppad/lu_solve.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/lu_solve.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,351 +0,0 @@ -/* $Id: lu_solve.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_LU_SOLVE_INCLUDED -# define CPPAD_LU_SOLVE_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin LuSolve$$ -$escape #$$ -$spell - cppad.hpp - det - exp - Leq - typename - bool - const - namespace - std - Geq - Lu - CppAD - signdet - logdet -$$ - -$index LuSolve$$ -$index linear, equation$$ -$index equation, linear$$ -$index determinant, Lu$$ -$index solve, linear equation$$ - -$section Compute Determinant and Solve Linear Equations$$ - -$pre -$$ - -$head Syntax$$ $code# include $$ -$pre -$$ -$icode%signdet% = LuSolve(%n%, %m%, %A%, %B%, %X%, %logdet%)%$$ - - -$head Description$$ -Use an LU factorization of the matrix $icode A$$ to -compute its determinant -and solve for $icode X$$ in the linear of equation -$latex \[ - A * X = B -\] $$ -where $icode A$$ is an -$icode n$$ by $icode n$$ matrix, -$icode X$$ is an -$icode n$$ by $icode m$$ matrix, and -$icode B$$ is an $latex n x m$$ matrix. - -$head Include$$ -The file $code cppad/lu_solve.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Factor and Invert$$ -This routine is an easy to user interface to -$cref LuFactor$$ and $cref LuInvert$$ for computing determinants and -solutions of linear equations. -These separate routines should be used if -one right hand side $icode B$$ -depends on the solution corresponding to another -right hand side (with the same value of $icode A$$). -In this case only one call to $code LuFactor$$ is required -but there will be multiple calls to $code LuInvert$$. - - -$head Matrix Storage$$ -All matrices are stored in row major order. -To be specific, if $latex Y$$ is a vector -that contains a $latex p$$ by $latex q$$ matrix, -the size of $latex Y$$ must be equal to $latex p * q $$ and for -$latex i = 0 , \ldots , p-1$$, -$latex j = 0 , \ldots , q-1$$, -$latex \[ - Y_{i,j} = Y[ i * q + j ] -\] $$ - -$head signdet$$ -The return value $icode signdet$$ is a $code int$$ value -that specifies the sign factor for the determinant of $icode A$$. -This determinant of $icode A$$ is zero if and only if $icode signdet$$ -is zero. - -$head n$$ -The argument $icode n$$ has type $code size_t$$ -and specifies the number of rows in the matrices -$icode A$$, -$icode X$$, -and $icode B$$. -The number of columns in $icode A$$ is also equal to $icode n$$. - -$head m$$ -The argument $icode m$$ has type $code size_t$$ -and specifies the number of columns in the matrices -$icode X$$ -and $icode B$$. -If $icode m$$ is zero, -only the determinant of $icode A$$ is computed and -the matrices $icode X$$ and $icode B$$ are not used. - -$head A$$ -The argument $icode A$$ has the prototype -$codei% - const %FloatVector% &%A% -%$$ -and the size of $icode A$$ must equal $latex n * n$$ -(see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). -This is the $latex n$$ by $icode n$$ matrix that -we are computing the determinant of -and that defines the linear equation. - -$head B$$ -The argument $icode B$$ has the prototype -$codei% - const %FloatVector% &%B% -%$$ -and the size of $icode B$$ must equal $latex n * m$$ -(see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). -This is the $latex n$$ by $icode m$$ matrix that -defines the right hand side of the linear equations. -If $icode m$$ is zero, $icode B$$ is not used. - -$head X$$ -The argument $icode X$$ has the prototype -$codei% - %FloatVector% &%X% -%$$ -and the size of $icode X$$ must equal $latex n * m$$ -(see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). -The input value of $icode X$$ does not matter. -On output, the elements of $icode X$$ contain the solution -of the equation we wish to solve -(unless $icode signdet$$ is equal to zero). -If $icode m$$ is zero, $icode X$$ is not used. - -$head logdet$$ -The argument $icode logdet$$ has prototype -$codei% - %Float% &%logdet% -%$$ -On input, the value of $icode logdet$$ does not matter. -On output, it has been set to the -log of the determinant of $icode A$$ -(but not quite). -To be more specific, -the determinant of $icode A$$ is given by the formula -$codei% - %det% = %signdet% * exp( %logdet% ) -%$$ -This enables $code LuSolve$$ to use logs of absolute values -in the case where $icode Float$$ corresponds to a real number. - -$head Float$$ -The type $icode Float$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. -In addition, the following operations must be defined for any pair -of $icode Float$$ objects $icode x$$ and $icode y$$: - -$table -$bold Operation$$ $cnext $bold Description$$ $rnext -$codei%log(%x%)%$$ $cnext - returns the logarithm of $icode x$$ as a $icode Float$$ object -$tend - -$head FloatVector$$ -The type $icode FloatVector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type Float/SimpleVector/Elements of Specified Type/$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head LeqZero$$ -Including the file $code lu_solve.hpp$$ defines the template function -$codei% - template - bool LeqZero<%Float%>(const %Float% &%x%) -%$$ -in the $code CppAD$$ namespace. -This function returns true if $icode x$$ is less than or equal to zero -and false otherwise. -It is used by $code LuSolve$$ to avoid taking the log of -zero (or a negative number if $icode Float$$ corresponds to real numbers). -This template function definition assumes that the operator -$code <=$$ is defined for $icode Float$$ objects. -If this operator is not defined for your use of $icode Float$$, -you will need to specialize this template so that it works for your -use of $code LuSolve$$. -$pre - -$$ -Complex numbers do not have the operation or $code <=$$ defined. -In addition, in the complex case, -one can take the log of a negative number. -The specializations -$codei% - bool LeqZero< std::complex > (const std::complex &%x%) - bool LeqZero< std::complex >(const std::complex &%x%) -%$$ -are defined by including $code lu_solve.hpp$$. -These return true if $icode x$$ is zero and false otherwise. - -$head AbsGeq$$ -Including the file $code lu_solve.hpp$$ defines the template function -$codei% - template - bool AbsGeq<%Float%>(const %Float% &%x%, const %Float% &%y%) -%$$ -If the type $icode Float$$ does not support the $code <=$$ operation -and it is not $code std::complex$$ or $code std::complex$$, -see the documentation for $code AbsGeq$$ in $cref/LuFactor/LuFactor/AbsGeq/$$. - -$children% - example/lu_solve.cpp% - omh/lu_solve_hpp.omh -%$$ -$head Example$$ -The file -$cref lu_solve.cpp$$ -contains an example and test of using this routine. -It returns true if it succeeds and false otherwise. - -$head Source$$ -The file $cref lu_solve.hpp$$ contains the -current source code that implements these specifications. - -$end --------------------------------------------------------------------------- -*/ -// BEGIN C++ -# include -# include - -// link exp for float and double cases -# include - -# include -# include -# include -# include -# include - -namespace CppAD { // BEGIN CppAD namespace - -// LeqZero -template -inline bool LeqZero(const Float &x) -{ return x <= Float(0); } -inline bool LeqZero( const std::complex &x ) -{ return x == std::complex(0); } -inline bool LeqZero( const std::complex &x ) -{ return x == std::complex(0); } - -// LuSolve -template -int LuSolve( - size_t n , - size_t m , - const FloatVector &A , - const FloatVector &B , - FloatVector &X , - Float &logdet ) -{ - // check numeric type specifications - CheckNumericType(); - - // check simple vector class specifications - CheckSimpleVector(); - - size_t p; // index of pivot element (diagonal of L) - int signdet; // sign of the determinant - Float pivot; // pivot element - - // the value zero - const Float zero(0); - - // pivot row and column order in the matrix - std::vector ip(n); - std::vector jp(n); - - // ------------------------------------------------------- - CPPAD_ASSERT_KNOWN( - size_t(A.size()) == n * n, - "Error in LuSolve: A must have size equal to n * n" - ); - CPPAD_ASSERT_KNOWN( - size_t(B.size()) == n * m, - "Error in LuSolve: B must have size equal to n * m" - ); - CPPAD_ASSERT_KNOWN( - size_t(X.size()) == n * m, - "Error in LuSolve: X must have size equal to n * m" - ); - // ------------------------------------------------------- - - // copy A so that it does not change - FloatVector Lu(A); - - // copy B so that it does not change - X = B; - - // Lu factor the matrix A - signdet = LuFactor(ip, jp, Lu); - - // compute the log of the determinant - logdet = Float(0); - for(p = 0; p < n; p++) - { // pivot using the max absolute element - pivot = Lu[ ip[p] * n + jp[p] ]; - - // check for determinant equal to zero - if( pivot == zero ) - { // abort the mission - logdet = Float(0); - return 0; - } - - // update the determinant - if( LeqZero ( pivot ) ) - { logdet += log( - pivot ); - signdet = - signdet; - } - else logdet += log( pivot ); - - } - - // solve the linear equations - LuInvert(ip, jp, Lu, X); - - // return the sign factor for the determinant - return signdet; -} -} // END CppAD namespace -// END C++ -# endif diff -Nru cppad-2015.00.00.9/cppad/memory_leak.hpp cppad-2016.00.00.1/cppad/memory_leak.hpp --- cppad-2015.00.00.9/cppad/memory_leak.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/memory_leak.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ -/* $Id: memory_leak.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_MEMORY_LEAK_INCLUDED -# define CPPAD_MEMORY_LEAK_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin memory_leak$$ -$spell - num - alloc - hpp - bool - inuse -$$ - -$section Memory Leak Detection$$ -$index memory_leak$$ -$index leak, memory$$ -$index check, memory leak$$ -$index static, memory leak check$$ - -$head Deprecated$$ -$index deprecated, memory leak$$ -This routine has been deprecated. -You should instead use the routine $cref ta_free_all$$. - -$head Syntax$$ -$icode%flag% = %memory_leak() -%$$ -$icode%flag% = %memory_leak(%add_static%)%$$ - -$head Purpose$$ -This routine checks that the are no memory leaks -caused by improper use of $cref thread_alloc$$ memory allocator. -The deprecated memory allocator $cref TrackNewDel$$ is also checked. -Memory errors in the deprecated $cref omp_alloc$$ allocator are -reported as being in $code thread_alloc$$. - -$head thread$$ -It is assumed that $cref/in_parallel()/ta_in_parallel/$$ is false -and $cref/thread_num/ta_thread_num/$$ is zero when -$code memory_leak$$ is called. - -$head add_static$$ -This argument has prototype -$codei% - size_t %add_static% -%$$ -and its default value is zero. -Static variables hold onto memory forever. -If the argument $icode add_static$$ is present (and non-zero), -$code memory_leak$$ adds this amount of memory to the -$cref/inuse/ta_inuse/$$ sum that corresponds to -static variables in the program. -A call with $icode add_static$$ should be make after -a routine that has static variables which -use $cref/get_memory/ta_get_memory/$$ to allocate memory. -The value of $icode add_static$$ should be the difference of -$codei% - thread_alloc::inuse(0) -%$$ -before and after the call. -Since multiple statics may be allocated in different places in the program, -it is expected that there will be multiple calls -that use this option. - -$head flag$$ -The return value $icode flag$$ has prototype -$codei% - bool %flag% -%$$ -If $icode add_static$$ is non-zero, -the return value for $code memory_leak$$ is false. -Otherwise, the return value for $code memory_leak$$ should be false -(indicating that the only allocated memory corresponds to static variables). - -$head inuse$$ -It is assumed that, when $code memory_leak$$ is called, -there should not be any memory -$cref/inuse/ta_inuse/$$ or $cref omp_inuse$$ for any thread -(except for inuse memory corresponding to static variables). -If there is, a message is printed and $code memory_leak$$ returns false. - -$head available$$ -It is assumed that, when $code memory_leak$$ is called, -there should not be any memory -$cref/available/ta_available/$$ or $cref omp_available$$ for any thread; -i.e., it all has been returned to the system. -If there is memory still available for any thread, -$code memory_leak$$ returns false. - -$head TRACK_COUNT$$ -It is assumed that, when $code memory_leak$$ is called, -$cref/TrackCount/TrackNewDel/TrackCount/$$ will return a zero value. -If it returns a non-zero value, -$code memory_leak$$ returns false. - -$head Error Message$$ -If this is the first call to $code memory_leak$$, no message is printed. -Otherwise, if it returns true, an error message is printed -to standard output describing the memory leak that was detected. - -$end -*/ -# include -# include -# include -# include -# include - -namespace CppAD { // BEGIN_CPPAD_NAMESPACE -/*! -\file memory_leak.hpp -File that implements a memory check at end of a CppAD program -*/ - -/*! -Function that checks -allocator \c thread_alloc for misuse that results in memory leaks. -Deprecated routines in track_new_del.hpp and omp_alloc.hpp are also checked. - -\param add_static [in] -The amount specified by \c add_static is added to the amount -of memory that is expected to be used by thread zero for static variables. - -\return -If \c add_static is non-zero, the return value is \c false. -Otherwise, if one of the following errors is detected, -the return value is \c true: - -\li -Thread zero does not have the expected amount of inuse memory -(for static variables). -\li -A thread, other than thread zero, has any inuse memory. -\li -Any thread has available memory. - -\par -If an error is detected, diagnostic information is printed to standard -output. -*/ -inline bool memory_leak(size_t add_static = 0) -{ // CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL not necessary given asserts below - static size_t thread_zero_static_inuse = 0; - using std::cout; - using std::endl; - using CppAD::thread_alloc; - using CppAD::omp_alloc; - // -------------------------------------------------------------------- - CPPAD_ASSERT_KNOWN( - ! thread_alloc::in_parallel(), - "memory_leak: in_parallel() is true." - ); - CPPAD_ASSERT_KNOWN( - thread_alloc::thread_num() == 0, - "memory_leak: thread_num() is not zero." - ); - if( add_static != 0 ) - { thread_zero_static_inuse += add_static; - return false; - } - bool leak = false; - size_t thread = 0; - - // check that memory in use for thread zero corresponds to statics - size_t num_bytes = thread_alloc::inuse(thread); - if( num_bytes != thread_zero_static_inuse ) - { leak = true; - cout << "thread zero: static inuse = " << thread_zero_static_inuse; - cout << "current inuse(thread) = " << num_bytes << endl; - } - // check that no memory is currently available for this thread - num_bytes = thread_alloc::available(thread); - if( num_bytes != 0 ) - { leak = true; - cout << "thread zero: available = "; - cout << num_bytes << endl; - } - for(thread = 1; thread < CPPAD_MAX_NUM_THREADS; thread++) - { - // check that no memory is currently in use for this thread - num_bytes = thread_alloc::inuse(thread); - if( num_bytes != 0 ) - { leak = true; - cout << "thread " << thread << ": inuse(thread) = "; - cout << num_bytes << endl; - } - // check that no memory is currently available for this thread - num_bytes = thread_alloc::available(thread); - if( num_bytes != 0 ) - { leak = true; - cout << "thread " << thread << ": available(thread) = "; - cout << num_bytes << endl; - } - } - // ---------------------------------------------------------------------- - // check track_new_del - if( CPPAD_TRACK_COUNT() != 0 ) - { leak = true; - CppAD::TrackElement::Print(); - } - return leak; -} - -} // END_CPPAD_NAMESPACE -# endif diff -Nru cppad-2015.00.00.9/cppad/nan.hpp cppad-2016.00.00.1/cppad/nan.hpp --- cppad-2015.00.00.9/cppad/nan.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/nan.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ -/* $Id: nan.hpp 3097 2014-02-18 02:48:28Z bradbell $ */ -# ifndef CPPAD_NAN_INCLUDED -# define CPPAD_NAN_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin nan$$ -$spell - hasnan - cppad - hpp - CppAD - isnan - bool - const -$$ - -$section Obtain Nan or Determine if a Value is Nan$$ - -$index isnan$$ -$index hasnan$$ -$index nan$$ - -$head Syntax$$ -$codei%# include -%$$ -$icode%s% = nan(%z%) -%$$ -$icode%b% = isnan(%s%) -%$$ -$icode%b% = hasnan(%v%)%$$ - -$head Purpose$$ -It obtain and check for the value not a number $code nan$$. -The IEEE standard specifies that a floating point value $icode a$$ -is $code nan$$ if and only if the following returns true -$codei% - %a% != %a% -%$$ - -$head Include$$ -The file $code cppad/nan.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$subhead Macros$$ -$index macro, nan$$ -$index macro, isnan$$ -$index nan, macro$$ -$index isnan, macro$$ -Some C++ compilers use preprocessor symbols called $code nan$$ -and $code isnan$$. -These preprocessor symbols will no longer be defined after -this file is included. - -$head nan$$ -This routine returns a $code nan$$ with the same type as $icode z$$. - -$subhead z$$ -The argument $icode z$$ has prototype -$codei% - const %Scalar% &%z% -%$$ -and its value is zero -(see $cref/Scalar/nan/Scalar/$$ for the definition of $icode Scalar$$). - -$subhead s$$ -The return value $icode s$$ has prototype -$codei% - %Scalar% %s% -%$$ -It is the value $code nan$$ for this floating point type. - -$head isnan$$ -This routine determines if a scalar value is $code nan$$. - -$subhead s$$ -The argument $icode s$$ has prototype -$codei% - const %Scalar% %s% -%$$ - -$subhead b$$ -The return value $icode b$$ has prototype -$codei% - bool %b% -%$$ -It is true if the value $icode s$$ is $code nan$$. - -$head hasnan$$ -This routine determines if a -$cref SimpleVector$$ has an element that is $code nan$$. - -$subhead v$$ -The argument $icode v$$ has prototype -$codei% - const %Vector% &%v% -%$$ -(see $cref/Vector/nan/Vector/$$ for the definition of $icode Vector$$). - -$subhead b$$ -The return value $icode b$$ has prototype -$codei% - bool %b% -%$$ -It is true if the vector $icode v$$ has a $code nan$$. - -$head Scalar$$ -The type $icode Scalar$$ must support the following operations; -$table -$bold Operation$$ $cnext $bold Description$$ $rnext -$icode%a% / %b%$$ $cnext - division operator (returns a $icode Scalar$$ object) -$rnext -$icode%a% == %b%$$ $cnext - equality operator (returns a $code bool$$ object) -$rnext -$icode%a% != %b%$$ $cnext - not equality operator (returns a $code bool$$ object) -$tend -Note that the division operator will be used with $icode a$$ and $icode b$$ -equal to zero. For some types (e.g. $code int$$) this may generate -an exception. No attempt is made to catch any such exception. - -$head Vector$$ -The type $icode Vector$$ must be a $cref SimpleVector$$ class with -elements of type $icode Scalar$$. - -$children% - example/nan.cpp -%$$ -$head Example$$ -The file $cref nan.cpp$$ -contains an example and test of this routine. -It returns true if it succeeds and false otherwise. - -$end -*/ - -# include -# include - -// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include - -/* -# define nan There must be a define for every CppAD undef -*/ -# ifdef nan -# undef nan -# endif - -/* -# define isnan There must be a define for every CppAD undef -*/ -# ifdef isnan -# undef isnan -# endif - -namespace CppAD { // BEGIN CppAD namespace - -template -inline Scalar nan(const Scalar &zero) -{ return zero / zero; -} - -template -inline bool isnan(const Scalar &s) -{ return (s != s); -} - -template -bool hasnan(const Vector &v) -{ - bool found_nan; - size_t i; - i = v.size(); - found_nan = false; - // on MS Visual Studio 2012, CppAD required in front of isnan ? - while(i--) - found_nan |= CppAD::isnan(v[i]); - return found_nan; -} - -} // End CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/NearEqual.h cppad-2016.00.00.1/cppad/NearEqual.h --- cppad-2015.00.00.9/cppad/NearEqual.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/NearEqual.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: NearEqual.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/near_equal.hpp" diff -Nru cppad-2015.00.00.9/cppad/near_equal.hpp cppad-2016.00.00.1/cppad/near_equal.hpp --- cppad-2015.00.00.9/cppad/near_equal.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/near_equal.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,277 +0,0 @@ -/* $Id: near_equal.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_NEAR_EQUAL_INCLUDED -# define CPPAD_NEAR_EQUAL_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin NearEqual$$ -$spell - cppad.hpp - sqrt - cout - endl - Microsoft - std - Cpp - namespace - const - bool -$$ - -$section Determine if Two Values Are Nearly Equal$$ - -$index NearEqual$$ -$index equal, near$$ -$index absolute, difference$$ -$index relative, difference$$ -$index difference, absolute$$ -$index difference, relative$$ - -$head Syntax$$ - -$code # include $$ -$pre -$$ -$icode%b% = NearEqual(%x%, %y%, %r%, %a%)%$$ - - -$head Purpose$$ -Returns true, -if $icode x$$ and $icode y$$ are nearly equal, -and false otherwise. - -$head x$$ -The argument $icode x$$ -has one of the following possible prototypes -$codei% - const %Type% &%x%, - const std::complex<%Type%> &%x%, -%$$ - -$head y$$ -The argument $icode y$$ -has one of the following possible prototypes -$codei% - const %Type% &%y%, - const std::complex<%Type%> &%y%, -%$$ - -$head r$$ -The relative error criteria $icode r$$ has prototype -$codei% - const %Type% &%r% -%$$ -It must be greater than or equal to zero. -The relative error condition is defined as: -$latex \[ - | x - y | \leq r ( |x| + |y| ) -\] $$ - -$head a$$ -The absolute error criteria $icode a$$ has prototype -$codei% - const %Type% &%a% -%$$ -It must be greater than or equal to zero. -The absolute error condition is defined as: -$latex \[ - | x - y | \leq a -\] $$ - -$head b$$ -The return value $icode b$$ has prototype -$codei% - bool %b% -%$$ -If either $icode x$$ or $icode y$$ is infinite or not a number, -the return value is false. -Otherwise, if either the relative or absolute error -condition (defined above) is satisfied, the return value is true. -Otherwise, the return value is false. - -$head Type$$ -The type $icode Type$$ must be a -$cref NumericType$$. -The routine $cref CheckNumericType$$ will generate -an error message if this is not the case. -In addition, the following operations must be defined objects -$icode a$$ and $icode b$$ of type $icode Type$$: -$table -$bold Operation$$ $cnext - $bold Description$$ $rnext -$icode%a% <= %b%$$ $cnext - less that or equal operator (returns a $code bool$$ object) -$tend - -$head Include Files$$ -The file $code cppad/near_equal.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Example$$ -$children% - example/near_equal.cpp -%$$ -The file $cref near_equal.cpp$$ contains an example -and test of $code NearEqual$$. -It return true if it succeeds and false otherwise. - -$head Exercise$$ -$index exercise, NearEqual$$ -Create and run a program that contains the following code: -$codep - using std::complex; - using std::cout; - using std::endl; - - complex one(1., 0), i(0., 1); - complex x = one / i; - complex y = - i; - double r = 1e-12; - double a = 0; - bool ok = CppAD::NearEqual(x, y, r, a); - if( ok ) - cout << "Ok" << endl; - else cout << "Error" << endl; -$$ - -$end - -*/ - -# include -# include -# include - -namespace CppAD { // Begin CppAD namespace - -// determine if both x and y are finite values (z1 and z2 are zero). -template -bool near_equal_isfinite( - const Type &z1, const Type &z2, const Type &x , const Type &y) -{ Type infinity = Type(1) / z1; - Type nan = z1 / z2; - - // handle bug where some compilers return true for nan == nan - bool xNan = ( x != x || x == nan ); - bool yNan = ( y != y || y == nan ); - - // infinite cases - bool xInf = (x == infinity || x == - infinity); - bool yInf = (x == infinity || x == - infinity); - - return ! (xNan | yNan | xInf | yInf); -} - -template -bool NearEqual(const Type &x, const Type &y, const Type &r, const Type &a) -{ - CheckNumericType(); - Type zero(0); - - CPPAD_ASSERT_KNOWN( - zero <= r, - "Error in NearEqual: relative error is less than zero" - ); - CPPAD_ASSERT_KNOWN( - zero <= a, - "Error in NearEqual: absolute error is less than zero" - ); - - // check for special cases - if( ! CppAD::near_equal_isfinite(zero, zero, x, y) ) - return false; - - Type ax = x; - if( ax <= zero ) - ax = - ax; - - Type ay = y; - if( ay <= zero ) - ay = - ay; - - Type ad = x - y; - if( ad <= zero ) - ad = - ad; - - if( ad <= a ) - return true; - - if( ad <= r * (ax + ay) ) - return true; - - return false; -} - -template -bool NearEqual( - const std::complex &x , - const std::complex &y , - const Type &r , - const Type & a ) -{ - CheckNumericType(); - Type zero(0); - - CPPAD_ASSERT_KNOWN( - zero <= r, - "Error in NearEqual: relative error is less than zero" - ); - CPPAD_ASSERT_KNOWN( - zero <= a, - "Error in NearEqual: absolute error is less than zero" - ); - - // check for special cases - if( ! CppAD::near_equal_isfinite(zero, zero, x.real(), x.imag()) ) - return false; - if( ! CppAD::near_equal_isfinite(zero, zero, y.real(), y.imag()) ) - return false; - - std::complex d = x - y; - - Type ad = std::abs(d); - if( ad <= a ) - return true; - - Type ax = std::abs(x); - Type ay = std::abs(y); - if( ad <= r * (ax + ay) ) - return true; - - return false; -} - -template -bool NearEqual( - const std::complex &x , - const Type &y , - const Type &r , - const Type & a ) -{ - return NearEqual(x, std::complex(y, Type(0)), r, a); -} - -template -bool NearEqual( - const Type &x , - const std::complex &y , - const Type &r , - const Type & a ) -{ - return NearEqual(std::complex(x, Type(0)), y, r, a); -} - -} // END CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/OdeErrControl.h cppad-2016.00.00.1/cppad/OdeErrControl.h --- cppad-2015.00.00.9/cppad/OdeErrControl.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/OdeErrControl.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: OdeErrControl.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/ode_err_control.hpp" diff -Nru cppad-2015.00.00.9/cppad/ode_err_control.hpp cppad-2016.00.00.1/cppad/ode_err_control.hpp --- cppad-2015.00.00.9/cppad/ode_err_control.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/ode_err_control.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,602 +0,0 @@ -/* $Id: ode_err_control.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ODE_ERR_CONTROL_INCLUDED -# define CPPAD_ODE_ERR_CONTROL_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin OdeErrControl$$ -$spell - cppad.hpp - nstep - maxabs - exp - scur - CppAD - xf - tf - xi - smin - smax - eabs - erel - ef - ta - tb - xa - xb - const - eb -$$ - -$index OdeErrControl$$ -$index ODE, control error$$ -$index control, ODE error$$ -$index error, control ODE$$ -$index differential, ODE error control$$ -$index equation, ODE error control$$ - - -$section An Error Controller for ODE Solvers$$ - -$head Syntax$$ -$code # include $$ -$pre -$$ -$icode%xf% = OdeErrControl(%method%, %ti%, %tf%, %xi%, - %smin%, %smax%, %scur%, %eabs%, %erel%, %ef% , %maxabs%, %nstep% )%$$ - - -$head Description$$ -Let $latex \B{R}$$ denote the real numbers -and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. -We define $latex X : [ti , tf] \rightarrow \B{R}^n$$ by -the following initial value problem: -$latex \[ -\begin{array}{rcl} - X(ti) & = & xi \\ - X'(t) & = & F[t , X(t)] -\end{array} -\] $$ -The routine $code OdeErrControl$$ can be used to adjust the step size -used an arbitrary integration methods in order to be as fast as possible -and still with in a requested error bound. - -$head Include$$ -The file $code cppad/ode_err_control.hpp$$ is included by -$code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Notation$$ -The template parameter types $cref/Scalar/OdeErrControl/Scalar/$$ and -$cref/Vector/OdeErrControl/Vector/$$ are documented below. - -$head xf$$ -The return value $icode xf$$ has the prototype -$codei% - %Vector% %xf% -%$$ -(see description of $cref/Vector/OdeErrControl/Vector/$$ below). -and the size of $icode xf$$ is equal to $icode n$$. -If $icode xf$$ contains not a number $cref nan$$, -see the discussion of $cref/step/OdeErrControl/Method/Nan/$$. - -$head Method$$ -The class $icode Method$$ -and the object $icode method$$ satisfy the following syntax -$codei% - %Method% &%method% -%$$ -The object $icode method$$ must support $code step$$ and -$code order$$ member functions defined below: - -$subhead step$$ -The syntax -$codei% - %method%.step(%ta%, %tb%, %xa%, %xb%, %eb%) -%$$ -executes one step of the integration method. -$codei% - -%ta% -%$$ -The argument $icode ta$$ has prototype -$codei% - const %Scalar% &%ta% -%$$ -It specifies the initial time for this step in the -ODE integration. -(see description of $cref/Scalar/OdeErrControl/Scalar/$$ below). -$codei% - -%tb% -%$$ -The argument $icode tb$$ has prototype -$codei% - const %Scalar% &%tb% -%$$ -It specifies the final time for this step in the -ODE integration. -$codei% - -%xa% -%$$ -The argument $icode xa$$ has prototype -$codei% - const %Vector% &%xa% -%$$ -and size $icode n$$. -It specifies the value of $latex X(ta)$$. -(see description of $cref/Vector/OdeErrControl/Vector/$$ below). -$codei% - -%xb% -%$$ -The argument value $icode xb$$ has prototype -$codei% - %Vector% &%xb% -%$$ -and size $icode n$$. -The input value of its elements does not matter. -On output, -it contains the approximation for $latex X(tb)$$ that the method obtains. -$codei% - -%eb% -%$$ -The argument value $icode eb$$ has prototype -$codei% - %Vector% &%eb% -%$$ -and size $icode n$$. -The input value of its elements does not matter. -On output, -it contains an estimate for the error in the approximation $icode xb$$. -It is assumed (locally) that the error bound in this approximation -nearly equal to $latex K (tb - ta)^m$$ -where $icode K$$ is a fixed constant and $icode m$$ -is the corresponding argument to $code CodeControl$$. - -$subhead Nan$$ -If any element of the vector $icode eb$$ or $icode xb$$ are -not a number $code nan$$, -the current step is considered to large. -If this happens with the current step size equal to $icode smin$$, -$code OdeErrControl$$ returns with $icode xf$$ and $icode ef$$ as vectors -of $code nan$$. - -$subhead order$$ -If $icode m$$ is $code size_t$$, -the object $icode method$$ must also support the following syntax -$codei% - %m% = %method%.order() -%$$ -The return value $icode m$$ is the order of the error estimate; -i.e., there is a constant K such that if $latex ti \leq ta \leq tb \leq tf$$, -$latex \[ - | eb(tb) | \leq K | tb - ta |^m -\] $$ -where $icode ta$$, $icode tb$$, and $icode eb$$ are as in -$icode%method%.step(%ta%, %tb%, %xa%, %xb%, %eb%)%$$ - - -$head ti$$ -The argument $icode ti$$ has prototype -$codei% - const %Scalar% &%ti% -%$$ -It specifies the initial time for the integration of -the differential equation. - - -$head tf$$ -The argument $icode tf$$ has prototype -$codei% - const %Scalar% &%tf% -%$$ -It specifies the final time for the integration of -the differential equation. - -$head xi$$ -The argument $icode xi$$ has prototype -$codei% - const %Vector% &%xi% -%$$ -and size $icode n$$. -It specifies value of $latex X(ti)$$. - -$head smin$$ -The argument $icode smin$$ has prototype -$codei% - const %Scalar% &%smin% -%$$ -The step size during a call to $icode method$$ is defined as -the corresponding value of $latex tb - ta$$. -If $latex tf - ti \leq smin$$, -the integration will be done in one step of size $icode tf - ti$$. -Otherwise, -the minimum value of $icode tb - ta$$ will be $latex smin$$ -except for the last two calls to $icode method$$ where it may be -as small as $latex smin / 2$$. - -$head smax$$ -The argument $icode smax$$ has prototype -$codei% - const %Scalar% &%smax% -%$$ -It specifies the maximum step size to use during the integration; -i.e., the maximum value for $latex tb - ta$$ in a call to $icode method$$. -The value of $icode smax$$ must be greater than or equal $icode smin$$. - -$head scur$$ -The argument $icode scur$$ has prototype -$codei% - %Scalar% &%scur% -%$$ -The value of $icode scur$$ is the suggested next step size, -based on error criteria, to try in the next call to $icode method$$. -On input it corresponds to the first call to $icode method$$, -in this call to $code OdeErrControl$$ (where $latex ta = ti$$). -On output it corresponds to the next call to $icode method$$, -in a subsequent call to $code OdeErrControl$$ (where $icode ta = tf$$). - -$head eabs$$ -The argument $icode eabs$$ has prototype -$codei% - const %Vector% &%eabs% -%$$ -and size $icode n$$. -Each of the elements of $icode eabs$$ must be -greater than or equal zero. -It specifies a bound for the absolute -error in the return value $icode xf$$ as an approximation for $latex X(tf)$$. -(see the -$cref/error criteria discussion/OdeErrControl/Error Criteria Discussion/$$ -below). - -$head erel$$ -The argument $icode erel$$ has prototype -$codei% - const %Scalar% &%erel% -%$$ -and is greater than or equal zero. -It specifies a bound for the relative -error in the return value $icode xf$$ as an approximation for $latex X(tf)$$ -(see the -$cref/error criteria discussion/OdeErrControl/Error Criteria Discussion/$$ -below). - -$head ef$$ -The argument value $icode ef$$ has prototype -$codei% - %Vector% &%ef% -%$$ -and size $icode n$$. -The input value of its elements does not matter. -On output, -it contains an estimated bound for the -absolute error in the approximation $icode xf$$; i.e., -$latex \[ - ef_i > | X( tf )_i - xf_i | -\] $$ -If on output $icode ef$$ contains not a number $code nan$$, -see the discussion of $cref/step/OdeErrControl/Method/Nan/$$. - -$head maxabs$$ -The argument $icode maxabs$$ is optional in the call to $code OdeErrControl$$. -If it is present, it has the prototype -$codei% - %Vector% &%maxabs% -%$$ -and size $icode n$$. -The input value of its elements does not matter. -On output, -it contains an estimate for the -maximum absolute value of $latex X(t)$$; i.e., -$latex \[ - maxabs[i] \approx \max \left\{ - | X( t )_i | \; : \; t \in [ti, tf] - \right\} -\] $$ - -$head nstep$$ -The argument $icode nstep$$ is optional in the call to $code OdeErrControl$$. -If it is present, it has the prototype -$codei% - %size_t% &%nstep% -%$$ -Its input value does not matter and its output value -is the number of calls to $icode%method%.step%$$ -used by $code OdeErrControl$$. - -$head Error Criteria Discussion$$ -The relative error criteria $icode erel$$ and -absolute error criteria $icode eabs$$ are enforced during each step of the -integration of the ordinary differential equations. -In addition, they are inversely scaled by the step size so that -the total error bound is less than the sum of the error bounds. -To be specific, if $latex \tilde{X} (t)$$ is the approximate solution -at time $latex t$$, -$icode ta$$ is the initial step time, -and $icode tb$$ is the final step time, -$latex \[ -\left| \tilde{X} (tb)_j - X (tb)_j \right| -\leq -\frac{tf - ti}{tb - ta} -\left[ eabs[j] + erel \; | \tilde{X} (tb)_j | \right] -\] $$ -If $latex X(tb)_j$$ is near zero for some $latex tb \in [ti , tf]$$, -and one uses an absolute error criteria $latex eabs[j]$$ of zero, -the error criteria above will force $code OdeErrControl$$ -to use step sizes equal to -$cref/smin/OdeErrControl/smin/$$ -for steps ending near $latex tb$$. -In this case, the error relative to $icode maxabs$$ can be judged after -$code OdeErrControl$$ returns. -If $icode ef$$ is to large relative to $icode maxabs$$, -$code OdeErrControl$$ can be called again -with a smaller value of $icode smin$$. - -$head Scalar$$ -The type $icode Scalar$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. -In addition, the following operations must be defined for -$icode Scalar$$ objects $icode a$$ and $icode b$$: - -$table -$bold Operation$$ $cnext $bold Description$$ $rnext -$icode%a% <= %b%$$ $cnext - returns true (false) if $icode a$$ is less than or equal - (greater than) $icode b$$. -$rnext -$icode%a% == %b%$$ $cnext - returns true (false) if $icode a$$ is equal to $icode b$$. -$rnext -$codei%log(%a%)%$$ $cnext - returns a $icode Scalar$$ equal to the logarithm of $icode a$$ -$rnext -$codei%exp(%a%)%$$ $cnext - returns a $icode Scalar$$ equal to the exponential of $icode a$$ -$tend - - -$head Vector$$ -The type $icode Vector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head Example$$ -$children% - example/ode_err_control.cpp% - example/ode_err_maxabs.cpp -%$$ -The files -$cref ode_err_control.cpp$$ -and -$cref ode_err_maxabs.cpp$$ -contain examples and tests of using this routine. -They return true if they succeed and false otherwise. - -$head Theory$$ -Let $latex e(s)$$ be the error as a function of the -step size $latex s$$ and suppose that there is a constant -$latex K$$ such that $latex e(s) = K s^m$$. -Let $latex a$$ be our error bound. -Given the value of $latex e(s)$$, a step of size $latex \lambda s$$ -would be ok provided that -$latex \[ -\begin{array}{rcl} - a & \geq & e( \lambda s ) (tf - ti) / ( \lambda s ) \\ - a & \geq & K \lambda^m s^m (tf - ti) / ( \lambda s ) \\ - a & \geq & \lambda^{m-1} s^{m-1} (tf - ti) e(s) / s^m \\ - a & \geq & \lambda^{m-1} (tf - ti) e(s) / s \\ - \lambda^{m-1} & \leq & \frac{a}{e(s)} \frac{s}{tf - ti} -\end{array} -\] $$ -Thus if the right hand side of the last inequality is greater -than or equal to one, the step of size $latex s$$ is ok. - -$head Source Code$$ -The source code for this routine is in the file -$code cppad/ode_err_control.hpp$$. - -$end --------------------------------------------------------------------------- -*/ - -// link exp and log for float and double -# include - -# include -# include -# include - -namespace CppAD { // Begin CppAD namespace - -template -Vector OdeErrControl( - Method &method, - const Scalar &ti , - const Scalar &tf , - const Vector &xi , - const Scalar &smin , - const Scalar &smax , - Scalar &scur , - const Vector &eabs , - const Scalar &erel , - Vector &ef , - Vector &maxabs, - size_t &nstep ) -{ - // check simple vector class specifications - CheckSimpleVector(); - - size_t n = size_t(xi.size()); - - CPPAD_ASSERT_KNOWN( - smin <= smax, - "Error in OdeErrControl: smin > smax" - ); - CPPAD_ASSERT_KNOWN( - size_t(eabs.size()) == n, - "Error in OdeErrControl: size of eabs is not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(maxabs.size()) == n, - "Error in OdeErrControl: size of maxabs is not equal to n" - ); - size_t m = method.order(); - CPPAD_ASSERT_KNOWN( - m > 1, - "Error in OdeErrControl: m is less than or equal one" - ); - - bool ok; - bool minimum_step; - size_t i; - Vector xa(n), xb(n), eb(n), nan_vec(n); - - // initialization - Scalar zero(0); - Scalar one(1); - Scalar two(2); - Scalar three(3); - Scalar m1(m-1); - Scalar ta = ti; - for(i = 0; i < n; i++) - { nan_vec[i] = nan(zero); - ef[i] = zero; - xa[i] = xi[i]; - if( zero <= xi[i] ) - maxabs[i] = xi[i]; - else maxabs[i] = - xi[i]; - - } - nstep = 0; - - Scalar tb, step, lambda, axbi, a, r, root; - while( ! (ta == tf) ) - { // start with value suggested by error criteria - step = scur; - - // check maximum - if( smax <= step ) - step = smax; - - // check minimum - minimum_step = step <= smin; - if( minimum_step ) - step = smin; - - // check if near the end - if( tf <= ta + step * three / two ) - tb = tf; - else tb = ta + step; - - // try using this step size - nstep++; - method.step(ta, tb, xa, xb, eb); - step = tb - ta; - - // check if this steps error estimate is ok - ok = ! (hasnan(xb) || hasnan(eb)); - if( (! ok) && minimum_step ) - { ef = nan_vec; - return nan_vec; - } - - // compute value of lambda for this step - lambda = Scalar(10) * scur / step; - for(i = 0; i < n; i++) - { if( zero <= xb[i] ) - axbi = xb[i]; - else axbi = - xb[i]; - a = eabs[i] + erel * axbi; - if( ! (eb[i] == zero) ) - { r = ( a / eb[i] ) * step / (tf - ti); - root = exp( log(r) / m1 ); - if( root <= lambda ) - lambda = root; - } - } - if( ok && ( one <= lambda || step <= smin * three / two) ) - { // this step is within error limits or - // close to the minimum size - ta = tb; - for(i = 0; i < n; i++) - { xa[i] = xb[i]; - ef[i] = ef[i] + eb[i]; - if( zero <= xb[i] ) - axbi = xb[i]; - else axbi = - xb[i]; - if( axbi > maxabs[i] ) - maxabs[i] = axbi; - } - } - if( ! ok ) - { // decrease step an see if method will work this time - scur = step / two; - } - else if( ! (ta == tf) ) - { // step suggested by the error criteria is not used - // on the last step because it may be very small. - scur = lambda * step / two; - } - } - return xa; -} - -template -Vector OdeErrControl( - Method &method, - const Scalar &ti , - const Scalar &tf , - const Vector &xi , - const Scalar &smin , - const Scalar &smax , - Scalar &scur , - const Vector &eabs , - const Scalar &erel , - Vector &ef ) -{ Vector maxabs(xi.size()); - size_t nstep; - return OdeErrControl( - method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep - ); -} - -template -Vector OdeErrControl( - Method &method, - const Scalar &ti , - const Scalar &tf , - const Vector &xi , - const Scalar &smin , - const Scalar &smax , - Scalar &scur , - const Vector &eabs , - const Scalar &erel , - Vector &ef , - Vector &maxabs) -{ size_t nstep; - return OdeErrControl( - method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep - ); -} - -} // End CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/OdeGearControl.h cppad-2016.00.00.1/cppad/OdeGearControl.h --- cppad-2015.00.00.9/cppad/OdeGearControl.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/OdeGearControl.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: OdeGearControl.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/ode_gear_control.hpp" diff -Nru cppad-2015.00.00.9/cppad/ode_gear_control.hpp cppad-2016.00.00.1/cppad/ode_gear_control.hpp --- cppad-2015.00.00.9/cppad/ode_gear_control.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/ode_gear_control.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,547 +0,0 @@ -/* $Id: ode_gear_control.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ODE_GEAR_CONTROL_INCLUDED -# define CPPAD_ODE_GEAR_CONTROL_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin OdeGearControl$$ -$spell - cppad.hpp - CppAD - xf - xi - smin - smax - eabs - ef - maxabs - nstep - tf - sini - erel - dep - const - tb - ta - exp -$$ - -$index OdeGearControl$$ -$index control, Ode Gear$$ -$index error, Gear Ode$$ -$index differential, Ode Gear control$$ -$index equation, Ode Gear control$$ - - -$section An Error Controller for Gear's Ode Solvers$$ - -$head Syntax$$ -$codei%# include -%$$ -$icode%xf% = OdeGearControl(%F%, %M%, %ti%, %tf%, %xi%, - %smin%, %smax%, %sini%, %eabs%, %erel%, %ef% , %maxabs%, %nstep% )%$$ - - -$head Purpose$$ -Let $latex \B{R}$$ denote the real numbers -and let $latex f : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. -We define $latex X : [ti , tf] \rightarrow \B{R}^n$$ by -the following initial value problem: -$latex \[ -\begin{array}{rcl} - X(ti) & = & xi \\ - X'(t) & = & f[t , X(t)] -\end{array} -\] $$ -The routine $cref OdeGear$$ is a stiff multi-step method that -can be used to approximate the solution to this equation. -The routine $code OdeGearControl$$ sets up this multi-step method -and controls the error during such an approximation. - -$head Include$$ -The file $code cppad/ode_gear_control.hpp$$ -is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Notation$$ -The template parameter types $cref/Scalar/OdeGearControl/Scalar/$$ and -$cref/Vector/OdeGearControl/Vector/$$ are documented below. - -$head xf$$ -The return value $icode xf$$ has the prototype -$codei% - %Vector% %xf% -%$$ -and the size of $icode xf$$ is equal to $icode n$$ -(see description of $cref/Vector/OdeGear/Vector/$$ below). -It is the approximation for $latex X(tf)$$. - -$head Fun$$ -The class $icode Fun$$ -and the object $icode F$$ satisfy the prototype -$codei% - %Fun% &%F% -%$$ -This must support the following set of calls -$codei% - %F%.Ode(%t%, %x%, %f%) - %F%.Ode_dep(%t%, %x%, %f_x%) -%$$ - -$subhead t$$ -The argument $icode t$$ has prototype -$codei% - const %Scalar% &%t% -%$$ -(see description of $cref/Scalar/OdeGear/Scalar/$$ below). - -$subhead x$$ -The argument $icode x$$ has prototype -$codei% - const %Vector% &%x% -%$$ -and has size $icode N$$ -(see description of $cref/Vector/OdeGear/Vector/$$ below). - -$subhead f$$ -The argument $icode f$$ to $icode%F%.Ode%$$ has prototype -$codei% - %Vector% &%f% -%$$ -On input and output, $icode f$$ is a vector of size $icode N$$ -and the input values of the elements of $icode f$$ do not matter. -On output, -$icode f$$ is set equal to $latex f(t, x)$$ -(see $icode f(t, x)$$ in $cref/Purpose/OdeGear/Purpose/$$). - -$subhead f_x$$ -The argument $icode f_x$$ has prototype -$codei% - %Vector% &%f_x% -%$$ -On input and output, $icode f_x$$ is a vector of size $latex N * N$$ -and the input values of the elements of $icode f_x$$ do not matter. -On output, -$latex \[ - f\_x [i * n + j] = \partial_{x(j)} f_i ( t , x ) -\] $$ - -$subhead Warning$$ -The arguments $icode f$$, and $icode f_x$$ -must have a call by reference in their prototypes; i.e., -do not forget the $code &$$ in the prototype for -$icode f$$ and $icode f_x$$. - -$head M$$ -The argument $icode M$$ has prototype -$codei% - size_t %M% -%$$ -It specifies the order of the multi-step method; i.e., -the order of the approximating polynomial -(after the initialization process). -The argument $icode M$$ must greater than or equal one. - -$head ti$$ -The argument $icode ti$$ has prototype -$codei% - const %Scalar% &%ti% -%$$ -It specifies the initial time for the integration of -the differential equation. - -$head tf$$ -The argument $icode tf$$ has prototype -$codei% - const %Scalar% &%tf% -%$$ -It specifies the final time for the integration of -the differential equation. - -$head xi$$ -The argument $icode xi$$ has prototype -$codei% - const %Vector% &%xi% -%$$ -and size $icode n$$. -It specifies value of $latex X(ti)$$. - -$head smin$$ -The argument $icode smin$$ has prototype -$codei% - const %Scalar% &%smin% -%$$ -The minimum value of $latex T[M] - T[M-1]$$ in a call to $code OdeGear$$ -will be $latex smin$$ except for the last two calls where it may be -as small as $latex smin / 2$$. -The value of $icode smin$$ must be less than or equal $icode smax$$. - -$head smax$$ -The argument $icode smax$$ has prototype -$codei% - const %Scalar% &%smax% -%$$ -It specifies the maximum step size to use during the integration; -i.e., the maximum value for $latex T[M] - T[M-1]$$ -in a call to $code OdeGear$$. - -$head sini$$ -The argument $icode sini$$ has prototype -$codei% - %Scalar% &%sini% -%$$ -The value of $icode sini$$ is the minimum -step size to use during initialization of the multi-step method; i.e., -for calls to $code OdeGear$$ where $latex m < M$$. -The value of $icode sini$$ must be less than or equal $icode smax$$ -(and can also be less than $icode smin$$). - -$head eabs$$ -The argument $icode eabs$$ has prototype -$codei% - const %Vector% &%eabs% -%$$ -and size $icode n$$. -Each of the elements of $icode eabs$$ must be -greater than or equal zero. -It specifies a bound for the absolute -error in the return value $icode xf$$ as an approximation for $latex X(tf)$$. -(see the -$cref/error criteria discussion/OdeGearControl/Error Criteria Discussion/$$ -below). - -$head erel$$ -The argument $icode erel$$ has prototype -$codei% - const %Scalar% &%erel% -%$$ -and is greater than or equal zero. -It specifies a bound for the relative -error in the return value $icode xf$$ as an approximation for $latex X(tf)$$ -(see the -$cref/error criteria discussion/OdeGearControl/Error Criteria Discussion/$$ -below). - -$head ef$$ -The argument value $icode ef$$ has prototype -$codei% - %Vector% &%ef% -%$$ -and size $icode n$$. -The input value of its elements does not matter. -On output, -it contains an estimated bound for the -absolute error in the approximation $icode xf$$; i.e., -$latex \[ - ef_i > | X( tf )_i - xf_i | -\] $$ - -$head maxabs$$ -The argument $icode maxabs$$ is optional in the call to $code OdeGearControl$$. -If it is present, it has the prototype -$codei% - %Vector% &%maxabs% -%$$ -and size $icode n$$. -The input value of its elements does not matter. -On output, -it contains an estimate for the -maximum absolute value of $latex X(t)$$; i.e., -$latex \[ - maxabs[i] \approx \max \left\{ - | X( t )_i | \; : \; t \in [ti, tf] - \right\} -\] $$ - -$head nstep$$ -The argument $icode nstep$$ has the prototype -$codei% - %size_t% &%nstep% -%$$ -Its input value does not matter and its output value -is the number of calls to $cref OdeGear$$ -used by $code OdeGearControl$$. - -$head Error Criteria Discussion$$ -The relative error criteria $icode erel$$ and -absolute error criteria $icode eabs$$ are enforced during each step of the -integration of the ordinary differential equations. -In addition, they are inversely scaled by the step size so that -the total error bound is less than the sum of the error bounds. -To be specific, if $latex \tilde{X} (t)$$ is the approximate solution -at time $latex t$$, -$icode ta$$ is the initial step time, -and $icode tb$$ is the final step time, -$latex \[ -\left| \tilde{X} (tb)_j - X (tb)_j \right| -\leq -\frac{tf - ti}{tb - ta} -\left[ eabs[j] + erel \; | \tilde{X} (tb)_j | \right] -\] $$ -If $latex X(tb)_j$$ is near zero for some $latex tb \in [ti , tf]$$, -and one uses an absolute error criteria $latex eabs[j]$$ of zero, -the error criteria above will force $code OdeGearControl$$ -to use step sizes equal to -$cref/smin/OdeGearControl/smin/$$ -for steps ending near $latex tb$$. -In this case, the error relative to $icode maxabs$$ can be judged after -$code OdeGearControl$$ returns. -If $icode ef$$ is to large relative to $icode maxabs$$, -$code OdeGearControl$$ can be called again -with a smaller value of $icode smin$$. - -$head Scalar$$ -The type $icode Scalar$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. -In addition, the following operations must be defined for -$icode Scalar$$ objects $icode a$$ and $icode b$$: - -$table -$bold Operation$$ $cnext $bold Description$$ $rnext -$icode%a% <= %b%$$ $cnext - returns true (false) if $icode a$$ is less than or equal - (greater than) $icode b$$. -$rnext -$icode%a% == %b%$$ $cnext - returns true (false) if $icode a$$ is equal to $icode b$$. -$rnext -$codei%log(%a%)%$$ $cnext - returns a $icode Scalar$$ equal to the logarithm of $icode a$$ -$rnext -$codei%exp(%a%)%$$ $cnext - returns a $icode Scalar$$ equal to the exponential of $icode a$$ -$tend - - -$head Vector$$ -The type $icode Vector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head Example$$ -$children% - example/ode_gear_control.cpp -%$$ -The file -$cref ode_gear_control.cpp$$ -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -$head Theory$$ -Let $latex e(s)$$ be the error as a function of the -step size $latex s$$ and suppose that there is a constant -$latex K$$ such that $latex e(s) = K s^m$$. -Let $latex a$$ be our error bound. -Given the value of $latex e(s)$$, a step of size $latex \lambda s$$ -would be ok provided that -$latex \[ -\begin{array}{rcl} - a & \geq & e( \lambda s ) (tf - ti) / ( \lambda s ) \\ - a & \geq & K \lambda^m s^m (tf - ti) / ( \lambda s ) \\ - a & \geq & \lambda^{m-1} s^{m-1} (tf - ti) e(s) / s^m \\ - a & \geq & \lambda^{m-1} (tf - ti) e(s) / s \\ - \lambda^{m-1} & \leq & \frac{a}{e(s)} \frac{s}{tf - ti} -\end{array} -\] $$ -Thus if the right hand side of the last inequality is greater -than or equal to one, the step of size $latex s$$ is ok. - -$head Source Code$$ -The source code for this routine is in the file -$code cppad/ode_gear_control.hpp$$. - -$end --------------------------------------------------------------------------- -*/ - -// link exp and log for float and double -# include - -# include - -namespace CppAD { // Begin CppAD namespace - -template -Vector OdeGearControl( - Fun &F , - size_t M , - const Scalar &ti , - const Scalar &tf , - const Vector &xi , - const Scalar &smin , - const Scalar &smax , - Scalar &sini , - const Vector &eabs , - const Scalar &erel , - Vector &ef , - Vector &maxabs, - size_t &nstep ) -{ - // check simple vector class specifications - CheckSimpleVector(); - - // dimension of the state space - size_t n = size_t(xi.size()); - - CPPAD_ASSERT_KNOWN( - M >= 1, - "Error in OdeGearControl: M is less than one" - ); - CPPAD_ASSERT_KNOWN( - smin <= smax, - "Error in OdeGearControl: smin is greater than smax" - ); - CPPAD_ASSERT_KNOWN( - sini <= smax, - "Error in OdeGearControl: sini is greater than smax" - ); - CPPAD_ASSERT_KNOWN( - size_t(eabs.size()) == n, - "Error in OdeGearControl: size of eabs is not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(maxabs.size()) == n, - "Error in OdeGearControl: size of maxabs is not equal to n" - ); - - // some constants - const Scalar zero(0); - const Scalar one(1); - const Scalar one_plus( Scalar(3) / Scalar(2) ); - const Scalar two(2); - const Scalar ten(10); - - // temporary indices - size_t i, k; - - // temporary Scalars - Scalar step, sprevious, lambda, axi, a, root, r; - - // vectors of Scalars - Vector T (M + 1); - Vector X( (M + 1) * n ); - Vector e(n); - Vector xf(n); - - // initial integer values - size_t m = 1; - nstep = 0; - - // initialize T - T[0] = ti; - - // initialize X, ef, maxabs - for(i = 0; i < n; i++) - for(i = 0; i < n; i++) - { X[i] = xi[i]; - ef[i] = zero; - X[i] = xi[i]; - if( zero <= xi[i] ) - maxabs[i] = xi[i]; - else maxabs[i] = - xi[i]; - - } - - // initial step size - step = smin; - - while( T[m-1] < tf ) - { sprevious = step; - - // check maximum - if( smax <= step ) - step = smax; - - // check minimum - if( m < M ) - { if( step <= sini ) - step = sini; - } - else if( step <= smin ) - step = smin; - - // check if near the end - if( tf <= T[m-1] + one_plus * step ) - T[m] = tf; - else T[m] = T[m-1] + step; - - // try using this step size - nstep++; - OdeGear(F, m, n, T, X, e); - step = T[m] - T[m-1]; - - // compute value of lambda for this step - lambda = Scalar(10) * sprevious / step; - for(i = 0; i < n; i++) - { axi = X[m * n + i]; - if( axi <= zero ) - axi = - axi; - a = eabs[i] + erel * axi; - if( e[i] > zero ) - { if( m == 1 ) - root = (a / e[i]) / ten; - else - { r = ( a / e[i] ) * step / (tf - ti); - root = exp( log(r) / Scalar(m-1) ); - } - if( root <= lambda ) - lambda = root; - } - } - - bool advance; - if( m == M ) - advance = one <= lambda || step <= one_plus * smin; - else advance = one <= lambda || step <= one_plus * sini; - - - if( advance ) - { // accept the results of this time step - CPPAD_ASSERT_UNKNOWN( m <= M ); - if( m == M ) - { // shift for next step - for(k = 0; k < m; k++) - { T[k] = T[k+1]; - for(i = 0; i < n; i++) - X[k*n + i] = X[(k+1)*n + i]; - } - } - // update ef and maxabs - for(i = 0; i < n; i++) - { ef[i] = ef[i] + e[i]; - axi = X[m * n + i]; - if( axi <= zero ) - axi = - axi; - if( axi > maxabs[i] ) - maxabs[i] = axi; - } - if( m != M ) - m++; // all we need do in this case - } - - // new step suggested by error criteria - step = std::min(lambda , ten) * step / two; - } - for(i = 0; i < n; i++) - xf[i] = X[(m-1) * n + i]; - - return xf; -} - -} // End CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/OdeGear.h cppad-2016.00.00.1/cppad/OdeGear.h --- cppad-2015.00.00.9/cppad/OdeGear.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/OdeGear.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: OdeGear.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/ode_gear.hpp" diff -Nru cppad-2015.00.00.9/cppad/ode_gear.hpp cppad-2016.00.00.1/cppad/ode_gear.hpp --- cppad-2015.00.00.9/cppad/ode_gear.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/ode_gear.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,526 +0,0 @@ -/* $Id: ode_gear.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ODE_GEAR_INCLUDED -# define CPPAD_ODE_GEAR_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin OdeGear$$ -$spell - cppad.hpp - Jan - bool - const - CppAD - dep -$$ - -$index OdeGear$$ -$index Ode, Gear$$ -$index Gear, Ode$$ -$index stiff, Ode$$ -$index differential, equation$$ -$index equation, differential$$ - -$section An Arbitrary Order Gear Method$$ - -$head Syntax$$ -$codei%# include -%$$ -$codei%OdeGear(%F%, %m%, %n%, %T%, %X%, %e%)%$$ - - -$head Purpose$$ -This routine applies -$cref/Gear's Method/OdeGear/Gear's Method/$$ -to solve an explicit set of ordinary differential equations. -We are given -$latex f : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. -This routine solves the following initial value problem -$latex \[ -\begin{array}{rcl} - x( t_{m-1} ) & = & x^0 \\ - x^\prime (t) & = & f[t , x(t)] -\end{array} -\] $$ -for the value of $latex x( t_m )$$. -If your set of ordinary differential equations are not stiff -an explicit method may be better (perhaps $cref Runge45$$.) - -$head Include$$ -The file $code cppad/ode_gear.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Fun$$ -The class $icode Fun$$ -and the object $icode F$$ satisfy the prototype -$codei% - %Fun% &%F% -%$$ -This must support the following set of calls -$codei% - %F%.Ode(%t%, %x%, %f%) - %F%.Ode_dep(%t%, %x%, %f_x%) -%$$ - -$subhead t$$ -The argument $icode t$$ has prototype -$codei% - const %Scalar% &%t% -%$$ -(see description of $cref/Scalar/OdeGear/Scalar/$$ below). - -$subhead x$$ -The argument $icode x$$ has prototype -$codei% - const %Vector% &%x% -%$$ -and has size $icode n$$ -(see description of $cref/Vector/OdeGear/Vector/$$ below). - -$subhead f$$ -The argument $icode f$$ to $icode%F%.Ode%$$ has prototype -$codei% - %Vector% &%f% -%$$ -On input and output, $icode f$$ is a vector of size $icode n$$ -and the input values of the elements of $icode f$$ do not matter. -On output, -$icode f$$ is set equal to $latex f(t, x)$$ -(see $icode f(t, x)$$ in $cref/Purpose/OdeGear/Purpose/$$). - -$subhead f_x$$ -The argument $icode f_x$$ has prototype -$codei% - %Vector% &%f_x% -%$$ -On input and output, $icode f_x$$ is a vector of size $latex n * n$$ -and the input values of the elements of $icode f_x$$ do not matter. -On output, -$latex \[ - f\_x [i * n + j] = \partial_{x(j)} f_i ( t , x ) -\] $$ - -$subhead Warning$$ -The arguments $icode f$$, and $icode f_x$$ -must have a call by reference in their prototypes; i.e., -do not forget the $code &$$ in the prototype for -$icode f$$ and $icode f_x$$. - -$head m$$ -The argument $icode m$$ has prototype -$codei% - size_t %m% -%$$ -It specifies the order (highest power of $latex t$$) -used to represent the function $latex x(t)$$ in the multi-step method. -Upon return from $code OdeGear$$, -the $th i$$ component of the polynomial is defined by -$latex \[ - p_i ( t_j ) = X[ j * n + i ] -\] $$ -for $latex j = 0 , \ldots , m$$ (where $latex 0 \leq i < n$$). -The value of $latex m$$ must be greater than or equal one. - -$head n$$ -The argument $icode n$$ has prototype -$codei% - size_t %n% -%$$ -It specifies the range space dimension of the -vector valued function $latex x(t)$$. - -$head T$$ -The argument $icode T$$ has prototype -$codei% - const %Vector% &%T% -%$$ -and size greater than or equal to $latex m+1$$. -For $latex j = 0 , \ldots m$$, $latex T[j]$$ is the time -corresponding to time corresponding -to a previous point in the multi-step method. -The value $latex T[m]$$ is the time -of the next point in the multi-step method. -The array $latex T$$ must be monotone increasing; i.e., -$latex T[j] < T[j+1]$$. -Above and below we often use the shorthand $latex t_j$$ for $latex T[j]$$. - - -$head X$$ -The argument $icode X$$ has the prototype -$codei% - %Vector% &%X% -%$$ -and size greater than or equal to $latex (m+1) * n$$. -On input to $code OdeGear$$, -for $latex j = 0 , \ldots , m-1$$, and -$latex i = 0 , \ldots , n-1$$ -$latex \[ - X[ j * n + i ] = x_i ( t_j ) -\] $$ -Upon return from $code OdeGear$$, -for $latex i = 0 , \ldots , n-1$$ -$latex \[ - X[ m * n + i ] \approx x_i ( t_m ) -\] $$ - -$head e$$ -The vector $icode e$$ is an approximate error bound for the result; i.e., -$latex \[ - e[i] \geq | X[ m * n + i ] - x_i ( t_m ) | -\] $$ -The order of this approximation is one less than the order of -the solution; i.e., -$latex \[ - e = O ( h^m ) -\] $$ -where $latex h$$ is the maximum of $latex t_{j+1} - t_j$$. - -$head Scalar$$ -The type $icode Scalar$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. -In addition, the following operations must be defined for -$icode Scalar$$ objects $icode a$$ and $icode b$$: - -$table -$bold Operation$$ $cnext $bold Description$$ $rnext -$icode%a% < %b%$$ $cnext - less than operator (returns a $code bool$$ object) -$tend - -$head Vector$$ -The type $icode Vector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head Example$$ -$children% - example/ode_gear.cpp -%$$ -The file -$cref ode_gear.cpp$$ -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -$head Source Code$$ -The source code for this routine is in the file -$code cppad/ode_gear.hpp$$. - -$head Theory$$ -For this discussion we use the shorthand $latex x_j$$ -for the value $latex x ( t_j ) \in \B{R}^n$$ which is not to be confused -with $latex x_i (t) \in \B{R}$$ in the notation above. -The interpolating polynomial $latex p(t)$$ is given by -$latex \[ -p(t) = -\sum_{j=0}^m -x_j -\frac{ - \prod_{i \neq j} ( t - t_i ) -}{ - \prod_{i \neq j} ( t_j - t_i ) -} -\] $$ -The derivative $latex p^\prime (t)$$ is given by -$latex \[ -p^\prime (t) = -\sum_{j=0}^m -x_j -\frac{ - \sum_{i \neq j} \prod_{k \neq i,j} ( t - t_k ) -}{ - \prod_{k \neq j} ( t_j - t_k ) -} -\] $$ -Evaluating the derivative at the point $latex t_\ell$$ we have -$latex \[ -\begin{array}{rcl} -p^\prime ( t_\ell ) & = & -x_\ell -\frac{ - \sum_{i \neq \ell} \prod_{k \neq i,\ell} ( t_\ell - t_k ) -}{ - \prod_{k \neq \ell} ( t_\ell - t_k ) -} -+ -\sum_{j \neq \ell} -x_j -\frac{ - \sum_{i \neq j} \prod_{k \neq i,j} ( t_\ell - t_k ) -}{ - \prod_{k \neq j} ( t_j - t_k ) -} -\\ -& = & -x_\ell -\sum_{i \neq \ell} -\frac{ 1 }{ t_\ell - t_i } -+ -\sum_{j \neq \ell} -x_j -\frac{ - \prod_{k \neq \ell,j} ( t_\ell - t_k ) -}{ - \prod_{k \neq j} ( t_j - t_k ) -} -\\ -& = & -x_\ell -\sum_{k \neq \ell} ( t_\ell - t_k )^{-1} -+ -\sum_{j \neq \ell} -x_j -( t_j - t_\ell )^{-1} -\prod_{k \neq \ell ,j} ( t_\ell - t_k ) / ( t_j - t_k ) -\end{array} -\] $$ -We define the vector $latex \alpha \in \B{R}^{m+1}$$ by -$latex \[ -\alpha_j = \left\{ \begin{array}{ll} -\sum_{k \neq m} ( t_m - t_k )^{-1} - & {\rm if} \; j = m -\\ -( t_j - t_m )^{-1} -\prod_{k \neq m,j} ( t_m - t_k ) / ( t_j - t_k ) - & {\rm otherwise} -\end{array} \right. -\] $$ -It follows that -$latex \[ - p^\prime ( t_m ) = \alpha_0 x_0 + \cdots + \alpha_m x_m -\] $$ -Gear's method determines $latex x_m$$ by solving the following -nonlinear equation -$latex \[ - f( t_m , x_m ) = \alpha_0 x_0 + \cdots + \alpha_m x_m -\] $$ -Newton's method for solving this equation determines iterates, -which we denote by $latex x_m^k$$, by solving the following affine -approximation of the equation above -$latex \[ -\begin{array}{rcl} -f( t_m , x_m^{k-1} ) + \partial_x f( t_m , x_m^{k-1} ) ( x_m^k - x_m^{k-1} ) -& = & -\alpha_0 x_0^k + \alpha_1 x_1 + \cdots + \alpha_m x_m -\\ -\left[ \alpha_m I - \partial_x f( t_m , x_m^{k-1} ) \right] x_m -& = & -\left[ -f( t_m , x_m^{k-1} ) - \partial_x f( t_m , x_m^{k-1} ) x_m^{k-1} -- \alpha_0 x_0 - \cdots - \alpha_{m-1} x_{m-1} -\right] -\end{array} -\] $$ -In order to initialize Newton's method; i.e. choose $latex x_m^0$$ -we define the vector $latex \beta \in \B{R}^{m+1}$$ by -$latex \[ -\beta_j = \left\{ \begin{array}{ll} -\sum_{k \neq m-1} ( t_{m-1} - t_k )^{-1} - & {\rm if} \; j = m-1 -\\ -( t_j - t_{m-1} )^{-1} -\prod_{k \neq m-1,j} ( t_{m-1} - t_k ) / ( t_j - t_k ) - & {\rm otherwise} -\end{array} \right. -\] $$ -It follows that -$latex \[ - p^\prime ( t_{m-1} ) = \beta_0 x_0 + \cdots + \beta_m x_m -\] $$ -We solve the following approximation of the equation above to determine -$latex x_m^0$$: -$latex \[ - f( t_{m-1} , x_{m-1} ) = - \beta_0 x_0 + \cdots + \beta_{m-1} x_{m-1} + \beta_m x_m^0 -\] $$ - - -$head Gear's Method$$ -C. W. Gear, -``Simultaneous Numerical Solution of Differential-Algebraic Equations,'' -IEEE Transactions on Circuit Theory, -vol. 18, no. 1, pp. 89-95, Jan. 1971. - - -$end --------------------------------------------------------------------------- -*/ - -# include -# include -# include -# include -# include -# include -# include - -namespace CppAD { // BEGIN CppAD namespace - -template -void OdeGear( - Fun &F , - size_t m , - size_t n , - const Vector &T , - Vector &X , - Vector &e ) -{ - // temporary indices - size_t i, j, k; - - typedef typename Vector::value_type Scalar; - - // check numeric type specifications - CheckNumericType(); - - // check simple vector class specifications - CheckSimpleVector(); - - CPPAD_ASSERT_KNOWN( - m >= 1, - "OdeGear: m is less than one" - ); - CPPAD_ASSERT_KNOWN( - n > 0, - "OdeGear: n is equal to zero" - ); - CPPAD_ASSERT_KNOWN( - size_t(T.size()) >= (m+1), - "OdeGear: size of T is not greater than or equal (m+1)" - ); - CPPAD_ASSERT_KNOWN( - size_t(X.size()) >= (m+1) * n, - "OdeGear: size of X is not greater than or equal (m+1) * n" - ); - for(j = 0; j < m; j++) CPPAD_ASSERT_KNOWN( - T[j] < T[j+1], - "OdeGear: the array T is not monotone increasing" - ); - - // some constants - Scalar zero(0); - Scalar one(1); - - // vectors required by method - Vector alpha(m + 1); - Vector beta(m + 1); - Vector f(n); - Vector f_x(n * n); - Vector x_m0(n); - Vector x_m(n); - Vector b(n); - Vector A(n * n); - - // compute alpha[m] - alpha[m] = zero; - for(k = 0; k < m; k++) - alpha[m] += one / (T[m] - T[k]); - - // compute beta[m-1] - beta[m-1] = one / (T[m-1] - T[m]); - for(k = 0; k < m-1; k++) - beta[m-1] += one / (T[m-1] - T[k]); - - - // compute other components of alpha - for(j = 0; j < m; j++) - { // compute alpha[j] - alpha[j] = one / (T[j] - T[m]); - for(k = 0; k < m; k++) - { if( k != j ) - { alpha[j] *= (T[m] - T[k]); - alpha[j] /= (T[j] - T[k]); - } - } - } - - // compute other components of beta - for(j = 0; j <= m; j++) - { if( j != m-1 ) - { // compute beta[j] - beta[j] = one / (T[j] - T[m-1]); - for(k = 0; k <= m; k++) - { if( k != j && k != m-1 ) - { beta[j] *= (T[m-1] - T[k]); - beta[j] /= (T[j] - T[k]); - } - } - } - } - - // evaluate f(T[m-1], x_{m-1} ) - for(i = 0; i < n; i++) - x_m[i] = X[(m-1) * n + i]; - F.Ode(T[m-1], x_m, f); - - // solve for x_m^0 - for(i = 0; i < n; i++) - { x_m[i] = f[i]; - for(j = 0; j < m; j++) - x_m[i] -= beta[j] * X[j * n + i]; - x_m[i] /= beta[m]; - } - x_m0 = x_m; - - // evaluate partial w.r.t x of f(T[m], x_m^0) - F.Ode_dep(T[m], x_m, f_x); - - // compute the matrix A = ( alpha[m] * I - f_x ) - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - A[i * n + j] = - f_x[i * n + j]; - A[i * n + i] += alpha[m]; - } - - // LU factor (and overwrite) the matrix A - int sign; - CppAD::vector ip(n) , jp(n); - sign = LuFactor(ip, jp, A); - CPPAD_ASSERT_KNOWN( - sign != 0, - "OdeGear: step size is to large" - ); - - // Iterations of Newton's method - for(k = 0; k < 3; k++) - { - // only evaluate f( T[m] , x_m ) keep f_x during iteration - F.Ode(T[m], x_m, f); - - // b = f + f_x x_m - alpha[0] x_0 - ... - alpha[m-1] x_{m-1} - for(i = 0; i < n; i++) - { b[i] = f[i]; - for(j = 0; j < n; j++) - b[i] -= f_x[i * n + j] * x_m[j]; - for(j = 0; j < m; j++) - b[i] -= alpha[j] * X[ j * n + i ]; - } - LuInvert(ip, jp, A, b); - x_m = b; - } - - // return estimate for x( t[k] ) and the estimated error bound - for(i = 0; i < n; i++) - { X[m * n + i] = x_m[i]; - e[i] = x_m[i] - x_m0[i]; - if( e[i] < zero ) - e[i] = - e[i]; - } -} - -} // End CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/omp_alloc.hpp cppad-2016.00.00.1/cppad/omp_alloc.hpp --- cppad-2015.00.00.9/cppad/omp_alloc.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/omp_alloc.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,763 +0,0 @@ -/* $Id: omp_alloc.hpp 2910 2013-10-07 13:27:58Z bradbell $ */ -# ifndef CPPAD_OMP_ALLOC_INCLUDED -# define CPPAD_OMP_ALLOC_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -# include -# ifdef _OPENMP -# include -# endif - -namespace CppAD { // BEGIN_CPPAD_NAMESPACE -class omp_alloc{ -// ============================================================================ -public: -/* -$begin omp_max_num_threads$$ -$spell - inv - CppAD - num - omp_alloc -$$ -$section Set and Get Maximum Number of Threads for omp_alloc Allocator$$ - -$head Deprecated$$ -$index set_max_num_threads, omp_alloc$$ -$index get_max_num_threads, omp_alloc$$ -Use the functions $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ -and $cref/thread_alloc:num_threads/ta_num_threads/$$ instead. - -$head Syntax$$ -$codei%omp_alloc::set_max_num_threads(%number%) -%$$ -$icode%number% = omp_alloc::get_max_num_threads() -%$$ - -$head Purpose$$ -By default there is only one thread and all execution is in sequential mode -(not $cref/parallel/omp_in_parallel/$$). - -$head number$$ -The argument and return value $icode number$$ has prototype -$codei% - size_t %number% -%$$ -and must be greater than zero. - -$head set_max_num_threads$$ -Informs $cref omp_alloc$$ of the maximum number of OpenMP threads. - -$head get_max_num_threads$$ -Returns the valued used in the previous call to $code set_max_num_threads$$. -If there was no such previous call, the value one is returned -(and only thread number zero can use $cref omp_alloc$$). - -$head Restrictions$$ -The function $code set_max_num_threads$$ must be called before -the program enters $cref/parallel/omp_in_parallel/$$ execution mode. -In addition, this function cannot be called while in parallel mode. - -$end -*/ - /*! - Inform omp_alloc of the maximum number of OpenMP threads and enable - parallel execution mode by initializing all statics in this file. - - \param number [in] - maximum number of OpenMP threads. - */ - static void set_max_num_threads(size_t number) - { thread_alloc::parallel_setup( - number, omp_alloc::in_parallel, omp_alloc::get_thread_num - ); - thread_alloc::hold_memory(number > 1); - } - /*! - Get the current maximum number of OpenMP threads that omp_alloc can use. - - \return - maximum number of OpenMP threads. - */ - static size_t get_max_num_threads(void) - { return thread_alloc::num_threads(); } - -/* ----------------------------------------------------------------------- -$begin omp_in_parallel$$ - -$section Is The Current Execution in OpenMP Parallel Mode$$ -$spell - omp_alloc - bool -$$ - -$head Deprecated$$ -$index in_parallel, omp_alloc$$ -$index omp_alloc, in_parallel$$ -Use the function $cref/thread_alloc::in_parallel/ta_in_parallel/$$ instead. - -$head Syntax$$ -$icode%flag% = omp_alloc::in_parallel()%$$ - -$head Purpose$$ -Some of the $cref omp_alloc$$ allocation routines have different -specifications for parallel (not sequential) execution mode. -This routine enables you to determine if the current execution mode -is sequential or parallel. - -$head flag$$ -The return value has prototype -$codei% - bool %flag% -%$$ -It is true if the current execution is in parallel mode -(possibly multi-threaded) and false otherwise (sequential mode). - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /// Are we in a parallel execution state; i.e., is it possible that - /// other threads are currently executing. - static bool in_parallel(void) - { -# ifdef _OPENMP - return static_cast( omp_in_parallel() ); -# else - return false; -# endif - } - -/* ----------------------------------------------------------------------- -$begin omp_get_thread_num$$ -$spell - CppAD - num - omp_alloc - cppad.hpp -$$ - -$section Get the Current OpenMP Thread Number$$ - -$head Deprecated$$ -$index get_thread_num, omp_alloc$$ -$index omp_alloc, get_thread_num$$ -Use the function $cref/thread_alloc::thread_num/ta_thread_num/$$ instead. - -$head Syntax$$ -$icode%thread% = omp_alloc::get_thread_num()%$$ - -$head Purpose$$ -Some of the $cref omp_alloc$$ allocation routines have a thread number. -This routine enables you to determine the current thread. - -$head thread$$ -The return value $icode thread$$ has prototype -$codei% - size_t %thread% -%$$ -and is the currently executing thread number. -If $code _OPENMP$$ is not defined, $icode thread$$ is zero. - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /// Get current OpenMP thread number (zero if _OpenMP not defined). - static size_t get_thread_num(void) - { -# ifdef _OPENMP - size_t thread = static_cast( omp_get_thread_num() ); - return thread; -# else - return 0; -# endif - } -/* ----------------------------------------------------------------------- -$begin omp_get_memory$$ -$spell - num - ptr - omp_alloc -$$ - -$section Get At Least A Specified Amount of Memory$$ - -$head Deprecated$$ -$index get_thread_num, omp_alloc$$ -$index omp_alloc, get_thread_num$$ -Use the function $cref/thread_alloc::get_memory/ta_get_memory/$$ instead. - -$head Syntax$$ -$icode%v_ptr% = omp_alloc::get_memory(%min_bytes%, %cap_bytes%)%$$ - -$head Purpose$$ -Use $cref omp_alloc$$ to obtain a minimum number of bytes of memory -(for use by the $cref/current thread/omp_get_thread_num/$$). - -$head min_bytes$$ -This argument has prototype -$codei% - size_t %min_bytes% -%$$ -It specifies the minimum number of bytes to allocate. - -$head cap_bytes$$ -This argument has prototype -$codei% - size_t& %cap_bytes% -%$$ -It's input value does not matter. -Upon return, it is the actual number of bytes (capacity) -that have been allocated for use, -$codei% - %min_bytes% <= %cap_bytes% -%$$ - -$head v_ptr$$ -The return value $icode v_ptr$$ has prototype -$codei% - void* %v_ptr% -%$$ -It is the location where the $icode cap_bytes$$ of memory -that have been allocated for use begins. - -$head Allocation Speed$$ -This allocation should be faster if the following conditions hold: -$list number$$ -The memory allocated by a previous call to $code get_memory$$ -is currently available for use. -$lnext -The current $icode min_bytes$$ is between -the previous $icode min_bytes$$ and previous $icode cap_bytes$$. -$lend - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /*! - Use omp_alloc to get a specified amount of memory. - - If the memory allocated by a previous call to \c get_memory is now - avaialable, and \c min_bytes is between its previous value - and the previous \c cap_bytes, this memory allocation will have - optimal speed. Otherwise, the memory allocation is more complicated and - may have to wait for other threads to complete an allocation. - - \param min_bytes [in] - The minimum number of bytes of memory to be obtained for use. - - \param cap_bytes [out] - The actual number of bytes of memory obtained for use. - - \return - pointer to the beginning of the memory allocted for use. - */ - static void* get_memory(size_t min_bytes, size_t& cap_bytes) - { return thread_alloc::get_memory(min_bytes, cap_bytes); } - -/* ----------------------------------------------------------------------- -$begin omp_return_memory$$ -$spell - ptr - omp_alloc -$$ - -$section Return Memory to omp_alloc$$ - -$head Deprecated$$ -$index return_memory, omp_alloc$$ -$index omp_alloc, return_memory$$ -Use the function $cref/thread_alloc::return_memory/ta_return_memory/$$ instead. - -$head Syntax$$ -$codei%omp_alloc::return_memory(%v_ptr%)%$$ - -$head Purpose$$ -If $cref omp_max_num_threads$$ is one, -the memory is returned to the system. -Otherwise, the memory is retained by $cref omp_alloc$$ for quick future use -by the thread that allocated to memory. - -$head v_ptr$$ -This argument has prototype -$codei% - void* %v_ptr% -%$$. -It must be a pointer to memory that is currently in use; i.e. -obtained by a previous call to $cref omp_get_memory$$ and not yet returned. - -$head Thread$$ -Either the $cref/current thread/omp_get_thread_num/$$ must be the same as during -the corresponding call to $cref omp_get_memory$$, -or the current execution mode must be sequential -(not $cref/parallel/omp_in_parallel/$$). - -$head NDEBUG$$ -If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). -Otherwise, a list of in use pointers is searched to make sure -that $icode v_ptr$$ is in the list. - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /*! - Return memory that was obtained by \c get_memory. - If max_num_threads(0) == 1, - the memory is returned to the system. - Otherwise, it is retained by \c omp_alloc and available for use by - \c get_memory for this thread. - - \param v_ptr [in] - Value of the pointer returned by \c get_memory and still in use. - After this call, this pointer will available (and not in use). - - \par - We must either be in sequential (not parallel) execution mode, - or the current thread must be the same as for the corresponding call - to \c get_memory. - */ - static void return_memory(void* v_ptr) - { thread_alloc::return_memory(v_ptr); } -/* ----------------------------------------------------------------------- -$begin omp_free_available$$ -$spell - omp_alloc -$$ - -$section Free Memory Currently Available for Quick Use by a Thread$$ - -$head Deprecated$$ -$index free_available, omp_alloc$$ -$index omp_alloc, free_available$$ -Use the function $cref/thread_alloc::free_available/ta_free_available/$$ -instead. - -$head Syntax$$ -$codei%omp_alloc::free_available(%thread%)%$$ - -$head Purpose$$ -Free memory, currently available for quick use by a specific thread, -for general future use. - -$head thread$$ -This argument has prototype -$codei% - size_t %thread% -%$$ -Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, -or the current execution mode must be sequential -(not $cref/parallel/omp_in_parallel/$$). - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /*! - Return all the memory being held as available for a thread to the system. - - \param thread [in] - this thread that will no longer have any available memory after this call. - This must either be the thread currently executing, or we must be - in sequential (not parallel) execution mode. - */ - static void free_available(size_t thread) - { thread_alloc::free_available(thread); } -/* ----------------------------------------------------------------------- -$begin omp_inuse$$ -$spell - num - inuse - omp_alloc -$$ - -$section Amount of Memory a Thread is Currently Using$$ - -$head Deprecated$$ -$index inuse, omp_alloc$$ -$index omp_alloc, inuse$$ - -$head Syntax$$ -$icode%num_bytes% = omp_alloc::inuse(%thread%)%$$ -Use the function $cref/thread_alloc::inuse/ta_inuse/$$ instead. - -$head Purpose$$ -Memory being managed by $cref omp_alloc$$ has two states, -currently in use by the specified thread, -and quickly available for future use by the specified thread. -This function informs the program how much memory is in use. - -$head thread$$ -This argument has prototype -$codei% - size_t %thread% -%$$ -Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, -or the current execution mode must be sequential -(not $cref/parallel/omp_in_parallel/$$). - -$head num_bytes$$ -The return value has prototype -$codei% - size_t %num_bytes% -%$$ -It is the number of bytes currently in use by the specified thread. - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /*! - Determine the amount of memory that is currently inuse. - - \param thread [in] - Thread for which we are determining the amount of memory - (must be < CPPAD_MAX_NUM_THREADS). - Durring parallel execution, this must be the thread - that is currently executing. - - \return - The amount of memory in bytes. - */ - static size_t inuse(size_t thread) - { return thread_alloc::inuse(thread); } -/* ----------------------------------------------------------------------- -$begin omp_available$$ -$spell - num - omp_alloc -$$ - -$section Amount of Memory Available for Quick Use by a Thread$$ - -$head Deprecated$$ -$index available, omp_alloc$$ -$index omp_alloc, available$$ -Use the function $cref/thread_alloc::available/ta_available/$$ instead. - -$head Syntax$$ -$icode%num_bytes% = omp_alloc::available(%thread%)%$$ - -$head Purpose$$ -Memory being managed by $cref omp_alloc$$ has two states, -currently in use by the specified thread, -and quickly available for future use by the specified thread. -This function informs the program how much memory is available. - -$head thread$$ -This argument has prototype -$codei% - size_t %thread% -%$$ -Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, -or the current execution mode must be sequential -(not $cref/parallel/omp_in_parallel/$$). - -$head num_bytes$$ -The return value has prototype -$codei% - size_t %num_bytes% -%$$ -It is the number of bytes currently available for use by the specified thread. - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /*! - Determine the amount of memory that is currently available for use. - - \copydetails inuse - */ - static size_t available(size_t thread) - { return thread_alloc::available(thread); } -/* ----------------------------------------------------------------------- -$begin omp_create_array$$ -$spell - omp_alloc - sizeof -$$ - -$section Allocate Memory and Create A Raw Array$$ - -$head Deprecated$$ -$index create_array, omp_alloc$$ -$index omp_alloc, create_array$$ -Use the function $cref/thread_alloc::create_array/ta_create_array/$$ instead. - -$head Syntax$$ -$icode%array% = omp_alloc::create_array<%Type%>(%size_min%, %size_out%)%$$. - -$head Purpose$$ -Create a new raw array using $cref omp_alloc$$ a fast memory allocator -that works well in a multi-threading OpenMP environment. - -$head Type$$ -The type of the elements of the array. - -$head size_min$$ -This argument has prototype -$codei% - size_t %size_min% -%$$ -This is the minimum number of elements that there can be -in the resulting $icode array$$. - -$head size_out$$ -This argument has prototype -$codei% - size_t& %size_out% -%$$ -The input value of this argument does not matter. -Upon return, it is the actual number of elements -in $icode array$$ -($icode% size_min %<=% size_out%$$). - -$head array$$ -The return value $icode array$$ has prototype -$codei% - %Type%* %array% -%$$ -It is array with $icode size_out$$ elements. -The default constructor for $icode Type$$ is used to initialize the -elements of $icode array$$. -Note that $cref omp_delete_array$$ -should be used to destroy the array when it is no longer needed. - -$head Delta$$ -The amount of memory $cref omp_inuse$$ by the current thread, -will increase $icode delta$$ where -$codei% - sizeof(%Type%) * (%size_out% + 1) > %delta% >= sizeof(%Type%) * %size_out% -%$$ -The $cref omp_available$$ memory will decrease by $icode delta$$, -(and the allocation will be faster) -if a previous allocation with $icode size_min$$ between its current value -and $icode size_out$$ is available. - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /*! - Use omp_alloc to Create a Raw Array. - - \tparam Type - The type of the elements of the array. - - \param size_min [in] - The minimum number of elements in the array. - - \param size_out [out] - The actual number of elements in the array. - - \return - pointer to the first element of the array. - The default constructor is used to initialize - all the elements of the array. - - \par - The \c extra_ field, in the \c omp_alloc node before the return value, - is set to size_out. - */ - template - static Type* create_array(size_t size_min, size_t& size_out) - { return thread_alloc::create_array(size_min, size_out); } -/* ----------------------------------------------------------------------- -$begin omp_delete_array$$ -$spell - omp_alloc - sizeof -$$ - -$section Return A Raw Array to The Available Memory for a Thread$$ - -$head Deprecated$$ -$index delete_array, omp_alloc$$ -$index omp_alloc, delete_array$$ -Use the function $cref/thread_alloc::delete_array/ta_delete_array/$$ instead. - -$head Syntax$$ -$codei%omp_alloc::delete_array(%array%)%$$. - -$head Purpose$$ -Returns memory corresponding to a raw array -(create by $cref omp_create_array$$) to the -$cref omp_available$$ memory pool for the current thread. - -$head Type$$ -The type of the elements of the array. - -$head array$$ -The argument $icode array$$ has prototype -$codei% - %Type%* %array% -%$$ -It is a value returned by $cref omp_create_array$$ and not yet deleted. -The $icode Type$$ destructor is called for each element in the array. - -$head Thread$$ -The $cref/current thread/omp_get_thread_num/$$ must be the -same as when $cref omp_create_array$$ returned the value $icode array$$. -There is an exception to this rule: -when the current execution mode is sequential -(not $cref/parallel/omp_in_parallel/$$) the current thread number does not matter. - -$head Delta$$ -The amount of memory $cref omp_inuse$$ will decrease by $icode delta$$, -and the $cref omp_available$$ memory will increase by $icode delta$$, -where $cref/delta/omp_create_array/Delta/$$ -is the same as for the corresponding call to $code create_array$$. - -$head Example$$ -$cref omp_alloc.cpp$$ - -$end -*/ - /*! - Return Memory Used for a Raw Array to the Available Pool. - - \tparam Type - The type of the elements of the array. - - \param array [in] - A value returned by \c create_array that has not yet been deleted. - The \c Type destructor is used to destroy each of the elements - of the array. - - \par - Durring parallel execution, the current thread must be the same - as during the corresponding call to \c create_array. - */ - template - static void delete_array(Type* array) - { thread_alloc::delete_array(array); } -}; -/* -------------------------------------------------------------------------- -$begin omp_efficient$$ -$spell - omp_alloc - ptr - num - bool - const -$$ - -$section Check If A Memory Allocation is Efficient for Another Use$$ - -$head Removed$$ -$index efficient, omp_alloc$$ -$index omp_alloc, efficient$$ -This function has been removed because speed tests seem to indicate -it is just as fast, or faster, to free and then reallocate the memory. - -$head Syntax$$ -$icode%flag% = omp_alloc::efficient(%v_ptr%, %num_bytes%)%$$ - -$head Purpose$$ -Check if memory that is currently in use is an efficient -allocation for a specified number of bytes. - -$head v_ptr$$ -This argument has prototype -$codei% - const void* %v_ptr% -%$$. -It must be a pointer to memory that is currently in use; i.e. -obtained by a previous call to $cref omp_get_memory$$ and not yet returned. - -$head num_bytes$$ -This argument has prototype -$codei% - size_t %num_bytes% -%$$ -It specifies the number of bytes of the memory allocated by $icode v_ptr$$ -that we want to use. - -$head flag$$ -The return value has prototype -$codei% - bool %flag% -%$$ -It is true, -a call to $code get_memory$$ with -$cref/min_bytes/omp_get_memory/min_bytes/$$ -equal to $icode num_bytes$$ would result in a value for -$cref/cap_bytes/omp_get_memory/cap_bytes/$$ that is the same as when $code v_ptr$$ -was returned by $code get_memory$$; i.e., -$icode v_ptr$$ is an efficient memory block for $icode num_bytes$$ -bytes of information. - -$head Thread$$ -Either the $cref/current thread/omp_get_thread_num/$$ must be the same as during -the corresponding call to $cref omp_get_memory$$, -or the current execution mode must be sequential -(not $cref/parallel/omp_in_parallel/$$). - -$head NDEBUG$$ -If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). -Otherwise, a list of in use pointers is searched to make sure -that $icode v_ptr$$ is in the list. - -$end ---------------------------------------------------------------------------- -$begin old_max_num_threads$$ -$spell - inv - CppAD - num - omp_alloc -$$ -$section Set Maximum Number of Threads for omp_alloc Allocator$$ - -$head Removed$$ -$index max_num_threads, omp_alloc$$ -$index omp_alloc, max_num_threads$$ -This function has been removed from the CppAD API. -Use the function $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ -in its place. - -$head Syntax$$ -$codei%omp_alloc::max_num_threads(%number%)%$$ - -$head Purpose$$ -By default there is only one thread and all execution is in sequential mode -(not $cref/parallel/omp_in_parallel/$$). - -$head number$$ -The argument $icode number$$ has prototype -$codei% - size_t %number% -%$$ -It must be greater than zero and specifies the maximum number of -OpenMP threads that will be active at one time. - -$head Restrictions$$ -This function must be called before the program enters -$cref/parallel/omp_in_parallel/$$ execution mode. - -$end -------------------------------------------------------------------------------- -*/ -} // END_CPPAD_NAMESPACE - -# endif diff -Nru cppad-2015.00.00.9/cppad/Poly.h cppad-2016.00.00.1/cppad/Poly.h --- cppad-2015.00.00.9/cppad/Poly.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/Poly.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: Poly.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/poly.hpp" diff -Nru cppad-2015.00.00.9/cppad/poly.hpp cppad-2016.00.00.1/cppad/poly.hpp --- cppad-2015.00.00.9/cppad/poly.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/poly.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,198 +0,0 @@ -/* $Id: poly.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_POLY_INCLUDED -# define CPPAD_POLY_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin Poly$$ -$spell - cppad.hpp - CppAD - namespace - cstddef - ifndef - endif - deg - const - std - da -$$ - -$index Poly$$ -$index polynomial$$ -$index derivative, polynomial template$$ -$index template, polynomial derivative$$ - -$section Evaluate a Polynomial or its Derivative$$ - -$head Syntax$$ -$code # include $$ -$pre -$$ -$icode%p% = Poly(%k%, %a%, %z%)%$$ - - -$head Description$$ -Computes the $th k$$ derivative of the polynomial -$latex \[ - P(z) = a_0 + a_1 z^1 + \cdots + a_d z^d -\] $$ -If $icode k$$ is equal to zero, the return value is $latex P(z)$$. - -$head Include$$ -The file $code cppad/poly.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. -Including this file defines -$code Poly$$ within the $code CppAD$$ namespace. - -$head k$$ -The argument $icode k$$ has prototype -$codei% - size_t %k% -%$$ -It specifies the order of the derivative to calculate. - -$head a$$ -The argument $icode a$$ has prototype -$codei% - const %Vector% &%a% -%$$ -(see $cref/Vector/Poly/Vector/$$ below). -It specifies the vector corresponding to the polynomial $latex P(z)$$. - -$head z$$ -The argument $icode z$$ has prototype -$codei% - const %Type% &%z% -%$$ -(see $icode Type$$ below). -It specifies the point at which to evaluate the polynomial - -$head p$$ -The result $icode p$$ has prototype -$codei% - %Type% %p% -%$$ -(see $cref/Type/Poly/Type/$$ below) -and it is equal to the $th k$$ derivative of $latex P(z)$$; i.e., -$latex \[ -p = \frac{k !}{0 !} a_k - + \frac{(k+1) !}{1 !} a_{k+1} z^1 - + \ldots - + \frac{d !}{(d - k) !} a_d z^{d - k} -\] -$$ -If $latex k > d$$, $icode%p% = %Type%(0)%$$. - -$head Type$$ -The type $icode Type$$ is determined by the argument $icode z$$. -It is assumed that -multiplication and addition of $icode Type$$ objects -are commutative. - -$subhead Operations$$ -The following operations must be supported where -$icode x$$ and $icode y$$ are objects of type $icode Type$$ -and $icode i$$ is an $code int$$: -$table -$icode%x% = %i%$$ $cnext assignment $rnext -$icode%x% = %y%$$ $cnext assignment $rnext -$icode%x% *= %y%$$ $cnext multiplication computed assignment $rnext -$icode%x% += %y%$$ $cnext addition computed assignment - -$tend - - -$head Vector$$ -The type $icode Vector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type/SimpleVector/Elements of Specified Type/$$ -$icode Type$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head Operation Sequence$$ -The $icode Type$$ operation sequence used to calculate $icode p$$ is -$cref/independent/glossary/Operation/Independent/$$ -of $icode z$$ and the elements of $icode a$$ -(it does depend on the size of the vector $icode a$$). - - -$children% - example/poly.cpp% - omh/poly_hpp.omh -%$$ - -$head Example$$ -The file -$cref poly.cpp$$ -contains an example and test of this routine. -It returns true if it succeeds and false otherwise. - -$head Source$$ -The file $cref poly.hpp$$ contains the -current source code that implements these specifications. - -$end ------------------------------------------------------------------------------- -*/ -// BEGIN C++ -# include // used to defined size_t -# include - -namespace CppAD { // BEGIN CppAD namespace - -template -Type Poly(size_t k, const Vector &a, const Type &z) -{ size_t i; - size_t d = a.size() - 1; - - Type tmp; - - // check Vector is Simple Vector class with Type elements - CheckSimpleVector(); - - // case where derivative order greater than degree of polynomial - if( k > d ) - { tmp = 0; - return tmp; - } - // case where we are evaluating a derivative - if( k > 0 ) - { // initialize factor as (k-1) ! - size_t factor = 1; - for(i = 2; i < k; i++) - factor *= i; - - // set b to coefficient vector corresponding to derivative - Vector b(d - k + 1); - for(i = k; i <= d; i++) - { factor *= i; - tmp = factor; - b[i - k] = a[i] * tmp; - factor /= (i - k + 1); - } - // value of derivative polynomial - return Poly(0, b, z); - } - // case where we are evaluating the original polynomial - Type sum = a[d]; - i = d; - while(i > 0) - { sum *= z; - sum += a[--i]; - } - return sum; -} -} // END CppAD namespace -// END C++ -# endif diff -Nru cppad-2015.00.00.9/cppad/PowInt.h cppad-2016.00.00.1/cppad/PowInt.h --- cppad-2015.00.00.9/cppad/PowInt.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/PowInt.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: PowInt.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/pow_int.hpp" diff -Nru cppad-2015.00.00.9/cppad/pow_int.hpp cppad-2016.00.00.1/cppad/pow_int.hpp --- cppad-2015.00.00.9/cppad/pow_int.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/pow_int.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -/* $Id: pow_int.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_POW_INT_INCLUDED -# define CPPAD_POW_INT_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -------------------------------------------------------------------------------- -$begin pow_int$$ -$spell - cppad.hpp - CppAD - namespace - const -$$ - -$index pow, integer$$ -$index exponent, integer$$ -$index integer, pow$$ - -$section The Integer Power Function$$ - -$head Syntax$$ -$code # include $$ -$pre -$$ -$icode%z% = pow(%x%, %y%)%$$ - -$head See Also$$ -$cref pow$$ - -$head Purpose$$ -Determines the value of the power function -$latex \[ - {\rm pow} (x, y) = x^y -\] $$ -for integer exponents $icode n$$ -using multiplication and possibly division to compute the value. -The other CppAD $cref pow$$ function may use logarithms and exponentiation -to compute derivatives of the same value -(which will not work if $icode x$$ is less than or equal zero). - -$head Include$$ -The file $code cppad/pow_int.h$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. -Including this file defines -this version of the $code pow$$ within the $code CppAD$$ namespace. - -$head x$$ -The argument $icode x$$ has prototype -$codei% - const %Type%& %x% -%$$ - -$head y$$ -The argument $icode y$$ has prototype -$codei% - const int& %y% -%$$ - -$head z$$ -The result $icode z$$ has prototype -$codei% - %Type% %z% -%$$ - -$head Type$$ -The type $icode Type$$ must support the following operations -where $icode a$$ and $icode b$$ are $icode Type$$ objects -and $icode i$$ is an $code int$$: -$table -$bold Operation$$ $pre $$ - $cnext $bold Description$$ - $cnext $bold Result Type$$ -$rnext -$icode%Type% %a%(%i%)%$$ - $cnext construction of a $icode Type$$ object from an $code int$$ - $cnext $icode Type$$ -$rnext -$icode%a% * %b%$$ - $cnext binary multiplication of $icode Type$$ objects - $cnext $icode Type$$ -$rnext -$icode%a% / %b%$$ - $cnext binary division of $icode Type$$ objects - $cnext $icode Type$$ -$tend - -$head Operation Sequence$$ -The $icode Type$$ operation sequence used to calculate $icode z$$ is -$cref/independent/glossary/Operation/Independent/$$ -of $icode x$$. - -$head Example$$ -$children% - example/pow_int.cpp -%$$ -The file $cref pow_int.cpp$$ -is an example and test of this function. -It returns true if it succeeds and false otherwise. - - -$end -------------------------------------------------------------------------------- -*/ - -namespace CppAD { - - template - inline Type pow (const Type& x, const int& n) - { - Type p(1); - int n2 = n / 2; - - if( n == 0 ) - return p; - if( n < 0 ) - return p / pow(x, -n); - if( n == 1 ) - return x; - - // p = (x^2)^(n/2) - p = pow( x * x , n2 ); - - // n is even case - if( n % 2 == 0 ) - return p; - - // n is odd case - return p * x; - } - -} - -# endif diff -Nru cppad-2015.00.00.9/cppad/RombergMul.h cppad-2016.00.00.1/cppad/RombergMul.h --- cppad-2015.00.00.9/cppad/RombergMul.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/RombergMul.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: RombergMul.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/romberg_mul.hpp" diff -Nru cppad-2015.00.00.9/cppad/romberg_mul.hpp cppad-2016.00.00.1/cppad/romberg_mul.hpp --- cppad-2015.00.00.9/cppad/romberg_mul.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/romberg_mul.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,331 +0,0 @@ -/* $Id: romberg_mul.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ROMBERG_MUL_INCLUDED -# define CPPAD_ROMBERG_MUL_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin RombergMul$$ -$spell - cppad.hpp - bool - const - Cpp - RombergMulMul -$$ - -$section Multi-dimensional Romberg Integration$$ - -$index integrate, multi-dimensional Romberg$$ -$index Romberg, multi-dimensional integrate$$ -$index multi, dimensional Romberg integration$$ -$index dimension, multi Romberg integration$$ - -$head Syntax$$ -$code # include $$ -$pre -$$ -$codei%RombergMul<%Fun%, %SizeVector%, %FloatVector%, %m%> %R%$$ -$pre -$$ -$icode%r% = %R%(%F%, %a%, %b%, %n%, %p%, %e%)%$$ - - -$head Description$$ -Returns the Romberg integration estimate -$latex r$$ for the multi-dimensional integral -$latex \[ -r = -\int_{a[0]}^{b[0]} \cdots \int_{a[m-1]}^{b[m-1]} -\; F(x) \; -{\bf d} x_0 \cdots {\bf d} x_{m-1} -\; + \; -\sum_{i=0}^{m-1} -O \left[ ( b[i] - a[i] ) / 2^{n[i]-1} \right]^{2(p[i]+1)} -\] $$ - -$head Include$$ -The file $code cppad/romberg_mul.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head m$$ -The template parameter $icode m$$ must be convertible to a $code size_t$$ -object with a value that can be determined at compile time; for example -$code 2$$. -It determines the dimension of the domain space for the integration. - -$head r$$ -The return value $icode r$$ has prototype -$codei% - %Float% %r% -%$$ -It is the estimate computed by $code RombergMul$$ for the integral above -(see description of $cref/Float/RombergMul/Float/$$ below). - -$head F$$ -The object $icode F$$ has the prototype -$codei% - %Fun% &%F% -%$$ -It must support the operation -$codei% - %F%(%x%) -%$$ -The argument $icode x$$ to $icode F$$ has prototype -$codei% - const %Float% &%x% -%$$ -The return value of $icode F$$ is a $icode Float$$ object - -$head a$$ -The argument $icode a$$ has prototype -$codei% - const %FloatVector% &%a% -%$$ -It specifies the lower limit for the integration -(see description of $cref/FloatVector/RombergMul/FloatVector/$$ below). - -$head b$$ -The argument $icode b$$ has prototype -$codei% - const %FloatVector% &%b% -%$$ -It specifies the upper limit for the integration. - -$head n$$ -The argument $icode n$$ has prototype -$codei% - const %SizeVector% &%n% -%$$ -A total number of $latex 2^{n[i]-1} + 1$$ -evaluations of $icode%F%(%x%)%$$ are used to estimate the integral -with respect to $latex {\bf d} x_i$$. - -$head p$$ -The argument $icode p$$ has prototype -$codei% - const %SizeVector% &%p% -%$$ -For $latex i = 0 , \ldots , m-1$$, -$latex n[i]$$ determines the accuracy order in the -approximation for the integral -that is returned by $code RombergMul$$. -The values in $icode p$$ must be less than or equal $icode n$$; i.e., -$icode%p%[%i%] <= %n%[%i%]%$$. - -$head e$$ -The argument $icode e$$ has prototype -$codei% - %Float% &%e% -%$$ -The input value of $icode e$$ does not matter -and its output value is an approximation for the absolute error in -the integral estimate. - -$head Float$$ -The type $icode Float$$ is defined as the type of the elements of -$cref/FloatVector/RombergMul/FloatVector/$$. -The type $icode Float$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. -In addition, if $icode x$$ and $icode y$$ are $icode Float$$ objects, -$codei% - %x% < %y% -%$$ -returns the $code bool$$ value true if $icode x$$ is less than -$icode y$$ and false otherwise. - -$head FloatVector$$ -The type $icode FloatVector$$ must be a $cref SimpleVector$$ class. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - - -$children% - example/romberg_mul.cpp -%$$ -$head Example$$ -$comment% - example/romberg_mul.cpp -%$$ -The file -$cref Rombergmul.cpp$$ -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -$head Source Code$$ -The source code for this routine is in the file -$code cppad/romberg_mul.hpp$$. - -$end -*/ - -# include -# include -# include - -namespace CppAD { // BEGIN CppAD namespace - -template -class SliceLast { - typedef typename FloatVector::value_type Float; -private: - Fun *F; - size_t last; - FloatVector x; -public: - SliceLast( Fun *F_, size_t last_, const FloatVector &x_ ) - : F(F_) , last(last_), x(last + 1) - { size_t i; - for(i = 0; i < last; i++) - x[i] = x_[i]; - } - double operator()(const Float &xlast) - { x[last] = xlast; - return (*F)(x); - } -}; - -template -class IntegrateLast { -private: - Fun *F; - const size_t last; - const FloatVector a; - const FloatVector b; - const SizeVector n; - const SizeVector p; - Float esum; - size_t ecount; - -public: - IntegrateLast( - Fun *F_ , - size_t last_ , - const FloatVector &a_ , - const FloatVector &b_ , - const SizeVector &n_ , - const SizeVector &p_ ) - : F(F_) , last(last_), a(a_) , b(b_) , n(n_) , p(p_) - { } - Float operator()(const FloatVector &x) - { Float r, e; - SliceLast S(F, last, x); - r = CppAD::RombergOne( - S, a[last], b[last], n[last], p[last], e - ); - esum = esum + e; - ecount++; - return r; - } - void ClearEsum(void) - { esum = 0.; } - Float GetEsum(void) - { return esum; } - - void ClearEcount(void) - { ecount = 0; } - size_t GetEcount(void) - { return ecount; } -}; - -template -class RombergMul { - typedef typename FloatVector::value_type Float; -public: - RombergMul(void) - { } - Float operator() ( - Fun &F , - const FloatVector &a , - const FloatVector &b , - const SizeVector &n , - const SizeVector &p , - Float &e ) - { Float r; - - typedef IntegrateLast< - Fun , - SizeVector , - FloatVector , - Float > IntegrateOne; - - IntegrateOne Fm1(&F, m-1, a, b, n, p); - RombergMul< - IntegrateOne, - SizeVector , - FloatVector , - m-1 > RombergMulM1; - - Fm1.ClearEsum(); - Fm1.ClearEcount(); - - r = RombergMulM1(Fm1, a, b, n, p, e); - - size_t i, j; - Float prod = 1; - size_t pow2 = 1; - for(i = 0; i < m-1; i++) - { prod *= (b[i] - a[i]); - for(j = 0; j < (n[i] - 1); j++) - pow2 *= 2; - } - assert( Fm1.GetEcount() == (pow2+1) ); - - e = e + Fm1.GetEsum() * prod / Fm1.GetEcount(); - - return r; - } -}; - -template -class RombergMul { - typedef typename FloatVector::value_type Float; -public: - Float operator() ( - Fun &F , - const FloatVector &a , - const FloatVector &b , - const SizeVector &n , - const SizeVector &p , - Float &e ) - { Float r; - typedef IntegrateLast< - Fun , - SizeVector , - FloatVector , - Float > IntegrateOne; - - // check simple vector class specifications - CheckSimpleVector(); - - // check numeric type specifications - CheckNumericType(); - - IntegrateOne F0(&F, 0, a, b, n, p); - - F0.ClearEsum(); - F0.ClearEcount(); - - r = F0(a); - - assert( F0.GetEcount() == 1 ); - e = F0.GetEsum(); - - return r; - } -}; - -} // END CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/RombergOne.h cppad-2016.00.00.1/cppad/RombergOne.h --- cppad-2015.00.00.9/cppad/RombergOne.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/RombergOne.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: RombergOne.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/romberg_one.hpp" diff -Nru cppad-2015.00.00.9/cppad/romberg_one.hpp cppad-2016.00.00.1/cppad/romberg_one.hpp --- cppad-2015.00.00.9/cppad/romberg_one.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/romberg_one.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,217 +0,0 @@ -/* $Id: romberg_one.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ROMBERG_ONE_INCLUDED -# define CPPAD_ROMBERG_ONE_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin RombergOne$$ -$spell - cppad.hpp - bool - const - Cpp - RombergOne -$$ - -$section One DimensionalRomberg Integration$$ - -$index integrate, Romberg$$ -$index Romberg, Integrate$$ - -$head Syntax$$ -$code # include $$ -$pre -$$ -$icode%r% = RombergOne(%F%, %a%, %b%, %n%, %e%)%$$ - - -$head Description$$ -Returns the Romberg integration estimate -$latex r$$ for a one dimensional integral -$latex \[ -r = \int_a^b F(x) {\bf d} x + O \left[ (b - a) / 2^{n-1} \right]^{2(p+1)} -\] $$ - -$head Include$$ -The file $code cppad/romberg_one.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head r$$ -The return value $icode r$$ has prototype -$codei% - %Float% %r% -%$$ -It is the estimate computed by $code RombergOne$$ for the integral above. - -$head F$$ -The object $icode F$$ can be of any type, but it must support -the operation -$codei% - %F%(%x%) -%$$ -The argument $icode x$$ to $icode F$$ has prototype -$codei% - const %Float% &%x% -%$$ -The return value of $icode F$$ is a $icode Float$$ object -(see description of $cref/Float/RombergOne/Float/$$ below). - -$head a$$ -The argument $icode a$$ has prototype -$codei% - const %Float% &%a% -%$$ -It specifies the lower limit for the integration. - -$head b$$ -The argument $icode b$$ has prototype -$codei% - const %Float% &%b% -%$$ -It specifies the upper limit for the integration. - -$head n$$ -The argument $icode n$$ has prototype -$codei% - size_t %n% -%$$ -A total number of $latex 2^{n-1} + 1$$ evaluations of $icode%F%(%x%)%$$ -are used to estimate the integral. - -$head p$$ -The argument $icode p$$ has prototype -$codei% - size_t %p% -%$$ -It must be less than or equal $latex n$$ -and determines the accuracy order in the approximation for the integral -that is returned by $code RombergOne$$. -To be specific -$latex \[ -r = \int_a^b F(x) {\bf d} x + O \left[ (b - a) / 2^{n-1} \right]^{2(p+1)} -\] $$ - - -$head e$$ -The argument $icode e$$ has prototype -$codei% - %Float% &%e% -%$$ -The input value of $icode e$$ does not matter -and its output value is an approximation for the error in -the integral estimates; i.e., -$latex \[ - e \approx \left| r - \int_a^b F(x) {\bf d} x \right| -\] $$ - -$head Float$$ -The type $icode Float$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. -In addition, if $icode x$$ and $icode y$$ are $icode Float$$ objects, -$codei% - %x% < %y% -%$$ -returns the $code bool$$ value true if $icode x$$ is less than -$icode y$$ and false otherwise. - -$children% - example/romberg_one.cpp -%$$ -$head Example$$ -$comment% - example/romberg_one.cpp -%$$ -The file -$cref romberg_one.cpp$$ -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -$head Source Code$$ -The source code for this routine is in the file -$code cppad/romberg_one.hpp$$. - -$end -*/ - -# include -# include -# include - -namespace CppAD { // BEGIN CppAD namespace - -template -Float RombergOne( - Fun &F , - const Float &a , - const Float &b , - size_t n , - size_t p , - Float &e ) -{ - size_t ipow2 = 1; - size_t k, i; - Float pow2, sum, x; - - Float zero = Float(0); - Float two = Float(2); - - // check specifications for a NumericType - CheckNumericType(); - - CPPAD_ASSERT_KNOWN( - n >= 2, - "RombergOne: n must be greater than or equal 2" - ); - CppAD::vector r(n); - - // set r[i] = trapazoidal rule with 2^i intervals in [a, b] - r[0] = ( F(a) + F(b) ) * (b - a) / two; - for(i = 1; i < n; i++) - { ipow2 *= 2; - // there must be a conversion from int to any numeric type - pow2 = Float(int(ipow2)); - sum = zero; - for(k = 1; k < ipow2; k += 2) - { // start = a + (b-a)/pow2, increment = 2*(b-a)/pow2 - x = ( (pow2 - Float(int(k))) * a + k * b ) / pow2; - sum = sum + F(x); - } - // combine function evaluations in sum with those in T[i-1] - r[i] = r[i-1] / two + sum * (b - a) / pow2; - } - - // now compute the higher order estimates - size_t ipow4 = 1; // order of accuract for previous estimate - Float pow4, pow4minus; - for(i = 0; i < p; i++) - { // compute estimate accurate to O[ step^(2*(i+1)) ] - // put resutls in r[n-1], r[n-2], ... , r[n-i+1] - ipow4 *= 4; - pow4 = Float(int(ipow4)); - pow4minus = Float(ipow4-1); - for(k = n-1; k > i; k--) - r[k] = ( pow4 * r[k] - r[k-1] ) / pow4minus; - } - - // error estimate for r[n] - e = r[n-1] - r[n-2]; - if( e < zero ) - e = - e; - return r[n-1]; -} - -} // END CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/Rosen34.h cppad-2016.00.00.1/cppad/Rosen34.h --- cppad-2015.00.00.9/cppad/Rosen34.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/Rosen34.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: Rosen34.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/rosen_34.hpp" diff -Nru cppad-2015.00.00.9/cppad/rosen_34.hpp cppad-2016.00.00.1/cppad/rosen_34.hpp --- cppad-2015.00.00.9/cppad/rosen_34.hpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/cppad/rosen_34.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,506 +0,0 @@ -/* $Id: rosen_34.hpp 2575 2012-11-17 12:25:04Z bradbell $ */ -# ifndef CPPAD_ROSEN_34_INCLUDED -# define CPPAD_ROSEN_34_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin Rosen34$$ -$spell - cppad.hpp - bool - xf - templated - const - Rosenbrock - CppAD - xi - ti - tf - Karp - Rosen - Shampine - ind - dep -$$ - -$index Rosen34$$ -$index ODE, Rosenbrock$$ -$index Rosenbrock, ODE$$ -$index solve, ODE$$ -$index stiff, ODE$$ -$index differential, equation$$ -$index equation, differential$$ - -$section A 3rd and 4th Order Rosenbrock ODE Solver$$ - -$head Syntax$$ -$codei%# include -%$$ -$icode%xf% = Rosen34(%F%, %M%, %ti%, %tf%, %xi%) -%$$ -$icode%xf% = Rosen34(%F%, %M%, %ti%, %tf%, %xi%, %e%) -%$$ - - -$head Description$$ -This is an embedded 3rd and 4th order Rosenbrock ODE solver -(see Section 16.6 of $cref/Numerical Recipes/Bib/Numerical Recipes/$$ -for a description of Rosenbrock ODE solvers). -In particular, we use the formulas taken from page 100 of -$cref/Shampine, L.F./Bib/Shampine, L.F./$$ -(except that the fraction 98/108 has been correction to be 97/108). -$pre - -$$ -We use $latex n$$ for the size of the vector $icode xi$$. -Let $latex \B{R}$$ denote the real numbers -and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. -The return value $icode xf$$ contains a 5th order -approximation for the value $latex X(tf)$$ where -$latex X : [ti , tf] \rightarrow \B{R}^n$$ is defined by -the following initial value problem: -$latex \[ -\begin{array}{rcl} - X(ti) & = & xi \\ - X'(t) & = & F[t , X(t)] -\end{array} -\] $$ -If your set of ordinary differential equations are not stiff -an explicit method may be better (perhaps $cref Runge45$$.) - -$head Include$$ -The file $code cppad/rosen_34.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head xf$$ -The return value $icode xf$$ has the prototype -$codei% - %Vector% %xf% -%$$ -and the size of $icode xf$$ is equal to $icode n$$ -(see description of $cref/Vector/Rosen34/Vector/$$ below). -$latex \[ - X(tf) = xf + O( h^5 ) -\] $$ -where $latex h = (tf - ti) / M$$ is the step size. -If $icode xf$$ contains not a number $cref nan$$, -see the discussion of $cref/f/Rosen34/Fun/Nan/$$. - -$head Fun$$ -The class $icode Fun$$ -and the object $icode F$$ satisfy the prototype -$codei% - %Fun% &%F% -%$$ -This must support the following set of calls -$codei% - %F%.Ode(%t%, %x%, %f%) - %F%.Ode_ind(%t%, %x%, %f_t%) - %F%.Ode_dep(%t%, %x%, %f_x%) -%$$ - -$subhead t$$ -In all three cases, -the argument $icode t$$ has prototype -$codei% - const %Scalar% &%t% -%$$ -(see description of $cref/Scalar/Rosen34/Scalar/$$ below). - -$subhead x$$ -In all three cases, -the argument $icode x$$ has prototype -$codei% - const %Vector% &%x% -%$$ -and has size $icode n$$ -(see description of $cref/Vector/Rosen34/Vector/$$ below). - -$subhead f$$ -The argument $icode f$$ to $icode%F%.Ode%$$ has prototype -$codei% - %Vector% &%f% -%$$ -On input and output, $icode f$$ is a vector of size $icode n$$ -and the input values of the elements of $icode f$$ do not matter. -On output, -$icode f$$ is set equal to $latex F(t, x)$$ -(see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). - -$subhead f_t$$ -The argument $icode f_t$$ to $icode%F%.Ode_ind%$$ has prototype -$codei% - %Vector% &%f_t% -%$$ -On input and output, $icode f_t$$ is a vector of size $icode n$$ -and the input values of the elements of $icode f_t$$ do not matter. -On output, the $th i$$ element of -$icode f_t$$ is set equal to $latex \partial_t F_i (t, x)$$ -(see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). - -$subhead f_x$$ -The argument $icode f_x$$ to $icode%F%.Ode_dep%$$ has prototype -$codei% - %Vector% &%f_x% -%$$ -On input and output, $icode f_x$$ is a vector of size $icode%n%*%n%$$ -and the input values of the elements of $icode f_x$$ do not matter. -On output, the [$icode%i%*%n%+%j%$$] element of -$icode f_x$$ is set equal to $latex \partial_{x(j)} F_i (t, x)$$ -(see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). - -$subhead Nan$$ -If any of the elements of $icode f$$, $icode f_t$$, or $icode f_x$$ -have the value not a number $code nan$$, -the routine $code Rosen34$$ returns with all the -elements of $icode xf$$ and $icode e$$ equal to $code nan$$. - -$subhead Warning$$ -The arguments $icode f$$, $icode f_t$$, and $icode f_x$$ -must have a call by reference in their prototypes; i.e., -do not forget the $code &$$ in the prototype for -$icode f$$, $icode f_t$$ and $icode f_x$$. - -$subhead Optimization$$ -Every call of the form -$codei% - %F%.Ode_ind(%t%, %x%, %f_t%) -%$$ -is directly followed by a call of the form -$codei% - %F%.Ode_dep(%t%, %x%, %f_x%) -%$$ -where the arguments $icode t$$ and $icode x$$ have not changed between calls. -In many cases it is faster to compute the values of $icode f_t$$ -and $icode f_x$$ together and then pass them back one at a time. - -$head M$$ -The argument $icode M$$ has prototype -$codei% - size_t %M% -%$$ -It specifies the number of steps -to use when solving the differential equation. -This must be greater than or equal one. -The step size is given by $latex h = (tf - ti) / M$$, thus -the larger $icode M$$, the more accurate the -return value $icode xf$$ is as an approximation -for $latex X(tf)$$. - -$head ti$$ -The argument $icode ti$$ has prototype -$codei% - const %Scalar% &%ti% -%$$ -(see description of $cref/Scalar/Rosen34/Scalar/$$ below). -It specifies the initial time for $icode t$$ in the -differential equation; i.e., -the time corresponding to the value $icode xi$$. - -$head tf$$ -The argument $icode tf$$ has prototype -$codei% - const %Scalar% &%tf% -%$$ -It specifies the final time for $icode t$$ in the -differential equation; i.e., -the time corresponding to the value $icode xf$$. - -$head xi$$ -The argument $icode xi$$ has the prototype -$codei% - const %Vector% &%xi% -%$$ -and the size of $icode xi$$ is equal to $icode n$$. -It specifies the value of $latex X(ti)$$ - -$head e$$ -The argument $icode e$$ is optional and has the prototype -$codei% - %Vector% &%e% -%$$ -If $icode e$$ is present, -the size of $icode e$$ must be equal to $icode n$$. -The input value of the elements of $icode e$$ does not matter. -On output -it contains an element by element -estimated bound for the absolute value of the error in $icode xf$$ -$latex \[ - e = O( h^4 ) -\] $$ -where $latex h = (tf - ti) / M$$ is the step size. - -$head Scalar$$ -The type $icode Scalar$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. -In addition, the following operations must be defined for -$icode Scalar$$ objects $icode a$$ and $icode b$$: - -$table -$bold Operation$$ $cnext $bold Description$$ $rnext -$icode%a% < %b%$$ $cnext - less than operator (returns a $code bool$$ object) -$tend - -$head Vector$$ -The type $icode Vector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head Parallel Mode$$ -$index parallel, Rosen34$$ -$index Rosen34, parallel$$ -For each set of types -$cref/Scalar/Rosen34/Scalar/$$, -$cref/Vector/Rosen34/Vector/$$, and -$cref/Fun/Rosen34/Fun/$$, -the first call to $code Rosen34$$ -must not be $cref/parallel/ta_in_parallel/$$ execution mode. - -$head Example$$ -$children% - example/rosen_34.cpp -%$$ -The file -$cref rosen_34.cpp$$ -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -$head Source Code$$ -The source code for this routine is in the file -$code cppad/rosen_34.hpp$$. - -$end --------------------------------------------------------------------------- -*/ - -# include -# include -# include -# include -# include -# include -# include - -// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include - -namespace CppAD { // BEGIN CppAD namespace - -template -Vector Rosen34( - Fun &F , - size_t M , - const Scalar &ti , - const Scalar &tf , - const Vector &xi ) -{ Vector e( xi.size() ); - return Rosen34(F, M, ti, tf, xi, e); -} - -template -Vector Rosen34( - Fun &F , - size_t M , - const Scalar &ti , - const Scalar &tf , - const Vector &xi , - Vector &e ) -{ - CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; - - // check numeric type specifications - CheckNumericType(); - - // check simple vector class specifications - CheckSimpleVector(); - - // Parameters for Shampine's Rosenbrock method - // are static to avoid recalculation on each call and - // do not use Vector to avoid possible memory leak - static Scalar a[3] = { - Scalar(0), - Scalar(1), - Scalar(3) / Scalar(5) - }; - static Scalar b[2 * 2] = { - Scalar(1), - Scalar(0), - Scalar(24) / Scalar(25), - Scalar(3) / Scalar(25) - }; - static Scalar ct[4] = { - Scalar(1) / Scalar(2), - - Scalar(3) / Scalar(2), - Scalar(121) / Scalar(50), - Scalar(29) / Scalar(250) - }; - static Scalar cg[3 * 3] = { - - Scalar(4), - Scalar(0), - Scalar(0), - Scalar(186) / Scalar(25), - Scalar(6) / Scalar(5), - Scalar(0), - - Scalar(56) / Scalar(125), - - Scalar(27) / Scalar(125), - - Scalar(1) / Scalar(5) - }; - static Scalar d3[3] = { - Scalar(97) / Scalar(108), - Scalar(11) / Scalar(72), - Scalar(25) / Scalar(216) - }; - static Scalar d4[4] = { - Scalar(19) / Scalar(18), - Scalar(1) / Scalar(4), - Scalar(25) / Scalar(216), - Scalar(125) / Scalar(216) - }; - CPPAD_ASSERT_KNOWN( - M >= 1, - "Error in Rosen34: the number of steps is less than one" - ); - CPPAD_ASSERT_KNOWN( - e.size() == xi.size(), - "Error in Rosen34: size of e not equal to size of xi" - ); - size_t i, j, k, l, m; // indices - - size_t n = xi.size(); // number of components in X(t) - Scalar ns = Scalar(double(M)); // number of steps as Scalar object - Scalar h = (tf - ti) / ns; // step size - Scalar zero = Scalar(0); // some constants - Scalar one = Scalar(1); - Scalar two = Scalar(2); - - // permutation vectors needed for LU factorization routine - CppAD::vector ip(n), jp(n); - - // vectors used to store values returned by F - Vector E(n * n), Eg(n), f_t(n); - Vector g(n * 3), x3(n), x4(n), xf(n), ftmp(n), xtmp(n), nan_vec(n); - - // initialize e = 0, nan_vec = nan - for(i = 0; i < n; i++) - { e[i] = zero; - nan_vec[i] = nan(zero); - } - - xf = xi; // initialize solution - for(m = 0; m < M; m++) - { // time at beginning of this interval - Scalar t = ti * (Scalar(int(M - m)) / ns) - + tf * (Scalar(int(m)) / ns); - - // value of x at beginning of this interval - x3 = x4 = xf; - - // evaluate partial derivatives at beginning of this interval - F.Ode_ind(t, xf, f_t); - F.Ode_dep(t, xf, E); // E = f_x - if( hasnan(f_t) || hasnan(E) ) - { e = nan_vec; - return nan_vec; - } - - // E = I - f_x * h / 2 - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - E[i * n + j] = - E[i * n + j] * h / two; - E[i * n + i] += one; - } - - // LU factor the matrix E -# ifndef NDEBUG - int sign = LuFactor(ip, jp, E); -# else - LuFactor(ip, jp, E); -# endif - CPPAD_ASSERT_KNOWN( - sign != 0, - "Error in Rosen34: I - f_x * h / 2 not invertible" - ); - - // loop over integration steps - for(k = 0; k < 3; k++) - { // set location for next function evaluation - xtmp = xf; - for(l = 0; l < k; l++) - { // loop over previous function evaluations - Scalar bkl = b[(k-1)*2 + l]; - for(i = 0; i < n; i++) - { // loop over elements of x - xtmp[i] += bkl * g[i*3 + l] * h; - } - } - // ftmp = F(t + a[k] * h, xtmp) - F.Ode(t + a[k] * h, xtmp, ftmp); - if( hasnan(ftmp) ) - { e = nan_vec; - return nan_vec; - } - - // Form Eg for this integration step - for(i = 0; i < n; i++) - Eg[i] = ftmp[i] + ct[k] * f_t[i] * h; - for(l = 0; l < k; l++) - { for(i = 0; i < n; i++) - Eg[i] += cg[(k-1)*3 + l] * g[i*3 + l]; - } - - // Solve the equation E * g = Eg - LuInvert(ip, jp, E, Eg); - - // save solution and advance x3, x4 - for(i = 0; i < n; i++) - { g[i*3 + k] = Eg[i]; - x3[i] += h * d3[k] * Eg[i]; - x4[i] += h * d4[k] * Eg[i]; - } - } - // Form Eg for last update to x4 only - for(i = 0; i < n; i++) - Eg[i] = ftmp[i] + ct[3] * f_t[i] * h; - for(l = 0; l < 3; l++) - { for(i = 0; i < n; i++) - Eg[i] += cg[2*3 + l] * g[i*3 + l]; - } - - // Solve the equation E * g = Eg - LuInvert(ip, jp, E, Eg); - - // advance x4 and accumulate error bound - for(i = 0; i < n; i++) - { x4[i] += h * d4[3] * Eg[i]; - - // cant use abs because cppad.hpp may not be included - Scalar diff = x4[i] - x3[i]; - if( diff < zero ) - e[i] -= diff; - else e[i] += diff; - } - - // advance xf for this step using x4 - xf = x4; - } - return xf; -} - -} // End CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/Runge45.h cppad-2016.00.00.1/cppad/Runge45.h --- cppad-2015.00.00.9/cppad/Runge45.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/Runge45.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: Runge45.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/runge_45.hpp" diff -Nru cppad-2015.00.00.9/cppad/runge_45.hpp cppad-2016.00.00.1/cppad/runge_45.hpp --- cppad-2015.00.00.9/cppad/runge_45.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/runge_45.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,437 +0,0 @@ -/* $Id: runge_45.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_RUNGE_45_INCLUDED -# define CPPAD_RUNGE_45_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin Runge45$$ -$spell - std - fabs - cppad.hpp - bool - xf - templated - const - Runge-Kutta - CppAD - xi - ti - tf - Karp -$$ - -$index Runge45$$ -$index ODE, Runge-Kutta$$ -$index Runge, ODE$$ -$index Kutta, ODE$$ -$index solve, ODE$$ -$index differential, equation$$ -$index equation, differential$$ - -$section An Embedded 4th and 5th Order Runge-Kutta ODE Solver$$ - -$head Syntax$$ -$codei%# include -%$$ -$icode%xf% = Runge45(%F%, %M%, %ti%, %tf%, %xi%) -%$$ -$icode%xf% = Runge45(%F%, %M%, %ti%, %tf%, %xi%, %e%) -%$$ - - -$head Purpose$$ -This is an implementation of the -Cash-Karp embedded 4th and 5th order Runge-Kutta ODE solver -described in Section 16.2 of $cref/Numerical Recipes/Bib/Numerical Recipes/$$. -We use $latex n$$ for the size of the vector $icode xi$$. -Let $latex \B{R}$$ denote the real numbers -and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ -be a smooth function. -The return value $icode xf$$ contains a 5th order -approximation for the value $latex X(tf)$$ where -$latex X : [ti , tf] \rightarrow \B{R}^n$$ is defined by -the following initial value problem: -$latex \[ -\begin{array}{rcl} - X(ti) & = & xi \\ - X'(t) & = & F[t , X(t)] -\end{array} -\] $$ -If your set of ordinary differential equations -are stiff, an implicit method may be better -(perhaps $cref Rosen34$$.) - -$head Operation Sequence$$ -The $cref/operation sequence/glossary/Operation/Sequence/$$ for $icode Runge$$ -does not depend on any of its $icode Scalar$$ input values provided that -the operation sequence for -$codei% - %F%.Ode(%t%, %x%, %f%) -%$$ -does not on any of its $icode Scalar$$ inputs (see below). - -$head Include$$ -The file $code cppad/runge_45.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head xf$$ -The return value $icode xf$$ has the prototype -$codei% - %Vector% %xf% -%$$ -and the size of $icode xf$$ is equal to $icode n$$ -(see description of $cref/Vector/Runge45/Vector/$$ below). -$latex \[ - X(tf) = xf + O( h^6 ) -\] $$ -where $latex h = (tf - ti) / M$$ is the step size. -If $icode xf$$ contains not a number $cref nan$$, -see the discussion for $cref/f/Runge45/Fun/f/$$. - -$head Fun$$ -The class $icode Fun$$ -and the object $icode F$$ satisfy the prototype -$codei% - %Fun% &%F% -%$$ -The object $icode F$$ (and the class $icode Fun$$) -must have a member function named $code Ode$$ -that supports the syntax -$codei% - %F%.Ode(%t%, %x%, %f%) -%$$ - -$subhead t$$ -The argument $icode t$$ to $icode%F%.Ode%$$ has prototype -$codei% - const %Scalar% &%t% -%$$ -(see description of $cref/Scalar/Runge45/Scalar/$$ below). - -$subhead x$$ -The argument $icode x$$ to $icode%F%.Ode%$$ has prototype -$codei% - const %Vector% &%x% -%$$ -and has size $icode n$$ -(see description of $cref/Vector/Runge45/Vector/$$ below). - -$subhead f$$ -The argument $icode f$$ to $icode%F%.Ode%$$ has prototype -$codei% - %Vector% &%f% -%$$ -On input and output, $icode f$$ is a vector of size $icode n$$ -and the input values of the elements of $icode f$$ do not matter. -On output, -$icode f$$ is set equal to $latex F(t, x)$$ in the differential equation. -If any of the elements of $icode f$$ have the value not a number $code nan$$ -the routine $code Runge45$$ returns with all the -elements of $icode xf$$ and $icode e$$ equal to $code nan$$. - -$subhead Warning$$ -The argument $icode f$$ to $icode%F%.Ode%$$ -must have a call by reference in its prototype; i.e., -do not forget the $code &$$ in the prototype for $icode f$$. - -$head M$$ -The argument $icode M$$ has prototype -$codei% - size_t %M% -%$$ -It specifies the number of steps -to use when solving the differential equation. -This must be greater than or equal one. -The step size is given by $latex h = (tf - ti) / M$$, thus -the larger $icode M$$, the more accurate the -return value $icode xf$$ is as an approximation -for $latex X(tf)$$. - -$head ti$$ -The argument $icode ti$$ has prototype -$codei% - const %Scalar% &%ti% -%$$ -(see description of $cref/Scalar/Runge45/Scalar/$$ below). -It specifies the initial time for $icode t$$ in the -differential equation; i.e., -the time corresponding to the value $icode xi$$. - -$head tf$$ -The argument $icode tf$$ has prototype -$codei% - const %Scalar% &%tf% -%$$ -It specifies the final time for $icode t$$ in the -differential equation; i.e., -the time corresponding to the value $icode xf$$. - -$head xi$$ -The argument $icode xi$$ has the prototype -$codei% - const %Vector% &%xi% -%$$ -and the size of $icode xi$$ is equal to $icode n$$. -It specifies the value of $latex X(ti)$$ - -$head e$$ -The argument $icode e$$ is optional and has the prototype -$codei% - %Vector% &%e% -%$$ -If $icode e$$ is present, -the size of $icode e$$ must be equal to $icode n$$. -The input value of the elements of $icode e$$ does not matter. -On output -it contains an element by element -estimated bound for the absolute value of the error in $icode xf$$ -$latex \[ - e = O( h^5 ) -\] $$ -where $latex h = (tf - ti) / M$$ is the step size. -If on output, $icode e$$ contains not a number $code nan$$, -see the discussion for $cref/f/Runge45/Fun/f/$$. - -$head Scalar$$ -The type $icode Scalar$$ must satisfy the conditions -for a $cref NumericType$$ type. -The routine $cref CheckNumericType$$ will generate an error message -if this is not the case. - -$subhead fabs$$ -In addition, the following function must be defined for -$icode Scalar$$ objects $icode a$$ and $icode b$$ -$codei% - %a% = fabs(%b%) -%$$ -Note that this operation is only used for computing $icode e$$; hence -the operation sequence for $icode xf$$ can still be independent of -the arguments to $code Runge45$$ even if -$codei% - fabs(%b%) = std::max(-%b%, %b%) -%$$. - -$head Vector$$ -The type $icode Vector$$ must be a $cref SimpleVector$$ class with -$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. -The routine $cref CheckSimpleVector$$ will generate an error message -if this is not the case. - -$head Parallel Mode$$ -$index parallel, Runge45$$ -$index Runge45, parallel$$ -For each set of types -$cref/Scalar/Runge45/Scalar/$$, -$cref/Vector/Runge45/Vector/$$, and -$cref/Fun/Runge45/Fun/$$, -the first call to $code Runge45$$ -must not be $cref/parallel/ta_in_parallel/$$ execution mode. - - -$head Example$$ -$children% - example/runge45_1.cpp% - example/runge45_2.cpp -%$$ -The file -$cref runge45_1.cpp$$ -contains a simple example and test of $code Runge45$$. -It returns true if it succeeds and false otherwise. -$pre - -$$ -The file -$cref runge45_2.cpp$$ contains an example using $code Runge45$$ -in the context of algorithmic differentiation. -It also returns true if it succeeds and false otherwise. - -$head Source Code$$ -The source code for this routine is in the file -$code cppad/runge_45.hpp$$. - -$end --------------------------------------------------------------------------- -*/ -# include -# include -# include -# include -# include - -// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL -# include - -namespace CppAD { // BEGIN CppAD namespace - -template -Vector Runge45( - Fun &F , - size_t M , - const Scalar &ti , - const Scalar &tf , - const Vector &xi ) -{ Vector e( xi.size() ); - return Runge45(F, M, ti, tf, xi, e); -} - -template -Vector Runge45( - Fun &F , - size_t M , - const Scalar &ti , - const Scalar &tf , - const Vector &xi , - Vector &e ) -{ - CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; - - // check numeric type specifications - CheckNumericType(); - - // check simple vector class specifications - CheckSimpleVector(); - - // Cash-Karp parameters for embedded Runge-Kutta method - // are static to avoid recalculation on each call and - // do not use Vector to avoid possible memory leak - static Scalar a[6] = { - Scalar(0), - Scalar(1) / Scalar(5), - Scalar(3) / Scalar(10), - Scalar(3) / Scalar(5), - Scalar(1), - Scalar(7) / Scalar(8) - }; - static Scalar b[5 * 5] = { - Scalar(1) / Scalar(5), - Scalar(0), - Scalar(0), - Scalar(0), - Scalar(0), - - Scalar(3) / Scalar(40), - Scalar(9) / Scalar(40), - Scalar(0), - Scalar(0), - Scalar(0), - - Scalar(3) / Scalar(10), - -Scalar(9) / Scalar(10), - Scalar(6) / Scalar(5), - Scalar(0), - Scalar(0), - - -Scalar(11) / Scalar(54), - Scalar(5) / Scalar(2), - -Scalar(70) / Scalar(27), - Scalar(35) / Scalar(27), - Scalar(0), - - Scalar(1631) / Scalar(55296), - Scalar(175) / Scalar(512), - Scalar(575) / Scalar(13824), - Scalar(44275) / Scalar(110592), - Scalar(253) / Scalar(4096) - }; - static Scalar c4[6] = { - Scalar(2825) / Scalar(27648), - Scalar(0), - Scalar(18575) / Scalar(48384), - Scalar(13525) / Scalar(55296), - Scalar(277) / Scalar(14336), - Scalar(1) / Scalar(4), - }; - static Scalar c5[6] = { - Scalar(37) / Scalar(378), - Scalar(0), - Scalar(250) / Scalar(621), - Scalar(125) / Scalar(594), - Scalar(0), - Scalar(512) / Scalar(1771) - }; - - CPPAD_ASSERT_KNOWN( - M >= 1, - "Error in Runge45: the number of steps is less than one" - ); - CPPAD_ASSERT_KNOWN( - e.size() == xi.size(), - "Error in Runge45: size of e not equal to size of xi" - ); - size_t i, j, k, m; // indices - - size_t n = xi.size(); // number of components in X(t) - Scalar ns = Scalar(int(M)); // number of steps as Scalar object - Scalar h = (tf - ti) / ns; // step size - Scalar zero_or_nan = Scalar(0); // zero (nan if Ode returns has a nan) - for(i = 0; i < n; i++) // initialize e = 0 - e[i] = zero_or_nan; - - // vectors used to store values returned by F - Vector fh(6 * n), xtmp(n), ftmp(n), x4(n), x5(n), xf(n); - - xf = xi; // initialize solution - for(m = 0; m < M; m++) - { // time at beginning of this interval - // (convert to int to avoid MS compiler warning) - Scalar t = ti * (Scalar(int(M - m)) / ns) - + tf * (Scalar(int(m)) / ns); - - // loop over integration steps - x4 = x5 = xf; // start x4 and x5 at same point for each step - for(j = 0; j < 6; j++) - { // loop over function evaluations for this step - xtmp = xf; // location for next function evaluation - for(k = 0; k < j; k++) - { // loop over previous function evaluations - Scalar bjk = b[ (j-1) * 5 + k ]; - for(i = 0; i < n; i++) - { // loop over elements of x - xtmp[i] += bjk * fh[i * 6 + k]; - } - } - // ftmp = F(t + a[j] * h, xtmp) - F.Ode(t + a[j] * h, xtmp, ftmp); - - // if ftmp has a nan, set zero_or_nan to nan - for(i = 0; i < n; i++) - zero_or_nan *= ftmp[i]; - - for(i = 0; i < n; i++) - { // loop over elements of x - Scalar fhi = ftmp[i] * h; - fh[i * 6 + j] = fhi; - x4[i] += c4[j] * fhi; - x5[i] += c5[j] * fhi; - x5[i] += zero_or_nan; - } - } - // accumulate error bound - for(i = 0; i < n; i++) - { // cant use abs because cppad.hpp may not be included - Scalar diff = x5[i] - x4[i]; - e[i] += fabs(diff); - e[i] += zero_or_nan; - } - - // advance xf for this step using x5 - xf = x5; - } - return xf; -} - -} // End CppAD namespace - -# endif diff -Nru cppad-2015.00.00.9/cppad/speed/det_33.hpp cppad-2016.00.00.1/cppad/speed/det_33.hpp --- cppad-2015.00.00.9/cppad/speed/det_33.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/det_33.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: det_33.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_DET_33_INCLUDED -# define CPPAD_DET_33_INCLUDED +// $Id: det_33.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DET_33_HPP +# define CPPAD_DET_33_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,12 +24,9 @@ bool $$ -$section Check Determinant of 3 by 3 matrix$$ +$section Check Determinant of 3 by 3 matrix$$ +$mindex det_33 correct$$ -$index det_33$$ -$index determinant, check correct$$ -$index correct, determinant check$$ -$index check, determinant correct$$ $head Syntax$$ $codei%# include @@ -42,10 +39,10 @@ $head Inclusion$$ The template function $code det_33$$ is defined in the $code CppAD$$ -namespace by including -the file $code cppad/speed/det_33.hpp$$ +namespace by including +the file $code cppad/speed/det_33.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -67,7 +64,7 @@ It is tested to see if $icode%d%[0]%$$ it is equal to $latex \det ( X )$$. $head Vector$$ -If $icode y$$ is a $icode Vector$$ object, +If $icode y$$ is a $icode Vector$$ object, it must support the syntax $codei% %y%[%i%] @@ -83,7 +80,7 @@ $codei% bool %ok% %$$ -It is true, if the determinant $icode%d%[0]%$$ +It is true, if the determinant $icode%d%[0]%$$ passes the test and false otherwise. $children% @@ -91,7 +88,7 @@ %$$ $head Source Code$$ -The file +The file $cref det_33.hpp$$ contains the source code for this template function. @@ -99,12 +96,12 @@ ------------------------------------------------------------------------------ */ // BEGIN C++ -# include +# include namespace CppAD { template bool det_33(const Vector &x, const Vector &d) { bool ok = true; - + // use expansion by minors to compute the determinant by hand double check = 0.; check += x[0] * ( x[4] * x[8] - x[5] * x[7] ); @@ -112,7 +109,7 @@ check += x[2] * ( x[3] * x[7] - x[4] * x[6] ); ok &= CppAD::NearEqual(check, d[0], 1e-10, 1e-10); - + return ok; } } diff -Nru cppad-2015.00.00.9/cppad/speed/det_by_lu.hpp cppad-2016.00.00.1/cppad/speed/det_by_lu.hpp --- cppad-2015.00.00.9/cppad/speed/det_by_lu.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/det_by_lu.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: det_by_lu.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_DET_BY_LU_INCLUDED -# define CPPAD_DET_BY_LU_INCLUDED +// $Id: det_by_lu.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DET_BY_LU_HPP +# define CPPAD_DET_BY_LU_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,11 +28,8 @@ $$ $section Determinant Using Expansion by Lu Factorization$$ +$mindex det_by_lu factor$$ -$index det_by_lu$$ -$index determinant, lu factor$$ -$index lu, factor determinant$$ -$index factor, lu determinant$$ $head Syntax$$ $codei%# include @@ -44,10 +41,10 @@ $head Inclusion$$ The template class $code det_by_lu$$ is defined in the $code CppAD$$ -namespace by including +namespace by including the file $code cppad/speed/det_by_lu.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -56,7 +53,7 @@ $codei% det_by_lu<%Scalar%> %det%(%n%) %$$ -constructs the object $icode det$$ which can be used for +constructs the object $icode det$$ which can be used for evaluating the determinant of $icode n$$ by $icode n$$ matrices using LU factorization. @@ -98,7 +95,7 @@ %$$ $head Vector$$ -If $icode y$$ is a $icode Vector$$ object, +If $icode y$$ is a $icode Vector$$ object, it must support the syntax $codei% %y%[%i%] @@ -116,13 +113,13 @@ $head Example$$ The file -$cref det_by_lu.cpp$$ +$cref det_by_lu.cpp$$ contains an example and test of $code det_by_lu.hpp$$. It returns true if it succeeds and false otherwise. $head Source Code$$ The file -$cref det_by_lu.hpp$$ +$cref det_by_lu.hpp$$ contains the source for this template function. @@ -136,7 +133,7 @@ // BEGIN CppAD namespace namespace CppAD { -// The AD complex case is used by examples by not used by speed tests +// The AD complex case is used by examples by not used by speed tests // Must define a specializatgion of LeqZero,AbsGeq for the ADComplex case typedef std::complex Complex; typedef CppAD::AD ADComplex; @@ -168,13 +165,13 @@ // copy matrix so it is not overwritten for(i = 0; i < n_ * n_; i++) A_[i] = x[i]; - + // comput log determinant signdet = CppAD::LuSolve( n_, m_, A_, B_, X_, logdet); /* - // Do not do this for speed test because it makes floating + // Do not do this for speed test because it makes floating // point operation sequence very simple. if( signdet == 0 ) det = 0; @@ -182,7 +179,7 @@ */ // convert to determinant - det = Scalar( signdet ) * exp( logdet ); + det = Scalar( signdet ) * exp( logdet ); # ifdef FADBAD // Fadbad requires tempories to be set to constants diff -Nru cppad-2015.00.00.9/cppad/speed/det_by_minor.hpp cppad-2016.00.00.1/cppad/speed/det_by_minor.hpp --- cppad-2015.00.00.9/cppad/speed/det_by_minor.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/det_by_minor.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: det_by_minor.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_DET_BY_MINOR_INCLUDED -# define CPPAD_DET_BY_MINOR_INCLUDED +// $Id: det_by_minor.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DET_BY_MINOR_HPP +# define CPPAD_DET_BY_MINOR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,9 +26,6 @@ $section Determinant Using Expansion by Minors$$ -$index determinant, minor expansion$$ -$index minor, expansion determinant$$ -$index expansion, minor determinant$$ $head Syntax$$ @@ -41,10 +38,10 @@ $head Inclusion$$ The template class $code det_by_minor$$ is defined in the $code CppAD$$ -namespace by including +namespace by including the file $code cppad/speed/det_by_minor.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -53,7 +50,7 @@ $codei% det_by_minor<%Scalar%> %det%(%n%) %$$ -constructs the object $icode det$$ which can be used for +constructs the object $icode det$$ which can be used for evaluating the determinant of $icode n$$ by $icode n$$ matrices using expansion by minors. @@ -95,7 +92,7 @@ It is equal to the determinant of $latex A$$. $head Vector$$ -If $icode y$$ is a $icode Vector$$ object, +If $icode y$$ is a $icode Vector$$ object, it must support the syntax $codei% %y%[%i%] @@ -113,13 +110,13 @@ $head Example$$ The file -$cref det_by_minor.cpp$$ +$cref det_by_minor.cpp$$ contains an example and test of $code det_by_minor.hpp$$. It returns true if it succeeds and false otherwise. $head Source Code$$ The file -$cref det_by_minor.hpp$$ +$cref det_by_minor.hpp$$ contains the source for this template function. @@ -163,7 +160,7 @@ { size_t i = m_ * m_; while(i--) a_[i] = x[i]; - return det_of_minor(a_, m_, m_, r_, c_); + return det_of_minor(a_, m_, m_, r_, c_); } }; diff -Nru cppad-2015.00.00.9/cppad/speed/det_grad_33.hpp cppad-2016.00.00.1/cppad/speed/det_grad_33.hpp --- cppad-2015.00.00.9/cppad/speed/det_grad_33.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/det_grad_33.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: det_grad_33.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_DET_GRAD_33_INCLUDED -# define CPPAD_DET_GRAD_33_INCLUDED +// $Id: det_grad_33.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DET_GRAD_33_HPP +# define CPPAD_DET_GRAD_33_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,12 +24,9 @@ bool $$ -$section Check Gradient of Determinant of 3 by 3 matrix$$ +$section Check Gradient of Determinant of 3 by 3 matrix$$ +$mindex det_grad_33 correct$$ -$index det_grad_33$$ -$index determinant, check correct$$ -$index correct, determinant check$$ -$index check, determinant correct$$ $head Syntax$$ $codei%# include @@ -37,15 +34,15 @@ $icode%ok% = det_grad_33(%x%, %g%)%$$ $head Purpose$$ -This routine can be used to check a method for computing the +This routine can be used to check a method for computing the gradient of the determinant of a matrix. $head Inclusion$$ The template function $code det_grad_33$$ is defined in the $code CppAD$$ -namespace by including -the file $code cppad/speed/det_grad_33.hpp$$ +namespace by including +the file $code cppad/speed/det_grad_33.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -71,7 +68,7 @@ \] $$ $head Vector$$ -If $icode y$$ is a $icode Vector$$ object, +If $icode y$$ is a $icode Vector$$ object, it must support the syntax $codei% %y%[%i%] @@ -86,7 +83,7 @@ $codei% bool %ok% %$$ -It is true, if the gradient $icode g$$ +It is true, if the gradient $icode g$$ passes the test and false otherwise. $children% @@ -94,7 +91,7 @@ %$$ $head Source Code$$ -The file +The file $cref det_grad_33.hpp$$ contains the source code for this template function. @@ -102,12 +99,15 @@ ------------------------------------------------------------------------------ */ // BEGIN C++ -# include +# include +# include namespace CppAD { template bool det_grad_33(const Vector &x, const Vector &g) { bool ok = true; - + typedef typename Vector::value_type Float; + Float eps = 10. * Float( std::numeric_limits::epsilon() ); + // use expansion by minors to compute the derivative by hand double check[9]; check[0] = + ( x[4] * x[8] - x[5] * x[7] ); @@ -120,12 +120,11 @@ // check[6] = + ( x[1] * x[5] - x[2] * x[4] ); check[7] = - ( x[0] * x[5] - x[2] * x[3] ); - check[8] = + ( x[0] * x[4] - x[1] * x[3] ); + check[8] = + ( x[0] * x[4] - x[1] * x[3] ); // - size_t i; - for(i = 0; i < 3 * 3; i++) - ok &= CppAD::NearEqual(check[i], g[i], 1e-10, 1e-10); - + for(size_t i = 0; i < 3 * 3; i++) + ok &= CppAD::NearEqual(check[i], g[i], eps, eps); + return ok; } } diff -Nru cppad-2015.00.00.9/cppad/speed/det_of_minor.hpp cppad-2016.00.00.1/cppad/speed/det_of_minor.hpp --- cppad-2015.00.00.9/cppad/speed/det_of_minor.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/det_of_minor.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: det_of_minor.hpp 3060 2013-12-27 20:38:57Z bradbell $ */ -# ifndef CPPAD_DET_OF_MINOR_INCLUDED -# define CPPAD_DET_OF_MINOR_INCLUDED +// $Id: det_of_minor.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_DET_OF_MINOR_HPP +# define CPPAD_DET_OF_MINOR_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,25 +24,22 @@ namespace $$ -$index det_of_minor$$ -$index determinant, matrix minor$$ -$index matrix, minor determinant$$ -$index minor, matrix determinant$$ $section Determinant of a Minor$$ +$mindex det_of_minor matrix$$ $head Syntax$$ $codei%# include -%$$ -$icode%d% = det_of_minor(%a%, %m%, %n%, %r%, %c%)%$$ +%$$ +$icode%d% = det_of_minor(%a%, %m%, %n%, %r%, %c%)%$$ $head Inclusion$$ The template function $code det_of_minor$$ is defined in the $code CppAD$$ -namespace by including -the file $code cppad/speed/det_of_minor.hpp$$ +namespace by including +the file $code cppad/speed/det_of_minor.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -50,13 +47,13 @@ This template function returns the determinant of a minor of the matrix $latex A$$ using expansion by minors. -The elements of the $latex n \times n$$ minor $latex M$$ +The elements of the $latex n \times n$$ minor $latex M$$ of the matrix $latex A$$ are defined, for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , n-1$$, by $latex \[ M_{i,j} = A_{R(i), C(j)} \]$$ -where the functions +where the functions $latex R(i)$$ is defined by the $cref/argument r/det_of_minor/r/$$ and $latex C(j)$$ is defined by the $cref/argument c/det_of_minor/c/$$. $pre @@ -66,7 +63,7 @@ is for example and testing purposes only. Expansion by minors is chosen as an example because it uses a lot of floating point operations yet does not require much source code -(on the order of $icode m$$ factorial floating point operations and +(on the order of $icode m$$ factorial floating point operations and about 70 lines of source code including comments). This is not an efficient method for computing a determinant; for example, using an LU factorization would be better. @@ -79,7 +76,7 @@ $list number$$ $latex n = m$$. $lnext -for $latex i = 0 , \ldots , m-1$$, $latex r[i] = i+1$$, +for $latex i = 0 , \ldots , m-1$$, $latex r[i] = i+1$$, and $latex r[m] = 0$$. $lnext for $latex j = 0 , \ldots , m-1$$, $latex c[j] = j+1$$, @@ -90,7 +87,7 @@ The argument $icode a$$ has prototype $codei% const std::vector<%Scalar%>& %a% -%$$ +%$$ and is a vector with size $latex m * m$$ (see description of $cref/Scalar/det_of_minor/Scalar/$$ below). The elements of the $latex m \times m$$ matrix $latex A$$ are defined, @@ -119,10 +116,10 @@ std::vector& %r% %$$ and is a vector with $latex m + 1$$ elements. -This vector defines the function $latex R(i)$$ +This vector defines the function $latex R(i)$$ which specifies the rows of the minor $latex M$$. -To be specific, the function $latex R(i)$$ -for $latex i = 0, \ldots , n-1$$ is defined by +To be specific, the function $latex R(i)$$ +for $latex i = 0, \ldots , n-1$$ is defined by $latex \[ \begin{array}{rcl} R(0) & = & r[m] @@ -132,7 +129,7 @@ \] $$ All the elements of $icode r$$ must have value less than or equal $icode m$$. -The elements of vector $icode r$$ are modified during the computation, +The elements of vector $icode r$$ are modified during the computation, and restored to their original value before the return from $code det_of_minor$$. @@ -142,10 +139,10 @@ std::vector& %c% %$$ and is a vector with $latex m + 1$$ elements -This vector defines the function $latex C(i)$$ +This vector defines the function $latex C(i)$$ which specifies the rows of the minor $latex M$$. -To be specific, the function $latex C(i)$$ -for $latex j = 0, \ldots , n-1$$ is defined by +To be specific, the function $latex C(i)$$ +for $latex j = 0, \ldots , n-1$$ is defined by $latex \[ \begin{array}{rcl} C(0) & = & c[m] @@ -155,7 +152,7 @@ \] $$ All the elements of $icode c$$ must have value less than or equal $icode m$$. -The elements of vector $icode c$$ are modified during the computation, +The elements of vector $icode c$$ are modified during the computation, and restored to their original value before the return from $code det_of_minor$$. @@ -171,7 +168,7 @@ and $icode i$$ is an object of type $code int$$, the $icode Scalar$$ must support the following operations: $table -$bold Syntax$$ +$bold Syntax$$ $cnext $bold Description$$ $cnext $bold Result Type$$ $rnext @@ -204,13 +201,13 @@ $head Example$$ The file -$cref det_of_minor.cpp$$ +$cref det_of_minor.cpp$$ contains an example and test of $code det_of_minor.hpp$$. It returns true if it succeeds and false otherwise. $head Source Code$$ The file -$cref det_of_minor.hpp$$ +$cref det_of_minor.hpp$$ contains the source for this template function. @@ -219,14 +216,14 @@ */ // BEGIN C++ namespace CppAD { // BEGIN CppAD namespace -template -Scalar det_of_minor( - const std::vector& a , - size_t m , - size_t n , - std::vector& r , +template +Scalar det_of_minor( + const std::vector& a , + size_t m , + size_t n , + std::vector& r , std::vector& c ) -{ +{ const size_t R0 = r[m]; // R(0) size_t Cj = c[m]; // C(j) (case j = 0) size_t Cj1 = m; // C(j-1) (case j = 0) @@ -265,7 +262,7 @@ // advance to next column of M Cj1 = Cj; Cj = c[Cj]; - s = - s; + s = - s; } // restore row zero to the minor representation for M diff -Nru cppad-2015.00.00.9/cppad/speed/mat_sum_sq.hpp cppad-2016.00.00.1/cppad/speed/mat_sum_sq.hpp --- cppad-2015.00.00.9/cppad/speed/mat_sum_sq.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/mat_sum_sq.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: mat_sum_sq.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_MAT_SUM_SQ_INCLUDED -# define CPPAD_MAT_SUM_SQ_INCLUDED +// $Id: mat_sum_sq.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_MAT_SUM_SQ_HPP +# define CPPAD_MAT_SUM_SQ_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,11 +24,7 @@ $$ $section Sum Elements of a Matrix Times Itself$$ -$index mat_sum_sq$$ -$index matrix, multiply speed test$$ -$index speed, matrix multiply test$$ -$index multiply, matrix speed test$$ -$index test, matrix multiply speed$$ +$mindex mat_sum_sq multiply speed test$$ $head Syntax$$ $codei%# include @@ -49,10 +45,10 @@ $head Inclusion$$ The template function $code mat_sum_sq$$ is defined in the $code CppAD$$ -namespace by including -the file $code cppad/speed/mat_sum_sq.hpp$$ +namespace by including +the file $code cppad/speed/mat_sum_sq.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -110,7 +106,7 @@ The type $icode Vector$$ is any $cref SimpleVector$$, or it can be a raw pointer to the vector elements. The element type must support -addition, multiplication, and assignment to both its own type +addition, multiplication, and assignment to both its own type and to a double value. $children% @@ -121,13 +117,13 @@ $head Example$$ The file -$cref mat_sum_sq.cpp$$ +$cref mat_sum_sq.cpp$$ contains an example and test of $code mat_sum_sq.hpp$$. It returns true if it succeeds and false otherwise. $head Source Code$$ The file -$cref mat_sum_sq.hpp$$ +$cref mat_sum_sq.hpp$$ contains the source for this template function. $end diff -Nru cppad-2015.00.00.9/cppad/speed/ode_evaluate.hpp cppad-2016.00.00.1/cppad/speed/ode_evaluate.hpp --- cppad-2015.00.00.9/cppad/speed/ode_evaluate.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/ode_evaluate.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ode_evaluate.hpp 2859 2013-05-28 06:03:21Z bradbell $ */ -# ifndef CPPAD_ODE_EVALUATE_INCLUDED -# define CPPAD_ODE_EVALUATE_INCLUDED +// $Id: ode_evaluate.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ODE_EVALUATE_HPP +# define CPPAD_ODE_EVALUATE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,16 +23,15 @@ const Cpp cppad - hpp + hpp fp namespace exp $$ $section Evaluate a Function Defined in Terms of an ODE$$ +$mindex ode_evaluate$$ -$index ode_evaluate, function$$ -$index function, ode_evaluate$$ $head Syntax$$ $codei%# include @@ -41,7 +40,7 @@ $head Purpose$$ This routine evaluates a function $latex f : \B{R}^n \rightarrow \B{R}^n$$ -defined by +defined by $latex \[ f(x) = y(x, 1) \] $$ @@ -57,11 +56,11 @@ is an unspecified function. $head Inclusion$$ -The template function $code ode_evaluate$$ -is defined in the $code CppAD$$ namespace by including -the file $code cppad/speed/ode_evaluate.hpp$$ +The template function $code ode_evaluate$$ +is defined in the $code CppAD$$ namespace by including +the file $code cppad/speed/ode_evaluate.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -69,10 +68,10 @@ $subhead Operation Sequence$$ The type $icode Float$$ must be a $cref NumericType$$. -The $icode Float$$ +The $icode Float$$ $cref/operation sequence/glossary/Operation/Sequence/$$ for this routine does not depend on the value of the argument $icode x$$, -hence it does not need to be retaped for each value of $latex x$$. +hence it does not need to be retaped for each value of $latex x$$. $subhead fabs$$ If $icode y$$ and $icode z$$ are $icode Float$$ objects, the syntax @@ -80,7 +79,7 @@ %y% = fabs(%z%) %$$ must be supported. Note that it does not matter if the operation -sequence for $code fabs$$ depends on $icode z$$ because the +sequence for $code fabs$$ depends on $icode z$$ because the corresponding results are not actually used by $code ode_evaluate$$; see $code fabs$$ in $cref/Runge45/Runge45/Scalar/fabs/$$. @@ -100,7 +99,7 @@ %$$ $subhead p == 0$$ -In this case a numerical method is used to solve the ode +In this case a numerical method is used to solve the ode and obtain an accurate approximation for $latex y(x, 1)$$. This numerical method has a fixed that does not depend on $icode x$$. @@ -121,7 +120,7 @@ and contains the value of $latex y(x, 1)$$. $subhead Gradient$$ -If $icode p$$ is one, $icode fp$$ has size equal to $icode n^2$$ +If $icode p$$ is one, $icode fp$$ has size equal to $icode n^2$$ and for $latex i = 0 , \ldots and n-1$$, $latex j = 0 , \ldots , n-1$$ $latex \[ \D{y[i]}{x[j]} (x, 1) = fp [ i \cdot n + j ] @@ -140,34 +139,34 @@ $head Source Code$$ -The file +The file $cref ode_evaluate.hpp$$ contains the source code for this template function. $end */ // BEGIN C++ -# include -# include -# include +# include +# include +# include -namespace CppAD { +namespace CppAD { template class ode_evaluate_fun { public: - // Given that y_i (0) = x_i, + // Given that y_i (0) = x_i, // the following y_i (t) satisfy the ODE below: // y_0 (t) = x[0] - // y_1 (t) = x[1] + x[0] * t + // y_1 (t) = x[1] + x[0] * t // y_2 (t) = x[2] + x[1] * t + x[0] * t^2/2 // y_3 (t) = x[3] + x[2] * t + x[1] * t^2/2 + x[0] * t^3 / 3! // ... void Ode( - const Float& t, - const CppAD::vector& y, + const Float& t, + const CppAD::vector& y, CppAD::vector& f) - { size_t n = y.size(); + { size_t n = y.size(); f[0] = 0.; for(size_t k = 1; k < n; k++) f[k] = y[k-1]; @@ -176,8 +175,8 @@ // template void ode_evaluate( - const CppAD::vector& x , - size_t p , + const CppAD::vector& x , + size_t p , CppAD::vector& fp ) { using CppAD::vector; typedef vector VectorFloat; @@ -186,7 +185,7 @@ CPPAD_ASSERT_KNOWN( p == 0 || p == 1, "ode_evaluate: p is not zero or one" ); - CPPAD_ASSERT_KNOWN( + CPPAD_ASSERT_KNOWN( ((p==0) & (fp.size()==n)) || ((p==1) & (fp.size()==n*n)), "ode_evaluate: the size of fp is not correct" ); @@ -208,7 +207,7 @@ // final value for y(x, t); i.e., y(x, 1) // (is a reference to fp) VectorFloat& yf = fp; - + // Use fourth order Runge-Kutta to solve ODE yf = CppAD::Runge45(F, M, ti, tf, yi); @@ -216,7 +215,7 @@ } /* Compute derivaitve of y(x, 1) w.r.t x y_0 (x, t) = x[0] - y_1 (x, t) = x[1] + x[0] * t + y_1 (x, t) = x[1] + x[0] * t y_2 (x, t) = x[2] + x[1] * t + x[0] * t^2/2 y_3 (x, t) = x[3] + x[2] * t + x[1] * t^2/2 + x[0] * t^3 / 3! ... @@ -229,7 +228,7 @@ size_t factorial = 1; for(k = 0; k < n; k++) { if( k > 1 ) - factorial *= k; + factorial *= k; for(i = k; i < n; i++) { // partial w.r.t x[i-k] of x[i-k] * t^k / k! j = i - k; diff -Nru cppad-2015.00.00.9/cppad/speed/sparse_hes_fun.hpp cppad-2016.00.00.1/cppad/speed/sparse_hes_fun.hpp --- cppad-2015.00.00.9/cppad/speed/sparse_hes_fun.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/sparse_hes_fun.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sparse_hes_fun.hpp 2859 2013-05-28 06:03:21Z bradbell $ */ -# ifndef CPPAD_SPARSE_HES_FUN_INCLUDED -# define CPPAD_SPARSE_HES_FUN_INCLUDED +// $Id: sparse_hes_fun.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_HES_FUN_HPP +# define CPPAD_SPARSE_HES_FUN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,10 +27,9 @@ arg $$ -$section Evaluate a Function That Has a Sparse Hessian$$ +$section Evaluate a Function That Has a Sparse Hessian$$ +$mindex sparse_hes_fun$$ -$index sparse_hes_fun, function$$ -$index function, sparse_hes_fun$$ $head Syntax$$ $codei%# include @@ -41,9 +40,9 @@ This routine evaluates $latex f(x)$$, $latex f^{(1)} (x)$$, or $latex f^{(2)} (x)$$ where the Hessian $latex f^{(2)} (x)$$ is sparse. -The function $latex f : \B{R}^n \rightarrow \B{R}$$ only depends on the -size and contents of the index vectors $icode row$$ and $icode col$$. -The non-zero entries in the Hessian of this function have +The function $latex f : \B{R}^n \rightarrow \B{R}$$ only depends on the +size and contents of the index vectors $icode row$$ and $icode col$$. +The non-zero entries in the Hessian of this function have one of the following forms: $latex \[ \DD{f}{x[row[k]]}{x[row[k]]} @@ -58,11 +57,11 @@ All the other terms of the Hessian are zero. $head Inclusion$$ -The template function $code sparse_hes_fun$$ -is defined in the $code CppAD$$ namespace by including -the file $code cppad/speed/sparse_hes_fun.hpp$$ +The template function $code sparse_hes_fun$$ +is defined in the $code CppAD$$ namespace by including +the file $code cppad/speed/sparse_hes_fun.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -71,13 +70,13 @@ In addition, if $icode y$$ and $icode z$$ are $icode Float$$ objects, $codei% %y% = exp(%z%) -%$$ +%$$ must set the $icode y$$ equal the exponential of $icode z$$, i.e., the derivative of $icode y$$ with respect to $icode z$$ is equal to $icode y$$. $head FloatVector$$ The type $icode FloatVector$$ is any -$cref SimpleVector$$, or it can be a raw pointer, +$cref SimpleVector$$, or it can be a raw pointer, with elements of type $icode Float$$. $head n$$ @@ -101,7 +100,7 @@ $codei% const CppAD::vector& %row% %$$ -It specifies one of the first +It specifies one of the first index of $latex x$$ for each non-zero Hessian term (see $cref/purpose/sparse_hes_fun/Purpose/$$ above). All the elements of $icode row$$ must be between zero and $icode%n%-1%$$. @@ -113,16 +112,21 @@ const CppAD::vector& %col% %$$ and its size must be $latex K$$; i.e., the same as for $icode col$$. -It specifies the second +It specifies the second index of $latex x$$ for the non-zero Hessian terms. All the elements of $icode col$$ must be between zero and $icode%n%-1%$$. +There are no duplicated entries requested, to be specific, +if $icode%k1% != %k2%$$ then +$codei% + ( %row%[%k1%] , %col%[%k1%] ) != ( %row%[%k2%] , %col%[%k2%] ) +%$$ $head p$$ The argument $icode p$$ has prototype $codei% size_t %p% %$$ -It is between zero and two and +It is either zero or two and specifies the order of the derivative of $latex f$$ that is being evaluated, i.e., $latex f^{(p)} (x)$$ is evaluated. @@ -137,19 +141,11 @@ If $icode p$$ is zero, $icode fp$$ has size one and $icode%fp%[0]%$$ is the value of $latex f(x)$$. -$subhead Gradient$$ -If $icode p$$ is one, $icode fp$$ has size $icode n$$ and -for $latex j = 0 , \ldots , n-1$$ -$latex \[ - \D{f}{x[j]} = fp [ j ] -\] $$ - $subhead Hessian$$ -If $icode p$$ is two, $icode fp$$ has size $icode%n% * %n%$$ and -for $latex i = 0 , \ldots , n-1$$, -$latex j = 0 , \ldots , n-1$$ +If $icode p$$ is two, $icode fp$$ has size $icode K$$ and +for $latex k = 0 , \ldots , K-1$$, $latex \[ - \DD{f}{x[i]}{x[j]} = fp [ i * n + j ] + \DD{f}{ x[ \R{row}[k] ] }{ x[ \R{col}[k] ]} = fp [k] \] $$ $children% @@ -164,7 +160,7 @@ It returns true if it succeeds and false otherwise. $head Source Code$$ -The file +The file $cref sparse_hes_fun.hpp$$ contains the source code for this template function. @@ -173,19 +169,19 @@ */ // BEGIN C++ # include -# include -# include +# include +# include // following needed by gcc under fedora 17 so that exp(double) is defined -# include +# include namespace CppAD { template void sparse_hes_fun( size_t n , const FloatVector& x , - const CppAD::vector& row , - const CppAD::vector& col , + const CppAD::vector& row , + const CppAD::vector& col , size_t p , FloatVector& fp ) { @@ -194,48 +190,78 @@ // check value of p CPPAD_ASSERT_KNOWN( - p < 3, - "sparse_hes_fun: p > 2" + p == 0 || p == 2, + "sparse_hes_fun: p != 0 and p != 2" ); + size_t K = row.size(); size_t i, j, k; - size_t size = 1; - for(k = 0; k < p; k++) - size *= n; - for(k = 0; k < size; k++) - fp[k] = Float(0); + if( p == 0 ) + fp[0] = Float(0); + else + { for(k = 0; k < K; k++) + fp[k] = Float(0); + } + + // determine which diagonal entries are present in row[k], col[k] + CppAD::vector diagonal(n); + for(i = 0; i < n; i++) + diagonal[i] = K; // no diagonal entry for this row + for(k = 0; k < K; k++) + { if( row[k] == col[k] ) + { CPPAD_ASSERT_UNKNOWN( diagonal[row[k]] == K ); + // index of the diagonal entry + diagonal[ row[k] ] = k; + } + } + + // determine which entries must be multiplied by a factor of two + CppAD::vector factor(K); + for(k = 0; k < K; k++) + { factor[k] = Float(1); + for(size_t k1 = 0; k1 < K; k1++) + { bool reflected = true; + reflected &= k != k1; + reflected &= row[k] != col[k]; + reflected &= row[k] == col[k1]; + reflected &= col[k] == row[k1]; + if( reflected ) + factor[k] = Float(2); + } + } - size_t K = row.size(); Float t; - Float dt_i; - Float dt_j; for(k = 0; k < K; k++) { i = row[k]; j = col[k]; - t = exp( x[i] * x[j] ); - dt_i = t * x[j]; - dt_j = t * x[i]; + t = exp( x[i] * x[j] ); switch(p) { case 0: fp[0] += t; break; - case 1: - fp[i] += dt_i; - fp[j] += dt_j; - break; - case 2: - fp[i * n + i] += dt_i * x[j]; - fp[i * n + j] += t + dt_j * x[j]; - // - fp[j * n + i] += t + dt_i * x[i]; - fp[j * n + j] += dt_j * x[i]; + if( i == j ) + { // dt_dxi = 2.0 * xi * t + fp[k] += ( Float(2) + Float(4) * x[i] * x[i] ) * t; + } + else + { // dt_dxi = xj * t + fp[k] += factor[k] * ( Float(1) + x[i] * x[j] ) * t; + if( diagonal[i] != K ) + { size_t ki = diagonal[i]; + fp[ki] += x[j] * x[j] * t; + } + if( diagonal[j] != K ) + { size_t kj = diagonal[j]; + fp[kj] += x[i] * x[i] * t; + } + } break; } } - + } } // END C++ diff -Nru cppad-2015.00.00.9/cppad/speed/sparse_jac_fun.hpp cppad-2016.00.00.1/cppad/speed/sparse_jac_fun.hpp --- cppad-2015.00.00.9/cppad/speed/sparse_jac_fun.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/sparse_jac_fun.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: sparse_jac_fun.hpp 2859 2013-05-28 06:03:21Z bradbell $ */ -# ifndef CPPAD_SPARSE_JAC_FUN_INCLUDED -# define CPPAD_SPARSE_JAC_FUN_INCLUDED +// $Id: sparse_jac_fun.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_JAC_FUN_HPP +# define CPPAD_SPARSE_JAC_FUN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,10 +28,9 @@ arg $$ -$section Evaluate a Function That Has a Sparse Jacobian$$ +$section Evaluate a Function That Has a Sparse Jacobian$$ +$mindex sparse_jac_fun$$ -$index sparse_jac_fun, function$$ -$index function, sparse_jac_fun$$ $head Syntax$$ $codei%# include @@ -42,9 +41,9 @@ This routine evaluates $latex f(x)$$ and $latex f^{(1)} (x)$$ where the Jacobian $latex f^{(1)} (x)$$ is sparse. -The function $latex f : \B{R}^n \rightarrow \B{R}^m$$ only depends on the -size and contents of the index vectors $icode row$$ and $icode col$$. -The non-zero entries in the Jacobian of this function have +The function $latex f : \B{R}^n \rightarrow \B{R}^m$$ only depends on the +size and contents of the index vectors $icode row$$ and $icode col$$. +The non-zero entries in the Jacobian of this function have one of the following forms: $latex \[ \D{ f[row[k]]}{x[col[k]]} @@ -53,11 +52,11 @@ All the other terms of the Jacobian are zero. $head Inclusion$$ -The template function $code sparse_jac_fun$$ -is defined in the $code CppAD$$ namespace by including -the file $code cppad/speed/sparse_jac_fun.hpp$$ +The template function $code sparse_jac_fun$$ +is defined in the $code CppAD$$ namespace by including +the file $code cppad/speed/sparse_jac_fun.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -66,13 +65,13 @@ In addition, if $icode y$$ and $icode z$$ are $icode Float$$ objects, $codei% %y% = exp(%z%) -%$$ +%$$ must set the $icode y$$ equal the exponential of $icode z$$, i.e., the derivative of $icode y$$ with respect to $icode z$$ is equal to $icode y$$. $head FloatVector$$ The type $icode FloatVector$$ is any -$cref SimpleVector$$, or it can be a raw pointer, +$cref SimpleVector$$, or it can be a raw pointer, with elements of type $icode Float$$. $head n$$ @@ -115,7 +114,7 @@ const CppAD::vector& %col% %$$ and its size must be $latex K$$; i.e., the same as for $icode col$$. -It specifies the component of $latex x$$ for +It specifies the component of $latex x$$ for the non-zero Jacobian terms. All the elements of $icode col$$ must be between zero and $icode%n%-1%$$. @@ -133,6 +132,8 @@ $codei% %FloatVector%& %fp% %$$ +If $icode%p% = 0%$$, it size is $icode m$$ +otherwise its size is $icode K$$. The input value of the elements of $icode fp$$ does not matter. $subhead Function$$ @@ -140,11 +141,10 @@ $codei%(%fp%[0]%, ... , %fp%[%m%-1])%$$ is the value of $latex f(x)$$. $subhead Jacobian$$ -If $icode p$$ is one, $icode fp$$ has size $icode%m% * %n%$$ and -for $latex i = 0 , \ldots , m-1$$, -$latex j = 0 , \ldots , n-1$$ +If $icode p$$ is one, $icode fp$$ has size $icode K$$ and +for $latex k = 0 , \ldots , K-1$$, $latex \[ - \D{f[i]}{x[j]} = fp [ i * n + j ] + \D{f[ \R{row}[i] ]}{x[ \R{col}[j] ]} = fp [k] \] $$ $children% @@ -159,7 +159,7 @@ It returns true if it succeeds and false otherwise. $head Source Code$$ -The file +The file $cref sparse_jac_fun.hpp$$ contains the source code for this template function. @@ -168,11 +168,11 @@ */ // BEGIN C++ # include -# include -# include +# include +# include // following needed by gcc under fedora 17 so that exp(double) is defined -# include +# include namespace CppAD { template @@ -180,8 +180,8 @@ size_t m , size_t n , const FloatVector& x , - const CppAD::vector& row , - const CppAD::vector& col , + const CppAD::vector& row , + const CppAD::vector& col , size_t p , FloatVector& fp ) { @@ -189,22 +189,25 @@ CheckNumericType(); // check value of p CPPAD_ASSERT_KNOWN( - p < 2, - "sparse_jac_fun: p > 1" + p == 0 || p == 1, + "sparse_jac_fun: p != 0 and p != 1" + ); + size_t K = row.size(); + CPPAD_ASSERT_KNOWN( + K >= m, + "sparse_jac_fun: row.size() < m" ); size_t i, j, k; - size_t size = m; - if( p > 0 ) - size *= n; - for(k = 0; k < size; k++) - fp[k] = Float(0); - size_t K = row.size(); + if( p == 0 ) + for(i = 0; i < m; i++) + fp[i] = Float(0); + Float t; for(k = 0; k < K; k++) { i = row[k]; j = col[k]; - t = exp( x[j] * x[j] / 2.0 ); + t = exp( x[j] * x[j] / 2.0 ); switch(p) { case 0: @@ -212,7 +215,7 @@ break; case 1: - fp[i * n + j] += t * x[j]; + fp[k] = t * x[j]; break; } } diff -Nru cppad-2015.00.00.9/cppad/speed/uniform_01.hpp cppad-2016.00.00.1/cppad/speed/uniform_01.hpp --- cppad-2015.00.00.9/cppad/speed/uniform_01.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed/uniform_01.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: uniform_01.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_UNIFORM_01_INCLUDED -# define CPPAD_UNIFORM_01_INCLUDED +// $Id: uniform_01.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_UNIFORM_01_HPP +# define CPPAD_UNIFORM_01_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,12 +20,9 @@ namespace $$ -$section Simulate a [0,1] Uniform Random Variate$$ +$section Simulate a [0,1] Uniform Random Variate$$ +$mindex uniform_01$$ -$index uniform_01$$ -$index random, uniform vector$$ -$index uniform, random vector$$ -$index vector, uniform random$$ $head Syntax$$ $codei%# include @@ -39,10 +36,10 @@ $head Inclusion$$ The template function $code uniform_01$$ is defined in the $code CppAD$$ -namespace by including -the file $code cppad/speed/uniform_01.hpp$$ +namespace by including +the file $code cppad/speed/uniform_01.hpp$$ (relative to the CppAD distribution directory). -It is only intended for example and testing purposes, +It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. @@ -85,7 +82,7 @@ %$$ $head Source Code$$ -The file +The file $cref uniform_01.hpp$$ constraints the source code for this template function. diff -Nru cppad-2015.00.00.9/cppad/SpeedTest.h cppad-2016.00.00.1/cppad/SpeedTest.h --- cppad-2015.00.00.9/cppad/SpeedTest.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/SpeedTest.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: SpeedTest.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/speed_test.hpp" diff -Nru cppad-2015.00.00.9/cppad/speed_test.hpp cppad-2016.00.00.1/cppad/speed_test.hpp --- cppad-2015.00.00.9/cppad/speed_test.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/speed_test.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,474 +0,0 @@ -/* $Id: speed_test.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_SPEED_TEST_INCLUDED -# define CPPAD_SPEED_TEST_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin speed_test$$ -$spell - gettimeofday - vec - cppad.hpp - Microsoft - namespace - std - const - cout - ctime - ifdef - const - endif - cpp -$$ - -$index speed_test$$ -$index test, speed$$ - -$section Run One Speed Test and Return Results$$ - -$head Syntax$$ -$code # include $$ -$pre -$$ -$icode%rate_vec% = speed_test(%test%, %size_vec%, %time_min%)%$$ - -$head Purpose$$ -The $code speed_test$$ function executes a speed test -for various sized problems -and reports the rate of execution. - -$head Motivation$$ -It is important to separate small calculation units -and test them individually. -This way individual changes can be tested in the context of the -routine that they are in. -On many machines, accurate timing of a very short execution -sequences is not possible. -In addition, -there may be set up and tear down time for a test that -we do not really want included in the timing. -For this reason $code speed_test$$ -automatically determines how many times to -repeat the section of the test that we wish to time. - - -$head Include$$ -The file $code cppad/speed_test.hpp$$ defines the -$code speed_test$$ function. -This file is included by $code cppad/cppad.hpp$$ -and it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Vector$$ -We use $icode Vector$$ to denote a -$cref/simple vector class/SimpleVector/$$ with elements -of type $code size_t$$. - -$head test$$ -The $code speed_test$$ argument $icode test$$ is a function with the syntax -$codei% - %test%(%size%, %repeat%) -%$$ -and its return value is $code void$$. - -$subhead size$$ -The $icode test$$ argument $icode size$$ has prototype -$codei% - size_t %size% -%$$ -It specifies the size for this test. - -$subhead repeat$$ -The $icode test$$ argument $icode repeat$$ has prototype -$codei% - size_t %repeat% -%$$ -It specifies the number of times to repeat the test. - -$head size_vec$$ -The $code speed_test$$ argument $icode size_vec$$ has prototype -$codei% - const %Vector%& %size_vec% -%$$ -This vector determines the size for each of the tests problems. - -$head time_min$$ -The argument $icode time_min$$ has prototype -$codei% - double %time_min% -%$$ -It specifies the minimum amount of time in seconds -that the $icode test$$ routine should take. -The $icode repeat$$ argument to $icode test$$ is increased -until this amount of execution time is reached. - -$head rate_vec$$ -The return value $icode rate_vec$$ has prototype -$codei% - %Vector%& %rate_vec% -%$$ -We use $latex n$$ to denote its size which is the same as -the vector $icode size_vec$$. -For $latex i = 0 , \ldots , n-1$$, -$codei% - %rate_vec%[%i%] -%$$ -is the ratio of $icode repeat$$ divided by time in seconds -for the problem with size $icode%size_vec%[%i%]%$$. - -$head Timing$$ -If your system supports the unix $code gettimeofday$$ function, -it will be used to measure time. -Otherwise, -time is measured by the difference in -$codep - (double) clock() / (double) CLOCKS_PER_SEC -$$ -in the context of the standard $code $$ definitions. - -$children% - speed/example/speed_test.cpp -%$$ -$head Example$$ -The routine $cref speed_test.cpp$$ is an example and test -of $code speed_test$$. - -$end ------------------------------------------------------------------------ -*/ - -# include -# include - -# include -# include - - -namespace CppAD { // BEGIN CppAD namespace - -// implemented as an inline so that can include in multiple link modules -// with this same file -template -inline Vector speed_test( - void test(size_t size, size_t repeat), - const Vector& size_vec , - double time_min ) -{ - // check that size_vec is a simple vector with size_t elements - CheckSimpleVector(); - - size_t n = size_vec.size(); - Vector rate_vec(n); - size_t i; - for(i = 0; i < n; i++) - { size_t size = size_vec[i]; - size_t repeat = 1; - double s0 = elapsed_seconds(); - double s1 = elapsed_seconds(); - while( s1 - s0 < time_min ) - { repeat = 2 * repeat; - s0 = elapsed_seconds(); - test(size, repeat); - s1 = elapsed_seconds(); - } - rate_vec[i] = (size_t)(.5 + repeat / (s1 - s0)); - } - return rate_vec; -} - -} // END CppAD namespace - -/* -$begin SpeedTest$$ -$spell - cppad.hpp - Microsoft - namespace - std - const - cout - ctime - ifdef - const - endif - cpp -$$ - -$index SpeedTest$$ -$index test, speed$$ - -$section Run One Speed Test and Print Results$$ - -$head Syntax$$ - -$code # include $$ -$pre -$$ -$codei%SpeedTest(%Test%, %first%, %inc%, %last%)%$$ - - -$head Purpose$$ -The $code SpeedTest$$ function executes a speed test -for various sized problems -and reports the results on standard output; i.e. $code std::cout$$. -The size of each test problem is included in its report -(unless $icode first$$ is equal to $icode last$$). - -$head Motivation$$ -It is important to separate small calculation units -and test them individually. -This way individual changes can be tested in the context of the -routine that they are in. -On many machines, accurate timing of a very short execution -sequences is not possible. -In addition, -there may be set up time for a test that -we do not really want included in the timing. -For this reason $code SpeedTest$$ -automatically determines how many times to -repeat the section of the test that we wish to time. - - -$head Include$$ -The file $code speed_test.hpp$$ contains the -$code SpeedTest$$ function. -This file is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head Test$$ -The $code SpeedTest$$ argument $icode Test$$ is a function with the syntax -$codei% - %name% = %Test%(%size%, %repeat%) -%$$ - -$subhead size$$ -The $icode Test$$ argument $icode size$$ has prototype -$codei% - size_t %size% -%$$ -It specifies the size for this test. - -$subhead repeat$$ -The $icode Test$$ argument $icode repeat$$ has prototype -$codei% - size_t %repeat% -%$$ -It specifies the number of times to repeat the test. - -$subhead name$$ -The $icode Test$$ result $icode name$$ has prototype -$codei% - std::string %name% -%$$ -The results for this test are reported on $code std::cout$$ -with $icode name$$ as an identifier for the test. -It is assumed that, -for the duration of this call to $code SpeedTest$$, -$icode Test$$ will always return -the same value for $icode name$$. -If $icode name$$ is the empty string, -no test name is reported by $code SpeedTest$$. - -$head first$$ -The $code SpeedTest$$ argument $icode first$$ has prototype -$codei% - size_t %first% -%$$ -It specifies the size of the first test problem reported by this call to -$code SpeedTest$$. - -$head last$$ -The $code SpeedTest$$ argument $icode last$$ has prototype -$codei% - size_t %last% -%$$ -It specifies the size of the last test problem reported by this call to -$code SpeedTest$$. - -$head inc$$ -The $code SpeedTest$$ argument $icode inc$$ has prototype -$codei% - int %inc% -%$$ -It specifies the increment between problem sizes; i.e., -all values of $icode size$$ in calls to $icode Test$$ are given by -$codei% - %size% = %first% + %j% * %inc% -%$$ -where $icode j$$ is a positive integer. -The increment can be positive or negative but it cannot be zero. -The values $icode first$$, $icode last$$ and $icode inc$$ must -satisfy the relation -$latex \[ - inc * ( last - first ) \geq 0 -\] $$ - -$head rate$$ -The value displayed in the $code rate$$ column on $code std::cout$$ -is defined as the value of $icode repeat$$ divided by the -corresponding elapsed execution time in seconds. -The elapsed execution time is measured by the difference in -$codep - (double) clock() / (double) CLOCKS_PER_SEC -$$ -in the context of the standard $code $$ definitions. - - -$head Errors$$ -If one of the restrictions above is violated, -the CppAD error handler is used to report the error. -You can redefine this action using the instructions in -$cref ErrorHandler$$ - -$head Example$$ -$children% - speed/example/speed_program.cpp -%$$ -The program $cref speed_program.cpp$$ is an example usage -of $code SpeedTest$$. - -$end ------------------------------------------------------------------------ -*/ -// BEGIN C++ - - -# include -# include -# include -# include - -namespace CppAD { // BEGIN CppAD namespace - -inline void SpeedTestNdigit(size_t value, size_t &ndigit, size_t &pow10) -{ pow10 = 10; - ndigit = 1; - while( pow10 <= value ) - { pow10 *= 10; - ndigit += 1; - } -} - -// implemented as an inline so that can include in multiple link modules -// with this same file -inline void SpeedTest( - std::string Test(size_t size, size_t repeat), - size_t first, - int inc, - size_t last -) -{ - - using std::cout; - using std::endl; - - size_t size; - size_t repeat; - size_t rate; - size_t digit; - size_t ndigit; - size_t pow10; - size_t maxSize; - size_t maxSizeDigit; - - double s0; - double s1; - - std::string name; - - CPPAD_ASSERT_KNOWN( - inc != 0 && first != 0 && last != 0, - "inc, first, or last is zero in call to SpeedTest" - ); - CPPAD_ASSERT_KNOWN( - (inc > 0 && first <= last) || (inc < 0 && first >= last), - "SpeedTest: increment is positive and first > last or " - "increment is negative and first < last" - ); - - // compute maxSize - maxSize = size = first; - while( (inc > 0 && size <= last) || (inc < 0 && size >= last) ) - { - if( size > maxSize ) - maxSize = size; - - // next size - if( ((int) size) + inc > 0 ) - size += inc; - else size = 0; - } - SpeedTestNdigit(maxSize, maxSizeDigit, pow10); - - size = first; - while( (inc > 0 && size <= last) || (inc < 0 && size >= last) ) - { - repeat = 1; - s0 = elapsed_seconds(); - s1 = elapsed_seconds(); - while( s1 - s0 < 1. ) - { repeat = 2 * repeat; - s0 = elapsed_seconds(); - name = Test(size, repeat); - s1 = elapsed_seconds(); - } - rate = (size_t)(.5 + repeat / (s1 - s0)); - - - if( size == first && name != "" ) - cout << name << endl; - - if( first != last ) - { - // convert int(size_t) to avoid warning on _MSC_VER sys - std::cout << "size = " << int(size); - - SpeedTestNdigit(size, ndigit, pow10); - while( ndigit < maxSizeDigit ) - { cout << " "; - ndigit++; - } - cout << " "; - } - - cout << "rate = "; - SpeedTestNdigit(rate, ndigit, pow10); - while( ndigit > 0 ) - { - pow10 /= 10; - digit = rate / pow10; - - // convert int(size_t) to avoid warning on _MSC_VER sys - std::cout << int(digit); - - rate = rate % pow10; - ndigit -= 1; - - if( (ndigit > 0) && (ndigit % 3 == 0) ) - cout << ","; - } - cout << endl; - - // next size - if( ((int) size) + inc > 0 ) - size += inc; - else size = 0; - } - return; -} - -} // END CppAD namespace - -// END C++ -# endif diff -Nru cppad-2015.00.00.9/cppad/thread_alloc.hpp cppad-2016.00.00.1/cppad/thread_alloc.hpp --- cppad-2015.00.00.9/cppad/thread_alloc.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad/thread_alloc.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1588 +0,0 @@ -/* $Id: thread_alloc.hpp 3408 2014-11-27 15:17:20Z bradbell $ */ -# ifndef CPPAD_THREAD_ALLOC_INCLUDED -# define CPPAD_THREAD_ALLOC_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -# include -# include -# include - - -# ifdef _MSC_VER -// Supress warning that Microsoft compiler changed its behavior and is now -// doing the correct thing at the statement: -// new(array + i) Type(); -# pragma warning(disable:4345) -# endif - -# include -# include -namespace CppAD { // BEGIN_CPPAD_NAMESPACE -/*! -\file thread_alloc.hpp -File used to define the CppAD multi-threading allocaor class -*/ - -/*! -\def CPPAD_MAX_NUM_CAPACITY -Maximum number of different capacities the allocator will attempt. -This must be larger than the log base two of numeric_limit::max(). -*/ -# define CPPAD_MAX_NUM_CAPACITY 100 - -/*! -\def CPPAD_MIN_DOUBLE_CAPACITY -Minimum number of double values that will fit in an allocation. -*/ -# define CPPAD_MIN_DOUBLE_CAPACITY 16 - -/*! -\def CPPAD_TRACE_CAPACITY -If NDEBUG is not defined, print all calls to \c get_memory and \c return_memory -that correspond to this capacity and thread CPPAD_TRACE_THREAD. -(Note that if CPPAD_TRACE_CAPACITY is zero, or any other value not in the list -of capacities, no tracing will be done.) -*/ -# define CPPAD_TRACE_CAPACITY 0 - -/*! -\def CPPAD_TRACE_THREAD -If NDEBUG is not defined, print all calls to \c get_memory and \c return_memory -that correspond to this thead and capacity CPPAD_TRACE_CAPACITY. -*/ -# define CPPAD_TRACE_THREAD 0 - -/* -Note that Section 3.6.2 of ISO/IEC 14882:1998(E) states: "The storage for -objects with static storage duration (3.7.1) shall be zero-initialized -(8.5) before any other initialization takes place." -*/ - -/*! -Capacity vector for memory allocation block sizes. - -Only one of these objects should be created and used as a -static variable inside of the \c thread_alloc::capacity_info function. -*/ - -/*! -Allocator class that works well with an multi-threading environment. -*/ -class thread_alloc{ -// ============================================================================ -private: - - class capacity_t { - public: - /// number of capacity values actually used - size_t number; - /// the different capacity values - size_t value[CPPAD_MAX_NUM_CAPACITY]; - /// ctor - capacity_t(void) - { // Cannot figure out how to call thread_alloc::in_parallel here. - // CPPAD_ASSERT_UNKNOWN( - // ! thread_alloc::in_parallel() , "thread_alloc: " - // "parallel mode and parallel_setup not yet called." - // ); - number = 0; - size_t capacity = CPPAD_MIN_DOUBLE_CAPACITY * sizeof(double); - while( capacity < std::numeric_limits::max() / 2 ) - { CPPAD_ASSERT_UNKNOWN( number < CPPAD_MAX_NUM_CAPACITY ); - value[number++] = capacity; - // next capactiy is 3/2 times the current one - capacity = 3 * ( (capacity + 1) / 2 ); - } - CPPAD_ASSERT_UNKNOWN( number > 0 ); - } - }; - - class block_t { - public: - /// extra information (currently used by create and delete array) - size_t extra_; - /// an index that uniquely idenfifies both thread and capacity - size_t tc_index_; - /// pointer to the next memory allocation with the same tc_index_ - void* next_; - // ----------------------------------------------------------------- - /// make default constructor private. It is only used by constructor - /// for `root arrays below. - block_t(void) : extra_(0), tc_index_(0), next_(CPPAD_NULL) - { } - }; - - // --------------------------------------------------------------------- - /// Vector of fixed capacity values for this allocator - static const capacity_t* capacity_info(void) - { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; - static const capacity_t capacity; - return &capacity; - } - // --------------------------------------------------------------------- - /// Structure of information for each thread - struct thread_alloc_info { - /// count of available bytes for this thread - size_t count_inuse_; - /// count of inuse bytes for this thread - size_t count_available_; - /// root of available list for this thread and each capacity - block_t root_available_[CPPAD_MAX_NUM_CAPACITY]; - /// root of inuse list for this thread and each capacity - /// If NDEBUG is true, this memory is not used, but it still - /// helps separate this structure from one for the next thread. - block_t root_inuse_[CPPAD_MAX_NUM_CAPACITY]; - }; - // --------------------------------------------------------------------- - /*! - Set and Get hold available memory flag. - - \param set [in] - if true, the value returned by this return is changed. - - \param new_value [in] - if \a set is true, this is the new value returned by this routine. - Otherwise, \c new_value is ignored. - - \return - the current setting for this routine (which is initially false). - */ - static bool set_get_hold_memory(bool set, bool new_value = false) - { static bool value = false; - if( set ) - value = new_value; - return value; - } - // --------------------------------------------------------------------- - /*! - Get pointer to the information for this thread. - - \param thread [in] - Is the thread number for this information pointer. - - \param clear - If \a clear is true, then the information pointer for this thread - is deleted and the \c CPPAD_NULL pointer is returned. - There must be no memory currently in either the inuse or avaialble - lists when this routine is called. - - \return - is the current informaiton pointer for this thread. - If \a clear is false, and the current pointer is CPPAD_NULL, - a new infromation record is allocated and its pointer returned. - In this case, if \c info is the retured pointer, - info->count_inuse == 0 and - info->count_available == 0. - In addition, - for c = 0 , ... , CPPAD_MAX_NUM_CAPACITY-1 - info->root_inuse_[c].next_ == CPPAD_NULL and - info->root_available_[c].next_ == CPPAD_NULL. - */ - static thread_alloc_info* thread_info( - size_t thread , - bool clear = false ) - { static thread_alloc_info* all_info[CPPAD_MAX_NUM_THREADS]; - static thread_alloc_info zero_info; - - CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; - - CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS ); - - thread_alloc_info* info = all_info[thread]; - if( clear ) - { if( info != CPPAD_NULL ) - { -# ifndef NDEBUG - CPPAD_ASSERT_UNKNOWN( - info->count_inuse_ == 0 && - info->count_available_ == 0 - ); - for(size_t c = 0; c < CPPAD_MAX_NUM_CAPACITY; c++) - { CPPAD_ASSERT_UNKNOWN( - info->root_inuse_[c].next_ == CPPAD_NULL && - info->root_available_[c].next_ == CPPAD_NULL - ); - } -# endif - if( thread != 0 ) - ::operator delete( reinterpret_cast(info) ); - info = CPPAD_NULL; - all_info[thread] = info; - } - } - else if( info == CPPAD_NULL ) - { if( thread == 0 ) - info = &zero_info; - else - { size_t size = sizeof(thread_alloc_info); - void* v_ptr = ::operator new(size); - info = reinterpret_cast(v_ptr); - } - all_info[thread] = info; - - // initialize the information record - for(size_t c = 0; c < CPPAD_MAX_NUM_CAPACITY; c++) - { info->root_inuse_[c].next_ = CPPAD_NULL; - info->root_available_[c].next_ = CPPAD_NULL; - } - info->count_inuse_ = 0; - info->count_available_ = 0; - } - return info; - } - // ----------------------------------------------------------------------- - /*! - Increase the number of bytes of memory that are currently in use; i.e., - that been obtained with \c get_memory and not yet returned. - - \param inc [in] - amount to increase memory in use. - - \param thread [in] - Thread for which we are increasing the number of bytes in use - (must be less than \c num_threads). - Durring parallel execution, this must be the thread - that is currently executing. - */ - static void inc_inuse(size_t inc, size_t thread) - { - CPPAD_ASSERT_UNKNOWN( thread < num_threads() ); - CPPAD_ASSERT_UNKNOWN( - thread == thread_num() || (! in_parallel()) - ); - thread_alloc_info* info = thread_info(thread); - - // do the addition - size_t result = info->count_inuse_ + inc; - CPPAD_ASSERT_UNKNOWN( result >= info->count_inuse_ ); - - info->count_inuse_ = result; - } - // ----------------------------------------------------------------------- - /*! - Increase the number of bytes of memory that are currently avaialble; i.e., - have been obtained obtained from the system and are being held future use. - - \copydetails inc_inuse - */ - static void inc_available(size_t inc, size_t thread) - { - CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); - CPPAD_ASSERT_UNKNOWN( - thread == thread_num() || (! in_parallel()) - ); - thread_alloc_info* info = thread_info(thread); - // do the addition - size_t result = info->count_available_ + inc; - CPPAD_ASSERT_UNKNOWN( result >= info->count_available_ ); - - info->count_available_ = result; - } - // ----------------------------------------------------------------------- - /*! - Decrease the number of bytes of memory that are currently in use; i.e., - that been obtained with \c get_memory and not yet returned. - - \param dec [in] - amount to decrease number of bytes in use. - - \param thread [in] - Thread for which we are decreasing the number of bytes in use - (must be less than \c num_threads). - Durring parallel execution, this must be the thread - that is currently executing. - */ - static void dec_inuse(size_t dec, size_t thread) - { - CPPAD_ASSERT_UNKNOWN( - thread < num_threads() || (! in_parallel()) - ); - CPPAD_ASSERT_UNKNOWN( - thread == thread_num() || (! in_parallel()) - ); - thread_alloc_info* info = thread_info(thread); - - // do the subtraction - CPPAD_ASSERT_UNKNOWN( info->count_inuse_ >= dec ); - info->count_inuse_ = info->count_inuse_ - dec; - } - // ----------------------------------------------------------------------- - /*! - Decrease the number of bytes of memory that are currently avaialble; i.e., - have been obtained obtained from the system and are being held future use. - - \copydetails dec_inuse - */ - static void dec_available(size_t dec, size_t thread) - { - CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); - CPPAD_ASSERT_UNKNOWN( - thread == thread_num() || (! in_parallel()) - ); - thread_alloc_info* info = thread_info(thread); - // do the subtraction - CPPAD_ASSERT_UNKNOWN( info->count_available_ >= dec ); - info->count_available_ = info->count_available_ - dec; - } - - // ---------------------------------------------------------------------- - /*! - Set and get the number of threads that are sharing memory. - - \param number_new - If \c number is zero, we are only retreiving the current maximum - number of threads. Otherwise, we are setting and retreiving - maximum number of threads. - - \return - the number of threads that are sharing memory. - If \c number_new is non-zero, the return value is equal to - \c number_new. - */ - static size_t set_get_num_threads(size_t number_new) - { static size_t number_user = 1; - - CPPAD_ASSERT_UNKNOWN( number_new <= CPPAD_MAX_NUM_THREADS ); - CPPAD_ASSERT_UNKNOWN( ! in_parallel() || (number_new == 0) ); - - // case where we are changing the number of threads - if( number_new != 0 ) - number_user = number_new; - - return number_user; - } - /*! - Set and call the routine that determine if we are in parallel - execution mode. - - \return - value retuned by most recent setting for \a parallel_new. - If \a set is true, - or the most recent setting is \c CPPAD_NULL (its initial value), - the return value is false. - Otherwise the function corresponding to the most recent setting - is called and its value returned by \c set_get_in_parallel. - - \param parallel_new [in] - If \a set is false, \a parallel_new it is not used. - Otherwise, the current value of \c parallel_new becomes the - most recent setting for in_parallel. - - \param set - If \a set is true, then \a parallel_new is becomes the most - recent setting for this \c set_get_in_parallel. - */ - static bool set_get_in_parallel( - bool (*parallel_new)(void) , - bool set = false ) - { static bool (*parallel_user)(void) = CPPAD_NULL; - - if( set ) - { parallel_user = parallel_new; - return false; - } - - if( parallel_user == CPPAD_NULL ) - return false; - - return parallel_user(); - } - /*! - Set and call the routine that determine the current thread number. - - \return - returns value for the most recent setting for \a thread_num_new. - If \a set is true, - or the most recent setting is \c CPPAD_NULL (its initial value), - the return value is zero. - Otherwise the routine corresponding to the most recent setting - is called and its value returned by \c set_get_thread_num. - - \param thread_num_new [in] - If \a set is false, \a thread_num_new it is not used. - Otherwise, the current value of \c thread_num_new becomes the - most recent setting for thread_num. - - \param set - If \a set is true, then \a thread_num_new is becomes the most - recent setting for this \c set_get_thread_num. - */ - static size_t set_get_thread_num( - size_t (*thread_num_new)(void) , - bool set = false ) - { static size_t (*thread_num_user)(void) = CPPAD_NULL; - - if( set ) - { thread_num_user = thread_num_new; - return 0; - } - - if( thread_num_user == CPPAD_NULL ) - return 0; - - size_t thread = thread_num_user(); - CPPAD_ASSERT_KNOWN( - thread < set_get_num_threads(0) , - "parallel_setup: thread_num() >= num_threads" - ); - return thread; - } -// ============================================================================ -public: -/* -$begin ta_parallel_setup$$ -$spell - alloc - num - bool -$$ -$section Setup thread_alloc For Use in Multi-Threading Environment$$ - -$index setup, thread_alloc$$ -$index thread_alloc, setup$$ -$index parallel, setup$$ -$index setup, parallel$$ - -$index num_threads$$ -$index in_parallel$$ -$index thread_num$$ - -$index multi-threading, initialize$$ -$index initialize, multi-threading$$ - -$head Syntax$$ -$codei%thread_alloc::parallel_setup(%num_threads%, %in_parallel%, %thread_num%) -%$$ - -$head Purpose$$ -By default there is only one thread and all execution is in sequential mode, -i.e., multiple threads are not sharing the same memory; i.e. -not in parallel mode. - -$head Speed$$ -It should be faster, even when $icode num_thread$$ is equal to one, -for $code thread_alloc$$ to hold onto memory. -This can be accomplished using the function call -$codei% - thread_alloc::hold_memory(true) -%$$ -see $cref/hold_memory/ta_hold_memory/$$. - -$head num_threads$$ -This argument has prototype -$codei% - size_t %num_threads% -%$$ -and must be greater than zero. -It specifies the number of threads that are sharing memory. -The case $icode%num_threads% == 1%$$ is a special case that is -used to terminate a multi-threading environment. - -$head in_parallel$$ -This function has prototype -$codei% - bool %in_parallel%(void) -%$$ -It must return $code true$$ if there is more than one thread -currently executing. -Otherwise it can return false. -$pre - -$$ -In the special case where $icode%num_threads% == 1%$$, -the routine $icode in_parallel$$ is not used. - -$head thread_num$$ -This function has prototype -$codei% - size_t %thread_num%(void) -%$$ -It must return a thread number that uniquely identifies the -currently executing thread. -Furthermore -$codei% - 0 <= %thread_num%() < %num_threads% -%$$. -In the special case where $icode%num_threads% == 1%$$, -the routine $icode thread_num$$ is not used. -$pre - -$$ -Note that this function is called by other routines so, -as soon as a new thread is executing, -one must be certain that $icode thread_num()$$ will -work for that thread. - -$head Restrictions$$ -The function $code parallel_setup$$ must be called before -the program enters $cref/parallel/ta_in_parallel/$$ execution mode. -In addition, this function cannot be called while in parallel mode. - -$head Example$$ -The files -$cref simple_ad_openmp.cpp$$, -$cref simple_ad_bthread.cpp$$, and -$cref simple_ad_pthread.cpp$$, -contain examples and tests that use this function. - -$end -*/ - /*! - Set thread_alloc up for parallel mode usage. - - \param num_threads [in] - Is the number of thread that may be executing at the same time. - - \param in_parallel [in] - Is the routine that determines if we are in parallel mode or not. - - \param thread_num [in] - Is the routine that determines the current thread number - (between zero and num_threads minus one). - */ - static void parallel_setup( - size_t num_threads , - bool (*in_parallel)(void) , - size_t (*thread_num)(void) ) - { - // Special case where we go back to single thread mode right away - // (previous settings may no longer be valid) - if( num_threads == 1 ) - { bool set = true; - set_get_num_threads(num_threads); - set_get_in_parallel(CPPAD_NULL, set); - set_get_thread_num(CPPAD_NULL, set); - return; - } - - CPPAD_ASSERT_KNOWN( - num_threads <= CPPAD_MAX_NUM_THREADS , - "parallel_setup: num_threads is too large" - ); - CPPAD_ASSERT_KNOWN( - num_threads != 0 , - "parallel_setup: num_threads == zero" - ); - CPPAD_ASSERT_KNOWN( - in_parallel != CPPAD_NULL , - "parallel_setup: num_threads != 1 and in_parallel == CPPAD_NULL" - ); - CPPAD_ASSERT_KNOWN( - thread_num != CPPAD_NULL , - "parallel_setup: num_threads != 1 and thread_num == CPPAD_NULL" - ); - - // Make sure that constructors for all static variables in this file - // are called in sequential mode. - for(size_t thread = 0; thread < num_threads; thread++) - thread_info(thread); - capacity_info(); - size_t cap_bytes; - void* v_ptr = get_memory(0, cap_bytes); - - // free memory allocated by call to get_memory above - return_memory(v_ptr); - free_available( set_get_thread_num(CPPAD_NULL) ); - - // delay this so thread_num() call above is in previous mode - // (current setings may not yet be valid) - if( num_threads > 1 ) - { bool set = true; - set_get_num_threads(num_threads); - set_get_in_parallel(in_parallel, set); - set_get_thread_num(thread_num, set); - } - } -/* -$begin ta_num_threads$$ -$spell - inv - CppAD - num - alloc -$$ -$section Get Number of Threads$$ - -$index num_threads, thread_alloc$$ -$index thread_alloc, num_threads$$ -$index threads, number of$$ - -$head Syntax$$ -$icode%number% = thread_alloc::num_threads()%$$ - -$head Purpose$$ -Determine the number of threads as set during $cref/parallel_setup/ta_parallel_setup/$$. - -$head number$$ -The return value $icode number$$ has prototype -$codei% - size_t %number% -%$$ -and is equal to the value of -$cref/num_threads/ta_parallel_setup/num_threads/$$ -in the previous call to $icode parallel_setup$$. -If there was no such previous call, the value one is returned. - -$head Example$$ -The example and test $cref thread_alloc.cpp$$ uses this routine. - -$end -*/ - /*! - Get the current number of threads that thread_alloc can use. - */ - static size_t num_threads(void) - { return set_get_num_threads(0); } -/* ----------------------------------------------------------------------- -$begin ta_in_parallel$$ - -$section Is The Current Execution in Parallel Mode$$ -$spell - thread_alloc - bool -$$ - -$index in_parallel, thread_alloc$$ -$index thread_alloc, in_parallel$$ -$index parallel, execution$$ -$index execution, parallel$$ -$index sequential, execution$$ - -$head Syntax$$ -$icode%flag% = thread_alloc::in_parallel()%$$ - -$head Purpose$$ -Some of the $cref thread_alloc$$ allocation routines have different -specifications for parallel (not sequential) execution mode. -This routine enables you to determine if the current execution mode -is sequential or parallel. - -$head flag$$ -The return value has prototype -$codei% - bool %flag% -%$$ -It is true if the current execution is in parallel mode -(possibly multi-threaded) and false otherwise (sequential mode). - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /// Are we in a parallel execution state; i.e., is it possible that - /// other threads are currently executing. - static bool in_parallel(void) - { return set_get_in_parallel(0); } -/* ----------------------------------------------------------------------- -$begin ta_thread_num$$ -$spell - CppAD - num - thread_alloc - cppad.hpp -$$ - -$section Get the Current Thread Number$$ - -$index thread_num, thread_alloc$$ -$index thread_alloc, thread_num$$ -$index thread, current$$ -$index current, thread$$ - -$head Syntax$$ -$icode%thread% = thread_alloc::thread_num()%$$ - -$head Purpose$$ -Some of the $cref thread_alloc$$ allocation routines have a thread number. -This routine enables you to determine the current thread. - -$head thread$$ -The return value $icode thread$$ has prototype -$codei% - size_t %thread% -%$$ -and is the currently executing thread number. -If $code _OPENMP$$ is not defined, $icode thread$$ is zero. - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /// Get current thread number - static size_t thread_num(void) - { return set_get_thread_num(CPPAD_NULL); } -/* ----------------------------------------------------------------------- -$begin ta_get_memory$$ -$spell - std - num - ptr - thread_alloc -$$ - -$section Get At Least A Specified Amount of Memory$$ - -$index thread_num, thread_alloc$$ -$index thread_alloc, thread_num$$ -$index memory, allocate$$ -$index allocate, memory$$ - -$head Syntax$$ -$icode%v_ptr% = thread_alloc::get_memory(%min_bytes%, %cap_bytes%)%$$ - -$head Purpose$$ -Use $cref thread_alloc$$ to obtain a minimum number of bytes of memory -(for use by the $cref/current thread/ta_thread_num/$$). - -$head min_bytes$$ -This argument has prototype -$codei% - size_t %min_bytes% -%$$ -It specifies the minimum number of bytes to allocate. -This value must be less than -$codep - std::numeric_limits::max() / 2 -$$ - -$head cap_bytes$$ -This argument has prototype -$codei% - size_t& %cap_bytes% -%$$ -It's input value does not matter. -Upon return, it is the actual number of bytes (capacity) -that have been allocated for use, -$codei% - %min_bytes% <= %cap_bytes% -%$$ - -$head v_ptr$$ -The return value $icode v_ptr$$ has prototype -$codei% - void* %v_ptr% -%$$ -It is the location where the $icode cap_bytes$$ of memory -that have been allocated for use begins. - -$head Allocation Speed$$ -This allocation should be faster if the following conditions hold: -$list number$$ -The memory allocated by a previous call to $code get_memory$$ -is currently available for use. -$lnext -The current $icode min_bytes$$ is between -the previous $icode min_bytes$$ and previous $icode cap_bytes$$. -$lend - -$head Alignment$$ -We call a memory allocation aligned if the address is a multiple -of the number of bytes in a $code size_t$$ value. -If the system $code new$$ allocator is aligned, then $icode v_ptr$$ -pointer is also aligned. - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /*! - Use thread_alloc to get a specified amount of memory. - - If the memory allocated by a previous call to \c get_memory is now - avaialable, and \c min_bytes is between its previous value - and the previous \c cap_bytes, this memory allocation will have - optimal speed. Otherwise, the memory allocation is more complicated and - may have to wait for other threads to complete an allocation. - - \param min_bytes [in] - The minimum number of bytes of memory to be obtained for use. - - \param cap_bytes [out] - The actual number of bytes of memory obtained for use. - - \return - pointer to the beginning of the memory allocated for use. - */ - static void* get_memory(size_t min_bytes, size_t& cap_bytes) - { // see first_trace below - CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; - - // check that number of requested bytes is not to large - CPPAD_ASSERT_KNOWN( - min_bytes < std::numeric_limits::max() / 2 , - "get_memory(min_bytes, cap_bytes): min_bytes is too large" - ); - - size_t num_cap = capacity_info()->number; - using std::cout; - using std::endl; - - // determine the capacity for this request - size_t c_index = 0; - const size_t* capacity_vec = capacity_info()->value; - while( capacity_vec[c_index] < min_bytes ) - { ++c_index; - CPPAD_ASSERT_UNKNOWN(c_index < num_cap ); - } - cap_bytes = capacity_vec[c_index]; - - // determine the thread, capacity, and info for this thread - size_t thread = thread_num(); - size_t tc_index = thread * num_cap + c_index; - thread_alloc_info* info = thread_info(thread); - -# ifndef NDEBUG - // trace allocation - static bool first_trace = true; - if( cap_bytes == CPPAD_TRACE_CAPACITY && - thread == CPPAD_TRACE_THREAD && first_trace ) - { cout << endl; - cout << "thread_alloc: Trace for Thread = " << thread; - cout << " and capacity = " << cap_bytes << endl; - if( first_trace ) - first_trace = false; - } - - // Root nodes for both lists. Note these are different for different - // threads because tc_index is different for different threads. - block_t* inuse_root = info->root_inuse_ + c_index; -# endif - block_t* available_root = info->root_available_ + c_index; - - // check if we already have a node we can use - void* v_node = available_root->next_; - block_t* node = reinterpret_cast(v_node); - if( node != CPPAD_NULL ) - { CPPAD_ASSERT_UNKNOWN( node->tc_index_ == tc_index ); - - // remove node from available list - available_root->next_ = node->next_; - - // return value for get_memory - void* v_ptr = reinterpret_cast(node + 1); -# ifndef NDEBUG - // add node to inuse list - node->next_ = inuse_root->next_; - inuse_root->next_ = v_node; - - // trace allocation - if( cap_bytes == CPPAD_TRACE_CAPACITY && - thread == CPPAD_TRACE_THREAD ) - { cout << "get_memory: v_ptr = " << v_ptr << endl; } -# endif - - // adjust counts - inc_inuse(cap_bytes, thread); - dec_available(cap_bytes, thread); - - // return pointer to memory, do not inclue thread_alloc information - return v_ptr; - } - - // Create a new node with thread_alloc information at front. - // This uses the system allocator, which is thread safe, but slower, - // because the thread might wait for a lock on the allocator. - v_node = ::operator new(sizeof(block_t) + cap_bytes); - node = reinterpret_cast(v_node); - node->tc_index_ = tc_index; - void* v_ptr = reinterpret_cast(node + 1); - -# ifndef NDEBUG - // add node to inuse list - node->next_ = inuse_root->next_; - inuse_root->next_ = v_node; - - // trace allocation - if( cap_bytes == CPPAD_TRACE_CAPACITY && - thread == CPPAD_TRACE_THREAD ) - { cout << "get_memory: v_ptr = " << v_ptr << endl; } -# endif - - // adjust counts - inc_inuse(cap_bytes, thread); - - return v_ptr; - } - -/* ----------------------------------------------------------------------- -$begin ta_return_memory$$ -$spell - num - ptr - thread_alloc -$$ - -$section Return Memory to thread_alloc$$ - -$index return_memory, thread_alloc$$ -$index thread_alloc, return_memory$$ -$index memory, available$$ -$index available, memory$$ -$index thread, available memory$$ - -$head Syntax$$ -$codei%thread_alloc::return_memory(%v_ptr%)%$$ - -$head Purpose$$ -If $cref/hold_memory/ta_hold_memory/$$ is false, -the memory is returned to the system. -Otherwise, the memory is retained by $cref thread_alloc$$ for quick future use -by the thread that allocated to memory. - -$head v_ptr$$ -This argument has prototype -$codei% - void* %v_ptr% -%$$. -It must be a pointer to memory that is currently in use; i.e. -obtained by a previous call to -$cref/get_memory/ta_get_memory/$$ and not yet returned. - -$head Thread$$ -Either the $cref/current thread/ta_thread_num/$$ must be the same as during -the corresponding call to $cref/get_memory/ta_get_memory/$$, -or the current execution mode must be sequential -(not $cref/parallel/ta_in_parallel/$$). - -$head NDEBUG$$ -If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). -Otherwise, a list of in use pointers is searched to make sure -that $icode v_ptr$$ is in the list. - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /*! - Return memory that was obtained by \c get_memory. - If num_threads() == 1, - the memory is returned to the system. - Otherwise, it is retained by \c thread_alloc and available for use by - \c get_memory for this thread. - - \param v_ptr [in] - Value of the pointer returned by \c get_memory and still in use. - After this call, this pointer will available (and not in use). - - \par - We must either be in sequential (not parallel) execution mode, - or the current thread must be the same as for the corresponding call - to \c get_memory. - */ - static void return_memory(void* v_ptr) - { size_t num_cap = capacity_info()->number; - - block_t* node = reinterpret_cast(v_ptr) - 1; - size_t tc_index = node->tc_index_; - size_t thread = tc_index / num_cap; - size_t c_index = tc_index % num_cap; - size_t capacity = capacity_info()->value[c_index]; - - CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS ); - CPPAD_ASSERT_KNOWN( - thread == thread_num() || (! in_parallel()), - "Attempt to return memory for a different thread " - "while in parallel mode" - ); - - thread_alloc_info* info = thread_info(thread); -# ifndef NDEBUG - // remove node from inuse list - void* v_node = reinterpret_cast(node); - block_t* inuse_root = info->root_inuse_ + c_index; - block_t* previous = inuse_root; - while( (previous->next_ != CPPAD_NULL) & (previous->next_ != v_node) ) - previous = reinterpret_cast(previous->next_); - - // check that v_ptr is valid - if( previous->next_ != v_node ) - { using std::endl; - std::ostringstream oss; - oss << "return_memory: attempt to return memory not in use"; - oss << endl; - oss << "v_ptr = " << v_ptr << endl; - oss << "thread = " << thread << endl; - oss << "capacity = " << capacity << endl; - oss << "See CPPAD_TRACE_THREAD & CPPAD_TRACE_CAPACITY in"; - oss << endl << "# include " << endl; - CPPAD_ASSERT_KNOWN(false, oss.str().c_str() ); - } - - // trace option - if( capacity==CPPAD_TRACE_CAPACITY && thread==CPPAD_TRACE_THREAD ) - { std::cout << "return_memory: v_ptr = " << v_ptr << std::endl; } - - // remove v_ptr from inuse list - previous->next_ = node->next_; -# endif - // capacity bytes are removed from the inuse pool - dec_inuse(capacity, thread); - - // check for case where we just return the memory to the system - if( ! set_get_hold_memory(false) ) - { ::operator delete( reinterpret_cast(node) ); - return; - } - - // add this node to available list for this thread and capacity - block_t* available_root = info->root_available_ + c_index; - node->next_ = available_root->next_; - available_root->next_ = reinterpret_cast(node); - - // capacity bytes are added to the available pool - inc_available(capacity, thread); - } -/* ----------------------------------------------------------------------- -$begin ta_free_available$$ -$spell - num - thread_alloc -$$ - -$section Free Memory Currently Available for Quick Use by a Thread$$ -$spell - inuse -$$ - -$index free_available, thread_alloc$$ -$index thread_alloc, free_available$$ -$index free, available$$ -$index available, free$$ -$index thread, free memory$$ - -$head Syntax$$ -$codei%thread_alloc::free_available(%thread%)%$$ - -$head Purpose$$ -Return to the system all the memory that is currently being -$cref/held/ta_hold_memory/$$ for quick use by the specified thread. - -$subhead Extra Memory$$ -In the case where $icode%thread% > 0%$$, -some extra memory is used to track allocations by the specified thread. -If -$codei% - thread_alloc::inuse(%thread%) == 0 -%$$ -the extra memory is also returned to the system. - -$head thread$$ -This argument has prototype -$codei% - size_t %thread% -%$$ -Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, -or the current execution mode must be sequential -(not $cref/parallel/ta_in_parallel/$$). - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /*! - Return all the memory being held as available for a thread to the system. - - \param thread [in] - this thread that will no longer have any available memory after this call. - This must either be the thread currently executing, or we must be - in sequential (not parallel) execution mode. - */ - static void free_available(size_t thread) - { CPPAD_ASSERT_KNOWN( - thread < CPPAD_MAX_NUM_THREADS, - "Attempt to free memory for a thread >= CPPAD_MAX_NUM_THREADS" - ); - CPPAD_ASSERT_KNOWN( - thread == thread_num() || (! in_parallel()), - "Attempt to free memory for a different thread " - "while in parallel mode" - ); - - size_t num_cap = capacity_info()->number; - if( num_cap == 0 ) - return; - const size_t* capacity_vec = capacity_info()->value; - size_t c_index; - thread_alloc_info* info = thread_info(thread); - for(c_index = 0; c_index < num_cap; c_index++) - { size_t capacity = capacity_vec[c_index]; - block_t* available_root = info->root_available_ + c_index; - void* v_ptr = available_root->next_; - while( v_ptr != CPPAD_NULL ) - { block_t* node = reinterpret_cast(v_ptr); - void* next = node->next_; - ::operator delete(v_ptr); - v_ptr = next; - - dec_available(capacity, thread); - } - available_root->next_ = CPPAD_NULL; - } - CPPAD_ASSERT_UNKNOWN( available(thread) == 0 ); - if( inuse(thread) == 0 ) - { // clear the information for this thread - thread_info(thread, true); - } - } -/* ----------------------------------------------------------------------- -$begin ta_hold_memory$$ -$spell - alloc - num -$$ - -$section Control When Thread Alloc Retains Memory For Future Use$$ -$index thread_alloc, hold memory$$ -$index hold, thread_alloc memory$$ -$index memory, thread_alloc hold$$ - -$head Syntax$$ -$codei%thread_alloc::hold_memory(%value%)%$$ - -$head Purpose$$ -It should be faster, even when $icode num_thread$$ is equal to one, -for $code thread_alloc$$ to hold onto memory. -Calling $icode hold_memory$$ with $icode value$$ equal to true, -instructs $code thread_alloc$$ to hold onto memory, -and put it in the $cref/available/ta_available/$$ pool, -after each call to $cref/return_memory/ta_return_memory/$$. - -$head value$$ -If $icode value$$ is true, -$code thread_alloc$$ with hold onto memory for future quick use. -If it is false, future calls to $cref/return_memory/ta_return_memory/$$ -will return the corresponding memory to the system. -By default (when $code hold_memory$$ has not been called) -$code thread_alloc$$ does not hold onto memory. - -$head free_available$$ -Memory that is being held by $code thread_alloc$$ can be returned -to the system using $cref/free_available/ta_free_available/$$. - -$end -*/ - /*! - Change the thread_alloc hold memory setting. - - \param value [in] - New value for the thread_alloc hold memory setting. - */ - static void hold_memory(bool value) - { bool set = true; - set_get_hold_memory(set, value); - } - -/* ----------------------------------------------------------------------- -$begin ta_inuse$$ -$spell - num - inuse - thread_alloc -$$ - -$section Amount of Memory a Thread is Currently Using$$ - -$index inuse, thread_alloc$$ -$index thread_alloc, inuse$$ -$index use, memory$$ -$index thread, memory inuse$$ - -$head Syntax$$ -$icode%num_bytes% = thread_alloc::inuse(%thread%)%$$ - -$head Purpose$$ -Memory being managed by $cref thread_alloc$$ has two states, -currently in use by the specified thread, -and quickly available for future use by the specified thread. -This function informs the program how much memory is in use. - -$head thread$$ -This argument has prototype -$codei% - size_t %thread% -%$$ -Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, -or the current execution mode must be sequential -(not $cref/parallel/ta_in_parallel/$$). - -$head num_bytes$$ -The return value has prototype -$codei% - size_t %num_bytes% -%$$ -It is the number of bytes currently in use by the specified thread. - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /*! - Determine the amount of memory that is currently inuse. - - \param thread [in] - Thread for which we are determining the amount of memory - (must be < CPPAD_MAX_NUM_THREADS). - Durring parallel execution, this must be the thread - that is currently executing. - - \return - The amount of memory in bytes. - */ - static size_t inuse(size_t thread) - { - CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); - CPPAD_ASSERT_UNKNOWN( - thread == thread_num() || (! in_parallel()) - ); - thread_alloc_info* info = thread_info(thread); - return info->count_inuse_; - } -/* ----------------------------------------------------------------------- -$begin ta_available$$ -$spell - num - thread_alloc -$$ - -$section Amount of Memory Available for Quick Use by a Thread$$ - -$index available, thread_alloc$$ -$index thread_alloc, available$$ -$index memory, available$$ -$index thread, available memory$$ - -$head Syntax$$ -$icode%num_bytes% = thread_alloc::available(%thread%)%$$ - -$head Purpose$$ -Memory being managed by $cref thread_alloc$$ has two states, -currently in use by the specified thread, -and quickly available for future use by the specified thread. -This function informs the program how much memory is available. - -$head thread$$ -This argument has prototype -$codei% - size_t %thread% -%$$ -Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, -or the current execution mode must be sequential -(not $cref/parallel/ta_in_parallel/$$). - -$head num_bytes$$ -The return value has prototype -$codei% - size_t %num_bytes% -%$$ -It is the number of bytes currently available for use by the specified thread. - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /*! - Determine the amount of memory that is currently available for use. - - \copydetails inuse - */ - static size_t available(size_t thread) - { - CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); - CPPAD_ASSERT_UNKNOWN( - thread == thread_num() || (! in_parallel()) - ); - thread_alloc_info* info = thread_info(thread); - return info->count_available_; - } -/* ----------------------------------------------------------------------- -$begin ta_create_array$$ -$spell - inuse - thread_alloc - sizeof -$$ - -$section Allocate An Array and Call Default Constructor for its Elements$$ - -$index create_array, thread_alloc$$ -$index thread_alloc, create_array$$ -$index array, allocate$$ -$index allocate, array$$ - -$head Syntax$$ -$icode%array% = thread_alloc::create_array<%Type%>(%size_min%, %size_out%)%$$. - -$head Purpose$$ -Create a new raw array using $cref thread_alloc$$ memory allocator -(works well in a multi-threading environment) -and call default constructor for each element. - -$head Type$$ -The type of the elements of the array. - -$head size_min$$ -This argument has prototype -$codei% - size_t %size_min% -%$$ -This is the minimum number of elements that there can be -in the resulting $icode array$$. - -$head size_out$$ -This argument has prototype -$codei% - size_t& %size_out% -%$$ -The input value of this argument does not matter. -Upon return, it is the actual number of elements -in $icode array$$ -($icode% size_min %<=% size_out%$$). - -$head array$$ -The return value $icode array$$ has prototype -$codei% - %Type%* %array% -%$$ -It is array with $icode size_out$$ elements. -The default constructor for $icode Type$$ is used to initialize the -elements of $icode array$$. -Note that $cref/delete_array/ta_delete_array/$$ -should be used to destroy the array when it is no longer needed. - -$head Delta$$ -The amount of memory $cref/inuse/ta_inuse/$$ by the current thread, -will increase $icode delta$$ where -$codei% - sizeof(%Type%) * (%size_out% + 1) > %delta% >= sizeof(%Type%) * %size_out% -%$$ -The $cref/available/ta_available/$$ memory will decrease by $icode delta$$, -(and the allocation will be faster) -if a previous allocation with $icode size_min$$ between its current value -and $icode size_out$$ is available. - -$head Alignment$$ -We call a memory allocation aligned if the address is a multiple -of the number of bytes in a $code size_t$$ value. -If the system $code new$$ allocator is aligned, then $icode array$$ -pointer is also aligned. - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /*! - Use thread_alloc to allocate an array, then call default construtor - for each element. - - \tparam Type - The type of the elements of the array. - - \param size_min [in] - The minimum number of elements in the array. - - \param size_out [out] - The actual number of elements in the array. - - \return - pointer to the first element of the array. - The default constructor is used to initialize - all the elements of the array. - - \par - The \c extra_ field, in the \c thread_alloc node before the return value, - is set to size_out. - */ - template - static Type* create_array(size_t size_min, size_t& size_out) - { // minimum number of bytes to allocate - size_t min_bytes = size_min * sizeof(Type); - // do the allocation - size_t num_bytes; - void* v_ptr = get_memory(min_bytes, num_bytes); - // This is where the array starts - Type* array = reinterpret_cast(v_ptr); - // number of Type values in the allocation - size_out = num_bytes / sizeof(Type); - // store this number in the extra field - block_t* node = reinterpret_cast(v_ptr) - 1; - node->extra_ = size_out; - - // call default constructor for each element - size_t i; - for(i = 0; i < size_out; i++) - new(array + i) Type(); - - return array; - } -/* ----------------------------------------------------------------------- -$begin ta_delete_array$$ -$spell - inuse - thread_alloc - sizeof - deallocate -$$ - -$section Deallocate An Array and Call Destructor for its Elements$$ - -$index delete_array, thread_alloc$$ -$index thread_alloc, delete_array$$ -$index array, allocate$$ -$index allocate, array$$ - -$head Syntax$$ -$codei%thread_alloc::delete_array(%array%)%$$. - -$head Purpose$$ -Returns memory corresponding to an array created by -(create by $cref/create_array/ta_create_array/$$) to the -$cref/available/ta_available/$$ memory pool for the current thread. - -$head Type$$ -The type of the elements of the array. - -$head array$$ -The argument $icode array$$ has prototype -$codei% - %Type%* %array% -%$$ -It is a value returned by $cref/create_array/ta_create_array/$$ and not yet deleted. -The $icode Type$$ destructor is called for each element in the array. - -$head Thread$$ -The $cref/current thread/ta_thread_num/$$ must be the -same as when $cref/create_array/ta_create_array/$$ returned the value $icode array$$. -There is an exception to this rule: -when the current execution mode is sequential -(not $cref/parallel/ta_in_parallel/$$) the current thread number does not matter. - -$head Delta$$ -The amount of memory $cref/inuse/ta_inuse/$$ will decrease by $icode delta$$, -and the $cref/available/ta_available/$$ memory will increase by $icode delta$$, -where $cref/delta/ta_create_array/Delta/$$ -is the same as for the corresponding call to $code create_array$$. - -$head Example$$ -$cref thread_alloc.cpp$$ - -$end -*/ - /*! - Return Memory Used for an Array to the Available Pool - (include destructor call for each element). - - \tparam Type - The type of the elements of the array. - - \param array [in] - A value returned by \c create_array that has not yet been deleted. - The \c Type destructor is used to destroy each of the elements - of the array. - - \par - Durring parallel execution, the current thread must be the same - as during the corresponding call to \c create_array. - */ - template - static void delete_array(Type* array) - { // determine the number of values in the array - block_t* node = reinterpret_cast(array) - 1; - size_t size = node->extra_; - - // call destructor for each element - size_t i; - for(i = 0; i < size; i++) - (array + i)->~Type(); - - // return the memory to the available pool for this thread - thread_alloc::return_memory( reinterpret_cast(array) ); - } -/* ----------------------------------------------------------------------- -$begin ta_free_all$$ -$spell - alloc - bool - inuse -$$ - -$section Free All Memory That Was Allocated for Use by thread_alloc$$ - -$index free, all thread_alloc$$ -$index thread_alloc, free all$$ - -$head Syntax$$ -$icode%ok% = thread_alloc::free_all()%$$. - -$head Purpose$$ -Returns all memory that was used by $code thread_alloc$$ to the system. - -$head ok$$ -The return value $icode ok$$ has prototype -$codei% - bool %ok% -%$$ -Its value will be $code true$$ if all the memory can be freed. -This requires that for all $icode thread$$ indices, there is no memory -$cref/inuse/ta_inuse/$$; i.e., -$codei% - 0 == thread_alloc::inuse(%thread%) -%$$ -Otherwise, the return value will be false. - -$head Restrictions$$ -This function cannot be called while in parallel mode. - -$head Example$$ -$cref thread_alloc.cpp$$ -$end -*/ - /*! - Return to the system all thread_alloc memory that is not currently inuse. - - \return - If no \c thread_alloc memory is currently inuse, - all memory is returned to the system and the return value is true. - Otherwise the return value is false. - */ - static bool free_all(void) - { CPPAD_ASSERT_KNOWN( - ! in_parallel(), - "free_all cannot be used while in parallel execution" - ); - bool ok = true; - size_t thread = CPPAD_MAX_NUM_THREADS; - while(thread--) - { ok &= inuse(thread) == 0; - free_available(thread); - } - return ok; - } -}; - - -} // END_CPPAD_NAMESPACE - -// preprocessor symbols local to this file -# undef CPPAD_MAX_NUM_CAPACITY -# undef CPPAD_MIN_DOUBLE_CAPACITY -# undef CPPAD_TRACE_CAPACITY -# undef CPPAD_TRACE_THREAD -# endif diff -Nru cppad-2015.00.00.9/cppad/time_test.hpp cppad-2016.00.00.1/cppad/time_test.hpp --- cppad-2015.00.00.9/cppad/time_test.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/time_test.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,225 +0,0 @@ -/* $Id: time_test.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_TIME_TEST_INCLUDED -# define CPPAD_TIME_TEST_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin time_test$$ -$spell - gettimeofday - vec - cppad.hpp - Microsoft - namespace - std - const - cout - ctime - ifdef - const - endif - cpp -$$ - -$index time_test$$ -$index test, speed$$ -$index test, time$$ - -$section Determine Amount of Time to Execute a Test$$ - -$head Syntax$$ -$codei%# include -%$$ -$icode%time% = time_test(%test%, %time_min%)%$$ -$icode%time% = time_test(%test%, %time_min%, %test_size%)%$$ - -$head Purpose$$ -The $code time_test$$ function executes a timing test -and reports the amount of wall clock time for execution. - -$head Motivation$$ -It is important to separate small calculation units -and test them individually. -This way individual changes can be tested in the context of the -routine that they are in. -On many machines, accurate timing of a very short execution -sequences is not possible. -In addition, -there may be set up and tear down time for a test that -we do not really want included in the timing. -For this reason $code time_test$$ -automatically determines how many times to -repeat the section of the test that we wish to time. - -$head Include$$ -The file $code cppad/time_test.hpp$$ defines the -$code time_test$$ function. -This file is included by $code cppad/cppad.hpp$$ -and it can also be included separately with out the rest of -the $code CppAD$$ routines. - -$head test$$ -The $code time_test$$ argument $icode test$$ is a function, -or function object. -In the case where $icode test_size$$ is not present, -$icode test$$ supports the syntax -$codei% - %test%(%repeat%) -%$$ -In the case where $icode test_size$$ is present, -$icode test$$ supports the syntax -$codei% - %test%(%size%, %repeat%) -%$$ -In either case, the return value for $icode test$$ is $code void$$. - -$subhead size$$ -If the argument $icode size$$ is present, -it has prototype -$codei% - size_t %size% -%$$ -and is equal to the $icode test_size$$ argument to $code time_test$$. - -$subhead repeat$$ -The $icode test$$ argument $icode repeat$$ has prototype -$codei% - size_t %repeat% -%$$ -It will be equal to the $icode size$$ argument to $code time_test$$. - -$head time_min$$ -The argument $icode time_min$$ has prototype -$codei% - double %time_min% -%$$ -It specifies the minimum amount of time in seconds -that the $icode test$$ routine should take. -The $icode repeat$$ argument to $icode test$$ is increased -until this amount of execution time (or more) is reached. - -$head test_size$$ -This argument has prototype -$codei% - size_t %test_size% -%$$ -It specifies the $icode size$$ argument to $icode test$$. - -$head time$$ -The return value $icode time$$ has prototype -$codei% - double %time% -%$$ -and is the number of wall clock seconds that it took -to execute $icode test$$ divided by the value used for $icode repeat$$. - -$head Timing$$ -The routine $cref elapsed_seconds$$ will be used to determine the -amount of time it took to execute the test. - -$children% - cppad/elapsed_seconds.hpp% - speed/example/time_test.cpp -%$$ -$head Example$$ -The routine $cref time_test.cpp$$ is an example and test -of $code time_test$$. - -$end ------------------------------------------------------------------------ -*/ - -# include -# include -# include -# include - -namespace CppAD { // BEGIN_CPPAD_NAMESPACE -/*! -\file time_test.hpp -\brief Function that preforms one timing test (for speed of execution). -*/ - -/*! -Preform one wall clock execution timing test. - -\tparam Test -Either the type void (*)(size_t) or a function object -type that supports the same syntax. - -\param test -The function, or function object, that supports the operation -test(repeat) where \c repeat is the number of times -to repeat the tests operaiton that is being timed. - -\param time_min -is the minimum amount of time that \c test should take to preform -the repetitions of the operation being timed. -*/ -template -double time_test(Test test, double time_min ) -{ - size_t repeat = 0; - double s0 = elapsed_seconds(); - double s1 = s0; - while( s1 - s0 < time_min ) - { repeat = std::max(size_t(1), 2 * repeat); - s0 = elapsed_seconds(); - test(repeat); - s1 = elapsed_seconds(); - } - double time = (s1 - s0) / double(repeat); - return time; -} - -/*! -Preform one wall clock execution timing test. - -\tparam Test -Either the type void (*)(size_t, size_t) or a function object -type that supports the same syntax. - -\param test -The function, or function object, that supports the operation -test(size, repeat) where -\c is the size for this test and -\c repeat is the number of times -to repeat the tests operaiton that is being timed. - -\param time_min -is the minimum amount of time that \c test should take to preform -the repetitions of the operation being timed. - -\param test_size -will be used for the value of \c size in the call to \c test. -*/ -template -double time_test(Test test, double time_min, size_t test_size) -{ - size_t repeat = 0; - double s0 = elapsed_seconds(); - double s1 = s0; - while( s1 - s0 < time_min ) - { repeat = std::max(size_t(1), 2 * repeat); - s0 = elapsed_seconds(); - test(test_size, repeat); - s1 = elapsed_seconds(); - } - double time = (s1 - s0) / double(repeat); - return time; -} - -} // END_CPPAD_NAMESPACE - -// END PROGRAM -# endif diff -Nru cppad-2015.00.00.9/cppad/TrackNewDel.h cppad-2016.00.00.1/cppad/TrackNewDel.h --- cppad-2015.00.00.9/cppad/TrackNewDel.h 2009-05-31 01:31:48.000000000 +0000 +++ cppad-2016.00.00.1/cppad/TrackNewDel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* $Id: TrackNewDel.h 1369 2009-05-31 01:31:48Z bradbell $ */ -# include "cppad/track_new_del.hpp" diff -Nru cppad-2015.00.00.9/cppad/track_new_del.hpp cppad-2016.00.00.1/cppad/track_new_del.hpp --- cppad-2015.00.00.9/cppad/track_new_del.hpp 2015-02-24 08:31:38.000000000 +0000 +++ cppad-2016.00.00.1/cppad/track_new_del.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,563 +0,0 @@ -/* $Id: track_new_del.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_TRACK_NEW_DEL_INCLUDED -# define CPPAD_TRACK_NEW_DEL_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin TrackNewDel$$ -$spell - cppad.hpp - Cpp - newptr - Vec - oldptr - newlen - ncopy - const -$$ - -$section Routines That Track Use of New and Delete$$ -$index new, track$$ -$index delete, track$$ -$index track, new and delete$$ -$index memory, track$$ - -$head Deprecated$$ -$index deprecated, track memory$$ -All these routines have been deprecated. -You should use the $cref thread_alloc$$ memory allocator instead -(which works better in both a single thread and -properly in multi-threading environment). - -$head Syntax$$ -$codei%# include -%$$ -$icode%newptr% = TrackNewVec(%file%, %line%, %newlen%, %oldptr%) -%$$ -$codei%TrackDelVec(%file%, %line%, %oldptr%) -%$$ -$icode%newptr% = TrackExtend(%file%, %line%, %newlen%, %ncopy%, %oldptr%) -%$$ -$icode%count% = TrackCount(%file%, %line%)%$$ - - -$head Purpose$$ -These routines -aid in the use of $code new[]$$ and $code delete[]$$ -during the execution of a C++ program. - -$head Include$$ -The file $code cppad/track_new_del.hpp$$ is included by -$code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of the -CppAD include files. - - -$head file$$ -The argument $icode file$$ has prototype -$codei% - const char *%file% -%$$ -It should be the source code file name -where the call to $code TrackNew$$ is located. -The best way to accomplish this is the use the preprocessor symbol -$code __FILE__$$ for this argument. - -$head line$$ -The argument $icode line$$ has prototype -$codei% - int %line% -%$$ -It should be the source code file line number -where the call to $code TrackNew$$ is located. -The best way to accomplish this is the use the preprocessor symbol -$code __LINE__$$ for this argument. - -$head oldptr$$ -The argument $icode oldptr$$ has prototype -$codei% - %Type% *%oldptr% -%$$ -This argument is used to identify the type $icode Type$$. - -$head newlen$$ -The argument $icode newlen$$ has prototype -$codei% - size_t %newlen% -%$$ - -$head head newptr$$ -The return value $icode newptr$$ has prototype -$codei% - %Type% *%newptr% -%$$ -It points to the newly allocated vector of objects -that were allocated using -$codei% - new Type[%newlen%] -%$$ - -$head ncopy$$ -The argument $icode ncopy$$ has prototype -$codei% - size_t %ncopy% -%$$ -This specifies the number of elements that are copied from -the old array to the new array. -The value of $icode ncopy$$ -must be less than or equal $icode newlen$$. - -$head TrackNewVec$$ -$index TrackNewVec$$ -$index NDEBUG$$ -If $code NDEBUG$$ is defined, this routine only sets -$codei% - %newptr% = %Type% new[%newlen%] -%$$ -The value of $icode oldptr$$ does not matter -(except that it is used to identify $icode Type$$). -If $code NDEBUG$$ is not defined, $code TrackNewVec$$ also -tracks the this memory allocation. -In this case, if memory cannot be allocated -$cref ErrorHandler$$ is used to generate a message -stating that there was not sufficient memory. - -$subhead Macro$$ -$index CPPAD_TRACK_NEW_VEC$$ -The preprocessor macro call -$codei% - CPPAD_TRACK_NEW_VEC(%newlen%, %oldptr%) -%$$ -expands to -$codei% - CppAD::TrackNewVec(__FILE__, __LINE__, %newlen%, %oldptr%) -%$$ - -$subhead Previously Deprecated$$ -$index CppADTrackNewVec$$ -The preprocessor macro $code CppADTrackNewVec$$ is the -same as $code CPPAD_TRACK_NEW_VEC$$ and was previously deprecated. - -$head TrackDelVec$$ -$index TrackDelVec$$ -This routine is used to a vector of objects -that have been allocated using $code TrackNew$$ or $code TrackExtend$$. -If $code NDEBUG$$ is defined, this routine only frees memory with -$codei% - delete [] %oldptr% -%$$ -If $code NDEBUG$$ is not defined, $code TrackDelete$$ also checks that -$icode oldptr$$ was allocated by $code TrackNew$$ or $code TrackExtend$$ -and has not yet been freed. -If this is not the case, -$cref ErrorHandler$$ is used to generate an error message. - -$subhead Macro$$ -$index CPPAD_TRACK_DEL_VEC$$ -The preprocessor macro call -$codei% - CPPAD_TRACK_DEL_VEC(%oldptr%) -%$$ -expands to -$codei% - CppAD::TrackDelVec(__FILE__, __LINE__, %oldptr%) -%$$ - -$subhead Previously Deprecated$$ -$index CppADTrackDelVec$$ -The preprocessor macro $code CppADTrackDelVec$$ is the -same as $code CPPAD_TRACK_DEL_VEC$$ was previously deprecated. - -$head TrackExtend$$ -$index TrackExtend$$ -This routine is used to -allocate a new vector (using $code TrackNewVec$$), -copy $icode ncopy$$ elements from the old vector to the new vector. -If $icode ncopy$$ is greater than zero, $icode oldptr$$ -must have been allocated using $code TrackNewVec$$ or $code TrackExtend$$. -In this case, the vector pointed to by $icode oldptr$$ -must be have at least $icode ncopy$$ elements -and it will be deleted (using $code TrackDelVec$$). -Note that the dependence of $code TrackExtend$$ on $code NDEBUG$$ -is indirectly through the routines $code TrackNewVec$$ and -$code TrackDelVec$$. - -$subhead Macro$$ -$index CPPAD_TRACK_EXTEND$$ -The preprocessor macro call -$codei% - CPPAD_TRACK_EXTEND(%newlen%, %ncopy%, %oldptr%) -%$$ -expands to -$codei% - CppAD::TrackExtend(__FILE__, __LINE__, %newlen%, %ncopy%, %oldptr%) -%$$ - -$subhead Previously Deprecated$$ -$index CppADTrackExtend$$ -The preprocessor macro $code CppADTrackExtend$$ is the -same as $code CPPAD_TRACK_EXTEND$$ and was previously deprecated. - -$head TrackCount$$ -$index TrackCount$$ -The return value $icode count$$ has prototype -$codei% - size_t %count% -%$$ -If $code NDEBUG$$ is defined, $icode count$$ will be zero. -Otherwise, it will be -the number of vectors that -have been allocated -(by $code TrackNewVec$$ or $code TrackExtend$$) -and not yet freed -(by $code TrackDelete$$). - -$subhead Macro$$ -$index CPPAD_TRACK_COUNT$$ -The preprocessor macro call -$codei% - CPPAD_TRACK_COUNT() -%$$ -expands to -$codei% - CppAD::TrackCount(__FILE__, __LINE__) -%$$ - -$subhead Previously Deprecated$$ -$index CppADTrackNewVec$$ -The preprocessor macro $code CppADTrackCount$$ is the -same as $code CPPAD_TRACK_COUNT$$ and was previously deprecated. - -$head Multi-Threading$$ -$index multi-threading, TrackCount$$ -$index TrackCount, multi-threading$$ -$index thread, multi TrackCount$$ -These routines cannot be used $cref/in_parallel/ta_in_parallel/$$ -execution mode. -Use the $cref thread_alloc$$ routines instead. - -$head Example$$ -$children% - test_more/track_new_del.cpp -%$$ -The file $cref TrackNewDel.cpp$$ -contains an example and test of these functions. -It returns true, if it succeeds, and false otherwise. - -$end ------------------------------------------------------------------------------- -*/ -# include -# include -# include -# include -# include - -# ifndef CPPAD_TRACK_DEBUG -# define CPPAD_TRACK_DEBUG 0 -# endif - -// ------------------------------------------------------------------------- -# define CPPAD_TRACK_NEW_VEC(newlen, oldptr) \ - CppAD::TrackNewVec(__FILE__, __LINE__, newlen, oldptr) - -# define CPPAD_TRACK_DEL_VEC(oldptr) \ - CppAD::TrackDelVec(__FILE__, __LINE__, oldptr) - -# define CPPAD_TRACK_EXTEND(newlen, ncopy, oldptr) \ - CppAD::TrackExtend(__FILE__, __LINE__, newlen, ncopy, oldptr) - -# define CPPAD_TRACK_COUNT() \ - CppAD::TrackCount(__FILE__, __LINE__) -// ------------------------------------------------------------------------- -# define CppADTrackNewVec CPPAD_TRACK_NEW_VEC -# define CppADTrackDelVec CPPAD_TRACK_DEL_VEC -# define CppADTrackExtend CPPAD_TRACK_EXTEND -# define CppADTrackCount CPPAD_TRACK_COUNT -// ------------------------------------------------------------------------- -namespace CppAD { // Begin CppAD namespace - -// TrackElement ------------------------------------------------------------ -class TrackElement { - -public: - std::string file; // corresponding file name - int line; // corresponding line number - void *ptr; // value returned by TrackNew - TrackElement *next; // next element in linked list - - // default contructor (used to initialize root) - TrackElement(void) - : file(""), line(0), ptr(CPPAD_NULL), next(CPPAD_NULL) - { } - - TrackElement(const char *f, int l, void *p) - : file(f), line(l), ptr(p), next(CPPAD_NULL) - { CPPAD_ASSERT_UNKNOWN( p != CPPAD_NULL); - } - - // There is only one tracking list and it starts it here - static TrackElement *Root(void) - { CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); - static TrackElement root; - return &root; - } - - // Print one tracking element - static void Print(TrackElement* E) - { - CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); - using std::cout; - cout << "E = " << E; - cout << ", E->next = " << E->next; - cout << ", E->ptr = " << E->ptr; - cout << ", E->line = " << E->line; - cout << ", E->file = " << E->file; - cout << std::endl; - } - - // Print the linked list for a thread - static void Print(void) - { - CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); - using std::cout; - using std::endl; - TrackElement *E = Root(); - // convert int(size_t) to avoid warning on _MSC_VER systems - cout << "Begin Track List" << endl; - while( E->next != CPPAD_NULL ) - { E = E->next; - Print(E); - } - cout << "End Track List:" << endl; - cout << endl; - } -}; - - -// TrackError ---------------------------------------------------------------- -inline void TrackError( - const char *routine, - const char *file, - int line, - const char *msg ) -{ - CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); - std::ostringstream buf; - buf << routine - << ": at line " - << line - << " in file " - << file - << std::endl - << msg; - std::string str = buf.str(); - size_t n = str.size(); - size_t i; - char *message = new char[n + 1]; - for(i = 0; i < n; i++) - message[i] = str[i]; - message[n] = '\0'; - CPPAD_ASSERT_KNOWN( false , message); -} - -// TrackNewVec --------------------------------------------------------------- -# ifdef NDEBUG -template -inline Type *TrackNewVec( - const char *file, int line, size_t len, Type * /* oldptr */ ) -{ -# if CPPAD_TRACK_DEBUG - static bool first = true; - if( first ) - { std::cout << "NDEBUG is defined for TrackNewVec" << std::endl; - first = false; - } -# endif - return (new Type[len]); -} - -# else - -template -Type *TrackNewVec( - const char *file , - int line , - size_t len , - Type * /* oldptr */ ) -{ - CPPAD_ASSERT_KNOWN( - ! thread_alloc::in_parallel() , - "attempt to use TrackNewVec in parallel execution mode." - ); - // try to allocate the new memrory - Type *newptr = CPPAD_NULL; - try - { newptr = new Type[len]; - } - catch(...) - { TrackError("TrackNewVec", file, line, - "Cannot allocate sufficient memory" - ); - } - // create tracking element - void *vptr = static_cast(newptr); - TrackElement *E = new TrackElement(file, line, vptr); - - // get the root - TrackElement *root = TrackElement::Root(); - - // put this elemenent at the front of linked list - E->next = root->next; - root->next = E; - -# if CPPAD_TRACK_DEBUG - std::cout << "TrackNewVec: "; - TrackElement::Print(E); -# endif - - return newptr; -} - -# endif - -// TrackDelVec -------------------------------------------------------------- -# ifdef NDEBUG -template -inline void TrackDelVec(const char *file, int line, Type *oldptr) -{ -# if CPPAD_TRACK_DEBUG - static bool first = true; - if( first ) - { std::cout << "NDEBUG is defined in TrackDelVec" << std::endl; - first = false; - } -# endif - delete [] oldptr; -} - -# else - -template -void TrackDelVec( - const char *file , - int line , - Type *oldptr ) -{ - CPPAD_ASSERT_KNOWN( - ! thread_alloc::in_parallel() , - "attempt to use TrackDelVec in parallel execution mode." - ); - TrackElement *P; - TrackElement *E; - - // search list for pointer - P = TrackElement::Root(); - E = P->next; - void *vptr = static_cast(oldptr); - while(E != CPPAD_NULL && E->ptr != vptr) - { P = E; - E = E->next; - } - - // check if pointer was not in list - if( E == CPPAD_NULL || E->ptr != vptr ) TrackError( - "TrackDelVec", file, line, - "Invalid value for the argument oldptr.\n" - "Possible linking of debug and NDEBUG compliations of CppAD." - ); - -# if CPPAD_TRACK_DEBUG - std::cout << "TrackDelVec: "; - TrackElement::Print(E); -# endif - - // remove tracking element from list - P->next = E->next; - - // delete allocated pointer - delete [] oldptr; - - // delete tracking element - delete E; - - return; -} - -# endif - -// TrackExtend -------------------------------------------------------------- -template -Type *TrackExtend( - const char *file , - int line , - size_t newlen , - size_t ncopy , - Type *oldptr ) -{ - CPPAD_ASSERT_KNOWN( - ! thread_alloc::in_parallel() , - "attempt to use TrackExtend in parallel execution mode." - ); - -# if CPPAD_TRACK_DEBUG - using std::cout; - cout << "TrackExtend: file = " << file; - cout << ", line = " << line; - cout << ", newlen = " << newlen; - cout << ", ncopy = " << ncopy; - cout << ", oldptr = " << oldptr; - cout << std::endl; -# endif - CPPAD_ASSERT_KNOWN( - ncopy <= newlen, - "TrackExtend: ncopy is greater than newlen." - ); - - // allocate the new memrory - Type *newptr = TrackNewVec(file, line, newlen, oldptr); - - // copy the data - size_t i; - for(i = 0; i < ncopy; i++) - newptr[i] = oldptr[i]; - - // delete the old vector - if( ncopy > 0 ) - TrackDelVec(file, line, oldptr); - - return newptr; -} - -// TrackCount -------------------------------------------------------------- -inline size_t TrackCount(const char *file, int line) -{ - CPPAD_ASSERT_KNOWN( - ! thread_alloc::in_parallel() , - "attempt to use TrackCount in parallel execution mode." - ); - size_t count = 0; - TrackElement *E = TrackElement::Root(); - while( E->next != CPPAD_NULL ) - { ++count; - E = E->next; - } - return count; -} -// --------------------------------------------------------------------------- - -} // End CppAD namespace - -// preprocessor symbols local to this file -# undef CPPAD_TRACK_DEBUG - -# endif diff -Nru cppad-2015.00.00.9/cppad/utility/check_numeric_type.hpp cppad-2016.00.00.1/cppad/utility/check_numeric_type.hpp --- cppad-2015.00.00.9/cppad/utility/check_numeric_type.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/check_numeric_type.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,176 @@ +// $Id: check_numeric_type.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_CHECK_NUMERIC_TYPE_HPP +# define CPPAD_CHECK_NUMERIC_TYPE_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin CheckNumericType$$ +$spell + alloc + cppad.hpp + CppAD +$$ + +$section Check NumericType Class Concept$$ +$mindex numeric CheckNumericType$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%CheckNumericType<%NumericType%>()%$$ + + +$head Purpose$$ +The syntax +$codei% + CheckNumericType<%NumericType%>() +%$$ +preforms compile and run time checks that the type specified +by $icode NumericType$$ satisfies all the requirements for +a $cref NumericType$$ class. +If a requirement is not satisfied, +a an error message makes it clear what condition is not satisfied. + +$head Include$$ +The file $code cppad/check_numeric_type.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest +if the CppAD include files. + +$head Parallel Mode$$ +The routine $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ +must be called before it +can be used in $cref/parallel/ta_in_parallel/$$ mode. + +$head Example$$ +$children% + example/check_numeric_type.cpp +%$$ +The file $cref check_numeric_type.cpp$$ +contains an example and test of this function. +It returns true, if it succeeds an false otherwise. +The comments in this example suggest a way to change the example +so an error message occurs. + +$end +--------------------------------------------------------------------------- +*/ + +# include +# include + +namespace CppAD { + +# ifdef NDEBUG + template + void CheckNumericType(void) + { } +# else + template + NumericType CheckNumericType(void) + { // Section 3.6.2 of ISO/IEC 14882:1998(E) states: "The storage for + // objects with static storage duration (3.7.1) shall be zero- + // initialized (8.5) before any other initialization takes place." + static size_t count[CPPAD_MAX_NUM_THREADS]; + size_t thread = thread_alloc::thread_num(); + if( count[thread] > 0 ) + return NumericType(0); + count[thread]++; + /* + contructors + */ + NumericType check_NumericType_default_constructor; + NumericType check_NumericType_constructor_from_int(1); + + const NumericType x(1); + + NumericType check_NumericType_copy_constructor(x); + + // assignment + NumericType check_NumericType_assignment; + check_NumericType_assignment = x; + + /* + unary operators + */ + const NumericType check_NumericType_unary_plus(1); + NumericType check_NumericType_unary_plus_result = + + check_NumericType_unary_plus; + + const NumericType check_NumericType_unary_minus(1); + NumericType check_NumericType_unary_minus_result = + - check_NumericType_unary_minus; + + /* + binary operators + */ + const NumericType check_NumericType_binary_addition(1); + NumericType check_NumericType_binary_addition_result = + check_NumericType_binary_addition + x; + + const NumericType check_NumericType_binary_subtraction(1); + NumericType check_NumericType_binary_subtraction_result = + check_NumericType_binary_subtraction - x; + + const NumericType check_NumericType_binary_multiplication(1); + NumericType check_NumericType_binary_multiplication_result = + check_NumericType_binary_multiplication * x; + + const NumericType check_NumericType_binary_division(1); + NumericType check_NumericType_binary_division_result = + check_NumericType_binary_division / x; + + /* + computed assignment operators + */ + NumericType + check_NumericType_computed_assignment_addition(1); + check_NumericType_computed_assignment_addition += x; + + NumericType + check_NumericType_computed_assignment_subtraction(1); + check_NumericType_computed_assignment_subtraction -= x; + + NumericType + check_NumericType_computed_assignment_multiplication(1); + check_NumericType_computed_assignment_multiplication *= x; + + NumericType + check_NumericType_computed_assignment_division(1); + check_NumericType_computed_assignment_division /= x; + + /* + use all values so as to avoid warnings + */ + check_NumericType_default_constructor = x; + return + + check_NumericType_default_constructor + + check_NumericType_constructor_from_int + + check_NumericType_copy_constructor + + check_NumericType_assignment + + check_NumericType_unary_plus_result + + check_NumericType_unary_minus_result + + check_NumericType_binary_addition_result + + check_NumericType_binary_subtraction_result + + check_NumericType_binary_multiplication_result + + check_NumericType_binary_division_result + + check_NumericType_computed_assignment_addition + + check_NumericType_computed_assignment_subtraction + + check_NumericType_computed_assignment_multiplication + + check_NumericType_computed_assignment_division + ; + } +# endif + +} // end namespace CppAD + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/check_simple_vector.hpp cppad-2016.00.00.1/cppad/utility/check_simple_vector.hpp --- cppad-2015.00.00.9/cppad/utility/check_simple_vector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/check_simple_vector.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,201 @@ +// $Id: check_simple_vector.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_CHECK_SIMPLE_VECTOR_HPP +# define CPPAD_CHECK_SIMPLE_VECTOR_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin CheckSimpleVector$$ +$spell + alloc + const + cppad.hpp + CppAD +$$ + +$section Check Simple Vector Concept$$ +$mindex CheckSimpleVector$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%CheckSimpleVector<%Scalar%, %Vector%>()%$$ +$pre +$$ +$codei%CheckSimpleVector<%Scalar%, %Vector%>(%x%, %y%)%$$ + + +$head Purpose$$ +Preforms compile and run time checks that the type specified +by $icode Vector$$ satisfies all the requirements for +a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Scalar$$. +If a requirement is not satisfied, +a an error message makes it clear what condition is not satisfied. + +$head x, y$$ +If the arguments $icode x$$ and $icode y$$ are present, +they have prototype +$codei% + const %Scalar%& %x% + const %Scalar%& %y% +%$$ +In addition, the check +$codei% + %x% == %x% +%$$ +will return the boolean value $code true$$, and +$codei% + %x% == %y% +%$$ +will return $code false$$. + +$head Restrictions$$ +If the arguments $icode x$$ and $icode y$$ are not present, +the following extra assumption is made by $code CheckSimpleVector$$: +If $icode x$$ is a $icode Scalar$$ object +$codei% + %x% = 0 + %y% = 1 +%$$ +assigns values to the objects $icode x$$ and $icode y$$. +In addition, +$icode%x% == %x%$$ would return the boolean value $code true$$ and +$icode%x% == %y%$$ would return $code false$$. + +$head Include$$ +The file $code cppad/check_simple_vector.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest +if the CppAD include files. + +$head Parallel Mode$$ +The routine $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ +must be called before it +can be used in $cref/parallel/ta_in_parallel/$$ mode. + +$head Example$$ +$children% + example/check_simple_vector.cpp +%$$ +The file $cref check_simple_vector.cpp$$ +contains an example and test of this function where $icode S$$ +is the same as $icode T$$. +It returns true, if it succeeds an false otherwise. +The comments in this example suggest a way to change the example +so $icode S$$ is not the same as $icode T$$. + +$end +--------------------------------------------------------------------------- +*/ + +# include +# include +# include +# include + +namespace CppAD { + +# ifdef NDEBUG + template + inline void CheckSimpleVector(const Scalar& x, const Scalar& y) + { } + template + inline void CheckSimpleVector(void) + { } +# else + template + struct ok_if_S_same_as_T { }; + + template + struct ok_if_S_same_as_T { T value; }; + + template + void CheckSimpleVector(const Scalar& x, const Scalar& y) + { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL + static size_t count; + if( count > 0 ) + return; + count++; + + // value_type must be type of elements of Vector + typedef typename Vector::value_type value_type; + + // check that elements of Vector have type Scalar + struct ok_if_S_same_as_T x_copy; + x_copy.value = x; + + // check default constructor + Vector d; + + // size member function + CPPAD_ASSERT_KNOWN( + d.size() == 0, + "default construtor result does not have size zero" + ); + + // resize to same size as other vectors in test + d.resize(1); + + // check sizing constructor + Vector s(1); + + // check element assignment + s[0] = y; + CPPAD_ASSERT_KNOWN( + s[0] == y, + "element assignment failed" + ); + + // check copy constructor + s[0] = x_copy.value; + const Vector c(s); + s[0] = y; + CPPAD_ASSERT_KNOWN( + c[0] == x, + "copy constructor is shallow" + ); + + // vector assignment operator + d[0] = x; + s = d; + s[0] = y; + CPPAD_ASSERT_KNOWN( + d[0] == x, + "assignment operator is shallow" + ); + + // element access, right side const + // element assignment, left side not const + d[0] = c[0]; + CPPAD_ASSERT_KNOWN( + d[0] == x, + "element assignment from const failed" + ); + } + template + void CheckSimpleVector(void) + { Scalar x; + Scalar y; + + // use assignment and not constructor + x = 0; + y = 1; + + CheckSimpleVector(x, y); + } + +# endif + +} // end namespace CppAD + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/elapsed_seconds.hpp cppad-2016.00.00.1/cppad/utility/elapsed_seconds.hpp --- cppad-2015.00.00.9/cppad/utility/elapsed_seconds.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/elapsed_seconds.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,175 @@ +// $Id: elapsed_seconds.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_ELAPSED_SECONDS_HPP +# define CPPAD_ELAPSED_SECONDS_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin elapsed_seconds$$ +$spell + cppad.hpp + Microsoft + gettimeofday + std + chrono +$$ + +$section Returns Elapsed Number of Seconds$$ +$mindex elapsed_seconds time$$ + + +$head Syntax$$ +$codei%# include +%$$ +$icode%s% = elapsed_seconds()%$$ + +$head Purpose$$ +This routine is accurate to within .02 seconds +(see $cref elapsed_seconds.cpp$$). +It does not necessary work for time intervals that are greater than a day. +$list number$$ +If the C++11 $code std::chrono::high_resolution_clock$$ is available, +it will be used for timing. +$lnext +Otherwise, if running under the Microsoft compiler, +$code ::GetSystemTime$$ will be used for timing. +$lnext +Otherwise, if $code gettimeofday$$ is available, it is used for timing. +$lnext +Otherwise, $code std::clock()$$ will be used for timing. +$lend + +$head s$$ +is a $code double$$ equal to the +number of seconds since the first call to $code elapsed_seconds$$. + +$head Microsoft Systems$$ +It you are using $code ::GetSystemTime$$, +you will need to link in the external routine +called $cref microsoft_timer$$. + +$children% + speed/example/elapsed_seconds.cpp +%$$ +$head Example$$ +The routine $cref elapsed_seconds.cpp$$ is +an example and test of this routine. + + +$end +----------------------------------------------------------------------- +*/ + +// For some unknown reason under Fedora (which needs to be understood), +// if you move this include for cppad_assert.hpp below include for define.hpp, +// cd work/speed/example +// make test.sh +// fails with the error message 'gettimeofday' not defined. +# include + +// define CPPAD_NULL +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +# if CPPAD_USE_CPLUSPLUS_2011 +# include +# elif _MSC_VER +extern double microsoft_timer(void); +# elif CPPAD_HAS_GETTIMEOFDAY +# include +# else +# include +# endif + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file elapsed_seconds.hpp +\brief Function that returns the elapsed seconds from first call. +*/ + +/*! +Returns the elapsed number since the first call to this function. + +This routine tries is accurate to within .02 seconds. +It does not necessary work for time intervals that are less than a day. +\li +If running under the Microsoft system, it uses \c ::%GetSystemTime for timing. +\li +Otherwise, if \c gettimeofday is available, it is used. +\li +Otherwise, \c std::clock() is used. + +\return +The number of seconds since the first call to \c elapsed_seconds. +*/ +inline double elapsed_seconds(void) +// -------------------------------------------------------------------------- +# if CPPAD_USE_CPLUSPLUS_2011 +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static bool first_ = true; + static std::chrono::time_point start_; + if( first_ ) + { start_ = std::chrono::high_resolution_clock::now(); + first_ = false; + return 0.0; + } + std::chrono::time_point now; + now = std::chrono::high_resolution_clock::now(); + std::chrono::duration difference = now - start_; + return difference.count(); +} +// -------------------------------------------------------------------------- +# elif _MSC_VER +{ return microsoft_timer(); } +// -------------------------------------------------------------------------- +# elif CPPAD_HAS_GETTIMEOFDAY +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static bool first_ = true; + static struct timeval tv_; + struct timeval tv; + if( first_ ) + { gettimeofday(&tv_, CPPAD_NULL); + first_ = false; + return 0.; + } + gettimeofday(&tv, CPPAD_NULL); + assert( tv.tv_sec >= tv_.tv_sec ); + + double sec = double(tv.tv_sec - tv_.tv_sec); + double usec = double(tv.tv_usec) - double(tv_.tv_usec); + double diff = sec + 1e-6*usec; + + return diff; +} +// -------------------------------------------------------------------------- +# else // Not CPPAD_USE_CPLUSPLUS_2011 or CPPAD_HAS_GETTIMEOFDAY +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static bool first_ = true; + static double tic_; + double tic; + if( first_ ) + { tic_ = double(std::clock()); + first_ = false; + return 0.; + } + tic = double( std::clock() ); + + double diff = (tic - tic_) / double(CLOCKS_PER_SEC); + + return diff; +} +# endif +// -------------------------------------------------------------------------- +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/error_handler.hpp cppad-2016.00.00.1/cppad/utility/error_handler.hpp --- cppad-2015.00.00.9/cppad/utility/error_handler.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/error_handler.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,236 @@ +// $Id: error_handler.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_ERROR_HANDLER_HPP +# define CPPAD_ERROR_HANDLER_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin ErrorHandler$$ +$spell + cppad.hpp + CppAD + exp + bool + const +$$ + +$section Replacing the CppAD Error Handler$$ +$mindex replace assert exception ErrorHandler$$ + +$head Syntax$$ +$codei%# include +%$$ +$codei%ErrorHandler %info%(%handler%) +%$$ +$codei%ErrorHandler::Call(%known%, %line%, %file%, %exp%, %msg%) +%$$ + +$head Constructor$$ +When you construct a $code ErrorHandler$$ object, +the current CppAD error handler is replaced by $icode handler$$. +When the object is destructed, the previous CppAD error handler is restored. + +$subhead Parallel Mode$$ +The $code ErrorHandler$$ constructor and destructor cannot be called in +$cref/parallel/ta_in_parallel/$$ execution mode. +Furthermore, this rule is not abided by, a raw C++ $code assert$$, +instead of one that uses this error handler, will be generated. + +$head Call$$ +When $code ErrorHandler::Call$$ is called, +the current CppAD error handler is used to report an error. +This starts out as a default error handler and can be replaced +using the $code ErrorHandler$$ constructor. + +$head info$$ +The object $icode info$$ is used to store information +that is necessary to restore the previous CppAD error handler. +This is done when the destructor for $icode info$$ is called. + + +$head handler$$ +The argument $icode handler$$ has prototype +$codei% + void (*%handler%) + (bool, int, const char *, const char *, const char *); +%$$ +When an error is detected, +it is called with the syntax +$codei% + %handler% (%known%, %line%, %file%, %exp%, %msg%) +%$$ +This routine should not return; i.e., upon detection of the error, +the routine calling $icode handler$$ does not know how to proceed. + +$head known$$ +The $icode handler$$ argument $icode known$$ has prototype +$codei% + bool %known% +%$$ +If it is true, the error being reported is from a know problem. + +$head line$$ +The $icode handler$$ argument $icode line$$ has prototype +$codei% + int %line% +%$$ +It reports the source code line number where the error is detected. + +$head file$$ +The $icode handler$$ argument $icode file$$ has prototype +$codei% + const char *%file% +%$$ +and is a $code '\0'$$ terminated character vector. +It reports the source code file where the error is detected. + +$head exp$$ +The $icode handler$$ argument $icode exp$$ has prototype +$codei% + const char *%exp% +%$$ +and is a $code '\0'$$ terminated character vector. +It is a source code boolean expression that should have been true, +but is false, +and thereby causes this call to $icode handler$$. + +$head msg$$ +The $icode handler$$ argument $icode msg$$ has prototype +$codei% + const char *%msg% +%$$ +and is a $code '\0'$$ terminated character vector. +It reports the meaning of the error from the C++ programmers point of view. + +$children% + example/error_handler.cpp% + cppad/local/cppad_assert.hpp +%$$ +$head Example$$ +The file +$cref error_handler.cpp$$ +contains an example and test a test of using this routine. +It returns true if it succeeds and false otherwise. + +$end +--------------------------------------------------------------------------- +*/ + +# include + +# include +# include +# include +# include + +namespace CppAD { // BEGIN CppAD namespace + +class ErrorHandler { + template + friend void parallel_ad(void); +public: + typedef void (*Handler) + (bool, int, const char *, const char *, const char *); + + // construct a new handler + ErrorHandler(Handler handler) : previous( Current() ) + { if( set_get_in_parallel(0) ) + { bool known = true; + int line = __LINE__; + const char* file = __FILE__; + const char* exp = "! set_get_in_parallel(0)"; + const char* msg = + "Using ErrorHandler constructor in parallel mode."; + Call(known, line, file, exp, msg); + } + Current() = handler; + } + + // destructor for an error handler + ~ErrorHandler(void) + { if( set_get_in_parallel(0) ) + { bool known = true; + int line = __LINE__; + const char* file = __FILE__; + const char* exp = "! set_get_in_parallel(0)"; + const char* msg = + "Using ErrorHandler destructor in parallel mode."; + Call(known, line, file, exp, msg); + } + Current() = previous; + } + + // report an error + static void Call( + bool known, + int line , + const char *file , + const char *exp , + const char *msg ) + { Handler handler = Current(); + handler(known, line, file, exp, msg); + } + +private: + const Handler previous; + + // The default error handler + static void Default( + bool known, + int line , + const char *file , + const char *exp , + const char *msg ) + { using std::cerr; + using std::endl; + + cerr << CPPAD_PACKAGE_STRING; + if( known ) + cerr << " error from a known source:" << endl; + else cerr << " error from unknown source" << endl; + if( msg[0] != '\0' ) + cerr << msg << endl; + cerr << "Error detected by false result for" << endl; + cerr << " " << exp << endl; + cerr << "at line " << line << " in the file " << endl; + cerr << " " << file << endl; + + // terminate program execution + assert(false); + + // termination when NDEBUG is defined + std::exit(1); + } + + // current error handler + static Handler &Current(void) + { static bool first_call = true; + static Handler current = Default; + if( first_call ) + { if( set_get_in_parallel(0) ) + { bool known = false; + int line = __LINE__; + const char* file = __FILE__; + const char* exp = ""; + const char* msg = ""; + Call(known, line, file, exp, msg); + } + first_call = false; + } + return current; + } +}; + +} // END CppAD namespace + + + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/index_sort.hpp cppad-2016.00.00.1/cppad/utility/index_sort.hpp --- cppad-2015.00.00.9/cppad/utility/index_sort.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/index_sort.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,179 @@ +// $Id: index_sort.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_INDEX_SORT_HPP +# define CPPAD_INDEX_SORT_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin index_sort$$ +$spell + cppad.hpp + ind + const +$$ + +$section Returns Indices that Sort a Vector$$ +$mindex index_sort$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%index_sort(%keys%, %ind%)%$$ + +$head keys$$ +The argument $icode keys$$ has prototype +$codei% + const %VectorKey%& %keys% +%$$ +where $icode VectorKey$$ is +a $cref SimpleVector$$ class with elements that support the $code <$$ +operation. + +$head ind$$ +The argument $icode ind$$ has prototype +$codei% + %VectorSize%& %ind% +%$$ +where $icode VectorSize$$ is +a $cref SimpleVector$$ class with elements of type $code size_t$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$subhead Input$$ +The size of $icode ind$$ must be the same as the size of $icode keys$$ +and the value of its input elements does not matter. + +$subhead Return$$ +Upon return, $icode ind$$ is a permutation of the set of indices +that yields increasing order for $icode keys$$. +In other words, for all $icode%i% != %j%$$, +$codei% + %ind%[%i%] != %ind%[%j%] +%$$ +and for $icode%i% = 0 , %...% , %size%-2%$$, +$codei% + ( %keys%[ %ind%[%i%+1] ] < %keys%[ %ind%[%i%] ] ) == false +%$$ + + +$head Example$$ +$children% + example/index_sort.cpp +%$$ +The file $cref index_sort.cpp$$ contains an example +and test of this routine. +It return true if it succeeds and false otherwise. + +$end +*/ +# include +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file index_sort.hpp +File used to implement the CppAD index sort utility +*/ + +/*! +Helper class used by index_sort +*/ +template +class index_sort_element { +private: + /// key used to determine position of this element + Compare key_; + /// index vlaue corresponding to this key + size_t index_; +public: + /// operator requried by std::sort + bool operator<(const index_sort_element& other) const + { return key_ < other.key_; } + /// set the key for this element + void set_key(const Compare& value) + { key_ = value; } + /// set the index for this element + void set_index(const size_t& index) + { index_ = index; } + /// get the key for this element + Compare get_key(void) const + { return key_; } + /// get the index for this element + size_t get_index(void) const + { return index_; } +}; + +/*! +Compute the indices that sort a vector of keys + +\tparam VectorKey +Simple vector type that deterimene the sorting order by \c < operator +on its elements. + +\tparam VectorSize +Simple vector type with elements of \c size_t +that is used to return index values. + +\param keys [in] +values that determine the sorting order. + +\param ind [out] +must have the same size as \c keys. +The input value of its elements does not matter. +The output value of its elements satisfy +\code +( keys[ ind[i] ] < keys[ ind[i+1] ] ) == false +\endcode +*/ +template +void index_sort(const VectorKey& keys, VectorSize& ind) +{ typedef typename VectorKey::value_type Compare; + CheckSimpleVector(); + + typedef index_sort_element element; + + CPPAD_ASSERT_KNOWN( + size_t(keys.size()) == size_t(ind.size()), + "index_sort: vector sizes do not match" + ); + + size_t size_work = size_t(keys.size()); + size_t size_out; + element* work = + thread_alloc::create_array(size_work, size_out); + + // copy initial order into work + size_t i; + for(i = 0; i < size_work; i++) + { work[i].set_key( keys[i] ); + work[i].set_index( i ); + } + + // sort the work array + std::sort(work, work+size_work); + + // copy the indices to the output vector + for(i = 0; i < size_work; i++) + ind[i] = work[i].get_index(); + + // we are done with this work array + thread_alloc::delete_array(work); + + return; +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/lu_factor.hpp cppad-2016.00.00.1/cppad/utility/lu_factor.hpp --- cppad-2015.00.00.9/cppad/utility/lu_factor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/lu_factor.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,394 @@ +// $Id: lu_factor.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_LU_FACTOR_HPP +# define CPPAD_LU_FACTOR_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin LuFactor$$ +$escape #$$ +$spell + cppad.hpp + Cpp + Geq + Lu + bool + const + ip + jp + namespace + std + typename +$$ + + +$section LU Factorization of A Square Matrix$$ +$mindex LuFactor linear equation solve$$ + +$pre +$$ + +$head Syntax$$ $codei%# include +%$$ +$icode%sign% = LuFactor(%ip%, %jp%, %LU%)%$$ + + +$head Description$$ +Computes an LU factorization of the matrix $icode A$$ +where $icode A$$ is a square matrix. + +$head Include$$ +The file $code cppad/lu_factor.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Matrix Storage$$ +All matrices are stored in row major order. +To be specific, if $latex Y$$ is a vector +that contains a $latex p$$ by $latex q$$ matrix, +the size of $latex Y$$ must be equal to $latex p * q $$ and for +$latex i = 0 , \ldots , p-1$$, +$latex j = 0 , \ldots , q-1$$, +$latex \[ + Y_{i,j} = Y[ i * q + j ] +\] $$ + +$head sign$$ +The return value $icode sign$$ has prototype +$codei% + int %sign% +%$$ +If $icode A$$ is invertible, $icode sign$$ is plus or minus one +and is the sign of the permutation corresponding to the row ordering +$icode ip$$ and column ordering $icode jp$$. +If $icode A$$ is not invertible, $icode sign$$ is zero. + +$head ip$$ +The argument $icode ip$$ has prototype +$codei% + %SizeVector% &%ip% +%$$ +(see description of $cref/SizeVector/LuFactor/SizeVector/$$ below). +The size of $icode ip$$ is referred to as $icode n$$ in the +specifications below. +The input value of the elements of $icode ip$$ does not matter. +The output value of the elements of $icode ip$$ determine +the order of the rows in the permuted matrix. + +$head jp$$ +The argument $icode jp$$ has prototype +$codei% + %SizeVector% &%jp% +%$$ +(see description of $cref/SizeVector/LuFactor/SizeVector/$$ below). +The size of $icode jp$$ must be equal to $icode n$$. +The input value of the elements of $icode jp$$ does not matter. +The output value of the elements of $icode jp$$ determine +the order of the columns in the permuted matrix. + +$head LU$$ +The argument $icode LU$$ has the prototype +$codei% + %FloatVector% &%LU% +%$$ +and the size of $icode LU$$ must equal $latex n * n$$ +(see description of $cref/FloatVector/LuFactor/FloatVector/$$ below). + +$subhead A$$ +We define $icode A$$ as the matrix corresponding to the input +value of $icode LU$$. + +$subhead P$$ +We define the permuted matrix $icode P$$ in terms of $icode A$$ by +$codei% + %P%(%i%, %j%) = %A%[ %ip%[%i%] * %n% + %jp%[%j%] ] +%$$ + +$subhead L$$ +We define the lower triangular matrix $icode L$$ in terms of the +output value of $icode LU$$. +The matrix $icode L$$ is zero above the diagonal +and the rest of the elements are defined by +$codei% + %L%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] +%$$ +for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , i$$. + +$subhead U$$ +We define the upper triangular matrix $icode U$$ in terms of the +output value of $icode LU$$. +The matrix $icode U$$ is zero below the diagonal, +one on the diagonal, +and the rest of the elements are defined by +$codei% + %U%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] +%$$ +for $latex i = 0 , \ldots , n-2$$ and $latex j = i+1 , \ldots , n-1$$. + +$subhead Factor$$ +If the return value $icode sign$$ is non-zero, +$codei% + %L% * %U% = %P% +%$$ +If the return value of $icode sign$$ is zero, +the contents of $icode L$$ and $icode U$$ are not defined. + +$subhead Determinant$$ +If the return value $icode sign$$ is zero, +the determinant of $icode A$$ is zero. +If $icode sign$$ is non-zero, +using the output value of $icode LU$$ +the determinant of the matrix $icode A$$ is equal to +$codei% +%sign% * %LU%[%ip%[0], %jp%[0]] * %...% * %LU%[%ip%[%n%-1], %jp%[%n%-1]] +%$$ + +$head SizeVector$$ +The type $icode SizeVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type size_t/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head FloatVector$$ +The type $icode FloatVector$$ must be a +$cref/simple vector class/SimpleVector/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Float$$ +This notation is used to denote the type corresponding +to the elements of a $icode FloatVector$$. +The type $icode Float$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. +In addition, the following operations must be defined for any pair +of $icode Float$$ objects $icode x$$ and $icode y$$: + +$table +$bold Operation$$ $cnext $bold Description$$ $rnext +$codei%log(%x%)%$$ $cnext + returns the logarithm of $icode x$$ as a $icode Float$$ object +$tend + +$head AbsGeq$$ +Including the file $code lu_factor.hpp$$ defines the template function +$codei% + template + bool AbsGeq<%Float%>(const %Float% &%x%, const %Float% &%y%) +%$$ +in the $code CppAD$$ namespace. +This function returns true if the absolute value of +$icode x$$ is greater than or equal the absolute value of $icode y$$. +It is used by $code LuFactor$$ to choose the pivot elements. +This template function definition uses the operator +$code <=$$ to obtain the absolute value for $icode Float$$ objects. +If this operator is not defined for your use of $icode Float$$, +you will need to specialize this template so that it works for your +use of $code LuFactor$$. +$pre + +$$ +Complex numbers do not have the operation $code <=$$ defined. +The specializations +$codei% +bool AbsGeq< std::complex > + (const std::complex &%x%, const std::complex &%y%) +bool AbsGeq< std::complex > + (const std::complex &%x%, const std::complex &%y%) +%$$ +are define by including $code lu_factor.hpp$$ +These return true if the sum of the square of the real and imaginary parts +of $icode x$$ is greater than or equal the +sum of the square of the real and imaginary parts of $icode y$$. + +$children% + example/lu_factor.cpp% + omh/lu_factor_hpp.omh +%$$ +$head Example$$ +The file +$cref lu_factor.cpp$$ +contains an example and test of using $code LuFactor$$ by itself. +It returns true if it succeeds and false otherwise. +$pre + +$$ +The file $cref lu_solve.hpp$$ provides a useful example usage of +$code LuFactor$$ with $code LuInvert$$. + +$head Source$$ +The file $cref lu_factor.hpp$$ contains the +current source code that implements these specifications. + +$end +-------------------------------------------------------------------------- +*/ +// BEGIN C++ + +# include +# include + +# include +# include +# include + +namespace CppAD { // BEGIN CppAD namespace + +// AbsGeq +template +inline bool AbsGeq(const Float &x, const Float &y) +{ Float xabs = x; + if( xabs <= Float(0) ) + xabs = - xabs; + Float yabs = y; + if( yabs <= Float(0) ) + yabs = - yabs; + return xabs >= yabs; +} +inline bool AbsGeq( + const std::complex &x, + const std::complex &y) +{ double xsq = x.real() * x.real() + x.imag() * x.imag(); + double ysq = y.real() * y.real() + y.imag() * y.imag(); + + return xsq >= ysq; +} +inline bool AbsGeq( + const std::complex &x, + const std::complex &y) +{ float xsq = x.real() * x.real() + x.imag() * x.imag(); + float ysq = y.real() * y.real() + y.imag() * y.imag(); + + return xsq >= ysq; +} + +// Lines that are different from code in cppad/local/lu_ratio.hpp end with // +template // +int LuFactor(SizeVector &ip, SizeVector &jp, FloatVector &LU) // +{ + // type of the elements of LU // + typedef typename FloatVector::value_type Float; // + + // check numeric type specifications + CheckNumericType(); + + // check simple vector class specifications + CheckSimpleVector(); + CheckSimpleVector(); + + size_t i, j; // some temporary indices + const Float zero( 0 ); // the value zero as a Float object + size_t imax; // row index of maximum element + size_t jmax; // column indx of maximum element + Float emax; // maximum absolute value + size_t p; // count pivots + int sign; // sign of the permutation + Float etmp; // temporary element + Float pivot; // pivot element + + // ------------------------------------------------------- + size_t n = ip.size(); + CPPAD_ASSERT_KNOWN( + size_t(jp.size()) == n, + "Error in LuFactor: jp must have size equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(LU.size()) == n * n, + "Error in LuFactor: LU must have size equal to n * m" + ); + // ------------------------------------------------------- + + // initialize row and column order in matrix not yet pivoted + for(i = 0; i < n; i++) + { ip[i] = i; + jp[i] = i; + } + // initialize the sign of the permutation + sign = 1; + // --------------------------------------------------------- + + // Reduce the matrix P to L * U using n pivots + for(p = 0; p < n; p++) + { // determine row and column corresponding to element of + // maximum absolute value in remaining part of P + imax = jmax = n; + emax = zero; + for(i = p; i < n; i++) + { for(j = p; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( + (ip[i] < n) & (jp[j] < n) + ); + etmp = LU[ ip[i] * n + jp[j] ]; + + // check if maximum absolute value so far + if( AbsGeq (etmp, emax) ) + { imax = i; + jmax = j; + emax = etmp; + } + } + } + CPPAD_ASSERT_KNOWN( + (imax < n) & (jmax < n) , + "LuFactor can't determine an element with " + "maximum absolute value.\n" + "Perhaps original matrix contains not a number or infinity.\n" + "Perhaps your specialization of AbsGeq is not correct." + ); + if( imax != p ) + { // switch rows so max absolute element is in row p + i = ip[p]; + ip[p] = ip[imax]; + ip[imax] = i; + sign = -sign; + } + if( jmax != p ) + { // switch columns so max absolute element is in column p + j = jp[p]; + jp[p] = jp[jmax]; + jp[jmax] = j; + sign = -sign; + } + // pivot using the max absolute element + pivot = LU[ ip[p] * n + jp[p] ]; + + // check for determinant equal to zero + if( pivot == zero ) + { // abort the mission + return 0; + } + + // Reduce U by the elementary transformations that maps + // LU( ip[p], jp[p] ) to one. Only need transform elements + // above the diagonal in U and LU( ip[p] , jp[p] ) is + // corresponding value below diagonal in L. + for(j = p+1; j < n; j++) + LU[ ip[p] * n + jp[j] ] /= pivot; + + // Reduce U by the elementary transformations that maps + // LU( ip[i], jp[p] ) to zero. Only need transform elements + // above the diagonal in U and LU( ip[i], jp[p] ) is + // corresponding value below diagonal in L. + for(i = p+1; i < n; i++ ) + { etmp = LU[ ip[i] * n + jp[p] ]; + for(j = p+1; j < n; j++) + { LU[ ip[i] * n + jp[j] ] -= + etmp * LU[ ip[p] * n + jp[j] ]; + } + } + } + return sign; +} +} // END CppAD namespace +// END C++ +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/lu_invert.hpp cppad-2016.00.00.1/cppad/utility/lu_invert.hpp --- cppad-2015.00.00.9/cppad/utility/lu_invert.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/lu_invert.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,240 @@ +// $Id: lu_invert.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_LU_INVERT_HPP +# define CPPAD_LU_INVERT_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin LuInvert$$ +$escape #$$ +$spell + cppad.hpp + Lu + Cpp + jp + ip + const + namespace + typename + etmp +$$ + + +$section Invert an LU Factored Equation$$ +$mindex LuInvert linear$$ + +$pre +$$ + +$head Syntax$$ $codei%# include +%$$ +$codei%LuInvert(%ip%, %jp%, %LU%, %X%)%$$ + + +$head Description$$ +Solves the matrix equation $icode%A% * %X% = %B%$$ +using an LU factorization computed by $cref LuFactor$$. + +$head Include$$ +The file $code cppad/lu_invert.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Matrix Storage$$ +All matrices are stored in row major order. +To be specific, if $latex Y$$ is a vector +that contains a $latex p$$ by $latex q$$ matrix, +the size of $latex Y$$ must be equal to $latex p * q $$ and for +$latex i = 0 , \ldots , p-1$$, +$latex j = 0 , \ldots , q-1$$, +$latex \[ + Y_{i,j} = Y[ i * q + j ] +\] $$ + +$head ip$$ +The argument $icode ip$$ has prototype +$codei% + const %SizeVector% &%ip% +%$$ +(see description for $icode SizeVector$$ in +$cref/LuFactor/LuFactor/SizeVector/$$ specifications). +The size of $icode ip$$ is referred to as $icode n$$ in the +specifications below. +The elements of $icode ip$$ determine +the order of the rows in the permuted matrix. + +$head jp$$ +The argument $icode jp$$ has prototype +$codei% + const %SizeVector% &%jp% +%$$ +(see description for $icode SizeVector$$ in +$cref/LuFactor/LuFactor/SizeVector/$$ specifications). +The size of $icode jp$$ must be equal to $icode n$$. +The elements of $icode jp$$ determine +the order of the columns in the permuted matrix. + +$head LU$$ +The argument $icode LU$$ has the prototype +$codei% + const %FloatVector% &%LU% +%$$ +and the size of $icode LU$$ must equal $latex n * n$$ +(see description for $icode FloatVector$$ in +$cref/LuFactor/LuFactor/FloatVector/$$ specifications). + +$subhead L$$ +We define the lower triangular matrix $icode L$$ in terms of $icode LU$$. +The matrix $icode L$$ is zero above the diagonal +and the rest of the elements are defined by +$codei% + %L%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] +%$$ +for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , i$$. + +$subhead U$$ +We define the upper triangular matrix $icode U$$ in terms of $icode LU$$. +The matrix $icode U$$ is zero below the diagonal, +one on the diagonal, +and the rest of the elements are defined by +$codei% + %U%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] +%$$ +for $latex i = 0 , \ldots , n-2$$ and $latex j = i+1 , \ldots , n-1$$. + +$subhead P$$ +We define the permuted matrix $icode P$$ in terms of +the matrix $icode L$$ and the matrix $icode U$$ +by $icode%P% = %L% * %U%$$. + +$subhead A$$ +The matrix $icode A$$, +which defines the linear equations that we are solving, is given by +$codei% + %P%(%i%, %j%) = %A%[ %ip%[%i%] * %n% + %jp%[%j%] ] +%$$ +(Hence +$icode LU$$ contains a permuted factorization of the matrix $icode A$$.) + + +$head X$$ +The argument $icode X$$ has prototype +$codei% + %FloatVector% &%X% +%$$ +(see description for $icode FloatVector$$ in +$cref/LuFactor/LuFactor/FloatVector/$$ specifications). +The matrix $icode X$$ +must have the same number of rows as the matrix $icode A$$. +The input value of $icode X$$ is the matrix $icode B$$ and the +output value solves the matrix equation $icode%A% * %X% = %B%$$. + + +$children% + example/lu_invert.cpp% + omh/lu_invert_hpp.omh +%$$ +$head Example$$ +The file $cref lu_solve.hpp$$ is a good example usage of +$code LuFactor$$ with $code LuInvert$$. +The file +$cref lu_invert.cpp$$ +contains an example and test of using $code LuInvert$$ by itself. +It returns true if it succeeds and false otherwise. + +$head Source$$ +The file $cref lu_invert.hpp$$ contains the +current source code that implements these specifications. + +$end +-------------------------------------------------------------------------- +*/ +// BEGIN C++ +# include +# include +# include + +namespace CppAD { // BEGIN CppAD namespace + +// LuInvert +template +void LuInvert( + const SizeVector &ip, + const SizeVector &jp, + const FloatVector &LU, + FloatVector &B ) +{ size_t k; // column index in X + size_t p; // index along diagonal in LU + size_t i; // row index in LU and X + + typedef typename FloatVector::value_type Float; + + // check numeric type specifications + CheckNumericType(); + + // check simple vector class specifications + CheckSimpleVector(); + CheckSimpleVector(); + + Float etmp; + + size_t n = ip.size(); + CPPAD_ASSERT_KNOWN( + size_t(jp.size()) == n, + "Error in LuInvert: jp must have size equal to n * n" + ); + CPPAD_ASSERT_KNOWN( + size_t(LU.size()) == n * n, + "Error in LuInvert: Lu must have size equal to n * m" + ); + size_t m = size_t(B.size()) / n; + CPPAD_ASSERT_KNOWN( + size_t(B.size()) == n * m, + "Error in LuSolve: B must have size equal to a multiple of n" + ); + + // temporary storage for reordered solution + FloatVector x(n); + + // loop over equations + for(k = 0; k < m; k++) + { // invert the equation c = L * b + for(p = 0; p < n; p++) + { // solve for c[p] + etmp = B[ ip[p] * m + k ] / LU[ ip[p] * n + jp[p] ]; + B[ ip[p] * m + k ] = etmp; + // subtract off effect on other variables + for(i = p+1; i < n; i++) + B[ ip[i] * m + k ] -= + etmp * LU[ ip[i] * n + jp[p] ]; + } + + // invert the equation x = U * c + p = n; + while( p > 0 ) + { --p; + etmp = B[ ip[p] * m + k ]; + x[ jp[p] ] = etmp; + for(i = 0; i < p; i++ ) + B[ ip[i] * m + k ] -= + etmp * LU[ ip[i] * n + jp[p] ]; + } + + // copy reordered solution into B + for(i = 0; i < n; i++) + B[i * m + k] = x[i]; + } + return; +} +} // END CppAD namespace +// END C++ +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/lu_solve.hpp cppad-2016.00.00.1/cppad/utility/lu_solve.hpp --- cppad-2015.00.00.9/cppad/utility/lu_solve.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/lu_solve.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,346 @@ +// $Id: lu_solve.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_LU_SOLVE_HPP +# define CPPAD_LU_SOLVE_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin LuSolve$$ +$escape #$$ +$spell + cppad.hpp + det + exp + Leq + typename + bool + const + namespace + std + Geq + Lu + CppAD + signdet + logdet +$$ + + +$section Compute Determinant and Solve Linear Equations$$ +$mindex LuSolve Lu$$ + +$pre +$$ + +$head Syntax$$ $codei%# include +%$$ +$icode%signdet% = LuSolve(%n%, %m%, %A%, %B%, %X%, %logdet%)%$$ + + +$head Description$$ +Use an LU factorization of the matrix $icode A$$ to +compute its determinant +and solve for $icode X$$ in the linear of equation +$latex \[ + A * X = B +\] $$ +where $icode A$$ is an +$icode n$$ by $icode n$$ matrix, +$icode X$$ is an +$icode n$$ by $icode m$$ matrix, and +$icode B$$ is an $latex n x m$$ matrix. + +$head Include$$ +The file $code cppad/lu_solve.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Factor and Invert$$ +This routine is an easy to user interface to +$cref LuFactor$$ and $cref LuInvert$$ for computing determinants and +solutions of linear equations. +These separate routines should be used if +one right hand side $icode B$$ +depends on the solution corresponding to another +right hand side (with the same value of $icode A$$). +In this case only one call to $code LuFactor$$ is required +but there will be multiple calls to $code LuInvert$$. + + +$head Matrix Storage$$ +All matrices are stored in row major order. +To be specific, if $latex Y$$ is a vector +that contains a $latex p$$ by $latex q$$ matrix, +the size of $latex Y$$ must be equal to $latex p * q $$ and for +$latex i = 0 , \ldots , p-1$$, +$latex j = 0 , \ldots , q-1$$, +$latex \[ + Y_{i,j} = Y[ i * q + j ] +\] $$ + +$head signdet$$ +The return value $icode signdet$$ is a $code int$$ value +that specifies the sign factor for the determinant of $icode A$$. +This determinant of $icode A$$ is zero if and only if $icode signdet$$ +is zero. + +$head n$$ +The argument $icode n$$ has type $code size_t$$ +and specifies the number of rows in the matrices +$icode A$$, +$icode X$$, +and $icode B$$. +The number of columns in $icode A$$ is also equal to $icode n$$. + +$head m$$ +The argument $icode m$$ has type $code size_t$$ +and specifies the number of columns in the matrices +$icode X$$ +and $icode B$$. +If $icode m$$ is zero, +only the determinant of $icode A$$ is computed and +the matrices $icode X$$ and $icode B$$ are not used. + +$head A$$ +The argument $icode A$$ has the prototype +$codei% + const %FloatVector% &%A% +%$$ +and the size of $icode A$$ must equal $latex n * n$$ +(see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). +This is the $latex n$$ by $icode n$$ matrix that +we are computing the determinant of +and that defines the linear equation. + +$head B$$ +The argument $icode B$$ has the prototype +$codei% + const %FloatVector% &%B% +%$$ +and the size of $icode B$$ must equal $latex n * m$$ +(see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). +This is the $latex n$$ by $icode m$$ matrix that +defines the right hand side of the linear equations. +If $icode m$$ is zero, $icode B$$ is not used. + +$head X$$ +The argument $icode X$$ has the prototype +$codei% + %FloatVector% &%X% +%$$ +and the size of $icode X$$ must equal $latex n * m$$ +(see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). +The input value of $icode X$$ does not matter. +On output, the elements of $icode X$$ contain the solution +of the equation we wish to solve +(unless $icode signdet$$ is equal to zero). +If $icode m$$ is zero, $icode X$$ is not used. + +$head logdet$$ +The argument $icode logdet$$ has prototype +$codei% + %Float% &%logdet% +%$$ +On input, the value of $icode logdet$$ does not matter. +On output, it has been set to the +log of the determinant of $icode A$$ +(but not quite). +To be more specific, +the determinant of $icode A$$ is given by the formula +$codei% + %det% = %signdet% * exp( %logdet% ) +%$$ +This enables $code LuSolve$$ to use logs of absolute values +in the case where $icode Float$$ corresponds to a real number. + +$head Float$$ +The type $icode Float$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. +In addition, the following operations must be defined for any pair +of $icode Float$$ objects $icode x$$ and $icode y$$: + +$table +$bold Operation$$ $cnext $bold Description$$ $rnext +$codei%log(%x%)%$$ $cnext + returns the logarithm of $icode x$$ as a $icode Float$$ object +$tend + +$head FloatVector$$ +The type $icode FloatVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type Float/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head LeqZero$$ +Including the file $code lu_solve.hpp$$ defines the template function +$codei% + template + bool LeqZero<%Float%>(const %Float% &%x%) +%$$ +in the $code CppAD$$ namespace. +This function returns true if $icode x$$ is less than or equal to zero +and false otherwise. +It is used by $code LuSolve$$ to avoid taking the log of +zero (or a negative number if $icode Float$$ corresponds to real numbers). +This template function definition assumes that the operator +$code <=$$ is defined for $icode Float$$ objects. +If this operator is not defined for your use of $icode Float$$, +you will need to specialize this template so that it works for your +use of $code LuSolve$$. +$pre + +$$ +Complex numbers do not have the operation or $code <=$$ defined. +In addition, in the complex case, +one can take the log of a negative number. +The specializations +$codei% + bool LeqZero< std::complex > (const std::complex &%x%) + bool LeqZero< std::complex >(const std::complex &%x%) +%$$ +are defined by including $code lu_solve.hpp$$. +These return true if $icode x$$ is zero and false otherwise. + +$head AbsGeq$$ +Including the file $code lu_solve.hpp$$ defines the template function +$codei% + template + bool AbsGeq<%Float%>(const %Float% &%x%, const %Float% &%y%) +%$$ +If the type $icode Float$$ does not support the $code <=$$ operation +and it is not $code std::complex$$ or $code std::complex$$, +see the documentation for $code AbsGeq$$ in $cref/LuFactor/LuFactor/AbsGeq/$$. + +$children% + example/lu_solve.cpp% + omh/lu_solve_hpp.omh +%$$ +$head Example$$ +The file +$cref lu_solve.cpp$$ +contains an example and test of using this routine. +It returns true if it succeeds and false otherwise. + +$head Source$$ +The file $cref lu_solve.hpp$$ contains the +current source code that implements these specifications. + +$end +-------------------------------------------------------------------------- +*/ +// BEGIN C++ +# include +# include + +// link exp for float and double cases +# include + +# include +# include +# include +# include +# include + +namespace CppAD { // BEGIN CppAD namespace + +// LeqZero +template +inline bool LeqZero(const Float &x) +{ return x <= Float(0); } +inline bool LeqZero( const std::complex &x ) +{ return x == std::complex(0); } +inline bool LeqZero( const std::complex &x ) +{ return x == std::complex(0); } + +// LuSolve +template +int LuSolve( + size_t n , + size_t m , + const FloatVector &A , + const FloatVector &B , + FloatVector &X , + Float &logdet ) +{ + // check numeric type specifications + CheckNumericType(); + + // check simple vector class specifications + CheckSimpleVector(); + + size_t p; // index of pivot element (diagonal of L) + int signdet; // sign of the determinant + Float pivot; // pivot element + + // the value zero + const Float zero(0); + + // pivot row and column order in the matrix + std::vector ip(n); + std::vector jp(n); + + // ------------------------------------------------------- + CPPAD_ASSERT_KNOWN( + size_t(A.size()) == n * n, + "Error in LuSolve: A must have size equal to n * n" + ); + CPPAD_ASSERT_KNOWN( + size_t(B.size()) == n * m, + "Error in LuSolve: B must have size equal to n * m" + ); + CPPAD_ASSERT_KNOWN( + size_t(X.size()) == n * m, + "Error in LuSolve: X must have size equal to n * m" + ); + // ------------------------------------------------------- + + // copy A so that it does not change + FloatVector Lu(A); + + // copy B so that it does not change + X = B; + + // Lu factor the matrix A + signdet = LuFactor(ip, jp, Lu); + + // compute the log of the determinant + logdet = Float(0); + for(p = 0; p < n; p++) + { // pivot using the max absolute element + pivot = Lu[ ip[p] * n + jp[p] ]; + + // check for determinant equal to zero + if( pivot == zero ) + { // abort the mission + logdet = Float(0); + return 0; + } + + // update the determinant + if( LeqZero ( pivot ) ) + { logdet += log( - pivot ); + signdet = - signdet; + } + else logdet += log( pivot ); + + } + + // solve the linear equations + LuInvert(ip, jp, Lu, X); + + // return the sign factor for the determinant + return signdet; +} +} // END CppAD namespace +// END C++ +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/memory_leak.hpp cppad-2016.00.00.1/cppad/utility/memory_leak.hpp --- cppad-2015.00.00.9/cppad/utility/memory_leak.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/memory_leak.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,215 @@ +// $Id: memory_leak.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_MEMORY_LEAK_HPP +# define CPPAD_MEMORY_LEAK_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin memory_leak$$ +$spell + cppad + num + alloc + hpp + bool + inuse +$$ + +$section Memory Leak Detection$$ +$mindex memory_leak check static$$ + +$head Deprecated 2012-04-06$$ +This routine has been deprecated. +You should instead use the routine $cref ta_free_all$$. + +$head Syntax$$ +$codei%# include +%$$ +$icode%flag% = %memory_leak() +%$$ +$icode%flag% = %memory_leak(%add_static%)%$$ + +$head Purpose$$ +This routine checks that the are no memory leaks +caused by improper use of $cref thread_alloc$$ memory allocator. +The deprecated memory allocator $cref TrackNewDel$$ is also checked. +Memory errors in the deprecated $cref omp_alloc$$ allocator are +reported as being in $code thread_alloc$$. + +$head thread$$ +It is assumed that $cref/in_parallel()/ta_in_parallel/$$ is false +and $cref/thread_num/ta_thread_num/$$ is zero when +$code memory_leak$$ is called. + +$head add_static$$ +This argument has prototype +$codei% + size_t %add_static% +%$$ +and its default value is zero. +Static variables hold onto memory forever. +If the argument $icode add_static$$ is present (and non-zero), +$code memory_leak$$ adds this amount of memory to the +$cref/inuse/ta_inuse/$$ sum that corresponds to +static variables in the program. +A call with $icode add_static$$ should be make after +a routine that has static variables which +use $cref/get_memory/ta_get_memory/$$ to allocate memory. +The value of $icode add_static$$ should be the difference of +$codei% + thread_alloc::inuse(0) +%$$ +before and after the call. +Since multiple statics may be allocated in different places in the program, +it is expected that there will be multiple calls +that use this option. + +$head flag$$ +The return value $icode flag$$ has prototype +$codei% + bool %flag% +%$$ +If $icode add_static$$ is non-zero, +the return value for $code memory_leak$$ is false. +Otherwise, the return value for $code memory_leak$$ should be false +(indicating that the only allocated memory corresponds to static variables). + +$head inuse$$ +It is assumed that, when $code memory_leak$$ is called, +there should not be any memory +$cref/inuse/ta_inuse/$$ or $cref omp_inuse$$ for any thread +(except for inuse memory corresponding to static variables). +If there is, a message is printed and $code memory_leak$$ returns false. + +$head available$$ +It is assumed that, when $code memory_leak$$ is called, +there should not be any memory +$cref/available/ta_available/$$ or $cref omp_available$$ for any thread; +i.e., it all has been returned to the system. +If there is memory still available for any thread, +$code memory_leak$$ returns false. + +$head TRACK_COUNT$$ +It is assumed that, when $code memory_leak$$ is called, +$cref/TrackCount/TrackNewDel/TrackCount/$$ will return a zero value. +If it returns a non-zero value, +$code memory_leak$$ returns false. + +$head Error Message$$ +If this is the first call to $code memory_leak$$, no message is printed. +Otherwise, if it returns true, an error message is printed +to standard output describing the memory leak that was detected. + +$end +*/ +# include +# include +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file memory_leak.hpp +File that implements a memory check at end of a CppAD program +*/ + +/*! +Function that checks +allocator \c thread_alloc for misuse that results in memory leaks. +Deprecated routines in track_new_del.hpp and omp_alloc.hpp are also checked. + +\param add_static [in] +The amount specified by \c add_static is added to the amount +of memory that is expected to be used by thread zero for static variables. + +\return +If \c add_static is non-zero, the return value is \c false. +Otherwise, if one of the following errors is detected, +the return value is \c true: + +\li +Thread zero does not have the expected amount of inuse memory +(for static variables). +\li +A thread, other than thread zero, has any inuse memory. +\li +Any thread has available memory. + +\par +If an error is detected, diagnostic information is printed to standard +output. +*/ +inline bool memory_leak(size_t add_static = 0) +{ // CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL not necessary given asserts below + static size_t thread_zero_static_inuse = 0; + using std::cout; + using std::endl; + using CppAD::thread_alloc; + using CppAD::omp_alloc; + // -------------------------------------------------------------------- + CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel(), + "memory_leak: in_parallel() is true." + ); + CPPAD_ASSERT_KNOWN( + thread_alloc::thread_num() == 0, + "memory_leak: thread_num() is not zero." + ); + if( add_static != 0 ) + { thread_zero_static_inuse += add_static; + return false; + } + bool leak = false; + size_t thread = 0; + + // check that memory in use for thread zero corresponds to statics + size_t num_bytes = thread_alloc::inuse(thread); + if( num_bytes != thread_zero_static_inuse ) + { leak = true; + cout << "thread zero: static inuse = " << thread_zero_static_inuse; + cout << "current inuse(thread) = " << num_bytes << endl; + } + // check that no memory is currently available for this thread + num_bytes = thread_alloc::available(thread); + if( num_bytes != 0 ) + { leak = true; + cout << "thread zero: available = "; + cout << num_bytes << endl; + } + for(thread = 1; thread < CPPAD_MAX_NUM_THREADS; thread++) + { + // check that no memory is currently in use for this thread + num_bytes = thread_alloc::inuse(thread); + if( num_bytes != 0 ) + { leak = true; + cout << "thread " << thread << ": inuse(thread) = "; + cout << num_bytes << endl; + } + // check that no memory is currently available for this thread + num_bytes = thread_alloc::available(thread); + if( num_bytes != 0 ) + { leak = true; + cout << "thread " << thread << ": available(thread) = "; + cout << num_bytes << endl; + } + } + // ---------------------------------------------------------------------- + // check track_new_del + if( CPPAD_TRACK_COUNT() != 0 ) + { leak = true; + CppAD::TrackElement::Print(); + } + return leak; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/nan.hpp cppad-2016.00.00.1/cppad/utility/nan.hpp --- cppad-2015.00.00.9/cppad/utility/nan.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/nan.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,194 @@ +// $Id: nan.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_NAN_HPP +# define CPPAD_NAN_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin nan$$ +$spell + hasnan + cppad + hpp + CppAD + isnan + bool + const +$$ + +$section Obtain Nan or Determine if a Value is Nan$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%b% = isnan(%s%) +%$$ +$icode%b% = hasnan(%v%)%$$ + +$head Purpose$$ +It obtain and check for the value not a number $code nan$$. +The IEEE standard specifies that a floating point value $icode a$$ +is $code nan$$ if and only if the following returns true +$codei% + %a% != %a% +%$$ + +$head Include$$ +The file $code cppad/nan.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$subhead Macros$$ +Some C++ compilers use preprocessor symbols called $code nan$$ +and $code isnan$$. +These preprocessor symbols will no longer be defined after +this file is included. + +$head isnan$$ +This routine determines if a scalar value is $code nan$$. + +$subhead s$$ +The argument $icode s$$ has prototype +$codei% + const %Scalar% %s% +%$$ + +$subhead b$$ +The return value $icode b$$ has prototype +$codei% + bool %b% +%$$ +It is true if the value $icode s$$ is $code nan$$. + +$head hasnan$$ +This routine determines if a +$cref SimpleVector$$ has an element that is $code nan$$. + +$subhead v$$ +The argument $icode v$$ has prototype +$codei% + const %Vector% &%v% +%$$ +(see $cref/Vector/nan/Vector/$$ for the definition of $icode Vector$$). + +$subhead b$$ +The return value $icode b$$ has prototype +$codei% + bool %b% +%$$ +It is true if the vector $icode v$$ has a $code nan$$. + + +$head nan(zero)$$ + +$subhead Deprecated 2015-10-04$$ +This routine has been deprecated, use CppAD numeric limits +$cref/quiet_NaN/numeric_limits/quiet_NaN/$$ in its place. + +$subhead Syntax$$ +$icode%s% = nan(%z%) +%$$ + +$subhead z$$ +The argument $icode z$$ has prototype +$codei% + const %Scalar% &%z% +%$$ +and its value is zero +(see $cref/Scalar/nan/Scalar/$$ for the definition of $icode Scalar$$). + +$subhead s$$ +The return value $icode s$$ has prototype +$codei% + %Scalar% %s% +%$$ +It is the value $code nan$$ for this floating point type. + +$head Scalar$$ +The type $icode Scalar$$ must support the following operations; +$table +$bold Operation$$ $cnext $bold Description$$ $rnext +$icode%a% / %b%$$ $cnext + division operator (returns a $icode Scalar$$ object) +$rnext +$icode%a% == %b%$$ $cnext + equality operator (returns a $code bool$$ object) +$rnext +$icode%a% != %b%$$ $cnext + not equality operator (returns a $code bool$$ object) +$tend +Note that the division operator will be used with $icode a$$ and $icode b$$ +equal to zero. For some types (e.g. $code int$$) this may generate +an exception. No attempt is made to catch any such exception. + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +elements of type $icode Scalar$$. + +$children% + example/nan.cpp +%$$ +$head Example$$ +The file $cref nan.cpp$$ +contains an example and test of this routine. +It returns true if it succeeds and false otherwise. + +$end +*/ + +# include +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +/* +# define nan There must be a define for every CppAD undef +*/ +# ifdef nan +# undef nan +# endif + +/* +# define isnan There must be a define for every CppAD undef +*/ +# ifdef isnan +# undef isnan +# endif + +namespace CppAD { // BEGIN CppAD namespace + +template +inline bool isnan(const Scalar &s) +{ return (s != s); +} + +template +bool hasnan(const Vector &v) +{ + bool found_nan; + size_t i; + i = v.size(); + found_nan = false; + // on MS Visual Studio 2012, CppAD required in front of isnan ? + while(i--) + found_nan |= CppAD::isnan(v[i]); + return found_nan; +} + +template +inline Scalar nan(const Scalar &zero) +{ return zero / zero; +} + +} // End CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/near_equal.hpp cppad-2016.00.00.1/cppad/utility/near_equal.hpp --- cppad-2015.00.00.9/cppad/utility/near_equal.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/near_equal.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,269 @@ +// $Id: near_equal.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_NEAR_EQUAL_HPP +# define CPPAD_NEAR_EQUAL_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin NearEqual$$ +$spell + cppad.hpp + sqrt + cout + endl + Microsoft + std + Cpp + namespace + const + bool +$$ + +$section Determine if Two Values Are Nearly Equal$$ +$mindex NearEqual near absolute difference relative$$ + + +$head Syntax$$ + +$codei%# include +%$$ +$icode%b% = NearEqual(%x%, %y%, %r%, %a%)%$$ + + +$head Purpose$$ +Returns true, +if $icode x$$ and $icode y$$ are nearly equal, +and false otherwise. + +$head x$$ +The argument $icode x$$ +has one of the following possible prototypes +$codei% + const %Type% &%x%, + const std::complex<%Type%> &%x%, +%$$ + +$head y$$ +The argument $icode y$$ +has one of the following possible prototypes +$codei% + const %Type% &%y%, + const std::complex<%Type%> &%y%, +%$$ + +$head r$$ +The relative error criteria $icode r$$ has prototype +$codei% + const %Type% &%r% +%$$ +It must be greater than or equal to zero. +The relative error condition is defined as: +$latex \[ + | x - y | \leq r ( |x| + |y| ) +\] $$ + +$head a$$ +The absolute error criteria $icode a$$ has prototype +$codei% + const %Type% &%a% +%$$ +It must be greater than or equal to zero. +The absolute error condition is defined as: +$latex \[ + | x - y | \leq a +\] $$ + +$head b$$ +The return value $icode b$$ has prototype +$codei% + bool %b% +%$$ +If either $icode x$$ or $icode y$$ is infinite or not a number, +the return value is false. +Otherwise, if either the relative or absolute error +condition (defined above) is satisfied, the return value is true. +Otherwise, the return value is false. + +$head Type$$ +The type $icode Type$$ must be a +$cref NumericType$$. +The routine $cref CheckNumericType$$ will generate +an error message if this is not the case. +In addition, the following operations must be defined objects +$icode a$$ and $icode b$$ of type $icode Type$$: +$table +$bold Operation$$ $cnext + $bold Description$$ $rnext +$icode%a% <= %b%$$ $cnext + less that or equal operator (returns a $code bool$$ object) +$tend + +$head Include Files$$ +The file $code cppad/near_equal.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Example$$ +$children% + example/near_equal.cpp +%$$ +The file $cref near_equal.cpp$$ contains an example +and test of $code NearEqual$$. +It return true if it succeeds and false otherwise. + +$head Exercise$$ +Create and run a program that contains the following code: +$codep + using std::complex; + using std::cout; + using std::endl; + + complex one(1., 0), i(0., 1); + complex x = one / i; + complex y = - i; + double r = 1e-12; + double a = 0; + bool ok = CppAD::NearEqual(x, y, r, a); + if( ok ) + cout << "Ok" << endl; + else cout << "Error" << endl; +$$ + +$end + +*/ + +# include +# include +# include +# include + +namespace CppAD { // Begin CppAD namespace + +// determine if both x and y are finite values +template +bool near_equal_isfinite(const Type &x , const Type &y) +{ Type infinity = Type( std::numeric_limits::infinity() ); + + // handle bug where some compilers return true for nan == nan + bool xNan = x != x; + bool yNan = y != y; + + // infinite cases + bool xInf = (x == infinity || x == - infinity); + bool yInf = (x == infinity || x == - infinity); + + return ! (xNan | yNan | xInf | yInf); +} + +template +bool NearEqual(const Type &x, const Type &y, const Type &r, const Type &a) +{ + CheckNumericType(); + Type zero(0); + + CPPAD_ASSERT_KNOWN( + zero <= r, + "Error in NearEqual: relative error is less than zero" + ); + CPPAD_ASSERT_KNOWN( + zero <= a, + "Error in NearEqual: absolute error is less than zero" + ); + + // check for special cases + if( ! CppAD::near_equal_isfinite(x, y) ) + return false; + + Type ax = x; + if( ax <= zero ) + ax = - ax; + + Type ay = y; + if( ay <= zero ) + ay = - ay; + + Type ad = x - y; + if( ad <= zero ) + ad = - ad; + + if( ad <= a ) + return true; + + if( ad <= r * (ax + ay) ) + return true; + + return false; +} + +template +bool NearEqual( + const std::complex &x , + const std::complex &y , + const Type &r , + const Type & a ) +{ + CheckNumericType(); + Type zero(0); + + CPPAD_ASSERT_KNOWN( + zero <= r, + "Error in NearEqual: relative error is less than zero" + ); + CPPAD_ASSERT_KNOWN( + zero <= a, + "Error in NearEqual: absolute error is less than zero" + ); + + // check for special cases + if( ! CppAD::near_equal_isfinite(x.real(), x.imag()) ) + return false; + if( ! CppAD::near_equal_isfinite(y.real(), y.imag()) ) + return false; + + std::complex d = x - y; + + Type ad = std::abs(d); + if( ad <= a ) + return true; + + Type ax = std::abs(x); + Type ay = std::abs(y); + if( ad <= r * (ax + ay) ) + return true; + + return false; +} + +template +bool NearEqual( + const std::complex &x , + const Type &y , + const Type &r , + const Type & a ) +{ + return NearEqual(x, std::complex(y, Type(0)), r, a); +} + +template +bool NearEqual( + const Type &x , + const std::complex &y , + const Type &r , + const Type & a ) +{ + return NearEqual(std::complex(x, Type(0)), y, r, a); +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/ode_err_control.hpp cppad-2016.00.00.1/cppad/utility/ode_err_control.hpp --- cppad-2015.00.00.9/cppad/utility/ode_err_control.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/ode_err_control.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,596 @@ +// $Id: ode_err_control.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_ODE_ERR_CONTROL_HPP +# define CPPAD_ODE_ERR_CONTROL_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin OdeErrControl$$ +$spell + cppad.hpp + nstep + maxabs + exp + scur + CppAD + xf + tf + xi + smin + smax + eabs + erel + ef + ta + tb + xa + xb + const + eb +$$ + + + +$section An Error Controller for ODE Solvers$$ +$mindex OdeErrControl differential equation$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%xf% = OdeErrControl(%method%, %ti%, %tf%, %xi%, + %smin%, %smax%, %scur%, %eabs%, %erel%, %ef% , %maxabs%, %nstep% )%$$ + + +$head Description$$ +Let $latex \B{R}$$ denote the real numbers +and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. +We define $latex X : [ti , tf] \rightarrow \B{R}^n$$ by +the following initial value problem: +$latex \[ +\begin{array}{rcl} + X(ti) & = & xi \\ + X'(t) & = & F[t , X(t)] +\end{array} +\] $$ +The routine $code OdeErrControl$$ can be used to adjust the step size +used an arbitrary integration methods in order to be as fast as possible +and still with in a requested error bound. + +$head Include$$ +The file $code cppad/ode_err_control.hpp$$ is included by +$code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Notation$$ +The template parameter types $cref/Scalar/OdeErrControl/Scalar/$$ and +$cref/Vector/OdeErrControl/Vector/$$ are documented below. + +$head xf$$ +The return value $icode xf$$ has the prototype +$codei% + %Vector% %xf% +%$$ +(see description of $cref/Vector/OdeErrControl/Vector/$$ below). +and the size of $icode xf$$ is equal to $icode n$$. +If $icode xf$$ contains not a number $cref nan$$, +see the discussion of $cref/step/OdeErrControl/Method/Nan/$$. + +$head Method$$ +The class $icode Method$$ +and the object $icode method$$ satisfy the following syntax +$codei% + %Method% &%method% +%$$ +The object $icode method$$ must support $code step$$ and +$code order$$ member functions defined below: + +$subhead step$$ +The syntax +$codei% + %method%.step(%ta%, %tb%, %xa%, %xb%, %eb%) +%$$ +executes one step of the integration method. +$codei% + +%ta% +%$$ +The argument $icode ta$$ has prototype +$codei% + const %Scalar% &%ta% +%$$ +It specifies the initial time for this step in the +ODE integration. +(see description of $cref/Scalar/OdeErrControl/Scalar/$$ below). +$codei% + +%tb% +%$$ +The argument $icode tb$$ has prototype +$codei% + const %Scalar% &%tb% +%$$ +It specifies the final time for this step in the +ODE integration. +$codei% + +%xa% +%$$ +The argument $icode xa$$ has prototype +$codei% + const %Vector% &%xa% +%$$ +and size $icode n$$. +It specifies the value of $latex X(ta)$$. +(see description of $cref/Vector/OdeErrControl/Vector/$$ below). +$codei% + +%xb% +%$$ +The argument value $icode xb$$ has prototype +$codei% + %Vector% &%xb% +%$$ +and size $icode n$$. +The input value of its elements does not matter. +On output, +it contains the approximation for $latex X(tb)$$ that the method obtains. +$codei% + +%eb% +%$$ +The argument value $icode eb$$ has prototype +$codei% + %Vector% &%eb% +%$$ +and size $icode n$$. +The input value of its elements does not matter. +On output, +it contains an estimate for the error in the approximation $icode xb$$. +It is assumed (locally) that the error bound in this approximation +nearly equal to $latex K (tb - ta)^m$$ +where $icode K$$ is a fixed constant and $icode m$$ +is the corresponding argument to $code CodeControl$$. + +$subhead Nan$$ +If any element of the vector $icode eb$$ or $icode xb$$ are +not a number $code nan$$, +the current step is considered to large. +If this happens with the current step size equal to $icode smin$$, +$code OdeErrControl$$ returns with $icode xf$$ and $icode ef$$ as vectors +of $code nan$$. + +$subhead order$$ +If $icode m$$ is $code size_t$$, +the object $icode method$$ must also support the following syntax +$codei% + %m% = %method%.order() +%$$ +The return value $icode m$$ is the order of the error estimate; +i.e., there is a constant K such that if $latex ti \leq ta \leq tb \leq tf$$, +$latex \[ + | eb(tb) | \leq K | tb - ta |^m +\] $$ +where $icode ta$$, $icode tb$$, and $icode eb$$ are as in +$icode%method%.step(%ta%, %tb%, %xa%, %xb%, %eb%)%$$ + + +$head ti$$ +The argument $icode ti$$ has prototype +$codei% + const %Scalar% &%ti% +%$$ +It specifies the initial time for the integration of +the differential equation. + + +$head tf$$ +The argument $icode tf$$ has prototype +$codei% + const %Scalar% &%tf% +%$$ +It specifies the final time for the integration of +the differential equation. + +$head xi$$ +The argument $icode xi$$ has prototype +$codei% + const %Vector% &%xi% +%$$ +and size $icode n$$. +It specifies value of $latex X(ti)$$. + +$head smin$$ +The argument $icode smin$$ has prototype +$codei% + const %Scalar% &%smin% +%$$ +The step size during a call to $icode method$$ is defined as +the corresponding value of $latex tb - ta$$. +If $latex tf - ti \leq smin$$, +the integration will be done in one step of size $icode tf - ti$$. +Otherwise, +the minimum value of $icode tb - ta$$ will be $latex smin$$ +except for the last two calls to $icode method$$ where it may be +as small as $latex smin / 2$$. + +$head smax$$ +The argument $icode smax$$ has prototype +$codei% + const %Scalar% &%smax% +%$$ +It specifies the maximum step size to use during the integration; +i.e., the maximum value for $latex tb - ta$$ in a call to $icode method$$. +The value of $icode smax$$ must be greater than or equal $icode smin$$. + +$head scur$$ +The argument $icode scur$$ has prototype +$codei% + %Scalar% &%scur% +%$$ +The value of $icode scur$$ is the suggested next step size, +based on error criteria, to try in the next call to $icode method$$. +On input it corresponds to the first call to $icode method$$, +in this call to $code OdeErrControl$$ (where $latex ta = ti$$). +On output it corresponds to the next call to $icode method$$, +in a subsequent call to $code OdeErrControl$$ (where $icode ta = tf$$). + +$head eabs$$ +The argument $icode eabs$$ has prototype +$codei% + const %Vector% &%eabs% +%$$ +and size $icode n$$. +Each of the elements of $icode eabs$$ must be +greater than or equal zero. +It specifies a bound for the absolute +error in the return value $icode xf$$ as an approximation for $latex X(tf)$$. +(see the +$cref/error criteria discussion/OdeErrControl/Error Criteria Discussion/$$ +below). + +$head erel$$ +The argument $icode erel$$ has prototype +$codei% + const %Scalar% &%erel% +%$$ +and is greater than or equal zero. +It specifies a bound for the relative +error in the return value $icode xf$$ as an approximation for $latex X(tf)$$ +(see the +$cref/error criteria discussion/OdeErrControl/Error Criteria Discussion/$$ +below). + +$head ef$$ +The argument value $icode ef$$ has prototype +$codei% + %Vector% &%ef% +%$$ +and size $icode n$$. +The input value of its elements does not matter. +On output, +it contains an estimated bound for the +absolute error in the approximation $icode xf$$; i.e., +$latex \[ + ef_i > | X( tf )_i - xf_i | +\] $$ +If on output $icode ef$$ contains not a number $code nan$$, +see the discussion of $cref/step/OdeErrControl/Method/Nan/$$. + +$head maxabs$$ +The argument $icode maxabs$$ is optional in the call to $code OdeErrControl$$. +If it is present, it has the prototype +$codei% + %Vector% &%maxabs% +%$$ +and size $icode n$$. +The input value of its elements does not matter. +On output, +it contains an estimate for the +maximum absolute value of $latex X(t)$$; i.e., +$latex \[ + maxabs[i] \approx \max \left\{ + | X( t )_i | \; : \; t \in [ti, tf] + \right\} +\] $$ + +$head nstep$$ +The argument $icode nstep$$ is optional in the call to $code OdeErrControl$$. +If it is present, it has the prototype +$codei% + %size_t% &%nstep% +%$$ +Its input value does not matter and its output value +is the number of calls to $icode%method%.step%$$ +used by $code OdeErrControl$$. + +$head Error Criteria Discussion$$ +The relative error criteria $icode erel$$ and +absolute error criteria $icode eabs$$ are enforced during each step of the +integration of the ordinary differential equations. +In addition, they are inversely scaled by the step size so that +the total error bound is less than the sum of the error bounds. +To be specific, if $latex \tilde{X} (t)$$ is the approximate solution +at time $latex t$$, +$icode ta$$ is the initial step time, +and $icode tb$$ is the final step time, +$latex \[ +\left| \tilde{X} (tb)_j - X (tb)_j \right| +\leq +\frac{tf - ti}{tb - ta} +\left[ eabs[j] + erel \; | \tilde{X} (tb)_j | \right] +\] $$ +If $latex X(tb)_j$$ is near zero for some $latex tb \in [ti , tf]$$, +and one uses an absolute error criteria $latex eabs[j]$$ of zero, +the error criteria above will force $code OdeErrControl$$ +to use step sizes equal to +$cref/smin/OdeErrControl/smin/$$ +for steps ending near $latex tb$$. +In this case, the error relative to $icode maxabs$$ can be judged after +$code OdeErrControl$$ returns. +If $icode ef$$ is to large relative to $icode maxabs$$, +$code OdeErrControl$$ can be called again +with a smaller value of $icode smin$$. + +$head Scalar$$ +The type $icode Scalar$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. +In addition, the following operations must be defined for +$icode Scalar$$ objects $icode a$$ and $icode b$$: + +$table +$bold Operation$$ $cnext $bold Description$$ $rnext +$icode%a% <= %b%$$ $cnext + returns true (false) if $icode a$$ is less than or equal + (greater than) $icode b$$. +$rnext +$icode%a% == %b%$$ $cnext + returns true (false) if $icode a$$ is equal to $icode b$$. +$rnext +$codei%log(%a%)%$$ $cnext + returns a $icode Scalar$$ equal to the logarithm of $icode a$$ +$rnext +$codei%exp(%a%)%$$ $cnext + returns a $icode Scalar$$ equal to the exponential of $icode a$$ +$tend + + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Example$$ +$children% + example/ode_err_control.cpp% + example/ode_err_maxabs.cpp +%$$ +The files +$cref ode_err_control.cpp$$ +and +$cref ode_err_maxabs.cpp$$ +contain examples and tests of using this routine. +They return true if they succeed and false otherwise. + +$head Theory$$ +Let $latex e(s)$$ be the error as a function of the +step size $latex s$$ and suppose that there is a constant +$latex K$$ such that $latex e(s) = K s^m$$. +Let $latex a$$ be our error bound. +Given the value of $latex e(s)$$, a step of size $latex \lambda s$$ +would be ok provided that +$latex \[ +\begin{array}{rcl} + a & \geq & e( \lambda s ) (tf - ti) / ( \lambda s ) \\ + a & \geq & K \lambda^m s^m (tf - ti) / ( \lambda s ) \\ + a & \geq & \lambda^{m-1} s^{m-1} (tf - ti) e(s) / s^m \\ + a & \geq & \lambda^{m-1} (tf - ti) e(s) / s \\ + \lambda^{m-1} & \leq & \frac{a}{e(s)} \frac{s}{tf - ti} +\end{array} +\] $$ +Thus if the right hand side of the last inequality is greater +than or equal to one, the step of size $latex s$$ is ok. + +$head Source Code$$ +The source code for this routine is in the file +$code cppad/ode_err_control.hpp$$. + +$end +-------------------------------------------------------------------------- +*/ + +// link exp and log for float and double +# include + +# include +# include +# include + +namespace CppAD { // Begin CppAD namespace + +template +Vector OdeErrControl( + Method &method, + const Scalar &ti , + const Scalar &tf , + const Vector &xi , + const Scalar &smin , + const Scalar &smax , + Scalar &scur , + const Vector &eabs , + const Scalar &erel , + Vector &ef , + Vector &maxabs, + size_t &nstep ) +{ + // check simple vector class specifications + CheckSimpleVector(); + + size_t n = size_t(xi.size()); + + CPPAD_ASSERT_KNOWN( + smin <= smax, + "Error in OdeErrControl: smin > smax" + ); + CPPAD_ASSERT_KNOWN( + size_t(eabs.size()) == n, + "Error in OdeErrControl: size of eabs is not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(maxabs.size()) == n, + "Error in OdeErrControl: size of maxabs is not equal to n" + ); + size_t m = method.order(); + CPPAD_ASSERT_KNOWN( + m > 1, + "Error in OdeErrControl: m is less than or equal one" + ); + + bool ok; + bool minimum_step; + size_t i; + Vector xa(n), xb(n), eb(n), nan_vec(n); + + // initialization + Scalar zero(0); + Scalar one(1); + Scalar two(2); + Scalar three(3); + Scalar m1(m-1); + Scalar ta = ti; + for(i = 0; i < n; i++) + { nan_vec[i] = nan(zero); + ef[i] = zero; + xa[i] = xi[i]; + if( zero <= xi[i] ) + maxabs[i] = xi[i]; + else maxabs[i] = - xi[i]; + + } + nstep = 0; + + Scalar tb, step, lambda, axbi, a, r, root; + while( ! (ta == tf) ) + { // start with value suggested by error criteria + step = scur; + + // check maximum + if( smax <= step ) + step = smax; + + // check minimum + minimum_step = step <= smin; + if( minimum_step ) + step = smin; + + // check if near the end + if( tf <= ta + step * three / two ) + tb = tf; + else tb = ta + step; + + // try using this step size + nstep++; + method.step(ta, tb, xa, xb, eb); + step = tb - ta; + + // check if this steps error estimate is ok + ok = ! (hasnan(xb) || hasnan(eb)); + if( (! ok) && minimum_step ) + { ef = nan_vec; + return nan_vec; + } + + // compute value of lambda for this step + lambda = Scalar(10) * scur / step; + for(i = 0; i < n; i++) + { if( zero <= xb[i] ) + axbi = xb[i]; + else axbi = - xb[i]; + a = eabs[i] + erel * axbi; + if( ! (eb[i] == zero) ) + { r = ( a / eb[i] ) * step / (tf - ti); + root = exp( log(r) / m1 ); + if( root <= lambda ) + lambda = root; + } + } + if( ok && ( one <= lambda || step <= smin * three / two) ) + { // this step is within error limits or + // close to the minimum size + ta = tb; + for(i = 0; i < n; i++) + { xa[i] = xb[i]; + ef[i] = ef[i] + eb[i]; + if( zero <= xb[i] ) + axbi = xb[i]; + else axbi = - xb[i]; + if( axbi > maxabs[i] ) + maxabs[i] = axbi; + } + } + if( ! ok ) + { // decrease step an see if method will work this time + scur = step / two; + } + else if( ! (ta == tf) ) + { // step suggested by the error criteria is not used + // on the last step because it may be very small. + scur = lambda * step / two; + } + } + return xa; +} + +template +Vector OdeErrControl( + Method &method, + const Scalar &ti , + const Scalar &tf , + const Vector &xi , + const Scalar &smin , + const Scalar &smax , + Scalar &scur , + const Vector &eabs , + const Scalar &erel , + Vector &ef ) +{ Vector maxabs(xi.size()); + size_t nstep; + return OdeErrControl( + method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep + ); +} + +template +Vector OdeErrControl( + Method &method, + const Scalar &ti , + const Scalar &tf , + const Vector &xi , + const Scalar &smin , + const Scalar &smax , + Scalar &scur , + const Vector &eabs , + const Scalar &erel , + Vector &ef , + Vector &maxabs) +{ size_t nstep; + return OdeErrControl( + method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep + ); +} + +} // End CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/ode_gear_control.hpp cppad-2016.00.00.1/cppad/utility/ode_gear_control.hpp --- cppad-2015.00.00.9/cppad/utility/ode_gear_control.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/ode_gear_control.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,543 @@ +// $Id: ode_gear_control.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_ODE_GEAR_CONTROL_HPP +# define CPPAD_ODE_GEAR_CONTROL_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin OdeGearControl$$ +$spell + cppad.hpp + CppAD + xf + xi + smin + smax + eabs + ef + maxabs + nstep + tf + sini + erel + dep + const + tb + ta + exp +$$ + + + +$section An Error Controller for Gear's Ode Solvers$$ +$mindex OdeGearControl Gear differential equation$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%xf% = OdeGearControl(%F%, %M%, %ti%, %tf%, %xi%, + %smin%, %smax%, %sini%, %eabs%, %erel%, %ef% , %maxabs%, %nstep% )%$$ + + +$head Purpose$$ +Let $latex \B{R}$$ denote the real numbers +and let $latex f : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. +We define $latex X : [ti , tf] \rightarrow \B{R}^n$$ by +the following initial value problem: +$latex \[ +\begin{array}{rcl} + X(ti) & = & xi \\ + X'(t) & = & f[t , X(t)] +\end{array} +\] $$ +The routine $cref OdeGear$$ is a stiff multi-step method that +can be used to approximate the solution to this equation. +The routine $code OdeGearControl$$ sets up this multi-step method +and controls the error during such an approximation. + +$head Include$$ +The file $code cppad/ode_gear_control.hpp$$ +is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Notation$$ +The template parameter types $cref/Scalar/OdeGearControl/Scalar/$$ and +$cref/Vector/OdeGearControl/Vector/$$ are documented below. + +$head xf$$ +The return value $icode xf$$ has the prototype +$codei% + %Vector% %xf% +%$$ +and the size of $icode xf$$ is equal to $icode n$$ +(see description of $cref/Vector/OdeGear/Vector/$$ below). +It is the approximation for $latex X(tf)$$. + +$head Fun$$ +The class $icode Fun$$ +and the object $icode F$$ satisfy the prototype +$codei% + %Fun% &%F% +%$$ +This must support the following set of calls +$codei% + %F%.Ode(%t%, %x%, %f%) + %F%.Ode_dep(%t%, %x%, %f_x%) +%$$ + +$subhead t$$ +The argument $icode t$$ has prototype +$codei% + const %Scalar% &%t% +%$$ +(see description of $cref/Scalar/OdeGear/Scalar/$$ below). + +$subhead x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +and has size $icode N$$ +(see description of $cref/Vector/OdeGear/Vector/$$ below). + +$subhead f$$ +The argument $icode f$$ to $icode%F%.Ode%$$ has prototype +$codei% + %Vector% &%f% +%$$ +On input and output, $icode f$$ is a vector of size $icode N$$ +and the input values of the elements of $icode f$$ do not matter. +On output, +$icode f$$ is set equal to $latex f(t, x)$$ +(see $icode f(t, x)$$ in $cref/Purpose/OdeGear/Purpose/$$). + +$subhead f_x$$ +The argument $icode f_x$$ has prototype +$codei% + %Vector% &%f_x% +%$$ +On input and output, $icode f_x$$ is a vector of size $latex N * N$$ +and the input values of the elements of $icode f_x$$ do not matter. +On output, +$latex \[ + f\_x [i * n + j] = \partial_{x(j)} f_i ( t , x ) +\] $$ + +$subhead Warning$$ +The arguments $icode f$$, and $icode f_x$$ +must have a call by reference in their prototypes; i.e., +do not forget the $code &$$ in the prototype for +$icode f$$ and $icode f_x$$. + +$head M$$ +The argument $icode M$$ has prototype +$codei% + size_t %M% +%$$ +It specifies the order of the multi-step method; i.e., +the order of the approximating polynomial +(after the initialization process). +The argument $icode M$$ must greater than or equal one. + +$head ti$$ +The argument $icode ti$$ has prototype +$codei% + const %Scalar% &%ti% +%$$ +It specifies the initial time for the integration of +the differential equation. + +$head tf$$ +The argument $icode tf$$ has prototype +$codei% + const %Scalar% &%tf% +%$$ +It specifies the final time for the integration of +the differential equation. + +$head xi$$ +The argument $icode xi$$ has prototype +$codei% + const %Vector% &%xi% +%$$ +and size $icode n$$. +It specifies value of $latex X(ti)$$. + +$head smin$$ +The argument $icode smin$$ has prototype +$codei% + const %Scalar% &%smin% +%$$ +The minimum value of $latex T[M] - T[M-1]$$ in a call to $code OdeGear$$ +will be $latex smin$$ except for the last two calls where it may be +as small as $latex smin / 2$$. +The value of $icode smin$$ must be less than or equal $icode smax$$. + +$head smax$$ +The argument $icode smax$$ has prototype +$codei% + const %Scalar% &%smax% +%$$ +It specifies the maximum step size to use during the integration; +i.e., the maximum value for $latex T[M] - T[M-1]$$ +in a call to $code OdeGear$$. + +$head sini$$ +The argument $icode sini$$ has prototype +$codei% + %Scalar% &%sini% +%$$ +The value of $icode sini$$ is the minimum +step size to use during initialization of the multi-step method; i.e., +for calls to $code OdeGear$$ where $latex m < M$$. +The value of $icode sini$$ must be less than or equal $icode smax$$ +(and can also be less than $icode smin$$). + +$head eabs$$ +The argument $icode eabs$$ has prototype +$codei% + const %Vector% &%eabs% +%$$ +and size $icode n$$. +Each of the elements of $icode eabs$$ must be +greater than or equal zero. +It specifies a bound for the absolute +error in the return value $icode xf$$ as an approximation for $latex X(tf)$$. +(see the +$cref/error criteria discussion/OdeGearControl/Error Criteria Discussion/$$ +below). + +$head erel$$ +The argument $icode erel$$ has prototype +$codei% + const %Scalar% &%erel% +%$$ +and is greater than or equal zero. +It specifies a bound for the relative +error in the return value $icode xf$$ as an approximation for $latex X(tf)$$ +(see the +$cref/error criteria discussion/OdeGearControl/Error Criteria Discussion/$$ +below). + +$head ef$$ +The argument value $icode ef$$ has prototype +$codei% + %Vector% &%ef% +%$$ +and size $icode n$$. +The input value of its elements does not matter. +On output, +it contains an estimated bound for the +absolute error in the approximation $icode xf$$; i.e., +$latex \[ + ef_i > | X( tf )_i - xf_i | +\] $$ + +$head maxabs$$ +The argument $icode maxabs$$ is optional in the call to $code OdeGearControl$$. +If it is present, it has the prototype +$codei% + %Vector% &%maxabs% +%$$ +and size $icode n$$. +The input value of its elements does not matter. +On output, +it contains an estimate for the +maximum absolute value of $latex X(t)$$; i.e., +$latex \[ + maxabs[i] \approx \max \left\{ + | X( t )_i | \; : \; t \in [ti, tf] + \right\} +\] $$ + +$head nstep$$ +The argument $icode nstep$$ has the prototype +$codei% + %size_t% &%nstep% +%$$ +Its input value does not matter and its output value +is the number of calls to $cref OdeGear$$ +used by $code OdeGearControl$$. + +$head Error Criteria Discussion$$ +The relative error criteria $icode erel$$ and +absolute error criteria $icode eabs$$ are enforced during each step of the +integration of the ordinary differential equations. +In addition, they are inversely scaled by the step size so that +the total error bound is less than the sum of the error bounds. +To be specific, if $latex \tilde{X} (t)$$ is the approximate solution +at time $latex t$$, +$icode ta$$ is the initial step time, +and $icode tb$$ is the final step time, +$latex \[ +\left| \tilde{X} (tb)_j - X (tb)_j \right| +\leq +\frac{tf - ti}{tb - ta} +\left[ eabs[j] + erel \; | \tilde{X} (tb)_j | \right] +\] $$ +If $latex X(tb)_j$$ is near zero for some $latex tb \in [ti , tf]$$, +and one uses an absolute error criteria $latex eabs[j]$$ of zero, +the error criteria above will force $code OdeGearControl$$ +to use step sizes equal to +$cref/smin/OdeGearControl/smin/$$ +for steps ending near $latex tb$$. +In this case, the error relative to $icode maxabs$$ can be judged after +$code OdeGearControl$$ returns. +If $icode ef$$ is to large relative to $icode maxabs$$, +$code OdeGearControl$$ can be called again +with a smaller value of $icode smin$$. + +$head Scalar$$ +The type $icode Scalar$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. +In addition, the following operations must be defined for +$icode Scalar$$ objects $icode a$$ and $icode b$$: + +$table +$bold Operation$$ $cnext $bold Description$$ $rnext +$icode%a% <= %b%$$ $cnext + returns true (false) if $icode a$$ is less than or equal + (greater than) $icode b$$. +$rnext +$icode%a% == %b%$$ $cnext + returns true (false) if $icode a$$ is equal to $icode b$$. +$rnext +$codei%log(%a%)%$$ $cnext + returns a $icode Scalar$$ equal to the logarithm of $icode a$$ +$rnext +$codei%exp(%a%)%$$ $cnext + returns a $icode Scalar$$ equal to the exponential of $icode a$$ +$tend + + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Example$$ +$children% + example/ode_gear_control.cpp +%$$ +The file +$cref ode_gear_control.cpp$$ +contains an example and test a test of using this routine. +It returns true if it succeeds and false otherwise. + +$head Theory$$ +Let $latex e(s)$$ be the error as a function of the +step size $latex s$$ and suppose that there is a constant +$latex K$$ such that $latex e(s) = K s^m$$. +Let $latex a$$ be our error bound. +Given the value of $latex e(s)$$, a step of size $latex \lambda s$$ +would be ok provided that +$latex \[ +\begin{array}{rcl} + a & \geq & e( \lambda s ) (tf - ti) / ( \lambda s ) \\ + a & \geq & K \lambda^m s^m (tf - ti) / ( \lambda s ) \\ + a & \geq & \lambda^{m-1} s^{m-1} (tf - ti) e(s) / s^m \\ + a & \geq & \lambda^{m-1} (tf - ti) e(s) / s \\ + \lambda^{m-1} & \leq & \frac{a}{e(s)} \frac{s}{tf - ti} +\end{array} +\] $$ +Thus if the right hand side of the last inequality is greater +than or equal to one, the step of size $latex s$$ is ok. + +$head Source Code$$ +The source code for this routine is in the file +$code cppad/ode_gear_control.hpp$$. + +$end +-------------------------------------------------------------------------- +*/ + +// link exp and log for float and double +# include + +# include + +namespace CppAD { // Begin CppAD namespace + +template +Vector OdeGearControl( + Fun &F , + size_t M , + const Scalar &ti , + const Scalar &tf , + const Vector &xi , + const Scalar &smin , + const Scalar &smax , + Scalar &sini , + const Vector &eabs , + const Scalar &erel , + Vector &ef , + Vector &maxabs, + size_t &nstep ) +{ + // check simple vector class specifications + CheckSimpleVector(); + + // dimension of the state space + size_t n = size_t(xi.size()); + + CPPAD_ASSERT_KNOWN( + M >= 1, + "Error in OdeGearControl: M is less than one" + ); + CPPAD_ASSERT_KNOWN( + smin <= smax, + "Error in OdeGearControl: smin is greater than smax" + ); + CPPAD_ASSERT_KNOWN( + sini <= smax, + "Error in OdeGearControl: sini is greater than smax" + ); + CPPAD_ASSERT_KNOWN( + size_t(eabs.size()) == n, + "Error in OdeGearControl: size of eabs is not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(maxabs.size()) == n, + "Error in OdeGearControl: size of maxabs is not equal to n" + ); + + // some constants + const Scalar zero(0); + const Scalar one(1); + const Scalar one_plus( Scalar(3) / Scalar(2) ); + const Scalar two(2); + const Scalar ten(10); + + // temporary indices + size_t i, k; + + // temporary Scalars + Scalar step, sprevious, lambda, axi, a, root, r; + + // vectors of Scalars + Vector T (M + 1); + Vector X( (M + 1) * n ); + Vector e(n); + Vector xf(n); + + // initial integer values + size_t m = 1; + nstep = 0; + + // initialize T + T[0] = ti; + + // initialize X, ef, maxabs + for(i = 0; i < n; i++) + for(i = 0; i < n; i++) + { X[i] = xi[i]; + ef[i] = zero; + X[i] = xi[i]; + if( zero <= xi[i] ) + maxabs[i] = xi[i]; + else maxabs[i] = - xi[i]; + + } + + // initial step size + step = smin; + + while( T[m-1] < tf ) + { sprevious = step; + + // check maximum + if( smax <= step ) + step = smax; + + // check minimum + if( m < M ) + { if( step <= sini ) + step = sini; + } + else if( step <= smin ) + step = smin; + + // check if near the end + if( tf <= T[m-1] + one_plus * step ) + T[m] = tf; + else T[m] = T[m-1] + step; + + // try using this step size + nstep++; + OdeGear(F, m, n, T, X, e); + step = T[m] - T[m-1]; + + // compute value of lambda for this step + lambda = Scalar(10) * sprevious / step; + for(i = 0; i < n; i++) + { axi = X[m * n + i]; + if( axi <= zero ) + axi = - axi; + a = eabs[i] + erel * axi; + if( e[i] > zero ) + { if( m == 1 ) + root = (a / e[i]) / ten; + else + { r = ( a / e[i] ) * step / (tf - ti); + root = exp( log(r) / Scalar(m-1) ); + } + if( root <= lambda ) + lambda = root; + } + } + + bool advance; + if( m == M ) + advance = one <= lambda || step <= one_plus * smin; + else advance = one <= lambda || step <= one_plus * sini; + + + if( advance ) + { // accept the results of this time step + CPPAD_ASSERT_UNKNOWN( m <= M ); + if( m == M ) + { // shift for next step + for(k = 0; k < m; k++) + { T[k] = T[k+1]; + for(i = 0; i < n; i++) + X[k*n + i] = X[(k+1)*n + i]; + } + } + // update ef and maxabs + for(i = 0; i < n; i++) + { ef[i] = ef[i] + e[i]; + axi = X[m * n + i]; + if( axi <= zero ) + axi = - axi; + if( axi > maxabs[i] ) + maxabs[i] = axi; + } + if( m != M ) + m++; // all we need do in this case + } + + // new step suggested by error criteria + step = std::min(lambda , ten) * step / two; + } + for(i = 0; i < n; i++) + xf[i] = X[(m-1) * n + i]; + + return xf; +} + +} // End CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/ode_gear.hpp cppad-2016.00.00.1/cppad/utility/ode_gear.hpp --- cppad-2015.00.00.9/cppad/utility/ode_gear.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/ode_gear.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,521 @@ +// $Id: ode_gear.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_ODE_GEAR_HPP +# define CPPAD_ODE_GEAR_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin OdeGear$$ +$spell + cppad.hpp + Jan + bool + const + CppAD + dep +$$ + + +$section An Arbitrary Order Gear Method$$ +$mindex OdeGear Ode stiff differential equation$$ + +$head Syntax$$ +$codei%# include +%$$ +$codei%OdeGear(%F%, %m%, %n%, %T%, %X%, %e%)%$$ + + +$head Purpose$$ +This routine applies +$cref/Gear's Method/OdeGear/Gear's Method/$$ +to solve an explicit set of ordinary differential equations. +We are given +$latex f : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. +This routine solves the following initial value problem +$latex \[ +\begin{array}{rcl} + x( t_{m-1} ) & = & x^0 \\ + x^\prime (t) & = & f[t , x(t)] +\end{array} +\] $$ +for the value of $latex x( t_m )$$. +If your set of ordinary differential equations are not stiff +an explicit method may be better (perhaps $cref Runge45$$.) + +$head Include$$ +The file $code cppad/ode_gear.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Fun$$ +The class $icode Fun$$ +and the object $icode F$$ satisfy the prototype +$codei% + %Fun% &%F% +%$$ +This must support the following set of calls +$codei% + %F%.Ode(%t%, %x%, %f%) + %F%.Ode_dep(%t%, %x%, %f_x%) +%$$ + +$subhead t$$ +The argument $icode t$$ has prototype +$codei% + const %Scalar% &%t% +%$$ +(see description of $cref/Scalar/OdeGear/Scalar/$$ below). + +$subhead x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +and has size $icode n$$ +(see description of $cref/Vector/OdeGear/Vector/$$ below). + +$subhead f$$ +The argument $icode f$$ to $icode%F%.Ode%$$ has prototype +$codei% + %Vector% &%f% +%$$ +On input and output, $icode f$$ is a vector of size $icode n$$ +and the input values of the elements of $icode f$$ do not matter. +On output, +$icode f$$ is set equal to $latex f(t, x)$$ +(see $icode f(t, x)$$ in $cref/Purpose/OdeGear/Purpose/$$). + +$subhead f_x$$ +The argument $icode f_x$$ has prototype +$codei% + %Vector% &%f_x% +%$$ +On input and output, $icode f_x$$ is a vector of size $latex n * n$$ +and the input values of the elements of $icode f_x$$ do not matter. +On output, +$latex \[ + f\_x [i * n + j] = \partial_{x(j)} f_i ( t , x ) +\] $$ + +$subhead Warning$$ +The arguments $icode f$$, and $icode f_x$$ +must have a call by reference in their prototypes; i.e., +do not forget the $code &$$ in the prototype for +$icode f$$ and $icode f_x$$. + +$head m$$ +The argument $icode m$$ has prototype +$codei% + size_t %m% +%$$ +It specifies the order (highest power of $latex t$$) +used to represent the function $latex x(t)$$ in the multi-step method. +Upon return from $code OdeGear$$, +the $th i$$ component of the polynomial is defined by +$latex \[ + p_i ( t_j ) = X[ j * n + i ] +\] $$ +for $latex j = 0 , \ldots , m$$ (where $latex 0 \leq i < n$$). +The value of $latex m$$ must be greater than or equal one. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ +It specifies the range space dimension of the +vector valued function $latex x(t)$$. + +$head T$$ +The argument $icode T$$ has prototype +$codei% + const %Vector% &%T% +%$$ +and size greater than or equal to $latex m+1$$. +For $latex j = 0 , \ldots m$$, $latex T[j]$$ is the time +corresponding to time corresponding +to a previous point in the multi-step method. +The value $latex T[m]$$ is the time +of the next point in the multi-step method. +The array $latex T$$ must be monotone increasing; i.e., +$latex T[j] < T[j+1]$$. +Above and below we often use the shorthand $latex t_j$$ for $latex T[j]$$. + + +$head X$$ +The argument $icode X$$ has the prototype +$codei% + %Vector% &%X% +%$$ +and size greater than or equal to $latex (m+1) * n$$. +On input to $code OdeGear$$, +for $latex j = 0 , \ldots , m-1$$, and +$latex i = 0 , \ldots , n-1$$ +$latex \[ + X[ j * n + i ] = x_i ( t_j ) +\] $$ +Upon return from $code OdeGear$$, +for $latex i = 0 , \ldots , n-1$$ +$latex \[ + X[ m * n + i ] \approx x_i ( t_m ) +\] $$ + +$head e$$ +The vector $icode e$$ is an approximate error bound for the result; i.e., +$latex \[ + e[i] \geq | X[ m * n + i ] - x_i ( t_m ) | +\] $$ +The order of this approximation is one less than the order of +the solution; i.e., +$latex \[ + e = O ( h^m ) +\] $$ +where $latex h$$ is the maximum of $latex t_{j+1} - t_j$$. + +$head Scalar$$ +The type $icode Scalar$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. +In addition, the following operations must be defined for +$icode Scalar$$ objects $icode a$$ and $icode b$$: + +$table +$bold Operation$$ $cnext $bold Description$$ $rnext +$icode%a% < %b%$$ $cnext + less than operator (returns a $code bool$$ object) +$tend + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Example$$ +$children% + example/ode_gear.cpp +%$$ +The file +$cref ode_gear.cpp$$ +contains an example and test a test of using this routine. +It returns true if it succeeds and false otherwise. + +$head Source Code$$ +The source code for this routine is in the file +$code cppad/ode_gear.hpp$$. + +$head Theory$$ +For this discussion we use the shorthand $latex x_j$$ +for the value $latex x ( t_j ) \in \B{R}^n$$ which is not to be confused +with $latex x_i (t) \in \B{R}$$ in the notation above. +The interpolating polynomial $latex p(t)$$ is given by +$latex \[ +p(t) = +\sum_{j=0}^m +x_j +\frac{ + \prod_{i \neq j} ( t - t_i ) +}{ + \prod_{i \neq j} ( t_j - t_i ) +} +\] $$ +The derivative $latex p^\prime (t)$$ is given by +$latex \[ +p^\prime (t) = +\sum_{j=0}^m +x_j +\frac{ + \sum_{i \neq j} \prod_{k \neq i,j} ( t - t_k ) +}{ + \prod_{k \neq j} ( t_j - t_k ) +} +\] $$ +Evaluating the derivative at the point $latex t_\ell$$ we have +$latex \[ +\begin{array}{rcl} +p^\prime ( t_\ell ) & = & +x_\ell +\frac{ + \sum_{i \neq \ell} \prod_{k \neq i,\ell} ( t_\ell - t_k ) +}{ + \prod_{k \neq \ell} ( t_\ell - t_k ) +} ++ +\sum_{j \neq \ell} +x_j +\frac{ + \sum_{i \neq j} \prod_{k \neq i,j} ( t_\ell - t_k ) +}{ + \prod_{k \neq j} ( t_j - t_k ) +} +\\ +& = & +x_\ell +\sum_{i \neq \ell} +\frac{ 1 }{ t_\ell - t_i } ++ +\sum_{j \neq \ell} +x_j +\frac{ + \prod_{k \neq \ell,j} ( t_\ell - t_k ) +}{ + \prod_{k \neq j} ( t_j - t_k ) +} +\\ +& = & +x_\ell +\sum_{k \neq \ell} ( t_\ell - t_k )^{-1} ++ +\sum_{j \neq \ell} +x_j +( t_j - t_\ell )^{-1} +\prod_{k \neq \ell ,j} ( t_\ell - t_k ) / ( t_j - t_k ) +\end{array} +\] $$ +We define the vector $latex \alpha \in \B{R}^{m+1}$$ by +$latex \[ +\alpha_j = \left\{ \begin{array}{ll} +\sum_{k \neq m} ( t_m - t_k )^{-1} + & {\rm if} \; j = m +\\ +( t_j - t_m )^{-1} +\prod_{k \neq m,j} ( t_m - t_k ) / ( t_j - t_k ) + & {\rm otherwise} +\end{array} \right. +\] $$ +It follows that +$latex \[ + p^\prime ( t_m ) = \alpha_0 x_0 + \cdots + \alpha_m x_m +\] $$ +Gear's method determines $latex x_m$$ by solving the following +nonlinear equation +$latex \[ + f( t_m , x_m ) = \alpha_0 x_0 + \cdots + \alpha_m x_m +\] $$ +Newton's method for solving this equation determines iterates, +which we denote by $latex x_m^k$$, by solving the following affine +approximation of the equation above +$latex \[ +\begin{array}{rcl} +f( t_m , x_m^{k-1} ) + \partial_x f( t_m , x_m^{k-1} ) ( x_m^k - x_m^{k-1} ) +& = & +\alpha_0 x_0^k + \alpha_1 x_1 + \cdots + \alpha_m x_m +\\ +\left[ \alpha_m I - \partial_x f( t_m , x_m^{k-1} ) \right] x_m +& = & +\left[ +f( t_m , x_m^{k-1} ) - \partial_x f( t_m , x_m^{k-1} ) x_m^{k-1} +- \alpha_0 x_0 - \cdots - \alpha_{m-1} x_{m-1} +\right] +\end{array} +\] $$ +In order to initialize Newton's method; i.e. choose $latex x_m^0$$ +we define the vector $latex \beta \in \B{R}^{m+1}$$ by +$latex \[ +\beta_j = \left\{ \begin{array}{ll} +\sum_{k \neq m-1} ( t_{m-1} - t_k )^{-1} + & {\rm if} \; j = m-1 +\\ +( t_j - t_{m-1} )^{-1} +\prod_{k \neq m-1,j} ( t_{m-1} - t_k ) / ( t_j - t_k ) + & {\rm otherwise} +\end{array} \right. +\] $$ +It follows that +$latex \[ + p^\prime ( t_{m-1} ) = \beta_0 x_0 + \cdots + \beta_m x_m +\] $$ +We solve the following approximation of the equation above to determine +$latex x_m^0$$: +$latex \[ + f( t_{m-1} , x_{m-1} ) = + \beta_0 x_0 + \cdots + \beta_{m-1} x_{m-1} + \beta_m x_m^0 +\] $$ + + +$head Gear's Method$$ +C. W. Gear, +``Simultaneous Numerical Solution of Differential-Algebraic Equations,'' +IEEE Transactions on Circuit Theory, +vol. 18, no. 1, pp. 89-95, Jan. 1971. + + +$end +-------------------------------------------------------------------------- +*/ + +# include +# include +# include +# include +# include +# include +# include + +namespace CppAD { // BEGIN CppAD namespace + +template +void OdeGear( + Fun &F , + size_t m , + size_t n , + const Vector &T , + Vector &X , + Vector &e ) +{ + // temporary indices + size_t i, j, k; + + typedef typename Vector::value_type Scalar; + + // check numeric type specifications + CheckNumericType(); + + // check simple vector class specifications + CheckSimpleVector(); + + CPPAD_ASSERT_KNOWN( + m >= 1, + "OdeGear: m is less than one" + ); + CPPAD_ASSERT_KNOWN( + n > 0, + "OdeGear: n is equal to zero" + ); + CPPAD_ASSERT_KNOWN( + size_t(T.size()) >= (m+1), + "OdeGear: size of T is not greater than or equal (m+1)" + ); + CPPAD_ASSERT_KNOWN( + size_t(X.size()) >= (m+1) * n, + "OdeGear: size of X is not greater than or equal (m+1) * n" + ); + for(j = 0; j < m; j++) CPPAD_ASSERT_KNOWN( + T[j] < T[j+1], + "OdeGear: the array T is not monotone increasing" + ); + + // some constants + Scalar zero(0); + Scalar one(1); + + // vectors required by method + Vector alpha(m + 1); + Vector beta(m + 1); + Vector f(n); + Vector f_x(n * n); + Vector x_m0(n); + Vector x_m(n); + Vector b(n); + Vector A(n * n); + + // compute alpha[m] + alpha[m] = zero; + for(k = 0; k < m; k++) + alpha[m] += one / (T[m] - T[k]); + + // compute beta[m-1] + beta[m-1] = one / (T[m-1] - T[m]); + for(k = 0; k < m-1; k++) + beta[m-1] += one / (T[m-1] - T[k]); + + + // compute other components of alpha + for(j = 0; j < m; j++) + { // compute alpha[j] + alpha[j] = one / (T[j] - T[m]); + for(k = 0; k < m; k++) + { if( k != j ) + { alpha[j] *= (T[m] - T[k]); + alpha[j] /= (T[j] - T[k]); + } + } + } + + // compute other components of beta + for(j = 0; j <= m; j++) + { if( j != m-1 ) + { // compute beta[j] + beta[j] = one / (T[j] - T[m-1]); + for(k = 0; k <= m; k++) + { if( k != j && k != m-1 ) + { beta[j] *= (T[m-1] - T[k]); + beta[j] /= (T[j] - T[k]); + } + } + } + } + + // evaluate f(T[m-1], x_{m-1} ) + for(i = 0; i < n; i++) + x_m[i] = X[(m-1) * n + i]; + F.Ode(T[m-1], x_m, f); + + // solve for x_m^0 + for(i = 0; i < n; i++) + { x_m[i] = f[i]; + for(j = 0; j < m; j++) + x_m[i] -= beta[j] * X[j * n + i]; + x_m[i] /= beta[m]; + } + x_m0 = x_m; + + // evaluate partial w.r.t x of f(T[m], x_m^0) + F.Ode_dep(T[m], x_m, f_x); + + // compute the matrix A = ( alpha[m] * I - f_x ) + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + A[i * n + j] = - f_x[i * n + j]; + A[i * n + i] += alpha[m]; + } + + // LU factor (and overwrite) the matrix A + int sign; + CppAD::vector ip(n) , jp(n); + sign = LuFactor(ip, jp, A); + CPPAD_ASSERT_KNOWN( + sign != 0, + "OdeGear: step size is to large" + ); + + // Iterations of Newton's method + for(k = 0; k < 3; k++) + { + // only evaluate f( T[m] , x_m ) keep f_x during iteration + F.Ode(T[m], x_m, f); + + // b = f + f_x x_m - alpha[0] x_0 - ... - alpha[m-1] x_{m-1} + for(i = 0; i < n; i++) + { b[i] = f[i]; + for(j = 0; j < n; j++) + b[i] -= f_x[i * n + j] * x_m[j]; + for(j = 0; j < m; j++) + b[i] -= alpha[j] * X[ j * n + i ]; + } + LuInvert(ip, jp, A, b); + x_m = b; + } + + // return estimate for x( t[k] ) and the estimated error bound + for(i = 0; i < n; i++) + { X[m * n + i] = x_m[i]; + e[i] = x_m[i] - x_m0[i]; + if( e[i] < zero ) + e[i] = - e[i]; + } +} + +} // End CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/omp_alloc.hpp cppad-2016.00.00.1/cppad/utility/omp_alloc.hpp --- cppad-2015.00.00.9/cppad/utility/omp_alloc.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/omp_alloc.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,783 @@ +// $Id: omp_alloc.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_OMP_ALLOC_HPP +# define CPPAD_OMP_ALLOC_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +# include +# ifdef _OPENMP +# include +# endif + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +class omp_alloc{ +// ============================================================================ +public: +/* +$begin omp_max_num_threads$$ +$spell + cppad.hpp + inv + CppAD + num + omp_alloc +$$ +$section Set and Get Maximum Number of Threads for omp_alloc Allocator$$ + +$head Deprecated 2011-08-31$$ +Use the functions $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ +and $cref/thread_alloc:num_threads/ta_num_threads/$$ instead. + +$head Syntax$$ +$codei%# include +%$$ +$codei%omp_alloc::set_max_num_threads(%number%) +%$$ +$icode%number% = omp_alloc::get_max_num_threads() +%$$ + +$head Purpose$$ +By default there is only one thread and all execution is in sequential mode +(not $cref/parallel/omp_in_parallel/$$). + +$head number$$ +The argument and return value $icode number$$ has prototype +$codei% + size_t %number% +%$$ +and must be greater than zero. + +$head set_max_num_threads$$ +Informs $cref omp_alloc$$ of the maximum number of OpenMP threads. + +$head get_max_num_threads$$ +Returns the valued used in the previous call to $code set_max_num_threads$$. +If there was no such previous call, the value one is returned +(and only thread number zero can use $cref omp_alloc$$). + +$head Restrictions$$ +The function $code set_max_num_threads$$ must be called before +the program enters $cref/parallel/omp_in_parallel/$$ execution mode. +In addition, this function cannot be called while in parallel mode. + +$end +*/ + /*! + Inform omp_alloc of the maximum number of OpenMP threads and enable + parallel execution mode by initializing all statics in this file. + + \param number [in] + maximum number of OpenMP threads. + */ + static void set_max_num_threads(size_t number) + { thread_alloc::parallel_setup( + number, omp_alloc::in_parallel, omp_alloc::get_thread_num + ); + thread_alloc::hold_memory(number > 1); + } + /*! + Get the current maximum number of OpenMP threads that omp_alloc can use. + + \return + maximum number of OpenMP threads. + */ + static size_t get_max_num_threads(void) + { return thread_alloc::num_threads(); } + +/* ----------------------------------------------------------------------- +$begin omp_in_parallel$$ + +$section Is The Current Execution in OpenMP Parallel Mode$$ +$mindex in_parallel$$ +$spell + cppad.hpp + omp_alloc + bool +$$ + +$head Deprecated 2011-08-31$$ +Use the function $cref/thread_alloc::in_parallel/ta_in_parallel/$$ instead. + +$head Syntax$$ +$codei%# include +%$$ +$icode%flag% = omp_alloc::in_parallel()%$$ + +$head Purpose$$ +Some of the $cref omp_alloc$$ allocation routines have different +specifications for parallel (not sequential) execution mode. +This routine enables you to determine if the current execution mode +is sequential or parallel. + +$head flag$$ +The return value has prototype +$codei% + bool %flag% +%$$ +It is true if the current execution is in parallel mode +(possibly multi-threaded) and false otherwise (sequential mode). + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /// Are we in a parallel execution state; i.e., is it possible that + /// other threads are currently executing. + static bool in_parallel(void) + { +# ifdef _OPENMP + return omp_in_parallel() != 0; +# else + return false; +# endif + } + +/* ----------------------------------------------------------------------- +$begin omp_get_thread_num$$ +$spell + cppad.hpp + CppAD + num + omp_alloc + cppad.hpp +$$ + +$section Get the Current OpenMP Thread Number$$ +$mindex get_thread_num$$ + +$head Deprecated 2011-08-31$$ +Use the function $cref/thread_alloc::thread_num/ta_thread_num/$$ instead. + +$head Syntax$$ +$codei%# include +%$$ +$icode%thread% = omp_alloc::get_thread_num()%$$ + +$head Purpose$$ +Some of the $cref omp_alloc$$ allocation routines have a thread number. +This routine enables you to determine the current thread. + +$head thread$$ +The return value $icode thread$$ has prototype +$codei% + size_t %thread% +%$$ +and is the currently executing thread number. +If $code _OPENMP$$ is not defined, $icode thread$$ is zero. + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /// Get current OpenMP thread number (zero if _OpenMP not defined). + static size_t get_thread_num(void) + { +# ifdef _OPENMP + size_t thread = static_cast( omp_get_thread_num() ); + return thread; +# else + return 0; +# endif + } +/* ----------------------------------------------------------------------- +$begin omp_get_memory$$ +$spell + cppad.hpp + num + ptr + omp_alloc +$$ + +$section Get At Least A Specified Amount of Memory$$ + +$head Deprecated 2011-08-31$$ +Use the function $cref/thread_alloc::get_memory/ta_get_memory/$$ instead. + +$head Syntax$$ +$codei%# include +%$$ +$icode%v_ptr% = omp_alloc::get_memory(%min_bytes%, %cap_bytes%)%$$ + +$head Purpose$$ +Use $cref omp_alloc$$ to obtain a minimum number of bytes of memory +(for use by the $cref/current thread/omp_get_thread_num/$$). + +$head min_bytes$$ +This argument has prototype +$codei% + size_t %min_bytes% +%$$ +It specifies the minimum number of bytes to allocate. + +$head cap_bytes$$ +This argument has prototype +$codei% + size_t& %cap_bytes% +%$$ +It's input value does not matter. +Upon return, it is the actual number of bytes (capacity) +that have been allocated for use, +$codei% + %min_bytes% <= %cap_bytes% +%$$ + +$head v_ptr$$ +The return value $icode v_ptr$$ has prototype +$codei% + void* %v_ptr% +%$$ +It is the location where the $icode cap_bytes$$ of memory +that have been allocated for use begins. + +$head Allocation Speed$$ +This allocation should be faster if the following conditions hold: +$list number$$ +The memory allocated by a previous call to $code get_memory$$ +is currently available for use. +$lnext +The current $icode min_bytes$$ is between +the previous $icode min_bytes$$ and previous $icode cap_bytes$$. +$lend + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /*! + Use omp_alloc to get a specified amount of memory. + + If the memory allocated by a previous call to \c get_memory is now + avaialable, and \c min_bytes is between its previous value + and the previous \c cap_bytes, this memory allocation will have + optimal speed. Otherwise, the memory allocation is more complicated and + may have to wait for other threads to complete an allocation. + + \param min_bytes [in] + The minimum number of bytes of memory to be obtained for use. + + \param cap_bytes [out] + The actual number of bytes of memory obtained for use. + + \return + pointer to the beginning of the memory allocted for use. + */ + static void* get_memory(size_t min_bytes, size_t& cap_bytes) + { return thread_alloc::get_memory(min_bytes, cap_bytes); } + +/* ----------------------------------------------------------------------- +$begin omp_return_memory$$ +$spell + cppad.hpp + ptr + omp_alloc +$$ + +$section Return Memory to omp_alloc$$ +$mindex return_memory$$ + +$head Deprecated 2011-08-31$$ +Use the function $cref/thread_alloc::return_memory/ta_return_memory/$$ instead. + +$head Syntax$$ +$codei%# include +%$$ +$codei%omp_alloc::return_memory(%v_ptr%)%$$ + +$head Purpose$$ +If $cref omp_max_num_threads$$ is one, +the memory is returned to the system. +Otherwise, the memory is retained by $cref omp_alloc$$ for quick future use +by the thread that allocated to memory. + +$head v_ptr$$ +This argument has prototype +$codei% + void* %v_ptr% +%$$. +It must be a pointer to memory that is currently in use; i.e. +obtained by a previous call to $cref omp_get_memory$$ and not yet returned. + +$head Thread$$ +Either the $cref/current thread/omp_get_thread_num/$$ must be the same as during +the corresponding call to $cref omp_get_memory$$, +or the current execution mode must be sequential +(not $cref/parallel/omp_in_parallel/$$). + +$head NDEBUG$$ +If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). +Otherwise, a list of in use pointers is searched to make sure +that $icode v_ptr$$ is in the list. + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /*! + Return memory that was obtained by \c get_memory. + If max_num_threads(0) == 1, + the memory is returned to the system. + Otherwise, it is retained by \c omp_alloc and available for use by + \c get_memory for this thread. + + \param v_ptr [in] + Value of the pointer returned by \c get_memory and still in use. + After this call, this pointer will available (and not in use). + + \par + We must either be in sequential (not parallel) execution mode, + or the current thread must be the same as for the corresponding call + to \c get_memory. + */ + static void return_memory(void* v_ptr) + { thread_alloc::return_memory(v_ptr); } +/* ----------------------------------------------------------------------- +$begin omp_free_available$$ +$spell + cppad.hpp + omp_alloc +$$ + +$section Free Memory Currently Available for Quick Use by a Thread$$ +$mindex free_available$$ + +$head Deprecated 2011-08-31$$ +Use the function $cref/thread_alloc::free_available/ta_free_available/$$ +instead. + +$head Syntax$$ +$codei%# include +%$$ +$codei%omp_alloc::free_available(%thread%)%$$ + +$head Purpose$$ +Free memory, currently available for quick use by a specific thread, +for general future use. + +$head thread$$ +This argument has prototype +$codei% + size_t %thread% +%$$ +Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, +or the current execution mode must be sequential +(not $cref/parallel/omp_in_parallel/$$). + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /*! + Return all the memory being held as available for a thread to the system. + + \param thread [in] + this thread that will no longer have any available memory after this call. + This must either be the thread currently executing, or we must be + in sequential (not parallel) execution mode. + */ + static void free_available(size_t thread) + { thread_alloc::free_available(thread); } +/* ----------------------------------------------------------------------- +$begin omp_inuse$$ +$spell + cppad.hpp + num + inuse + omp_alloc +$$ + +$section Amount of Memory a Thread is Currently Using$$ +$mindex inuse$$ + +$head Deprecated 2011-08-31$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%num_bytes% = omp_alloc::inuse(%thread%)%$$ +Use the function $cref/thread_alloc::inuse/ta_inuse/$$ instead. + +$head Purpose$$ +Memory being managed by $cref omp_alloc$$ has two states, +currently in use by the specified thread, +and quickly available for future use by the specified thread. +This function informs the program how much memory is in use. + +$head thread$$ +This argument has prototype +$codei% + size_t %thread% +%$$ +Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, +or the current execution mode must be sequential +(not $cref/parallel/omp_in_parallel/$$). + +$head num_bytes$$ +The return value has prototype +$codei% + size_t %num_bytes% +%$$ +It is the number of bytes currently in use by the specified thread. + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /*! + Determine the amount of memory that is currently inuse. + + \param thread [in] + Thread for which we are determining the amount of memory + (must be < CPPAD_MAX_NUM_THREADS). + Durring parallel execution, this must be the thread + that is currently executing. + + \return + The amount of memory in bytes. + */ + static size_t inuse(size_t thread) + { return thread_alloc::inuse(thread); } +/* ----------------------------------------------------------------------- +$begin omp_available$$ +$spell + cppad.hpp + num + omp_alloc +$$ + +$section Amount of Memory Available for Quick Use by a Thread$$ + +$head Deprecated 2011-08-31$$ +Use the function $cref/thread_alloc::available/ta_available/$$ instead. + +$head Syntax$$ +$codei%# include +%$$ +$icode%num_bytes% = omp_alloc::available(%thread%)%$$ + +$head Purpose$$ +Memory being managed by $cref omp_alloc$$ has two states, +currently in use by the specified thread, +and quickly available for future use by the specified thread. +This function informs the program how much memory is available. + +$head thread$$ +This argument has prototype +$codei% + size_t %thread% +%$$ +Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, +or the current execution mode must be sequential +(not $cref/parallel/omp_in_parallel/$$). + +$head num_bytes$$ +The return value has prototype +$codei% + size_t %num_bytes% +%$$ +It is the number of bytes currently available for use by the specified thread. + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /*! + Determine the amount of memory that is currently available for use. + + \copydetails inuse + */ + static size_t available(size_t thread) + { return thread_alloc::available(thread); } +/* ----------------------------------------------------------------------- +$begin omp_create_array$$ +$spell + cppad.hpp + omp_alloc + sizeof +$$ + +$section Allocate Memory and Create A Raw Array$$ +$mindex create_array$$ + +$head Deprecated 2011-08-31$$ +Use the function $cref/thread_alloc::create_array/ta_create_array/$$ instead. + +$head Syntax$$ +$codei%# include +%$$ +$icode%array% = omp_alloc::create_array<%Type%>(%size_min%, %size_out%)%$$. + +$head Purpose$$ +Create a new raw array using $cref omp_alloc$$ a fast memory allocator +that works well in a multi-threading OpenMP environment. + +$head Type$$ +The type of the elements of the array. + +$head size_min$$ +This argument has prototype +$codei% + size_t %size_min% +%$$ +This is the minimum number of elements that there can be +in the resulting $icode array$$. + +$head size_out$$ +This argument has prototype +$codei% + size_t& %size_out% +%$$ +The input value of this argument does not matter. +Upon return, it is the actual number of elements +in $icode array$$ +($icode% size_min %<=% size_out%$$). + +$head array$$ +The return value $icode array$$ has prototype +$codei% + %Type%* %array% +%$$ +It is array with $icode size_out$$ elements. +The default constructor for $icode Type$$ is used to initialize the +elements of $icode array$$. +Note that $cref omp_delete_array$$ +should be used to destroy the array when it is no longer needed. + +$head Delta$$ +The amount of memory $cref omp_inuse$$ by the current thread, +will increase $icode delta$$ where +$codei% + sizeof(%Type%) * (%size_out% + 1) > %delta% >= sizeof(%Type%) * %size_out% +%$$ +The $cref omp_available$$ memory will decrease by $icode delta$$, +(and the allocation will be faster) +if a previous allocation with $icode size_min$$ between its current value +and $icode size_out$$ is available. + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /*! + Use omp_alloc to Create a Raw Array. + + \tparam Type + The type of the elements of the array. + + \param size_min [in] + The minimum number of elements in the array. + + \param size_out [out] + The actual number of elements in the array. + + \return + pointer to the first element of the array. + The default constructor is used to initialize + all the elements of the array. + + \par + The \c extra_ field, in the \c omp_alloc node before the return value, + is set to size_out. + */ + template + static Type* create_array(size_t size_min, size_t& size_out) + { return thread_alloc::create_array(size_min, size_out); } +/* ----------------------------------------------------------------------- +$begin omp_delete_array$$ +$spell + cppad.hpp + omp_alloc + sizeof +$$ + +$section Return A Raw Array to The Available Memory for a Thread$$ +$mindex delete_array$$ + +$head Deprecated 2011-08-31$$ +Use the function $cref/thread_alloc::delete_array/ta_delete_array/$$ instead. + +$head Syntax$$ +$codei%# include +%$$ +$codei%omp_alloc::delete_array(%array%)%$$. + +$head Purpose$$ +Returns memory corresponding to a raw array +(create by $cref omp_create_array$$) to the +$cref omp_available$$ memory pool for the current thread. + +$head Type$$ +The type of the elements of the array. + +$head array$$ +The argument $icode array$$ has prototype +$codei% + %Type%* %array% +%$$ +It is a value returned by $cref omp_create_array$$ and not yet deleted. +The $icode Type$$ destructor is called for each element in the array. + +$head Thread$$ +The $cref/current thread/omp_get_thread_num/$$ must be the +same as when $cref omp_create_array$$ returned the value $icode array$$. +There is an exception to this rule: +when the current execution mode is sequential +(not $cref/parallel/omp_in_parallel/$$) the current thread number does not matter. + +$head Delta$$ +The amount of memory $cref omp_inuse$$ will decrease by $icode delta$$, +and the $cref omp_available$$ memory will increase by $icode delta$$, +where $cref/delta/omp_create_array/Delta/$$ +is the same as for the corresponding call to $code create_array$$. + +$head Example$$ +$cref omp_alloc.cpp$$ + +$end +*/ + /*! + Return Memory Used for a Raw Array to the Available Pool. + + \tparam Type + The type of the elements of the array. + + \param array [in] + A value returned by \c create_array that has not yet been deleted. + The \c Type destructor is used to destroy each of the elements + of the array. + + \par + Durring parallel execution, the current thread must be the same + as during the corresponding call to \c create_array. + */ + template + static void delete_array(Type* array) + { thread_alloc::delete_array(array); } +}; +/* -------------------------------------------------------------------------- +$begin omp_efficient$$ +$spell + cppad.hpp + omp_alloc + ptr + num + bool + const +$$ + +$section Check If A Memory Allocation is Efficient for Another Use$$ + +$head Removed$$ +This function has been removed because speed tests seem to indicate +it is just as fast, or faster, to free and then reallocate the memory. + +$head Syntax$$ +$codei%# include +%$$ +$icode%flag% = omp_alloc::efficient(%v_ptr%, %num_bytes%)%$$ + +$head Purpose$$ +Check if memory that is currently in use is an efficient +allocation for a specified number of bytes. + +$head v_ptr$$ +This argument has prototype +$codei% + const void* %v_ptr% +%$$. +It must be a pointer to memory that is currently in use; i.e. +obtained by a previous call to $cref omp_get_memory$$ and not yet returned. + +$head num_bytes$$ +This argument has prototype +$codei% + size_t %num_bytes% +%$$ +It specifies the number of bytes of the memory allocated by $icode v_ptr$$ +that we want to use. + +$head flag$$ +The return value has prototype +$codei% + bool %flag% +%$$ +It is true, +a call to $code get_memory$$ with +$cref/min_bytes/omp_get_memory/min_bytes/$$ +equal to $icode num_bytes$$ would result in a value for +$cref/cap_bytes/omp_get_memory/cap_bytes/$$ that is the same as when $code v_ptr$$ +was returned by $code get_memory$$; i.e., +$icode v_ptr$$ is an efficient memory block for $icode num_bytes$$ +bytes of information. + +$head Thread$$ +Either the $cref/current thread/omp_get_thread_num/$$ must be the same as during +the corresponding call to $cref omp_get_memory$$, +or the current execution mode must be sequential +(not $cref/parallel/omp_in_parallel/$$). + +$head NDEBUG$$ +If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). +Otherwise, a list of in use pointers is searched to make sure +that $icode v_ptr$$ is in the list. + +$end +--------------------------------------------------------------------------- +$begin old_max_num_threads$$ +$spell + cppad.hpp + inv + CppAD + num + omp_alloc +$$ +$section Set Maximum Number of Threads for omp_alloc Allocator$$ +$mindex max_num_threads$$ + +$head Removed$$ +This function has been removed from the CppAD API. +Use the function $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ +in its place. + +$head Syntax$$ +$codei%# include +%$$ +$codei%omp_alloc::max_num_threads(%number%)%$$ + +$head Purpose$$ +By default there is only one thread and all execution is in sequential mode +(not $cref/parallel/omp_in_parallel/$$). + +$head number$$ +The argument $icode number$$ has prototype +$codei% + size_t %number% +%$$ +It must be greater than zero and specifies the maximum number of +OpenMP threads that will be active at one time. + +$head Restrictions$$ +This function must be called before the program enters +$cref/parallel/omp_in_parallel/$$ execution mode. + +$end +------------------------------------------------------------------------------- +*/ +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/poly.hpp cppad-2016.00.00.1/cppad/utility/poly.hpp --- cppad-2015.00.00.9/cppad/utility/poly.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/poly.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,194 @@ +// $Id: poly.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_POLY_HPP +# define CPPAD_POLY_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin Poly$$ +$spell + cppad.hpp + CppAD + namespace + cstddef + ifndef + endif + deg + const + std + da +$$ + + +$section Evaluate a Polynomial or its Derivative$$ +$mindex Poly template$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%p% = Poly(%k%, %a%, %z%)%$$ + + +$head Description$$ +Computes the $th k$$ derivative of the polynomial +$latex \[ + P(z) = a_0 + a_1 z^1 + \cdots + a_d z^d +\] $$ +If $icode k$$ is equal to zero, the return value is $latex P(z)$$. + +$head Include$$ +The file $code cppad/poly.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. +Including this file defines +$code Poly$$ within the $code CppAD$$ namespace. + +$head k$$ +The argument $icode k$$ has prototype +$codei% + size_t %k% +%$$ +It specifies the order of the derivative to calculate. + +$head a$$ +The argument $icode a$$ has prototype +$codei% + const %Vector% &%a% +%$$ +(see $cref/Vector/Poly/Vector/$$ below). +It specifies the vector corresponding to the polynomial $latex P(z)$$. + +$head z$$ +The argument $icode z$$ has prototype +$codei% + const %Type% &%z% +%$$ +(see $icode Type$$ below). +It specifies the point at which to evaluate the polynomial + +$head p$$ +The result $icode p$$ has prototype +$codei% + %Type% %p% +%$$ +(see $cref/Type/Poly/Type/$$ below) +and it is equal to the $th k$$ derivative of $latex P(z)$$; i.e., +$latex \[ +p = \frac{k !}{0 !} a_k + + \frac{(k+1) !}{1 !} a_{k+1} z^1 + + \ldots + + \frac{d !}{(d - k) !} a_d z^{d - k} +\] +$$ +If $latex k > d$$, $icode%p% = %Type%(0)%$$. + +$head Type$$ +The type $icode Type$$ is determined by the argument $icode z$$. +It is assumed that +multiplication and addition of $icode Type$$ objects +are commutative. + +$subhead Operations$$ +The following operations must be supported where +$icode x$$ and $icode y$$ are objects of type $icode Type$$ +and $icode i$$ is an $code int$$: +$table +$icode%x% = %i%$$ $cnext assignment $rnext +$icode%x% = %y%$$ $cnext assignment $rnext +$icode%x% *= %y%$$ $cnext multiplication computed assignment $rnext +$icode%x% += %y%$$ $cnext addition computed assignment + +$tend + + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Type$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Operation Sequence$$ +The $icode Type$$ operation sequence used to calculate $icode p$$ is +$cref/independent/glossary/Operation/Independent/$$ +of $icode z$$ and the elements of $icode a$$ +(it does depend on the size of the vector $icode a$$). + + +$children% + example/poly.cpp% + omh/poly_hpp.omh +%$$ + +$head Example$$ +The file +$cref poly.cpp$$ +contains an example and test of this routine. +It returns true if it succeeds and false otherwise. + +$head Source$$ +The file $cref poly.hpp$$ contains the +current source code that implements these specifications. + +$end +------------------------------------------------------------------------------ +*/ +// BEGIN C++ +# include // used to defined size_t +# include + +namespace CppAD { // BEGIN CppAD namespace + +template +Type Poly(size_t k, const Vector &a, const Type &z) +{ size_t i; + size_t d = a.size() - 1; + + Type tmp; + + // check Vector is Simple Vector class with Type elements + CheckSimpleVector(); + + // case where derivative order greater than degree of polynomial + if( k > d ) + { tmp = 0; + return tmp; + } + // case where we are evaluating a derivative + if( k > 0 ) + { // initialize factor as (k-1) ! + size_t factor = 1; + for(i = 2; i < k; i++) + factor *= i; + + // set b to coefficient vector corresponding to derivative + Vector b(d - k + 1); + for(i = k; i <= d; i++) + { factor *= i; + tmp = factor; + b[i - k] = a[i] * tmp; + factor /= (i - k + 1); + } + // value of derivative polynomial + return Poly(0, b, z); + } + // case where we are evaluating the original polynomial + Type sum = a[d]; + i = d; + while(i > 0) + { sum *= z; + sum += a[--i]; + } + return sum; +} +} // END CppAD namespace +// END C++ +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/pow_int.hpp cppad-2016.00.00.1/cppad/utility/pow_int.hpp --- cppad-2015.00.00.9/cppad/utility/pow_int.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/pow_int.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,142 @@ +// $Id: pow_int.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_POW_INT_HPP +# define CPPAD_POW_INT_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin pow_int$$ +$spell + cppad.hpp + CppAD + namespace + const +$$ + + +$section The Integer Power Function$$ +$mindex pow exponent$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%z% = pow(%x%, %y%)%$$ + +$head See Also$$ +$cref pow$$ + +$head Purpose$$ +Determines the value of the power function +$latex \[ + {\rm pow} (x, y) = x^y +\] $$ +for integer exponents $icode n$$ +using multiplication and possibly division to compute the value. +The other CppAD $cref pow$$ function may use logarithms and exponentiation +to compute derivatives of the same value +(which will not work if $icode x$$ is less than or equal zero). + +$head Include$$ +The file $code cppad/pow_int.h$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. +Including this file defines +this version of the $code pow$$ within the $code CppAD$$ namespace. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Type%& %x% +%$$ + +$head y$$ +The argument $icode y$$ has prototype +$codei% + const int& %y% +%$$ + +$head z$$ +The result $icode z$$ has prototype +$codei% + %Type% %z% +%$$ + +$head Type$$ +The type $icode Type$$ must support the following operations +where $icode a$$ and $icode b$$ are $icode Type$$ objects +and $icode i$$ is an $code int$$: +$table +$bold Operation$$ $pre $$ + $cnext $bold Description$$ + $cnext $bold Result Type$$ +$rnext +$icode%Type% %a%(%i%)%$$ + $cnext construction of a $icode Type$$ object from an $code int$$ + $cnext $icode Type$$ +$rnext +$icode%a% * %b%$$ + $cnext binary multiplication of $icode Type$$ objects + $cnext $icode Type$$ +$rnext +$icode%a% / %b%$$ + $cnext binary division of $icode Type$$ objects + $cnext $icode Type$$ +$tend + +$head Operation Sequence$$ +The $icode Type$$ operation sequence used to calculate $icode z$$ is +$cref/independent/glossary/Operation/Independent/$$ +of $icode x$$. + +$head Example$$ +$children% + example/pow_int.cpp +%$$ +The file $cref pow_int.cpp$$ +is an example and test of this function. +It returns true if it succeeds and false otherwise. + + +$end +------------------------------------------------------------------------------- +*/ + +namespace CppAD { + + template + inline Type pow (const Type& x, const int& n) + { + Type p(1); + int n2 = n / 2; + + if( n == 0 ) + return p; + if( n < 0 ) + return p / pow(x, -n); + if( n == 1 ) + return x; + + // p = (x^2)^(n/2) + p = pow( x * x , n2 ); + + // n is even case + if( n % 2 == 0 ) + return p; + + // n is odd case + return p * x; + } + +} + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/romberg_mul.hpp cppad-2016.00.00.1/cppad/utility/romberg_mul.hpp --- cppad-2015.00.00.9/cppad/utility/romberg_mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/romberg_mul.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,327 @@ +// $Id: romberg_mul.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_ROMBERG_MUL_HPP +# define CPPAD_ROMBERG_MUL_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin RombergMul$$ +$spell + cppad.hpp + bool + const + Cpp + RombergMulMul +$$ + +$section Multi-dimensional Romberg Integration$$ +$mindex integrate multi dimensional dimension$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%RombergMul<%Fun%, %SizeVector%, %FloatVector%, %m%> %R%$$ +$pre +$$ +$icode%r% = %R%(%F%, %a%, %b%, %n%, %p%, %e%)%$$ + + +$head Description$$ +Returns the Romberg integration estimate +$latex r$$ for the multi-dimensional integral +$latex \[ +r = +\int_{a[0]}^{b[0]} \cdots \int_{a[m-1]}^{b[m-1]} +\; F(x) \; +{\bf d} x_0 \cdots {\bf d} x_{m-1} +\; + \; +\sum_{i=0}^{m-1} +O \left[ ( b[i] - a[i] ) / 2^{n[i]-1} \right]^{2(p[i]+1)} +\] $$ + +$head Include$$ +The file $code cppad/romberg_mul.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head m$$ +The template parameter $icode m$$ must be convertible to a $code size_t$$ +object with a value that can be determined at compile time; for example +$code 2$$. +It determines the dimension of the domain space for the integration. + +$head r$$ +The return value $icode r$$ has prototype +$codei% + %Float% %r% +%$$ +It is the estimate computed by $code RombergMul$$ for the integral above +(see description of $cref/Float/RombergMul/Float/$$ below). + +$head F$$ +The object $icode F$$ has the prototype +$codei% + %Fun% &%F% +%$$ +It must support the operation +$codei% + %F%(%x%) +%$$ +The argument $icode x$$ to $icode F$$ has prototype +$codei% + const %Float% &%x% +%$$ +The return value of $icode F$$ is a $icode Float$$ object + +$head a$$ +The argument $icode a$$ has prototype +$codei% + const %FloatVector% &%a% +%$$ +It specifies the lower limit for the integration +(see description of $cref/FloatVector/RombergMul/FloatVector/$$ below). + +$head b$$ +The argument $icode b$$ has prototype +$codei% + const %FloatVector% &%b% +%$$ +It specifies the upper limit for the integration. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + const %SizeVector% &%n% +%$$ +A total number of $latex 2^{n[i]-1} + 1$$ +evaluations of $icode%F%(%x%)%$$ are used to estimate the integral +with respect to $latex {\bf d} x_i$$. + +$head p$$ +The argument $icode p$$ has prototype +$codei% + const %SizeVector% &%p% +%$$ +For $latex i = 0 , \ldots , m-1$$, +$latex n[i]$$ determines the accuracy order in the +approximation for the integral +that is returned by $code RombergMul$$. +The values in $icode p$$ must be less than or equal $icode n$$; i.e., +$icode%p%[%i%] <= %n%[%i%]%$$. + +$head e$$ +The argument $icode e$$ has prototype +$codei% + %Float% &%e% +%$$ +The input value of $icode e$$ does not matter +and its output value is an approximation for the absolute error in +the integral estimate. + +$head Float$$ +The type $icode Float$$ is defined as the type of the elements of +$cref/FloatVector/RombergMul/FloatVector/$$. +The type $icode Float$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. +In addition, if $icode x$$ and $icode y$$ are $icode Float$$ objects, +$codei% + %x% < %y% +%$$ +returns the $code bool$$ value true if $icode x$$ is less than +$icode y$$ and false otherwise. + +$head FloatVector$$ +The type $icode FloatVector$$ must be a $cref SimpleVector$$ class. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + + +$children% + example/romberg_mul.cpp +%$$ +$head Example$$ +$comment% + example/romberg_mul.cpp +%$$ +The file +$cref Rombergmul.cpp$$ +contains an example and test a test of using this routine. +It returns true if it succeeds and false otherwise. + +$head Source Code$$ +The source code for this routine is in the file +$code cppad/romberg_mul.hpp$$. + +$end +*/ + +# include +# include +# include + +namespace CppAD { // BEGIN CppAD namespace + +template +class SliceLast { + typedef typename FloatVector::value_type Float; +private: + Fun *F; + size_t last; + FloatVector x; +public: + SliceLast( Fun *F_, size_t last_, const FloatVector &x_ ) + : F(F_) , last(last_), x(last + 1) + { size_t i; + for(i = 0; i < last; i++) + x[i] = x_[i]; + } + double operator()(const Float &xlast) + { x[last] = xlast; + return (*F)(x); + } +}; + +template +class IntegrateLast { +private: + Fun *F; + const size_t last; + const FloatVector a; + const FloatVector b; + const SizeVector n; + const SizeVector p; + Float esum; + size_t ecount; + +public: + IntegrateLast( + Fun *F_ , + size_t last_ , + const FloatVector &a_ , + const FloatVector &b_ , + const SizeVector &n_ , + const SizeVector &p_ ) + : F(F_) , last(last_), a(a_) , b(b_) , n(n_) , p(p_) + { } + Float operator()(const FloatVector &x) + { Float r, e; + SliceLast S(F, last, x); + r = CppAD::RombergOne( + S, a[last], b[last], n[last], p[last], e + ); + esum = esum + e; + ecount++; + return r; + } + void ClearEsum(void) + { esum = 0.; } + Float GetEsum(void) + { return esum; } + + void ClearEcount(void) + { ecount = 0; } + size_t GetEcount(void) + { return ecount; } +}; + +template +class RombergMul { + typedef typename FloatVector::value_type Float; +public: + RombergMul(void) + { } + Float operator() ( + Fun &F , + const FloatVector &a , + const FloatVector &b , + const SizeVector &n , + const SizeVector &p , + Float &e ) + { Float r; + + typedef IntegrateLast< + Fun , + SizeVector , + FloatVector , + Float > IntegrateOne; + + IntegrateOne Fm1(&F, m-1, a, b, n, p); + RombergMul< + IntegrateOne, + SizeVector , + FloatVector , + m-1 > RombergMulM1; + + Fm1.ClearEsum(); + Fm1.ClearEcount(); + + r = RombergMulM1(Fm1, a, b, n, p, e); + + size_t i, j; + Float prod = 1; + size_t pow2 = 1; + for(i = 0; i < m-1; i++) + { prod *= (b[i] - a[i]); + for(j = 0; j < (n[i] - 1); j++) + pow2 *= 2; + } + assert( Fm1.GetEcount() == (pow2+1) ); + + e = e + Fm1.GetEsum() * prod / Fm1.GetEcount(); + + return r; + } +}; + +template +class RombergMul { + typedef typename FloatVector::value_type Float; +public: + Float operator() ( + Fun &F , + const FloatVector &a , + const FloatVector &b , + const SizeVector &n , + const SizeVector &p , + Float &e ) + { Float r; + typedef IntegrateLast< + Fun , + SizeVector , + FloatVector , + Float > IntegrateOne; + + // check simple vector class specifications + CheckSimpleVector(); + + // check numeric type specifications + CheckNumericType(); + + IntegrateOne F0(&F, 0, a, b, n, p); + + F0.ClearEsum(); + F0.ClearEcount(); + + r = F0(a); + + assert( F0.GetEcount() == 1 ); + e = F0.GetEsum(); + + return r; + } +}; + +} // END CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/romberg_one.hpp cppad-2016.00.00.1/cppad/utility/romberg_one.hpp --- cppad-2015.00.00.9/cppad/utility/romberg_one.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/romberg_one.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,215 @@ +// $Id: romberg_one.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_ROMBERG_ONE_HPP +# define CPPAD_ROMBERG_ONE_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin RombergOne$$ +$spell + cppad.hpp + bool + const + Cpp + RombergOne +$$ + +$section One DimensionalRomberg Integration$$ +$mindex integrate Romberg$$ + + +$head Syntax$$ +$codei%# include +%$$ +$icode%r% = RombergOne(%F%, %a%, %b%, %n%, %e%)%$$ + + +$head Description$$ +Returns the Romberg integration estimate +$latex r$$ for a one dimensional integral +$latex \[ +r = \int_a^b F(x) {\bf d} x + O \left[ (b - a) / 2^{n-1} \right]^{2(p+1)} +\] $$ + +$head Include$$ +The file $code cppad/romberg_one.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head r$$ +The return value $icode r$$ has prototype +$codei% + %Float% %r% +%$$ +It is the estimate computed by $code RombergOne$$ for the integral above. + +$head F$$ +The object $icode F$$ can be of any type, but it must support +the operation +$codei% + %F%(%x%) +%$$ +The argument $icode x$$ to $icode F$$ has prototype +$codei% + const %Float% &%x% +%$$ +The return value of $icode F$$ is a $icode Float$$ object +(see description of $cref/Float/RombergOne/Float/$$ below). + +$head a$$ +The argument $icode a$$ has prototype +$codei% + const %Float% &%a% +%$$ +It specifies the lower limit for the integration. + +$head b$$ +The argument $icode b$$ has prototype +$codei% + const %Float% &%b% +%$$ +It specifies the upper limit for the integration. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ +A total number of $latex 2^{n-1} + 1$$ evaluations of $icode%F%(%x%)%$$ +are used to estimate the integral. + +$head p$$ +The argument $icode p$$ has prototype +$codei% + size_t %p% +%$$ +It must be less than or equal $latex n$$ +and determines the accuracy order in the approximation for the integral +that is returned by $code RombergOne$$. +To be specific +$latex \[ +r = \int_a^b F(x) {\bf d} x + O \left[ (b - a) / 2^{n-1} \right]^{2(p+1)} +\] $$ + + +$head e$$ +The argument $icode e$$ has prototype +$codei% + %Float% &%e% +%$$ +The input value of $icode e$$ does not matter +and its output value is an approximation for the error in +the integral estimates; i.e., +$latex \[ + e \approx \left| r - \int_a^b F(x) {\bf d} x \right| +\] $$ + +$head Float$$ +The type $icode Float$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. +In addition, if $icode x$$ and $icode y$$ are $icode Float$$ objects, +$codei% + %x% < %y% +%$$ +returns the $code bool$$ value true if $icode x$$ is less than +$icode y$$ and false otherwise. + +$children% + example/romberg_one.cpp +%$$ +$head Example$$ +$comment% + example/romberg_one.cpp +%$$ +The file +$cref romberg_one.cpp$$ +contains an example and test a test of using this routine. +It returns true if it succeeds and false otherwise. + +$head Source Code$$ +The source code for this routine is in the file +$code cppad/romberg_one.hpp$$. + +$end +*/ + +# include +# include +# include + +namespace CppAD { // BEGIN CppAD namespace + +template +Float RombergOne( + Fun &F , + const Float &a , + const Float &b , + size_t n , + size_t p , + Float &e ) +{ + size_t ipow2 = 1; + size_t k, i; + Float pow2, sum, x; + + Float zero = Float(0); + Float two = Float(2); + + // check specifications for a NumericType + CheckNumericType(); + + CPPAD_ASSERT_KNOWN( + n >= 2, + "RombergOne: n must be greater than or equal 2" + ); + CppAD::vector r(n); + + // set r[i] = trapazoidal rule with 2^i intervals in [a, b] + r[0] = ( F(a) + F(b) ) * (b - a) / two; + for(i = 1; i < n; i++) + { ipow2 *= 2; + // there must be a conversion from int to any numeric type + pow2 = Float(int(ipow2)); + sum = zero; + for(k = 1; k < ipow2; k += 2) + { // start = a + (b-a)/pow2, increment = 2*(b-a)/pow2 + x = ( (pow2 - Float(int(k))) * a + k * b ) / pow2; + sum = sum + F(x); + } + // combine function evaluations in sum with those in T[i-1] + r[i] = r[i-1] / two + sum * (b - a) / pow2; + } + + // now compute the higher order estimates + size_t ipow4 = 1; // order of accuract for previous estimate + Float pow4, pow4minus; + for(i = 0; i < p; i++) + { // compute estimate accurate to O[ step^(2*(i+1)) ] + // put resutls in r[n-1], r[n-2], ... , r[n-i+1] + ipow4 *= 4; + pow4 = Float(int(ipow4)); + pow4minus = Float(ipow4-1); + for(k = n-1; k > i; k--) + r[k] = ( pow4 * r[k] - r[k-1] ) / pow4minus; + } + + // error estimate for r[n] + e = r[n-1] - r[n-2]; + if( e < zero ) + e = - e; + return r[n-1]; +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/rosen_34.hpp cppad-2016.00.00.1/cppad/utility/rosen_34.hpp --- cppad-2015.00.00.9/cppad/utility/rosen_34.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/rosen_34.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,498 @@ +// $Id: rosen_34.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_ROSEN_34_HPP +# define CPPAD_ROSEN_34_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin Rosen34$$ +$spell + cppad.hpp + bool + xf + templated + const + Rosenbrock + CppAD + xi + ti + tf + Karp + Rosen + Shampine + ind + dep +$$ + + +$section A 3rd and 4th Order Rosenbrock ODE Solver$$ +$mindex Rosen34 solve stiff differential equation$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%xf% = Rosen34(%F%, %M%, %ti%, %tf%, %xi%) +%$$ +$icode%xf% = Rosen34(%F%, %M%, %ti%, %tf%, %xi%, %e%) +%$$ + + +$head Description$$ +This is an embedded 3rd and 4th order Rosenbrock ODE solver +(see Section 16.6 of $cref/Numerical Recipes/Bib/Numerical Recipes/$$ +for a description of Rosenbrock ODE solvers). +In particular, we use the formulas taken from page 100 of +$cref/Shampine, L.F./Bib/Shampine, L.F./$$ +(except that the fraction 98/108 has been correction to be 97/108). +$pre + +$$ +We use $latex n$$ for the size of the vector $icode xi$$. +Let $latex \B{R}$$ denote the real numbers +and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. +The return value $icode xf$$ contains a 5th order +approximation for the value $latex X(tf)$$ where +$latex X : [ti , tf] \rightarrow \B{R}^n$$ is defined by +the following initial value problem: +$latex \[ +\begin{array}{rcl} + X(ti) & = & xi \\ + X'(t) & = & F[t , X(t)] +\end{array} +\] $$ +If your set of ordinary differential equations are not stiff +an explicit method may be better (perhaps $cref Runge45$$.) + +$head Include$$ +The file $code cppad/rosen_34.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head xf$$ +The return value $icode xf$$ has the prototype +$codei% + %Vector% %xf% +%$$ +and the size of $icode xf$$ is equal to $icode n$$ +(see description of $cref/Vector/Rosen34/Vector/$$ below). +$latex \[ + X(tf) = xf + O( h^5 ) +\] $$ +where $latex h = (tf - ti) / M$$ is the step size. +If $icode xf$$ contains not a number $cref nan$$, +see the discussion of $cref/f/Rosen34/Fun/Nan/$$. + +$head Fun$$ +The class $icode Fun$$ +and the object $icode F$$ satisfy the prototype +$codei% + %Fun% &%F% +%$$ +This must support the following set of calls +$codei% + %F%.Ode(%t%, %x%, %f%) + %F%.Ode_ind(%t%, %x%, %f_t%) + %F%.Ode_dep(%t%, %x%, %f_x%) +%$$ + +$subhead t$$ +In all three cases, +the argument $icode t$$ has prototype +$codei% + const %Scalar% &%t% +%$$ +(see description of $cref/Scalar/Rosen34/Scalar/$$ below). + +$subhead x$$ +In all three cases, +the argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +and has size $icode n$$ +(see description of $cref/Vector/Rosen34/Vector/$$ below). + +$subhead f$$ +The argument $icode f$$ to $icode%F%.Ode%$$ has prototype +$codei% + %Vector% &%f% +%$$ +On input and output, $icode f$$ is a vector of size $icode n$$ +and the input values of the elements of $icode f$$ do not matter. +On output, +$icode f$$ is set equal to $latex F(t, x)$$ +(see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). + +$subhead f_t$$ +The argument $icode f_t$$ to $icode%F%.Ode_ind%$$ has prototype +$codei% + %Vector% &%f_t% +%$$ +On input and output, $icode f_t$$ is a vector of size $icode n$$ +and the input values of the elements of $icode f_t$$ do not matter. +On output, the $th i$$ element of +$icode f_t$$ is set equal to $latex \partial_t F_i (t, x)$$ +(see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). + +$subhead f_x$$ +The argument $icode f_x$$ to $icode%F%.Ode_dep%$$ has prototype +$codei% + %Vector% &%f_x% +%$$ +On input and output, $icode f_x$$ is a vector of size $icode%n%*%n%$$ +and the input values of the elements of $icode f_x$$ do not matter. +On output, the [$icode%i%*%n%+%j%$$] element of +$icode f_x$$ is set equal to $latex \partial_{x(j)} F_i (t, x)$$ +(see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). + +$subhead Nan$$ +If any of the elements of $icode f$$, $icode f_t$$, or $icode f_x$$ +have the value not a number $code nan$$, +the routine $code Rosen34$$ returns with all the +elements of $icode xf$$ and $icode e$$ equal to $code nan$$. + +$subhead Warning$$ +The arguments $icode f$$, $icode f_t$$, and $icode f_x$$ +must have a call by reference in their prototypes; i.e., +do not forget the $code &$$ in the prototype for +$icode f$$, $icode f_t$$ and $icode f_x$$. + +$subhead Optimization$$ +Every call of the form +$codei% + %F%.Ode_ind(%t%, %x%, %f_t%) +%$$ +is directly followed by a call of the form +$codei% + %F%.Ode_dep(%t%, %x%, %f_x%) +%$$ +where the arguments $icode t$$ and $icode x$$ have not changed between calls. +In many cases it is faster to compute the values of $icode f_t$$ +and $icode f_x$$ together and then pass them back one at a time. + +$head M$$ +The argument $icode M$$ has prototype +$codei% + size_t %M% +%$$ +It specifies the number of steps +to use when solving the differential equation. +This must be greater than or equal one. +The step size is given by $latex h = (tf - ti) / M$$, thus +the larger $icode M$$, the more accurate the +return value $icode xf$$ is as an approximation +for $latex X(tf)$$. + +$head ti$$ +The argument $icode ti$$ has prototype +$codei% + const %Scalar% &%ti% +%$$ +(see description of $cref/Scalar/Rosen34/Scalar/$$ below). +It specifies the initial time for $icode t$$ in the +differential equation; i.e., +the time corresponding to the value $icode xi$$. + +$head tf$$ +The argument $icode tf$$ has prototype +$codei% + const %Scalar% &%tf% +%$$ +It specifies the final time for $icode t$$ in the +differential equation; i.e., +the time corresponding to the value $icode xf$$. + +$head xi$$ +The argument $icode xi$$ has the prototype +$codei% + const %Vector% &%xi% +%$$ +and the size of $icode xi$$ is equal to $icode n$$. +It specifies the value of $latex X(ti)$$ + +$head e$$ +The argument $icode e$$ is optional and has the prototype +$codei% + %Vector% &%e% +%$$ +If $icode e$$ is present, +the size of $icode e$$ must be equal to $icode n$$. +The input value of the elements of $icode e$$ does not matter. +On output +it contains an element by element +estimated bound for the absolute value of the error in $icode xf$$ +$latex \[ + e = O( h^4 ) +\] $$ +where $latex h = (tf - ti) / M$$ is the step size. + +$head Scalar$$ +The type $icode Scalar$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. +In addition, the following operations must be defined for +$icode Scalar$$ objects $icode a$$ and $icode b$$: + +$table +$bold Operation$$ $cnext $bold Description$$ $rnext +$icode%a% < %b%$$ $cnext + less than operator (returns a $code bool$$ object) +$tend + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Parallel Mode$$ +For each set of types +$cref/Scalar/Rosen34/Scalar/$$, +$cref/Vector/Rosen34/Vector/$$, and +$cref/Fun/Rosen34/Fun/$$, +the first call to $code Rosen34$$ +must not be $cref/parallel/ta_in_parallel/$$ execution mode. + +$head Example$$ +$children% + example/rosen_34.cpp +%$$ +The file +$cref rosen_34.cpp$$ +contains an example and test a test of using this routine. +It returns true if it succeeds and false otherwise. + +$head Source Code$$ +The source code for this routine is in the file +$code cppad/rosen_34.hpp$$. + +$end +-------------------------------------------------------------------------- +*/ + +# include +# include +# include +# include +# include +# include +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +namespace CppAD { // BEGIN CppAD namespace + +template +Vector Rosen34( + Fun &F , + size_t M , + const Scalar &ti , + const Scalar &tf , + const Vector &xi ) +{ Vector e( xi.size() ); + return Rosen34(F, M, ti, tf, xi, e); +} + +template +Vector Rosen34( + Fun &F , + size_t M , + const Scalar &ti , + const Scalar &tf , + const Vector &xi , + Vector &e ) +{ + CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + + // check numeric type specifications + CheckNumericType(); + + // check simple vector class specifications + CheckSimpleVector(); + + // Parameters for Shampine's Rosenbrock method + // are static to avoid recalculation on each call and + // do not use Vector to avoid possible memory leak + static Scalar a[3] = { + Scalar(0), + Scalar(1), + Scalar(3) / Scalar(5) + }; + static Scalar b[2 * 2] = { + Scalar(1), + Scalar(0), + Scalar(24) / Scalar(25), + Scalar(3) / Scalar(25) + }; + static Scalar ct[4] = { + Scalar(1) / Scalar(2), + - Scalar(3) / Scalar(2), + Scalar(121) / Scalar(50), + Scalar(29) / Scalar(250) + }; + static Scalar cg[3 * 3] = { + - Scalar(4), + Scalar(0), + Scalar(0), + Scalar(186) / Scalar(25), + Scalar(6) / Scalar(5), + Scalar(0), + - Scalar(56) / Scalar(125), + - Scalar(27) / Scalar(125), + - Scalar(1) / Scalar(5) + }; + static Scalar d3[3] = { + Scalar(97) / Scalar(108), + Scalar(11) / Scalar(72), + Scalar(25) / Scalar(216) + }; + static Scalar d4[4] = { + Scalar(19) / Scalar(18), + Scalar(1) / Scalar(4), + Scalar(25) / Scalar(216), + Scalar(125) / Scalar(216) + }; + CPPAD_ASSERT_KNOWN( + M >= 1, + "Error in Rosen34: the number of steps is less than one" + ); + CPPAD_ASSERT_KNOWN( + e.size() == xi.size(), + "Error in Rosen34: size of e not equal to size of xi" + ); + size_t i, j, k, l, m; // indices + + size_t n = xi.size(); // number of components in X(t) + Scalar ns = Scalar(double(M)); // number of steps as Scalar object + Scalar h = (tf - ti) / ns; // step size + Scalar zero = Scalar(0); // some constants + Scalar one = Scalar(1); + Scalar two = Scalar(2); + + // permutation vectors needed for LU factorization routine + CppAD::vector ip(n), jp(n); + + // vectors used to store values returned by F + Vector E(n * n), Eg(n), f_t(n); + Vector g(n * 3), x3(n), x4(n), xf(n), ftmp(n), xtmp(n), nan_vec(n); + + // initialize e = 0, nan_vec = nan + for(i = 0; i < n; i++) + { e[i] = zero; + nan_vec[i] = nan(zero); + } + + xf = xi; // initialize solution + for(m = 0; m < M; m++) + { // time at beginning of this interval + Scalar t = ti * (Scalar(int(M - m)) / ns) + + tf * (Scalar(int(m)) / ns); + + // value of x at beginning of this interval + x3 = x4 = xf; + + // evaluate partial derivatives at beginning of this interval + F.Ode_ind(t, xf, f_t); + F.Ode_dep(t, xf, E); // E = f_x + if( hasnan(f_t) || hasnan(E) ) + { e = nan_vec; + return nan_vec; + } + + // E = I - f_x * h / 2 + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + E[i * n + j] = - E[i * n + j] * h / two; + E[i * n + i] += one; + } + + // LU factor the matrix E +# ifndef NDEBUG + int sign = LuFactor(ip, jp, E); +# else + LuFactor(ip, jp, E); +# endif + CPPAD_ASSERT_KNOWN( + sign != 0, + "Error in Rosen34: I - f_x * h / 2 not invertible" + ); + + // loop over integration steps + for(k = 0; k < 3; k++) + { // set location for next function evaluation + xtmp = xf; + for(l = 0; l < k; l++) + { // loop over previous function evaluations + Scalar bkl = b[(k-1)*2 + l]; + for(i = 0; i < n; i++) + { // loop over elements of x + xtmp[i] += bkl * g[i*3 + l] * h; + } + } + // ftmp = F(t + a[k] * h, xtmp) + F.Ode(t + a[k] * h, xtmp, ftmp); + if( hasnan(ftmp) ) + { e = nan_vec; + return nan_vec; + } + + // Form Eg for this integration step + for(i = 0; i < n; i++) + Eg[i] = ftmp[i] + ct[k] * f_t[i] * h; + for(l = 0; l < k; l++) + { for(i = 0; i < n; i++) + Eg[i] += cg[(k-1)*3 + l] * g[i*3 + l]; + } + + // Solve the equation E * g = Eg + LuInvert(ip, jp, E, Eg); + + // save solution and advance x3, x4 + for(i = 0; i < n; i++) + { g[i*3 + k] = Eg[i]; + x3[i] += h * d3[k] * Eg[i]; + x4[i] += h * d4[k] * Eg[i]; + } + } + // Form Eg for last update to x4 only + for(i = 0; i < n; i++) + Eg[i] = ftmp[i] + ct[3] * f_t[i] * h; + for(l = 0; l < 3; l++) + { for(i = 0; i < n; i++) + Eg[i] += cg[2*3 + l] * g[i*3 + l]; + } + + // Solve the equation E * g = Eg + LuInvert(ip, jp, E, Eg); + + // advance x4 and accumulate error bound + for(i = 0; i < n; i++) + { x4[i] += h * d4[3] * Eg[i]; + + // cant use abs because cppad.hpp may not be included + Scalar diff = x4[i] - x3[i]; + if( diff < zero ) + e[i] -= diff; + else e[i] += diff; + } + + // advance xf for this step using x4 + xf = x4; + } + return xf; +} + +} // End CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/runge_45.hpp cppad-2016.00.00.1/cppad/utility/runge_45.hpp --- cppad-2015.00.00.9/cppad/utility/runge_45.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/runge_45.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,429 @@ +// $Id: runge_45.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_RUNGE_45_HPP +# define CPPAD_RUNGE_45_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin Runge45$$ +$spell + std + fabs + cppad.hpp + bool + xf + templated + const + Runge-Kutta + CppAD + xi + ti + tf + Karp +$$ + + +$section An Embedded 4th and 5th Order Runge-Kutta ODE Solver$$ +$mindex Runge45 Runge Kutta solve differential equation$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%xf% = Runge45(%F%, %M%, %ti%, %tf%, %xi%) +%$$ +$icode%xf% = Runge45(%F%, %M%, %ti%, %tf%, %xi%, %e%) +%$$ + + +$head Purpose$$ +This is an implementation of the +Cash-Karp embedded 4th and 5th order Runge-Kutta ODE solver +described in Section 16.2 of $cref/Numerical Recipes/Bib/Numerical Recipes/$$. +We use $latex n$$ for the size of the vector $icode xi$$. +Let $latex \B{R}$$ denote the real numbers +and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ +be a smooth function. +The return value $icode xf$$ contains a 5th order +approximation for the value $latex X(tf)$$ where +$latex X : [ti , tf] \rightarrow \B{R}^n$$ is defined by +the following initial value problem: +$latex \[ +\begin{array}{rcl} + X(ti) & = & xi \\ + X'(t) & = & F[t , X(t)] +\end{array} +\] $$ +If your set of ordinary differential equations +are stiff, an implicit method may be better +(perhaps $cref Rosen34$$.) + +$head Operation Sequence$$ +The $cref/operation sequence/glossary/Operation/Sequence/$$ for $icode Runge$$ +does not depend on any of its $icode Scalar$$ input values provided that +the operation sequence for +$codei% + %F%.Ode(%t%, %x%, %f%) +%$$ +does not on any of its $icode Scalar$$ inputs (see below). + +$head Include$$ +The file $code cppad/runge_45.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head xf$$ +The return value $icode xf$$ has the prototype +$codei% + %Vector% %xf% +%$$ +and the size of $icode xf$$ is equal to $icode n$$ +(see description of $cref/Vector/Runge45/Vector/$$ below). +$latex \[ + X(tf) = xf + O( h^6 ) +\] $$ +where $latex h = (tf - ti) / M$$ is the step size. +If $icode xf$$ contains not a number $cref nan$$, +see the discussion for $cref/f/Runge45/Fun/f/$$. + +$head Fun$$ +The class $icode Fun$$ +and the object $icode F$$ satisfy the prototype +$codei% + %Fun% &%F% +%$$ +The object $icode F$$ (and the class $icode Fun$$) +must have a member function named $code Ode$$ +that supports the syntax +$codei% + %F%.Ode(%t%, %x%, %f%) +%$$ + +$subhead t$$ +The argument $icode t$$ to $icode%F%.Ode%$$ has prototype +$codei% + const %Scalar% &%t% +%$$ +(see description of $cref/Scalar/Runge45/Scalar/$$ below). + +$subhead x$$ +The argument $icode x$$ to $icode%F%.Ode%$$ has prototype +$codei% + const %Vector% &%x% +%$$ +and has size $icode n$$ +(see description of $cref/Vector/Runge45/Vector/$$ below). + +$subhead f$$ +The argument $icode f$$ to $icode%F%.Ode%$$ has prototype +$codei% + %Vector% &%f% +%$$ +On input and output, $icode f$$ is a vector of size $icode n$$ +and the input values of the elements of $icode f$$ do not matter. +On output, +$icode f$$ is set equal to $latex F(t, x)$$ in the differential equation. +If any of the elements of $icode f$$ have the value not a number $code nan$$ +the routine $code Runge45$$ returns with all the +elements of $icode xf$$ and $icode e$$ equal to $code nan$$. + +$subhead Warning$$ +The argument $icode f$$ to $icode%F%.Ode%$$ +must have a call by reference in its prototype; i.e., +do not forget the $code &$$ in the prototype for $icode f$$. + +$head M$$ +The argument $icode M$$ has prototype +$codei% + size_t %M% +%$$ +It specifies the number of steps +to use when solving the differential equation. +This must be greater than or equal one. +The step size is given by $latex h = (tf - ti) / M$$, thus +the larger $icode M$$, the more accurate the +return value $icode xf$$ is as an approximation +for $latex X(tf)$$. + +$head ti$$ +The argument $icode ti$$ has prototype +$codei% + const %Scalar% &%ti% +%$$ +(see description of $cref/Scalar/Runge45/Scalar/$$ below). +It specifies the initial time for $icode t$$ in the +differential equation; i.e., +the time corresponding to the value $icode xi$$. + +$head tf$$ +The argument $icode tf$$ has prototype +$codei% + const %Scalar% &%tf% +%$$ +It specifies the final time for $icode t$$ in the +differential equation; i.e., +the time corresponding to the value $icode xf$$. + +$head xi$$ +The argument $icode xi$$ has the prototype +$codei% + const %Vector% &%xi% +%$$ +and the size of $icode xi$$ is equal to $icode n$$. +It specifies the value of $latex X(ti)$$ + +$head e$$ +The argument $icode e$$ is optional and has the prototype +$codei% + %Vector% &%e% +%$$ +If $icode e$$ is present, +the size of $icode e$$ must be equal to $icode n$$. +The input value of the elements of $icode e$$ does not matter. +On output +it contains an element by element +estimated bound for the absolute value of the error in $icode xf$$ +$latex \[ + e = O( h^5 ) +\] $$ +where $latex h = (tf - ti) / M$$ is the step size. +If on output, $icode e$$ contains not a number $code nan$$, +see the discussion for $cref/f/Runge45/Fun/f/$$. + +$head Scalar$$ +The type $icode Scalar$$ must satisfy the conditions +for a $cref NumericType$$ type. +The routine $cref CheckNumericType$$ will generate an error message +if this is not the case. + +$subhead fabs$$ +In addition, the following function must be defined for +$icode Scalar$$ objects $icode a$$ and $icode b$$ +$codei% + %a% = fabs(%b%) +%$$ +Note that this operation is only used for computing $icode e$$; hence +the operation sequence for $icode xf$$ can still be independent of +the arguments to $code Runge45$$ even if +$codei% + fabs(%b%) = std::max(-%b%, %b%) +%$$. + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Parallel Mode$$ +For each set of types +$cref/Scalar/Runge45/Scalar/$$, +$cref/Vector/Runge45/Vector/$$, and +$cref/Fun/Runge45/Fun/$$, +the first call to $code Runge45$$ +must not be $cref/parallel/ta_in_parallel/$$ execution mode. + + +$head Example$$ +$children% + example/runge45_1.cpp% + example/runge45_2.cpp +%$$ +The file +$cref runge45_1.cpp$$ +contains a simple example and test of $code Runge45$$. +It returns true if it succeeds and false otherwise. +$pre + +$$ +The file +$cref runge45_2.cpp$$ contains an example using $code Runge45$$ +in the context of algorithmic differentiation. +It also returns true if it succeeds and false otherwise. + +$head Source Code$$ +The source code for this routine is in the file +$code cppad/runge_45.hpp$$. + +$end +-------------------------------------------------------------------------- +*/ +# include +# include +# include +# include +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +namespace CppAD { // BEGIN CppAD namespace + +template +Vector Runge45( + Fun &F , + size_t M , + const Scalar &ti , + const Scalar &tf , + const Vector &xi ) +{ Vector e( xi.size() ); + return Runge45(F, M, ti, tf, xi, e); +} + +template +Vector Runge45( + Fun &F , + size_t M , + const Scalar &ti , + const Scalar &tf , + const Vector &xi , + Vector &e ) +{ + CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + + // check numeric type specifications + CheckNumericType(); + + // check simple vector class specifications + CheckSimpleVector(); + + // Cash-Karp parameters for embedded Runge-Kutta method + // are static to avoid recalculation on each call and + // do not use Vector to avoid possible memory leak + static Scalar a[6] = { + Scalar(0), + Scalar(1) / Scalar(5), + Scalar(3) / Scalar(10), + Scalar(3) / Scalar(5), + Scalar(1), + Scalar(7) / Scalar(8) + }; + static Scalar b[5 * 5] = { + Scalar(1) / Scalar(5), + Scalar(0), + Scalar(0), + Scalar(0), + Scalar(0), + + Scalar(3) / Scalar(40), + Scalar(9) / Scalar(40), + Scalar(0), + Scalar(0), + Scalar(0), + + Scalar(3) / Scalar(10), + -Scalar(9) / Scalar(10), + Scalar(6) / Scalar(5), + Scalar(0), + Scalar(0), + + -Scalar(11) / Scalar(54), + Scalar(5) / Scalar(2), + -Scalar(70) / Scalar(27), + Scalar(35) / Scalar(27), + Scalar(0), + + Scalar(1631) / Scalar(55296), + Scalar(175) / Scalar(512), + Scalar(575) / Scalar(13824), + Scalar(44275) / Scalar(110592), + Scalar(253) / Scalar(4096) + }; + static Scalar c4[6] = { + Scalar(2825) / Scalar(27648), + Scalar(0), + Scalar(18575) / Scalar(48384), + Scalar(13525) / Scalar(55296), + Scalar(277) / Scalar(14336), + Scalar(1) / Scalar(4), + }; + static Scalar c5[6] = { + Scalar(37) / Scalar(378), + Scalar(0), + Scalar(250) / Scalar(621), + Scalar(125) / Scalar(594), + Scalar(0), + Scalar(512) / Scalar(1771) + }; + + CPPAD_ASSERT_KNOWN( + M >= 1, + "Error in Runge45: the number of steps is less than one" + ); + CPPAD_ASSERT_KNOWN( + e.size() == xi.size(), + "Error in Runge45: size of e not equal to size of xi" + ); + size_t i, j, k, m; // indices + + size_t n = xi.size(); // number of components in X(t) + Scalar ns = Scalar(int(M)); // number of steps as Scalar object + Scalar h = (tf - ti) / ns; // step size + Scalar zero_or_nan = Scalar(0); // zero (nan if Ode returns has a nan) + for(i = 0; i < n; i++) // initialize e = 0 + e[i] = zero_or_nan; + + // vectors used to store values returned by F + Vector fh(6 * n), xtmp(n), ftmp(n), x4(n), x5(n), xf(n); + + xf = xi; // initialize solution + for(m = 0; m < M; m++) + { // time at beginning of this interval + // (convert to int to avoid MS compiler warning) + Scalar t = ti * (Scalar(int(M - m)) / ns) + + tf * (Scalar(int(m)) / ns); + + // loop over integration steps + x4 = x5 = xf; // start x4 and x5 at same point for each step + for(j = 0; j < 6; j++) + { // loop over function evaluations for this step + xtmp = xf; // location for next function evaluation + for(k = 0; k < j; k++) + { // loop over previous function evaluations + Scalar bjk = b[ (j-1) * 5 + k ]; + for(i = 0; i < n; i++) + { // loop over elements of x + xtmp[i] += bjk * fh[i * 6 + k]; + } + } + // ftmp = F(t + a[j] * h, xtmp) + F.Ode(t + a[j] * h, xtmp, ftmp); + + // if ftmp has a nan, set zero_or_nan to nan + for(i = 0; i < n; i++) + zero_or_nan *= ftmp[i]; + + for(i = 0; i < n; i++) + { // loop over elements of x + Scalar fhi = ftmp[i] * h; + fh[i * 6 + j] = fhi; + x4[i] += c4[j] * fhi; + x5[i] += c5[j] * fhi; + x5[i] += zero_or_nan; + } + } + // accumulate error bound + for(i = 0; i < n; i++) + { // cant use abs because cppad.hpp may not be included + Scalar diff = x5[i] - x4[i]; + e[i] += fabs(diff); + e[i] += zero_or_nan; + } + + // advance xf for this step using x5 + xf = x5; + } + return xf; +} + +} // End CppAD namespace + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/speed_test.hpp cppad-2016.00.00.1/cppad/utility/speed_test.hpp --- cppad-2015.00.00.9/cppad/utility/speed_test.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/speed_test.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,470 @@ +// $Id: speed_test.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_SPEED_TEST_HPP +# define CPPAD_SPEED_TEST_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin speed_test$$ +$spell + gettimeofday + vec + cppad.hpp + Microsoft + namespace + std + const + cout + ctime + ifdef + const + endif + cpp +$$ + + +$section Run One Speed Test and Return Results$$ +$mindex speed_test$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%rate_vec% = speed_test(%test%, %size_vec%, %time_min%)%$$ + +$head Purpose$$ +The $code speed_test$$ function executes a speed test +for various sized problems +and reports the rate of execution. + +$head Motivation$$ +It is important to separate small calculation units +and test them individually. +This way individual changes can be tested in the context of the +routine that they are in. +On many machines, accurate timing of a very short execution +sequences is not possible. +In addition, +there may be set up and tear down time for a test that +we do not really want included in the timing. +For this reason $code speed_test$$ +automatically determines how many times to +repeat the section of the test that we wish to time. + + +$head Include$$ +The file $code cppad/speed_test.hpp$$ defines the +$code speed_test$$ function. +This file is included by $code cppad/cppad.hpp$$ +and it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Vector$$ +We use $icode Vector$$ to denote a +$cref/simple vector class/SimpleVector/$$ with elements +of type $code size_t$$. + +$head test$$ +The $code speed_test$$ argument $icode test$$ is a function with the syntax +$codei% + %test%(%size%, %repeat%) +%$$ +and its return value is $code void$$. + +$subhead size$$ +The $icode test$$ argument $icode size$$ has prototype +$codei% + size_t %size% +%$$ +It specifies the size for this test. + +$subhead repeat$$ +The $icode test$$ argument $icode repeat$$ has prototype +$codei% + size_t %repeat% +%$$ +It specifies the number of times to repeat the test. + +$head size_vec$$ +The $code speed_test$$ argument $icode size_vec$$ has prototype +$codei% + const %Vector%& %size_vec% +%$$ +This vector determines the size for each of the tests problems. + +$head time_min$$ +The argument $icode time_min$$ has prototype +$codei% + double %time_min% +%$$ +It specifies the minimum amount of time in seconds +that the $icode test$$ routine should take. +The $icode repeat$$ argument to $icode test$$ is increased +until this amount of execution time is reached. + +$head rate_vec$$ +The return value $icode rate_vec$$ has prototype +$codei% + %Vector%& %rate_vec% +%$$ +We use $latex n$$ to denote its size which is the same as +the vector $icode size_vec$$. +For $latex i = 0 , \ldots , n-1$$, +$codei% + %rate_vec%[%i%] +%$$ +is the ratio of $icode repeat$$ divided by time in seconds +for the problem with size $icode%size_vec%[%i%]%$$. + +$head Timing$$ +If your system supports the unix $code gettimeofday$$ function, +it will be used to measure time. +Otherwise, +time is measured by the difference in +$codep + (double) clock() / (double) CLOCKS_PER_SEC +$$ +in the context of the standard $code $$ definitions. + +$children% + speed/example/speed_test.cpp +%$$ +$head Example$$ +The routine $cref speed_test.cpp$$ is an example and test +of $code speed_test$$. + +$end +----------------------------------------------------------------------- +*/ + +# include +# include + +# include +# include + + +namespace CppAD { // BEGIN CppAD namespace + +// implemented as an inline so that can include in multiple link modules +// with this same file +template +inline Vector speed_test( + void test(size_t size, size_t repeat), + const Vector& size_vec , + double time_min ) +{ + // check that size_vec is a simple vector with size_t elements + CheckSimpleVector(); + + size_t n = size_vec.size(); + Vector rate_vec(n); + size_t i; + for(i = 0; i < n; i++) + { size_t size = size_vec[i]; + size_t repeat = 1; + double s0 = elapsed_seconds(); + double s1 = elapsed_seconds(); + while( s1 - s0 < time_min ) + { repeat = 2 * repeat; + s0 = elapsed_seconds(); + test(size, repeat); + s1 = elapsed_seconds(); + } + rate_vec[i] = (size_t)(.5 + repeat / (s1 - s0)); + } + return rate_vec; +} + +} // END CppAD namespace + +/* +$begin SpeedTest$$ +$spell + cppad.hpp + Microsoft + namespace + std + const + cout + ctime + ifdef + const + endif + cpp +$$ + + +$section Run One Speed Test and Print Results$$ +$mindex SpeedTest$$ + +$head Syntax$$ + +$codei%# include +%$$ +$codei%SpeedTest(%Test%, %first%, %inc%, %last%)%$$ + + +$head Purpose$$ +The $code SpeedTest$$ function executes a speed test +for various sized problems +and reports the results on standard output; i.e. $code std::cout$$. +The size of each test problem is included in its report +(unless $icode first$$ is equal to $icode last$$). + +$head Motivation$$ +It is important to separate small calculation units +and test them individually. +This way individual changes can be tested in the context of the +routine that they are in. +On many machines, accurate timing of a very short execution +sequences is not possible. +In addition, +there may be set up time for a test that +we do not really want included in the timing. +For this reason $code SpeedTest$$ +automatically determines how many times to +repeat the section of the test that we wish to time. + + +$head Include$$ +The file $code speed_test.hpp$$ contains the +$code SpeedTest$$ function. +This file is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head Test$$ +The $code SpeedTest$$ argument $icode Test$$ is a function with the syntax +$codei% + %name% = %Test%(%size%, %repeat%) +%$$ + +$subhead size$$ +The $icode Test$$ argument $icode size$$ has prototype +$codei% + size_t %size% +%$$ +It specifies the size for this test. + +$subhead repeat$$ +The $icode Test$$ argument $icode repeat$$ has prototype +$codei% + size_t %repeat% +%$$ +It specifies the number of times to repeat the test. + +$subhead name$$ +The $icode Test$$ result $icode name$$ has prototype +$codei% + std::string %name% +%$$ +The results for this test are reported on $code std::cout$$ +with $icode name$$ as an identifier for the test. +It is assumed that, +for the duration of this call to $code SpeedTest$$, +$icode Test$$ will always return +the same value for $icode name$$. +If $icode name$$ is the empty string, +no test name is reported by $code SpeedTest$$. + +$head first$$ +The $code SpeedTest$$ argument $icode first$$ has prototype +$codei% + size_t %first% +%$$ +It specifies the size of the first test problem reported by this call to +$code SpeedTest$$. + +$head last$$ +The $code SpeedTest$$ argument $icode last$$ has prototype +$codei% + size_t %last% +%$$ +It specifies the size of the last test problem reported by this call to +$code SpeedTest$$. + +$head inc$$ +The $code SpeedTest$$ argument $icode inc$$ has prototype +$codei% + int %inc% +%$$ +It specifies the increment between problem sizes; i.e., +all values of $icode size$$ in calls to $icode Test$$ are given by +$codei% + %size% = %first% + %j% * %inc% +%$$ +where $icode j$$ is a positive integer. +The increment can be positive or negative but it cannot be zero. +The values $icode first$$, $icode last$$ and $icode inc$$ must +satisfy the relation +$latex \[ + inc * ( last - first ) \geq 0 +\] $$ + +$head rate$$ +The value displayed in the $code rate$$ column on $code std::cout$$ +is defined as the value of $icode repeat$$ divided by the +corresponding elapsed execution time in seconds. +The elapsed execution time is measured by the difference in +$codep + (double) clock() / (double) CLOCKS_PER_SEC +$$ +in the context of the standard $code $$ definitions. + + +$head Errors$$ +If one of the restrictions above is violated, +the CppAD error handler is used to report the error. +You can redefine this action using the instructions in +$cref ErrorHandler$$ + +$head Example$$ +$children% + speed/example/speed_program.cpp +%$$ +The program $cref speed_program.cpp$$ is an example usage +of $code SpeedTest$$. + +$end +----------------------------------------------------------------------- +*/ +// BEGIN C++ + + +# include +# include +# include +# include + +namespace CppAD { // BEGIN CppAD namespace + +inline void SpeedTestNdigit(size_t value, size_t &ndigit, size_t &pow10) +{ pow10 = 10; + ndigit = 1; + while( pow10 <= value ) + { pow10 *= 10; + ndigit += 1; + } +} + +// implemented as an inline so that can include in multiple link modules +// with this same file +inline void SpeedTest( + std::string Test(size_t size, size_t repeat), + size_t first, + int inc, + size_t last +) +{ + + using std::cout; + using std::endl; + + size_t size; + size_t repeat; + size_t rate; + size_t digit; + size_t ndigit; + size_t pow10; + size_t maxSize; + size_t maxSizeDigit; + + double s0; + double s1; + + std::string name; + + CPPAD_ASSERT_KNOWN( + inc != 0 && first != 0 && last != 0, + "inc, first, or last is zero in call to SpeedTest" + ); + CPPAD_ASSERT_KNOWN( + (inc > 0 && first <= last) || (inc < 0 && first >= last), + "SpeedTest: increment is positive and first > last or " + "increment is negative and first < last" + ); + + // compute maxSize + maxSize = size = first; + while( (inc > 0 && size <= last) || (inc < 0 && size >= last) ) + { + if( size > maxSize ) + maxSize = size; + + // next size + if( ((int) size) + inc > 0 ) + size += inc; + else size = 0; + } + SpeedTestNdigit(maxSize, maxSizeDigit, pow10); + + size = first; + while( (inc > 0 && size <= last) || (inc < 0 && size >= last) ) + { + repeat = 1; + s0 = elapsed_seconds(); + s1 = elapsed_seconds(); + while( s1 - s0 < 1. ) + { repeat = 2 * repeat; + s0 = elapsed_seconds(); + name = Test(size, repeat); + s1 = elapsed_seconds(); + } + rate = (size_t)(.5 + repeat / (s1 - s0)); + + + if( size == first && name != "" ) + cout << name << endl; + + if( first != last ) + { + // convert int(size_t) to avoid warning on _MSC_VER sys + std::cout << "size = " << int(size); + + SpeedTestNdigit(size, ndigit, pow10); + while( ndigit < maxSizeDigit ) + { cout << " "; + ndigit++; + } + cout << " "; + } + + cout << "rate = "; + SpeedTestNdigit(rate, ndigit, pow10); + while( ndigit > 0 ) + { + pow10 /= 10; + digit = rate / pow10; + + // convert int(size_t) to avoid warning on _MSC_VER sys + std::cout << int(digit); + + rate = rate % pow10; + ndigit -= 1; + + if( (ndigit > 0) && (ndigit % 3 == 0) ) + cout << ","; + } + cout << endl; + + // next size + if( ((int) size) + inc > 0 ) + size += inc; + else size = 0; + } + return; +} + +} // END CppAD namespace + +// END C++ +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/thread_alloc.hpp cppad-2016.00.00.1/cppad/utility/thread_alloc.hpp --- cppad-2015.00.00.9/cppad/utility/thread_alloc.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/thread_alloc.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,1515 @@ +// $Id: thread_alloc.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_THREAD_ALLOC_HPP +# define CPPAD_THREAD_ALLOC_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include +# include +# include + + +# ifdef _MSC_VER +// Supress warning that Microsoft compiler changed its behavior and is now +// doing the correct thing at the statement: +// new(array + i) Type(); +# pragma warning(disable:4345) +# endif + +# include +# include +# include +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file thread_alloc.hpp +File used to define the CppAD multi-threading allocator class +*/ + +/*! +\def CPPAD_MAX_NUM_CAPACITY +Maximum number of different capacities the allocator will attempt. +This must be larger than the log base two of numeric_limit::max(). +*/ +# define CPPAD_MAX_NUM_CAPACITY 100 + +/*! +\def CPPAD_MIN_DOUBLE_CAPACITY +Minimum number of double values that will fit in an allocation. +*/ +# define CPPAD_MIN_DOUBLE_CAPACITY 16 + +/*! +\def CPPAD_TRACE_CAPACITY +If NDEBUG is not defined, print all calls to \c get_memory and \c return_memory +that correspond to this capacity and thread CPPAD_TRACE_THREAD. +(Note that if CPPAD_TRACE_CAPACITY is zero, or any other value not in the list +of capacities, no tracing will be done.) +*/ +# define CPPAD_TRACE_CAPACITY 0 + +/*! +\def CPPAD_TRACE_THREAD +If NDEBUG is not defined, print all calls to \c get_memory and \c return_memory +that correspond to this thead and capacity CPPAD_TRACE_CAPACITY. +*/ +# define CPPAD_TRACE_THREAD 0 + +/* +Note that Section 3.6.2 of ISO/IEC 14882:1998(E) states: "The storage for +objects with static storage duration (3.7.1) shall be zero-initialized +(8.5) before any other initialization takes place." +*/ + +/*! +Capacity vector for memory allocation block sizes. + +Only one of these objects should be created and used as a +static variable inside of the \c thread_alloc::capacity_info function. +*/ + +/*! +Allocator class that works well with an multi-threading environment. +*/ +class thread_alloc{ +// ============================================================================ +private: + + class capacity_t { + public: + /// number of capacity values actually used + size_t number; + /// the different capacity values + size_t value[CPPAD_MAX_NUM_CAPACITY]; + /// ctor + capacity_t(void) + { // Cannot figure out how to call thread_alloc::in_parallel here. + // CPPAD_ASSERT_UNKNOWN( + // ! thread_alloc::in_parallel() , "thread_alloc: " + // "parallel mode and parallel_setup not yet called." + // ); + number = 0; + size_t capacity = CPPAD_MIN_DOUBLE_CAPACITY * sizeof(double); + while( capacity < std::numeric_limits::max() / 2 ) + { CPPAD_ASSERT_UNKNOWN( number < CPPAD_MAX_NUM_CAPACITY ); + value[number++] = capacity; + // next capactiy is 3/2 times the current one + capacity = 3 * ( (capacity + 1) / 2 ); + } + CPPAD_ASSERT_UNKNOWN( number > 0 ); + } + }; + + class block_t { + public: + /// extra information (currently used by create and delete array) + size_t extra_; + /// an index that uniquely idenfifies both thread and capacity + size_t tc_index_; + /// pointer to the next memory allocation with the same tc_index_ + void* next_; + // ----------------------------------------------------------------- + /// make default constructor private. It is only used by constructor + /// for `root arrays below. + block_t(void) : extra_(0), tc_index_(0), next_(CPPAD_NULL) + { } + }; + + // --------------------------------------------------------------------- + /// Vector of fixed capacity values for this allocator + static const capacity_t* capacity_info(void) + { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static const capacity_t capacity; + return &capacity; + } + // --------------------------------------------------------------------- + /// Structure of information for each thread + struct thread_alloc_info { + /// count of available bytes for this thread + size_t count_inuse_; + /// count of inuse bytes for this thread + size_t count_available_; + /// root of available list for this thread and each capacity + block_t root_available_[CPPAD_MAX_NUM_CAPACITY]; + /// root of inuse list for this thread and each capacity + /// If NDEBUG is true, this memory is not used, but it still + /// helps separate this structure from one for the next thread. + block_t root_inuse_[CPPAD_MAX_NUM_CAPACITY]; + }; + // --------------------------------------------------------------------- + /*! + Set and Get hold available memory flag. + + \param set [in] + if true, the value returned by this return is changed. + + \param new_value [in] + if \a set is true, this is the new value returned by this routine. + Otherwise, \c new_value is ignored. + + \return + the current setting for this routine (which is initially false). + */ + static bool set_get_hold_memory(bool set, bool new_value = false) + { static bool value = false; + if( set ) + value = new_value; + return value; + } + // --------------------------------------------------------------------- + /*! + Get pointer to the information for this thread. + + \param thread [in] + Is the thread number for this information pointer. + + \param clear + If \a clear is true, then the information pointer for this thread + is deleted and the \c CPPAD_NULL pointer is returned. + There must be no memory currently in either the inuse or avaialble + lists when this routine is called. + + \return + is the current informaiton pointer for this thread. + If \a clear is false, and the current pointer is CPPAD_NULL, + a new infromation record is allocated and its pointer returned. + In this case, if \c info is the retured pointer, + info->count_inuse == 0 and + info->count_available == 0. + In addition, + for c = 0 , ... , CPPAD_MAX_NUM_CAPACITY-1 + info->root_inuse_[c].next_ == CPPAD_NULL and + info->root_available_[c].next_ == CPPAD_NULL. + */ + static thread_alloc_info* thread_info( + size_t thread , + bool clear = false ) + { static thread_alloc_info* all_info[CPPAD_MAX_NUM_THREADS]; + static thread_alloc_info zero_info; + + CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + + CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS ); + + thread_alloc_info* info = all_info[thread]; + if( clear ) + { if( info != CPPAD_NULL ) + { +# ifndef NDEBUG + CPPAD_ASSERT_UNKNOWN( + info->count_inuse_ == 0 && + info->count_available_ == 0 + ); + for(size_t c = 0; c < CPPAD_MAX_NUM_CAPACITY; c++) + { CPPAD_ASSERT_UNKNOWN( + info->root_inuse_[c].next_ == CPPAD_NULL && + info->root_available_[c].next_ == CPPAD_NULL + ); + } +# endif + if( thread != 0 ) + ::operator delete( reinterpret_cast(info) ); + info = CPPAD_NULL; + all_info[thread] = info; + } + } + else if( info == CPPAD_NULL ) + { if( thread == 0 ) + info = &zero_info; + else + { size_t size = sizeof(thread_alloc_info); + void* v_ptr = ::operator new(size); + info = reinterpret_cast(v_ptr); + } + all_info[thread] = info; + + // initialize the information record + for(size_t c = 0; c < CPPAD_MAX_NUM_CAPACITY; c++) + { info->root_inuse_[c].next_ = CPPAD_NULL; + info->root_available_[c].next_ = CPPAD_NULL; + } + info->count_inuse_ = 0; + info->count_available_ = 0; + } + return info; + } + // ----------------------------------------------------------------------- + /*! + Increase the number of bytes of memory that are currently in use; i.e., + that been obtained with \c get_memory and not yet returned. + + \param inc [in] + amount to increase memory in use. + + \param thread [in] + Thread for which we are increasing the number of bytes in use + (must be less than \c num_threads). + Durring parallel execution, this must be the thread + that is currently executing. + */ + static void inc_inuse(size_t inc, size_t thread) + { + CPPAD_ASSERT_UNKNOWN( thread < num_threads() ); + CPPAD_ASSERT_UNKNOWN( + thread == thread_num() || (! in_parallel()) + ); + thread_alloc_info* info = thread_info(thread); + + // do the addition + size_t result = info->count_inuse_ + inc; + CPPAD_ASSERT_UNKNOWN( result >= info->count_inuse_ ); + + info->count_inuse_ = result; + } + // ----------------------------------------------------------------------- + /*! + Increase the number of bytes of memory that are currently avaialble; i.e., + have been obtained obtained from the system and are being held future use. + + \copydetails inc_inuse + */ + static void inc_available(size_t inc, size_t thread) + { + CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); + CPPAD_ASSERT_UNKNOWN( + thread == thread_num() || (! in_parallel()) + ); + thread_alloc_info* info = thread_info(thread); + // do the addition + size_t result = info->count_available_ + inc; + CPPAD_ASSERT_UNKNOWN( result >= info->count_available_ ); + + info->count_available_ = result; + } + // ----------------------------------------------------------------------- + /*! + Decrease the number of bytes of memory that are currently in use; i.e., + that been obtained with \c get_memory and not yet returned. + + \param dec [in] + amount to decrease number of bytes in use. + + \param thread [in] + Thread for which we are decreasing the number of bytes in use + (must be less than \c num_threads). + Durring parallel execution, this must be the thread + that is currently executing. + */ + static void dec_inuse(size_t dec, size_t thread) + { + CPPAD_ASSERT_UNKNOWN( + thread < num_threads() || (! in_parallel()) + ); + CPPAD_ASSERT_UNKNOWN( + thread == thread_num() || (! in_parallel()) + ); + thread_alloc_info* info = thread_info(thread); + + // do the subtraction + CPPAD_ASSERT_UNKNOWN( info->count_inuse_ >= dec ); + info->count_inuse_ = info->count_inuse_ - dec; + } + // ----------------------------------------------------------------------- + /*! + Decrease the number of bytes of memory that are currently avaialble; i.e., + have been obtained obtained from the system and are being held future use. + + \copydetails dec_inuse + */ + static void dec_available(size_t dec, size_t thread) + { + CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); + CPPAD_ASSERT_UNKNOWN( + thread == thread_num() || (! in_parallel()) + ); + thread_alloc_info* info = thread_info(thread); + // do the subtraction + CPPAD_ASSERT_UNKNOWN( info->count_available_ >= dec ); + info->count_available_ = info->count_available_ - dec; + } + + // ---------------------------------------------------------------------- + /*! + Set and get the number of threads that are sharing memory. + + \param number_new + If \c number is zero, we are only retreiving the current maximum + number of threads. Otherwise, we are setting and retreiving + maximum number of threads. + + \return + the number of threads that are sharing memory. + If \c number_new is non-zero, the return value is equal to + \c number_new. + */ + static size_t set_get_num_threads(size_t number_new) + { static size_t number_user = 1; + + CPPAD_ASSERT_UNKNOWN( number_new <= CPPAD_MAX_NUM_THREADS ); + CPPAD_ASSERT_UNKNOWN( ! in_parallel() || (number_new == 0) ); + + // case where we are changing the number of threads + if( number_new != 0 ) + number_user = number_new; + + return number_user; + } + /*! + Set and call the routine that determine the current thread number. + + \return + returns value for the most recent setting for \a thread_num_new. + If \a set is true, + or the most recent setting is \c CPPAD_NULL (its initial value), + the return value is zero. + Otherwise the routine corresponding to the most recent setting + is called and its value returned by \c set_get_thread_num. + + \param thread_num_new [in] + If \a set is false, \a thread_num_new it is not used. + Otherwise, the current value of \c thread_num_new becomes the + most recent setting for thread_num. + + \param set + If \a set is true, then \a thread_num_new is becomes the most + recent setting for this \c set_get_thread_num. + */ + static size_t set_get_thread_num( + size_t (*thread_num_new)(void) , + bool set = false ) + { static size_t (*thread_num_user)(void) = CPPAD_NULL; + + if( set ) + { thread_num_user = thread_num_new; + return 0; + } + + if( thread_num_user == CPPAD_NULL ) + return 0; + + size_t thread = thread_num_user(); + CPPAD_ASSERT_KNOWN( + thread < set_get_num_threads(0) , + "parallel_setup: thread_num() >= num_threads" + ); + return thread; + } +// ============================================================================ +public: +/* +$begin ta_parallel_setup$$ +$spell + alloc + num + bool +$$ +$section Setup thread_alloc For Use in Multi-Threading Environment$$ +$mindex parallel initialize$$ + + + + +$head Syntax$$ +$codei%thread_alloc::parallel_setup(%num_threads%, %in_parallel%, %thread_num%) +%$$ + +$head Purpose$$ +By default there is only one thread and all execution is in sequential mode, +i.e., multiple threads are not sharing the same memory; i.e. +not in parallel mode. + +$head Speed$$ +It should be faster, even when $icode num_thread$$ is equal to one, +for $code thread_alloc$$ to hold onto memory. +This can be accomplished using the function call +$codei% + thread_alloc::hold_memory(true) +%$$ +see $cref/hold_memory/ta_hold_memory/$$. + +$head num_threads$$ +This argument has prototype +$codei% + size_t %num_threads% +%$$ +and must be greater than zero. +It specifies the number of threads that are sharing memory. +The case $icode%num_threads% == 1%$$ is a special case that is +used to terminate a multi-threading environment. + +$head in_parallel$$ +This function has prototype +$codei% + bool %in_parallel%(void) +%$$ +It must return $code true$$ if there is more than one thread +currently executing. +Otherwise it can return false. +$pre + +$$ +In the special case where $icode%num_threads% == 1%$$, +the routine $icode in_parallel$$ is not used. + +$head thread_num$$ +This function has prototype +$codei% + size_t %thread_num%(void) +%$$ +It must return a thread number that uniquely identifies the +currently executing thread. +Furthermore +$codei% + 0 <= %thread_num%() < %num_threads% +%$$. +In the special case where $icode%num_threads% == 1%$$, +the routine $icode thread_num$$ is not used. +$pre + +$$ +Note that this function is called by other routines so, +as soon as a new thread is executing, +one must be certain that $icode thread_num()$$ will +work for that thread. + +$head Restrictions$$ +The function $code parallel_setup$$ must be called before +the program enters $cref/parallel/ta_in_parallel/$$ execution mode. +In addition, this function cannot be called while in parallel mode. + +$head Example$$ +The files +$cref simple_ad_openmp.cpp$$, +$cref simple_ad_bthread.cpp$$, and +$cref simple_ad_pthread.cpp$$, +contain examples and tests that use this function. + +$end +*/ + /*! + Set thread_alloc up for parallel mode usage. + + \param num_threads [in] + Is the number of thread that may be executing at the same time. + + \param in_parallel [in] + Is the routine that determines if we are in parallel mode or not. + + \param thread_num [in] + Is the routine that determines the current thread number + (between zero and num_threads minus one). + */ + static void parallel_setup( + size_t num_threads , + bool (*in_parallel)(void) , + size_t (*thread_num)(void) ) + { + // Special case where we go back to single thread mode right away + // (previous settings may no longer be valid) + if( num_threads == 1 ) + { bool set = true; + set_get_num_threads(num_threads); + // emphasize that this routine is outside thread_alloc class + CppAD::set_get_in_parallel(CPPAD_NULL, set); + set_get_thread_num(CPPAD_NULL, set); + return; + } + + CPPAD_ASSERT_KNOWN( + num_threads <= CPPAD_MAX_NUM_THREADS , + "parallel_setup: num_threads is too large" + ); + CPPAD_ASSERT_KNOWN( + num_threads != 0 , + "parallel_setup: num_threads == zero" + ); + CPPAD_ASSERT_KNOWN( + in_parallel != CPPAD_NULL , + "parallel_setup: num_threads != 1 and in_parallel == CPPAD_NULL" + ); + CPPAD_ASSERT_KNOWN( + thread_num != CPPAD_NULL , + "parallel_setup: num_threads != 1 and thread_num == CPPAD_NULL" + ); + + // Make sure that constructors for all static variables in this file + // are called in sequential mode. + for(size_t thread = 0; thread < num_threads; thread++) + thread_info(thread); + capacity_info(); + size_t cap_bytes; + void* v_ptr = get_memory(0, cap_bytes); + + // free memory allocated by call to get_memory above + return_memory(v_ptr); + free_available( set_get_thread_num(CPPAD_NULL) ); + + // delay this so thread_num() call above is in previous mode + // (current setings may not yet be valid) + if( num_threads > 1 ) + { bool set = true; + set_get_num_threads(num_threads); + // emphasize that this routine is outside thread_alloc class + CppAD::set_get_in_parallel(in_parallel, set); + set_get_thread_num(thread_num, set); + } + } +/* +$begin ta_num_threads$$ +$spell + inv + CppAD + num + alloc +$$ +$section Get Number of Threads$$ + + +$head Syntax$$ +$icode%number% = thread_alloc::num_threads()%$$ + +$head Purpose$$ +Determine the number of threads as set during $cref/parallel_setup/ta_parallel_setup/$$. + +$head number$$ +The return value $icode number$$ has prototype +$codei% + size_t %number% +%$$ +and is equal to the value of +$cref/num_threads/ta_parallel_setup/num_threads/$$ +in the previous call to $icode parallel_setup$$. +If there was no such previous call, the value one is returned. + +$head Example$$ +The example and test $cref thread_alloc.cpp$$ uses this routine. + +$end +*/ + /*! + Get the current number of threads that thread_alloc can use. + */ + static size_t num_threads(void) + { return set_get_num_threads(0); } +/* ----------------------------------------------------------------------- +$begin ta_in_parallel$$ + +$section Is The Current Execution in Parallel Mode$$ +$mindex sequential$$ +$spell + thread_alloc + bool +$$ + + +$head Syntax$$ +$icode%flag% = thread_alloc::in_parallel()%$$ + +$head Purpose$$ +Some of the $cref thread_alloc$$ allocation routines have different +specifications for parallel (not sequential) execution mode. +This routine enables you to determine if the current execution mode +is sequential or parallel. + +$head flag$$ +The return value has prototype +$codei% + bool %flag% +%$$ +It is true if the current execution is in parallel mode +(possibly multi-threaded) and false otherwise (sequential mode). + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /// Are we in a parallel execution state; i.e., is it possible that + /// other threads are currently executing. + static bool in_parallel(void) + { // emphasize that this routine is outside thread_alloc class + return CppAD::set_get_in_parallel(0); + } +/* ----------------------------------------------------------------------- +$begin ta_thread_num$$ +$spell + CppAD + num + thread_alloc + cppad.hpp +$$ + +$section Get the Current Thread Number$$ + + +$head Syntax$$ +$icode%thread% = thread_alloc::thread_num()%$$ + +$head Purpose$$ +Some of the $cref thread_alloc$$ allocation routines have a thread number. +This routine enables you to determine the current thread. + +$head thread$$ +The return value $icode thread$$ has prototype +$codei% + size_t %thread% +%$$ +and is the currently executing thread number. + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /// Get current thread number + static size_t thread_num(void) + { return set_get_thread_num(CPPAD_NULL); } +/* ----------------------------------------------------------------------- +$begin ta_get_memory$$ +$spell + std + num + ptr + thread_alloc +$$ + +$section Get At Least A Specified Amount of Memory$$ +$mindex allocate$$ + + +$head Syntax$$ +$icode%v_ptr% = thread_alloc::get_memory(%min_bytes%, %cap_bytes%)%$$ + +$head Purpose$$ +Use $cref thread_alloc$$ to obtain a minimum number of bytes of memory +(for use by the $cref/current thread/ta_thread_num/$$). + +$head min_bytes$$ +This argument has prototype +$codei% + size_t %min_bytes% +%$$ +It specifies the minimum number of bytes to allocate. +This value must be less than +$codep + std::numeric_limits::max() / 2 +$$ + +$head cap_bytes$$ +This argument has prototype +$codei% + size_t& %cap_bytes% +%$$ +It's input value does not matter. +Upon return, it is the actual number of bytes (capacity) +that have been allocated for use, +$codei% + %min_bytes% <= %cap_bytes% +%$$ + +$head v_ptr$$ +The return value $icode v_ptr$$ has prototype +$codei% + void* %v_ptr% +%$$ +It is the location where the $icode cap_bytes$$ of memory +that have been allocated for use begins. + +$head Allocation Speed$$ +This allocation should be faster if the following conditions hold: +$list number$$ +The memory allocated by a previous call to $code get_memory$$ +is currently available for use. +$lnext +The current $icode min_bytes$$ is between +the previous $icode min_bytes$$ and previous $icode cap_bytes$$. +$lend + +$head Alignment$$ +We call a memory allocation aligned if the address is a multiple +of the number of bytes in a $code size_t$$ value. +If the system $code new$$ allocator is aligned, then $icode v_ptr$$ +pointer is also aligned. + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /*! + Use thread_alloc to get a specified amount of memory. + + If the memory allocated by a previous call to \c get_memory is now + avaialable, and \c min_bytes is between its previous value + and the previous \c cap_bytes, this memory allocation will have + optimal speed. Otherwise, the memory allocation is more complicated and + may have to wait for other threads to complete an allocation. + + \param min_bytes [in] + The minimum number of bytes of memory to be obtained for use. + + \param cap_bytes [out] + The actual number of bytes of memory obtained for use. + + \return + pointer to the beginning of the memory allocated for use. + */ + static void* get_memory(size_t min_bytes, size_t& cap_bytes) + { // see first_trace below + CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + + // check that number of requested bytes is not to large + CPPAD_ASSERT_KNOWN( + min_bytes < std::numeric_limits::max() / 2 , + "get_memory(min_bytes, cap_bytes): min_bytes is too large" + ); + + size_t num_cap = capacity_info()->number; + using std::cout; + using std::endl; + + // determine the capacity for this request + size_t c_index = 0; + const size_t* capacity_vec = capacity_info()->value; + while( capacity_vec[c_index] < min_bytes ) + { ++c_index; + CPPAD_ASSERT_UNKNOWN(c_index < num_cap ); + } + cap_bytes = capacity_vec[c_index]; + + // determine the thread, capacity, and info for this thread + size_t thread = thread_num(); + size_t tc_index = thread * num_cap + c_index; + thread_alloc_info* info = thread_info(thread); + +# ifndef NDEBUG + // trace allocation + static bool first_trace = true; + if( cap_bytes == CPPAD_TRACE_CAPACITY && + thread == CPPAD_TRACE_THREAD && first_trace ) + { cout << endl; + cout << "thread_alloc: Trace for Thread = " << thread; + cout << " and capacity = " << cap_bytes << endl; + if( first_trace ) + first_trace = false; + } + + // Root nodes for both lists. Note these are different for different + // threads because tc_index is different for different threads. + block_t* inuse_root = info->root_inuse_ + c_index; +# endif + block_t* available_root = info->root_available_ + c_index; + + // check if we already have a node we can use + void* v_node = available_root->next_; + block_t* node = reinterpret_cast(v_node); + if( node != CPPAD_NULL ) + { CPPAD_ASSERT_UNKNOWN( node->tc_index_ == tc_index ); + + // remove node from available list + available_root->next_ = node->next_; + + // return value for get_memory + void* v_ptr = reinterpret_cast(node + 1); +# ifndef NDEBUG + // add node to inuse list + node->next_ = inuse_root->next_; + inuse_root->next_ = v_node; + + // trace allocation + if( cap_bytes == CPPAD_TRACE_CAPACITY && + thread == CPPAD_TRACE_THREAD ) + { cout << "get_memory: v_ptr = " << v_ptr << endl; } +# endif + + // adjust counts + inc_inuse(cap_bytes, thread); + dec_available(cap_bytes, thread); + + // return pointer to memory, do not inclue thread_alloc information + return v_ptr; + } + + // Create a new node with thread_alloc information at front. + // This uses the system allocator, which is thread safe, but slower, + // because the thread might wait for a lock on the allocator. + v_node = ::operator new(sizeof(block_t) + cap_bytes); + node = reinterpret_cast(v_node); + node->tc_index_ = tc_index; + void* v_ptr = reinterpret_cast(node + 1); + +# ifndef NDEBUG + // add node to inuse list + node->next_ = inuse_root->next_; + inuse_root->next_ = v_node; + + // trace allocation + if( cap_bytes == CPPAD_TRACE_CAPACITY && + thread == CPPAD_TRACE_THREAD ) + { cout << "get_memory: v_ptr = " << v_ptr << endl; } +# endif + + // adjust counts + inc_inuse(cap_bytes, thread); + + return v_ptr; + } + +/* ----------------------------------------------------------------------- +$begin ta_return_memory$$ +$spell + num + ptr + thread_alloc +$$ + +$section Return Memory to thread_alloc$$ +$mindex return_memory available$$ + + +$head Syntax$$ +$codei%thread_alloc::return_memory(%v_ptr%)%$$ + +$head Purpose$$ +If $cref/hold_memory/ta_hold_memory/$$ is false, +the memory is returned to the system. +Otherwise, the memory is retained by $cref thread_alloc$$ for quick future use +by the thread that allocated to memory. + +$head v_ptr$$ +This argument has prototype +$codei% + void* %v_ptr% +%$$. +It must be a pointer to memory that is currently in use; i.e. +obtained by a previous call to +$cref/get_memory/ta_get_memory/$$ and not yet returned. + +$head Thread$$ +Either the $cref/current thread/ta_thread_num/$$ must be the same as during +the corresponding call to $cref/get_memory/ta_get_memory/$$, +or the current execution mode must be sequential +(not $cref/parallel/ta_in_parallel/$$). + +$head NDEBUG$$ +If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). +Otherwise, a list of in use pointers is searched to make sure +that $icode v_ptr$$ is in the list. + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /*! + Return memory that was obtained by \c get_memory. + If num_threads() == 1, + the memory is returned to the system. + Otherwise, it is retained by \c thread_alloc and available for use by + \c get_memory for this thread. + + \param v_ptr [in] + Value of the pointer returned by \c get_memory and still in use. + After this call, this pointer will available (and not in use). + + \par + We must either be in sequential (not parallel) execution mode, + or the current thread must be the same as for the corresponding call + to \c get_memory. + */ + static void return_memory(void* v_ptr) + { size_t num_cap = capacity_info()->number; + + block_t* node = reinterpret_cast(v_ptr) - 1; + size_t tc_index = node->tc_index_; + size_t thread = tc_index / num_cap; + size_t c_index = tc_index % num_cap; + size_t capacity = capacity_info()->value[c_index]; + + CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS ); + CPPAD_ASSERT_KNOWN( + thread == thread_num() || (! in_parallel()), + "Attempt to return memory for a different thread " + "while in parallel mode" + ); + + thread_alloc_info* info = thread_info(thread); +# ifndef NDEBUG + // remove node from inuse list + void* v_node = reinterpret_cast(node); + block_t* inuse_root = info->root_inuse_ + c_index; + block_t* previous = inuse_root; + while( (previous->next_ != CPPAD_NULL) & (previous->next_ != v_node) ) + previous = reinterpret_cast(previous->next_); + + // check that v_ptr is valid + if( previous->next_ != v_node ) + { using std::endl; + std::ostringstream oss; + oss << "return_memory: attempt to return memory not in use"; + oss << endl; + oss << "v_ptr = " << v_ptr << endl; + oss << "thread = " << thread << endl; + oss << "capacity = " << capacity << endl; + oss << "See CPPAD_TRACE_THREAD & CPPAD_TRACE_CAPACITY in"; + oss << endl << "%# include " << endl; + // oss.str() returns a string object with a copy of the current + // contents in the stream buffer. + std::string msg_str = oss.str(); + // msg_str.c_str() returns a pointer to the c-string + // representation of the string object's value. + const char* msg_char_star = msg_str.c_str(); + CPPAD_ASSERT_KNOWN(false, msg_char_star ); + } + + // trace option + if( capacity==CPPAD_TRACE_CAPACITY && thread==CPPAD_TRACE_THREAD ) + { std::cout << "return_memory: v_ptr = " << v_ptr << std::endl; } + + // remove v_ptr from inuse list + previous->next_ = node->next_; +# endif + // capacity bytes are removed from the inuse pool + dec_inuse(capacity, thread); + + // check for case where we just return the memory to the system + if( ! set_get_hold_memory(false) ) + { ::operator delete( reinterpret_cast(node) ); + return; + } + + // add this node to available list for this thread and capacity + block_t* available_root = info->root_available_ + c_index; + node->next_ = available_root->next_; + available_root->next_ = reinterpret_cast(node); + + // capacity bytes are added to the available pool + inc_available(capacity, thread); + } +/* ----------------------------------------------------------------------- +$begin ta_free_available$$ +$spell + num + thread_alloc +$$ + +$section Free Memory Currently Available for Quick Use by a Thread$$ +$mindex free_available$$ +$spell + inuse +$$ + + +$head Syntax$$ +$codei%thread_alloc::free_available(%thread%)%$$ + +$head Purpose$$ +Return to the system all the memory that is currently being +$cref/held/ta_hold_memory/$$ for quick use by the specified thread. + +$subhead Extra Memory$$ +In the case where $icode%thread% > 0%$$, +some extra memory is used to track allocations by the specified thread. +If +$codei% + thread_alloc::inuse(%thread%) == 0 +%$$ +the extra memory is also returned to the system. + +$head thread$$ +This argument has prototype +$codei% + size_t %thread% +%$$ +Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, +or the current execution mode must be sequential +(not $cref/parallel/ta_in_parallel/$$). + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /*! + Return all the memory being held as available for a thread to the system. + + \param thread [in] + this thread that will no longer have any available memory after this call. + This must either be the thread currently executing, or we must be + in sequential (not parallel) execution mode. + */ + static void free_available(size_t thread) + { CPPAD_ASSERT_KNOWN( + thread < CPPAD_MAX_NUM_THREADS, + "Attempt to free memory for a thread >= CPPAD_MAX_NUM_THREADS" + ); + CPPAD_ASSERT_KNOWN( + thread == thread_num() || (! in_parallel()), + "Attempt to free memory for a different thread " + "while in parallel mode" + ); + + size_t num_cap = capacity_info()->number; + if( num_cap == 0 ) + return; + const size_t* capacity_vec = capacity_info()->value; + size_t c_index; + thread_alloc_info* info = thread_info(thread); + for(c_index = 0; c_index < num_cap; c_index++) + { size_t capacity = capacity_vec[c_index]; + block_t* available_root = info->root_available_ + c_index; + void* v_ptr = available_root->next_; + while( v_ptr != CPPAD_NULL ) + { block_t* node = reinterpret_cast(v_ptr); + void* next = node->next_; + ::operator delete(v_ptr); + v_ptr = next; + + dec_available(capacity, thread); + } + available_root->next_ = CPPAD_NULL; + } + CPPAD_ASSERT_UNKNOWN( available(thread) == 0 ); + if( inuse(thread) == 0 ) + { // clear the information for this thread + thread_info(thread, true); + } + } +/* ----------------------------------------------------------------------- +$begin ta_hold_memory$$ +$spell + alloc + num +$$ + +$section Control When Thread Alloc Retains Memory For Future Use$$ +$mindex hold$$ + +$head Syntax$$ +$codei%thread_alloc::hold_memory(%value%)%$$ + +$head Purpose$$ +It should be faster, even when $icode num_thread$$ is equal to one, +for $code thread_alloc$$ to hold onto memory. +Calling $icode hold_memory$$ with $icode value$$ equal to true, +instructs $code thread_alloc$$ to hold onto memory, +and put it in the $cref/available/ta_available/$$ pool, +after each call to $cref/return_memory/ta_return_memory/$$. + +$head value$$ +If $icode value$$ is true, +$code thread_alloc$$ with hold onto memory for future quick use. +If it is false, future calls to $cref/return_memory/ta_return_memory/$$ +will return the corresponding memory to the system. +By default (when $code hold_memory$$ has not been called) +$code thread_alloc$$ does not hold onto memory. + +$head free_available$$ +Memory that is being held by $code thread_alloc$$ can be returned +to the system using $cref/free_available/ta_free_available/$$. + +$end +*/ + /*! + Change the thread_alloc hold memory setting. + + \param value [in] + New value for the thread_alloc hold memory setting. + */ + static void hold_memory(bool value) + { bool set = true; + set_get_hold_memory(set, value); + } + +/* ----------------------------------------------------------------------- +$begin ta_inuse$$ +$spell + num + inuse + thread_alloc +$$ + +$section Amount of Memory a Thread is Currently Using$$ +$mindex inuse$$ + + +$head Syntax$$ +$icode%num_bytes% = thread_alloc::inuse(%thread%)%$$ + +$head Purpose$$ +Memory being managed by $cref thread_alloc$$ has two states, +currently in use by the specified thread, +and quickly available for future use by the specified thread. +This function informs the program how much memory is in use. + +$head thread$$ +This argument has prototype +$codei% + size_t %thread% +%$$ +Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, +or the current execution mode must be sequential +(not $cref/parallel/ta_in_parallel/$$). + +$head num_bytes$$ +The return value has prototype +$codei% + size_t %num_bytes% +%$$ +It is the number of bytes currently in use by the specified thread. + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /*! + Determine the amount of memory that is currently inuse. + + \param thread [in] + Thread for which we are determining the amount of memory + (must be < CPPAD_MAX_NUM_THREADS). + Durring parallel execution, this must be the thread + that is currently executing. + + \return + The amount of memory in bytes. + */ + static size_t inuse(size_t thread) + { + CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); + CPPAD_ASSERT_UNKNOWN( + thread == thread_num() || (! in_parallel()) + ); + thread_alloc_info* info = thread_info(thread); + return info->count_inuse_; + } +/* ----------------------------------------------------------------------- +$begin ta_available$$ +$spell + num + thread_alloc +$$ + +$section Amount of Memory Available for Quick Use by a Thread$$ + + +$head Syntax$$ +$icode%num_bytes% = thread_alloc::available(%thread%)%$$ + +$head Purpose$$ +Memory being managed by $cref thread_alloc$$ has two states, +currently in use by the specified thread, +and quickly available for future use by the specified thread. +This function informs the program how much memory is available. + +$head thread$$ +This argument has prototype +$codei% + size_t %thread% +%$$ +Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, +or the current execution mode must be sequential +(not $cref/parallel/ta_in_parallel/$$). + +$head num_bytes$$ +The return value has prototype +$codei% + size_t %num_bytes% +%$$ +It is the number of bytes currently available for use by the specified thread. + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /*! + Determine the amount of memory that is currently available for use. + + \copydetails inuse + */ + static size_t available(size_t thread) + { + CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); + CPPAD_ASSERT_UNKNOWN( + thread == thread_num() || (! in_parallel()) + ); + thread_alloc_info* info = thread_info(thread); + return info->count_available_; + } +/* ----------------------------------------------------------------------- +$begin ta_create_array$$ +$spell + inuse + thread_alloc + sizeof +$$ + +$section Allocate An Array and Call Default Constructor for its Elements$$ +$mindex create_array$$ + + +$head Syntax$$ +$icode%array% = thread_alloc::create_array<%Type%>(%size_min%, %size_out%)%$$. + +$head Purpose$$ +Create a new raw array using $cref thread_alloc$$ memory allocator +(works well in a multi-threading environment) +and call default constructor for each element. + +$head Type$$ +The type of the elements of the array. + +$head size_min$$ +This argument has prototype +$codei% + size_t %size_min% +%$$ +This is the minimum number of elements that there can be +in the resulting $icode array$$. + +$head size_out$$ +This argument has prototype +$codei% + size_t& %size_out% +%$$ +The input value of this argument does not matter. +Upon return, it is the actual number of elements +in $icode array$$ +($icode% size_min %<=% size_out%$$). + +$head array$$ +The return value $icode array$$ has prototype +$codei% + %Type%* %array% +%$$ +It is array with $icode size_out$$ elements. +The default constructor for $icode Type$$ is used to initialize the +elements of $icode array$$. +Note that $cref/delete_array/ta_delete_array/$$ +should be used to destroy the array when it is no longer needed. + +$head Delta$$ +The amount of memory $cref/inuse/ta_inuse/$$ by the current thread, +will increase $icode delta$$ where +$codei% + sizeof(%Type%) * (%size_out% + 1) > %delta% >= sizeof(%Type%) * %size_out% +%$$ +The $cref/available/ta_available/$$ memory will decrease by $icode delta$$, +(and the allocation will be faster) +if a previous allocation with $icode size_min$$ between its current value +and $icode size_out$$ is available. + +$head Alignment$$ +We call a memory allocation aligned if the address is a multiple +of the number of bytes in a $code size_t$$ value. +If the system $code new$$ allocator is aligned, then $icode array$$ +pointer is also aligned. + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /*! + Use thread_alloc to allocate an array, then call default construtor + for each element. + + \tparam Type + The type of the elements of the array. + + \param size_min [in] + The minimum number of elements in the array. + + \param size_out [out] + The actual number of elements in the array. + + \return + pointer to the first element of the array. + The default constructor is used to initialize + all the elements of the array. + + \par + The \c extra_ field, in the \c thread_alloc node before the return value, + is set to size_out. + */ + template + static Type* create_array(size_t size_min, size_t& size_out) + { // minimum number of bytes to allocate + size_t min_bytes = size_min * sizeof(Type); + // do the allocation + size_t num_bytes; + void* v_ptr = get_memory(min_bytes, num_bytes); + // This is where the array starts + Type* array = reinterpret_cast(v_ptr); + // number of Type values in the allocation + size_out = num_bytes / sizeof(Type); + // store this number in the extra field + block_t* node = reinterpret_cast(v_ptr) - 1; + node->extra_ = size_out; + + // call default constructor for each element + size_t i; + for(i = 0; i < size_out; i++) + new(array + i) Type(); + + return array; + } +/* ----------------------------------------------------------------------- +$begin ta_delete_array$$ +$spell + inuse + thread_alloc + sizeof + deallocate +$$ + +$section Deallocate An Array and Call Destructor for its Elements$$ +$mindex delete_array$$ + + +$head Syntax$$ +$codei%thread_alloc::delete_array(%array%)%$$. + +$head Purpose$$ +Returns memory corresponding to an array created by +(create by $cref/create_array/ta_create_array/$$) to the +$cref/available/ta_available/$$ memory pool for the current thread. + +$head Type$$ +The type of the elements of the array. + +$head array$$ +The argument $icode array$$ has prototype +$codei% + %Type%* %array% +%$$ +It is a value returned by $cref/create_array/ta_create_array/$$ and not yet deleted. +The $icode Type$$ destructor is called for each element in the array. + +$head Thread$$ +The $cref/current thread/ta_thread_num/$$ must be the +same as when $cref/create_array/ta_create_array/$$ returned the value $icode array$$. +There is an exception to this rule: +when the current execution mode is sequential +(not $cref/parallel/ta_in_parallel/$$) the current thread number does not matter. + +$head Delta$$ +The amount of memory $cref/inuse/ta_inuse/$$ will decrease by $icode delta$$, +and the $cref/available/ta_available/$$ memory will increase by $icode delta$$, +where $cref/delta/ta_create_array/Delta/$$ +is the same as for the corresponding call to $code create_array$$. + +$head Example$$ +$cref thread_alloc.cpp$$ + +$end +*/ + /*! + Return Memory Used for an Array to the Available Pool + (include destructor call for each element). + + \tparam Type + The type of the elements of the array. + + \param array [in] + A value returned by \c create_array that has not yet been deleted. + The \c Type destructor is used to destroy each of the elements + of the array. + + \par + Durring parallel execution, the current thread must be the same + as during the corresponding call to \c create_array. + */ + template + static void delete_array(Type* array) + { // determine the number of values in the array + block_t* node = reinterpret_cast(array) - 1; + size_t size = node->extra_; + + // call destructor for each element + size_t i; + for(i = 0; i < size; i++) + (array + i)->~Type(); + + // return the memory to the available pool for this thread + thread_alloc::return_memory( reinterpret_cast(array) ); + } +/* ----------------------------------------------------------------------- +$begin ta_free_all$$ +$spell + alloc + bool + inuse +$$ + +$section Free All Memory That Was Allocated for Use by thread_alloc$$ + + +$head Syntax$$ +$icode%ok% = thread_alloc::free_all()%$$. + +$head Purpose$$ +Returns all memory that was used by $code thread_alloc$$ to the system. + +$head ok$$ +The return value $icode ok$$ has prototype +$codei% + bool %ok% +%$$ +Its value will be $code true$$ if all the memory can be freed. +This requires that for all $icode thread$$ indices, there is no memory +$cref/inuse/ta_inuse/$$; i.e., +$codei% + 0 == thread_alloc::inuse(%thread%) +%$$ +Otherwise, the return value will be false. + +$head Restrictions$$ +This function cannot be called while in parallel mode. + +$head Example$$ +$cref thread_alloc.cpp$$ +$end +*/ + /*! + Return to the system all thread_alloc memory that is not currently inuse. + + \return + If no \c thread_alloc memory is currently inuse, + all memory is returned to the system and the return value is true. + Otherwise the return value is false. + */ + static bool free_all(void) + { CPPAD_ASSERT_KNOWN( + ! in_parallel(), + "free_all cannot be used while in parallel execution" + ); + bool ok = true; + size_t thread = CPPAD_MAX_NUM_THREADS; + while(thread--) + { ok &= inuse(thread) == 0; + free_available(thread); + } + return ok; + } +}; + + +} // END_CPPAD_NAMESPACE + +// preprocessor symbols local to this file +# undef CPPAD_MAX_NUM_CAPACITY +# undef CPPAD_MIN_DOUBLE_CAPACITY +# undef CPPAD_TRACE_CAPACITY +# undef CPPAD_TRACE_THREAD +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/time_test.hpp cppad-2016.00.00.1/cppad/utility/time_test.hpp --- cppad-2015.00.00.9/cppad/utility/time_test.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/time_test.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,233 @@ +// $Id: time_test.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_TIME_TEST_HPP +# define CPPAD_TIME_TEST_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin time_test$$ +$spell + gettimeofday + vec + cppad.hpp + Microsoft + namespace + std + const + cout + ctime + ifdef + const + endif + cpp +$$ + + +$section Determine Amount of Time to Execute a Test$$ +$mindex time_test speed$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%time% = time_test(%test%, %time_min%)%$$ +$icode%time% = time_test(%test%, %time_min%, %test_size%)%$$ + +$head Purpose$$ +The $code time_test$$ function executes a timing test +and reports the amount of wall clock time for execution. + +$head Motivation$$ +It is important to separate small calculation units +and test them individually. +This way individual changes can be tested in the context of the +routine that they are in. +On many machines, accurate timing of a very short execution +sequences is not possible. +In addition, +there may be set up and tear down time for a test that +we do not really want included in the timing. +For this reason $code time_test$$ +automatically determines how many times to +repeat the section of the test that we wish to time. + +$head Include$$ +The file $code cppad/time_test.hpp$$ defines the +$code time_test$$ function. +This file is included by $code cppad/cppad.hpp$$ +and it can also be included separately with out the rest of +the $code CppAD$$ routines. + +$head test$$ +The $code time_test$$ argument $icode test$$ is a function, +or function object. +In the case where $icode test_size$$ is not present, +$icode test$$ supports the syntax +$codei% + %test%(%repeat%) +%$$ +In the case where $icode test_size$$ is present, +$icode test$$ supports the syntax +$codei% + %test%(%size%, %repeat%) +%$$ +In either case, the return value for $icode test$$ is $code void$$. + +$subhead size$$ +If the argument $icode size$$ is present, +it has prototype +$codei% + size_t %size% +%$$ +and is equal to the $icode test_size$$ argument to $code time_test$$. + +$subhead repeat$$ +The $icode test$$ argument $icode repeat$$ has prototype +$codei% + size_t %repeat% +%$$ +It will be equal to the $icode size$$ argument to $code time_test$$. + +$head time_min$$ +The argument $icode time_min$$ has prototype +$codei% + double %time_min% +%$$ +It specifies the minimum amount of time in seconds +that the $icode test$$ routine should take. +The $icode repeat$$ argument to $icode test$$ is increased +until this amount of execution time (or more) is reached. + +$head test_size$$ +This argument has prototype +$codei% + size_t %test_size% +%$$ +It specifies the $icode size$$ argument to $icode test$$. + +$head time$$ +The return value $icode time$$ has prototype +$codei% + double %time% +%$$ +and is the number of wall clock seconds that it took +to execute $icode test$$ divided by the value used for $icode repeat$$. + +$head Timing$$ +The routine $cref elapsed_seconds$$ will be used to determine the +amount of time it took to execute the test. + +$children% + cppad/utility/elapsed_seconds.hpp% + speed/example/time_test.cpp +%$$ +$head Example$$ +The routine $cref time_test.cpp$$ is an example and test +of $code time_test$$. + +$end +----------------------------------------------------------------------- +*/ + +# include +# include +# include +# include +# include + +# define CPPAD_EXTRA_RUN_BEFORE_TIMING 0 + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file time_test.hpp +\brief Function that preforms one timing test (for speed of execution). +*/ + +/*! +Preform one wall clock execution timing test. + +\tparam Test +Either the type void (*)(size_t) or a function object +type that supports the same syntax. + +\param test +The function, or function object, that supports the operation +test(repeat) where \c repeat is the number of times +to repeat the tests operaiton that is being timed. + +\param time_min +is the minimum amount of time that \c test should take to preform +the repetitions of the operation being timed. +*/ +template +double time_test(Test test, double time_min ) +{ +# if CPPAD_EXTRA_RUN_BEFORE_TIMING + test(1); +# endif + size_t repeat = 0; + double s0 = elapsed_seconds(); + double s1 = s0; + while( s1 - s0 < time_min ) + { repeat = std::max(size_t(1), 2 * repeat); + s0 = elapsed_seconds(); + test(repeat); + s1 = elapsed_seconds(); + } + double time = (s1 - s0) / double(repeat); + return time; +} + +/*! +Preform one wall clock execution timing test. + +\tparam Test +Either the type void (*)(size_t, size_t) or a function object +type that supports the same syntax. + +\param test +The function, or function object, that supports the operation +test(size, repeat) where +\c is the size for this test and +\c repeat is the number of times +to repeat the tests operaiton that is being timed. + +\param time_min +is the minimum amount of time that \c test should take to preform +the repetitions of the operation being timed. + +\param test_size +will be used for the value of \c size in the call to \c test. +*/ +template +double time_test(Test test, double time_min, size_t test_size) +{ +# if CPPAD_EXTRA_RUN_BEFORE_TIMING + test(test_size, 1); +# endif + size_t repeat = 0; + double s0 = elapsed_seconds(); + double s1 = s0; + while( s1 - s0 < time_min ) + { repeat = std::max(size_t(1), 2 * repeat); + s0 = elapsed_seconds(); + test(test_size, repeat); + s1 = elapsed_seconds(); + } + double time = (s1 - s0) / double(repeat); + return time; +} + +} // END_CPPAD_NAMESPACE + +# undef CPPAD_EXTRA_RUN_BEFORE_TIMING +// END PROGRAM +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/to_string.hpp cppad-2016.00.00.1/cppad/utility/to_string.hpp --- cppad-2015.00.00.9/cppad/utility/to_string.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/to_string.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,172 @@ +// $Id$ +# ifndef CPPAD_TO_STRING_HPP +# define CPPAD_TO_STRING_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin to_string$$ +$spell + cppad.hpp + long long + std + const + ostringstream +$$ + +$section Convert Certain Types to a String$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%s% = to_string(%value%)%$$. + +$head See Also$$ +$cref base_to_string$$, $cref ad_to_string$$ + +$head Purpose$$ +This routine is similar to the C++11 routine $code std::to_string$$ +with the following differences: +$list number$$ +It works with C++98. +$lnext +It has been extended to the fundamental floating point types. +$lnext +It has specifications for extending to an arbitrary type; see +$cref base_to_string$$. +$lnext +If $code $$ is included, +and it has been extended to a $icode Base$$ type, +it automatically extends to the +$cref/AD types above Base/glossary/AD Type Above Base/$$. +$lend + +$head value$$ + +$subhead Integer$$ +The argument $icode value$$ can have the following prototype +$codei% + const %Integer%& %value% +%$$ +where $icode Integer$$ is any of the fundamental integer types; e.g., +$code short int$$ and $code unsigned long$$. +Note that if C++11 is supported by this compilation, +$code unsigned long long$$ is also a fundamental integer type. + +$subhead Float$$ +The argument $icode value$$ can have the following prototype +$codei% + const %Float%& %value% +%$$ +where $icode Float$$ is any of the fundamental floating point types; i.e., +$code float$$, $code double$$, and $code long double$$. + +$head s$$ +The return value has prototype +$codei% + std::string %s% +%$$ +and contains a representation of the specified $icode value$$. + +$subhead Integer$$ +If $icode value$$ is an $codei Integer$$, +the representation is equivalent to $codei%os% << %value%$$ +where $icode os$$ is an $code std::ostringstream$$. + +$subhead Float$$ +If $icode value$$ is a $codei Float$$, +enough digits are used in the representation so that +the result is accurate to withing round off error. + +$children% + example/to_string.cpp +%$$ +$head Example$$ +The file $cref to_string.cpp$$ +contains an example and test of this routine. +It returns true if it succeeds and false otherwise. + +$end +*/ +# include +# include +# include +# include +# include + +# define CPPAD_SPECIALIZE_TO_STRING_INTEGER(Type) \ +template <> struct to_string_struct\ +{ std::string operator()(const Type& value) \ + { std::stringstream os;\ + os << value;\ + return os.str();\ + }\ +}; + +# define CPPAD_SPECIALIZE_TO_STRING_FLOAT(Float) \ +template <> struct to_string_struct\ +{ std::string operator()(const Float& value) \ + { std::stringstream os;\ + Float epsilon = std::numeric_limits::epsilon();\ + size_t n_digits = 1 - int( std::log10(epsilon) );\ + os << std::setprecision(n_digits);\ + os << value;\ + return os.str();\ + }\ +}; + +namespace CppAD { + + // Default implementation, + // each type must define its own specilization. + template + struct to_string_struct + { std::string operator()(const Type& value) + { CPPAD_ASSERT_KNOWN( + false, + "to_string is not implemented for this type" + ); + // return empty string + return std::string(""); + } + }; + + // specialization for the fundamental integer types + CPPAD_SPECIALIZE_TO_STRING_INTEGER(signed short) + CPPAD_SPECIALIZE_TO_STRING_INTEGER(unsigned short) + // + CPPAD_SPECIALIZE_TO_STRING_INTEGER(signed int) + CPPAD_SPECIALIZE_TO_STRING_INTEGER(unsigned int) + // + CPPAD_SPECIALIZE_TO_STRING_INTEGER(signed long) + CPPAD_SPECIALIZE_TO_STRING_INTEGER(unsigned long) + // +# if CPPAD_USE_CPLUSPLUS_2011 + CPPAD_SPECIALIZE_TO_STRING_INTEGER(signed long long) + CPPAD_SPECIALIZE_TO_STRING_INTEGER(unsigned long long) +# endif + + // specialization for the fundamental floating point types + CPPAD_SPECIALIZE_TO_STRING_FLOAT(float) + CPPAD_SPECIALIZE_TO_STRING_FLOAT(double) + CPPAD_SPECIALIZE_TO_STRING_FLOAT(long double) + + // link from function to function object in structure + template + std::string to_string(const Type& value) + { to_string_struct to_str; + return to_str(value); + } +} + +# undef CPPAD_SPECIALIZE_TO_STRING_FLOAT +# undef CPPAD_SPECIALIZE_TO_STRING_INTEGER +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/track_new_del.hpp cppad-2016.00.00.1/cppad/utility/track_new_del.hpp --- cppad-2015.00.00.9/cppad/utility/track_new_del.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/track_new_del.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,543 @@ +// $Id: track_new_del.hpp 3769 2015-12-29 16:13:16Z bradbell $ +# ifndef CPPAD_TRACK_NEW_DEL_HPP +# define CPPAD_TRACK_NEW_DEL_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin TrackNewDel$$ +$spell + cppad.hpp + Cpp + newptr + Vec + oldptr + newlen + ncopy + const +$$ + +$section Routines That Track Use of New and Delete$$ +$mindex memory NDEBUG CPPAD_TRACK_NEW_VEC CppADTrackNewVec CPPAD_TRACK_DEL_VEC CppADTrackDelVec CPPAD_TRACK_EXTEND CppADTrackExtend CPPAD_TRACK_COUNT thread multi$$ + +$head Deprecated 2007-07-23$$ +All these routines have been deprecated. +You should use the $cref thread_alloc$$ memory allocator instead +(which works better in both a single thread and +properly in multi-threading environment). + +$head Syntax$$ +$codei%# include +%$$ +$icode%newptr% = TrackNewVec(%file%, %line%, %newlen%, %oldptr%) +%$$ +$codei%TrackDelVec(%file%, %line%, %oldptr%) +%$$ +$icode%newptr% = TrackExtend(%file%, %line%, %newlen%, %ncopy%, %oldptr%) +%$$ +$icode%count% = TrackCount(%file%, %line%)%$$ + + +$head Purpose$$ +These routines +aid in the use of $code new[]$$ and $code delete[]$$ +during the execution of a C++ program. + +$head Include$$ +The file $code cppad/track_new_del.hpp$$ is included by +$code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of the +CppAD include files. + + +$head file$$ +The argument $icode file$$ has prototype +$codei% + const char *%file% +%$$ +It should be the source code file name +where the call to $code TrackNew$$ is located. +The best way to accomplish this is the use the preprocessor symbol +$code __FILE__$$ for this argument. + +$head line$$ +The argument $icode line$$ has prototype +$codei% + int %line% +%$$ +It should be the source code file line number +where the call to $code TrackNew$$ is located. +The best way to accomplish this is the use the preprocessor symbol +$code __LINE__$$ for this argument. + +$head oldptr$$ +The argument $icode oldptr$$ has prototype +$codei% + %Type% *%oldptr% +%$$ +This argument is used to identify the type $icode Type$$. + +$head newlen$$ +The argument $icode newlen$$ has prototype +$codei% + size_t %newlen% +%$$ + +$head head newptr$$ +The return value $icode newptr$$ has prototype +$codei% + %Type% *%newptr% +%$$ +It points to the newly allocated vector of objects +that were allocated using +$codei% + new Type[%newlen%] +%$$ + +$head ncopy$$ +The argument $icode ncopy$$ has prototype +$codei% + size_t %ncopy% +%$$ +This specifies the number of elements that are copied from +the old array to the new array. +The value of $icode ncopy$$ +must be less than or equal $icode newlen$$. + +$head TrackNewVec$$ +If $code NDEBUG$$ is defined, this routine only sets +$codei% + %newptr% = %Type% new[%newlen%] +%$$ +The value of $icode oldptr$$ does not matter +(except that it is used to identify $icode Type$$). +If $code NDEBUG$$ is not defined, $code TrackNewVec$$ also +tracks the this memory allocation. +In this case, if memory cannot be allocated +$cref ErrorHandler$$ is used to generate a message +stating that there was not sufficient memory. + +$subhead Macro$$ +The preprocessor macro call +$codei% + CPPAD_TRACK_NEW_VEC(%newlen%, %oldptr%) +%$$ +expands to +$codei% + CppAD::TrackNewVec(__FILE__, __LINE__, %newlen%, %oldptr%) +%$$ + +$subhead Previously Deprecated$$ +The preprocessor macro $code CppADTrackNewVec$$ is the +same as $code CPPAD_TRACK_NEW_VEC$$ and was previously deprecated. + +$head TrackDelVec$$ +This routine is used to a vector of objects +that have been allocated using $code TrackNew$$ or $code TrackExtend$$. +If $code NDEBUG$$ is defined, this routine only frees memory with +$codei% + delete [] %oldptr% +%$$ +If $code NDEBUG$$ is not defined, $code TrackDelete$$ also checks that +$icode oldptr$$ was allocated by $code TrackNew$$ or $code TrackExtend$$ +and has not yet been freed. +If this is not the case, +$cref ErrorHandler$$ is used to generate an error message. + +$subhead Macro$$ +The preprocessor macro call +$codei% + CPPAD_TRACK_DEL_VEC(%oldptr%) +%$$ +expands to +$codei% + CppAD::TrackDelVec(__FILE__, __LINE__, %oldptr%) +%$$ + +$subhead Previously Deprecated$$ +The preprocessor macro $code CppADTrackDelVec$$ is the +same as $code CPPAD_TRACK_DEL_VEC$$ was previously deprecated. + +$head TrackExtend$$ +This routine is used to +allocate a new vector (using $code TrackNewVec$$), +copy $icode ncopy$$ elements from the old vector to the new vector. +If $icode ncopy$$ is greater than zero, $icode oldptr$$ +must have been allocated using $code TrackNewVec$$ or $code TrackExtend$$. +In this case, the vector pointed to by $icode oldptr$$ +must be have at least $icode ncopy$$ elements +and it will be deleted (using $code TrackDelVec$$). +Note that the dependence of $code TrackExtend$$ on $code NDEBUG$$ +is indirectly through the routines $code TrackNewVec$$ and +$code TrackDelVec$$. + +$subhead Macro$$ +The preprocessor macro call +$codei% + CPPAD_TRACK_EXTEND(%newlen%, %ncopy%, %oldptr%) +%$$ +expands to +$codei% + CppAD::TrackExtend(__FILE__, __LINE__, %newlen%, %ncopy%, %oldptr%) +%$$ + +$subhead Previously Deprecated$$ +The preprocessor macro $code CppADTrackExtend$$ is the +same as $code CPPAD_TRACK_EXTEND$$ and was previously deprecated. + +$head TrackCount$$ +The return value $icode count$$ has prototype +$codei% + size_t %count% +%$$ +If $code NDEBUG$$ is defined, $icode count$$ will be zero. +Otherwise, it will be +the number of vectors that +have been allocated +(by $code TrackNewVec$$ or $code TrackExtend$$) +and not yet freed +(by $code TrackDelete$$). + +$subhead Macro$$ +The preprocessor macro call +$codei% + CPPAD_TRACK_COUNT() +%$$ +expands to +$codei% + CppAD::TrackCount(__FILE__, __LINE__) +%$$ + +$subhead Previously Deprecated$$ +The preprocessor macro $code CppADTrackCount$$ is the +same as $code CPPAD_TRACK_COUNT$$ and was previously deprecated. + +$head Multi-Threading$$ +These routines cannot be used $cref/in_parallel/ta_in_parallel/$$ +execution mode. +Use the $cref thread_alloc$$ routines instead. + +$head Example$$ +$children% + test_more/track_new_del.cpp +%$$ +The file $cref TrackNewDel.cpp$$ +contains an example and test of these functions. +It returns true, if it succeeds, and false otherwise. + +$end +------------------------------------------------------------------------------ +*/ +# include +# include +# include +# include +# include + +# ifndef CPPAD_TRACK_DEBUG +# define CPPAD_TRACK_DEBUG 0 +# endif + +// ------------------------------------------------------------------------- +# define CPPAD_TRACK_NEW_VEC(newlen, oldptr) \ + CppAD::TrackNewVec(__FILE__, __LINE__, newlen, oldptr) + +# define CPPAD_TRACK_DEL_VEC(oldptr) \ + CppAD::TrackDelVec(__FILE__, __LINE__, oldptr) + +# define CPPAD_TRACK_EXTEND(newlen, ncopy, oldptr) \ + CppAD::TrackExtend(__FILE__, __LINE__, newlen, ncopy, oldptr) + +# define CPPAD_TRACK_COUNT() \ + CppAD::TrackCount(__FILE__, __LINE__) +// ------------------------------------------------------------------------- +# define CppADTrackNewVec CPPAD_TRACK_NEW_VEC +# define CppADTrackDelVec CPPAD_TRACK_DEL_VEC +# define CppADTrackExtend CPPAD_TRACK_EXTEND +# define CppADTrackCount CPPAD_TRACK_COUNT +// ------------------------------------------------------------------------- +namespace CppAD { // Begin CppAD namespace + +// TrackElement ------------------------------------------------------------ +class TrackElement { + +public: + std::string file; // corresponding file name + int line; // corresponding line number + void *ptr; // value returned by TrackNew + TrackElement *next; // next element in linked list + + // default contructor (used to initialize root) + TrackElement(void) + : file(""), line(0), ptr(CPPAD_NULL), next(CPPAD_NULL) + { } + + TrackElement(const char *f, int l, void *p) + : file(f), line(l), ptr(p), next(CPPAD_NULL) + { CPPAD_ASSERT_UNKNOWN( p != CPPAD_NULL); + } + + // There is only one tracking list and it starts it here + static TrackElement *Root(void) + { CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); + static TrackElement root; + return &root; + } + + // Print one tracking element + static void Print(TrackElement* E) + { + CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); + using std::cout; + cout << "E = " << E; + cout << ", E->next = " << E->next; + cout << ", E->ptr = " << E->ptr; + cout << ", E->line = " << E->line; + cout << ", E->file = " << E->file; + cout << std::endl; + } + + // Print the linked list for a thread + static void Print(void) + { + CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); + using std::cout; + using std::endl; + TrackElement *E = Root(); + // convert int(size_t) to avoid warning on _MSC_VER systems + cout << "Begin Track List" << endl; + while( E->next != CPPAD_NULL ) + { E = E->next; + Print(E); + } + cout << "End Track List:" << endl; + cout << endl; + } +}; + + +// TrackError ---------------------------------------------------------------- +inline void TrackError( + const char *routine, + const char *file, + int line, + const char *msg ) +{ + CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); + std::ostringstream buf; + buf << routine + << ": at line " + << line + << " in file " + << file + << std::endl + << msg; + std::string str = buf.str(); + size_t n = str.size(); + size_t i; + char *message = new char[n + 1]; + for(i = 0; i < n; i++) + message[i] = str[i]; + message[n] = '\0'; + CPPAD_ASSERT_KNOWN( false , message); +} + +// TrackNewVec --------------------------------------------------------------- +# ifdef NDEBUG +template +inline Type *TrackNewVec( + const char *file, int line, size_t len, Type * /* oldptr */ ) +{ +# if CPPAD_TRACK_DEBUG + static bool first = true; + if( first ) + { std::cout << "NDEBUG is defined for TrackNewVec" << std::endl; + first = false; + } +# endif + return (new Type[len]); +} + +# else + +template +Type *TrackNewVec( + const char *file , + int line , + size_t len , + Type * /* oldptr */ ) +{ + CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "attempt to use TrackNewVec in parallel execution mode." + ); + // try to allocate the new memrory + Type *newptr = CPPAD_NULL; + try + { newptr = new Type[len]; + } + catch(...) + { TrackError("TrackNewVec", file, line, + "Cannot allocate sufficient memory" + ); + } + // create tracking element + void *vptr = static_cast(newptr); + TrackElement *E = new TrackElement(file, line, vptr); + + // get the root + TrackElement *root = TrackElement::Root(); + + // put this elemenent at the front of linked list + E->next = root->next; + root->next = E; + +# if CPPAD_TRACK_DEBUG + std::cout << "TrackNewVec: "; + TrackElement::Print(E); +# endif + + return newptr; +} + +# endif + +// TrackDelVec -------------------------------------------------------------- +# ifdef NDEBUG +template +inline void TrackDelVec(const char *file, int line, Type *oldptr) +{ +# if CPPAD_TRACK_DEBUG + static bool first = true; + if( first ) + { std::cout << "NDEBUG is defined in TrackDelVec" << std::endl; + first = false; + } +# endif + delete [] oldptr; +} + +# else + +template +void TrackDelVec( + const char *file , + int line , + Type *oldptr ) +{ + CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "attempt to use TrackDelVec in parallel execution mode." + ); + TrackElement *P; + TrackElement *E; + + // search list for pointer + P = TrackElement::Root(); + E = P->next; + void *vptr = static_cast(oldptr); + while(E != CPPAD_NULL && E->ptr != vptr) + { P = E; + E = E->next; + } + + // check if pointer was not in list + if( E == CPPAD_NULL || E->ptr != vptr ) TrackError( + "TrackDelVec", file, line, + "Invalid value for the argument oldptr.\n" + "Possible linking of debug and NDEBUG compilations of CppAD." + ); + +# if CPPAD_TRACK_DEBUG + std::cout << "TrackDelVec: "; + TrackElement::Print(E); +# endif + + // remove tracking element from list + P->next = E->next; + + // delete allocated pointer + delete [] oldptr; + + // delete tracking element + delete E; + + return; +} + +# endif + +// TrackExtend -------------------------------------------------------------- +template +Type *TrackExtend( + const char *file , + int line , + size_t newlen , + size_t ncopy , + Type *oldptr ) +{ + CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "attempt to use TrackExtend in parallel execution mode." + ); + +# if CPPAD_TRACK_DEBUG + using std::cout; + cout << "TrackExtend: file = " << file; + cout << ", line = " << line; + cout << ", newlen = " << newlen; + cout << ", ncopy = " << ncopy; + cout << ", oldptr = " << oldptr; + cout << std::endl; +# endif + CPPAD_ASSERT_KNOWN( + ncopy <= newlen, + "TrackExtend: ncopy is greater than newlen." + ); + + // allocate the new memrory + Type *newptr = TrackNewVec(file, line, newlen, oldptr); + + // copy the data + size_t i; + for(i = 0; i < ncopy; i++) + newptr[i] = oldptr[i]; + + // delete the old vector + if( ncopy > 0 ) + TrackDelVec(file, line, oldptr); + + return newptr; +} + +// TrackCount -------------------------------------------------------------- +inline size_t TrackCount(const char *file, int line) +{ + CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "attempt to use TrackCount in parallel execution mode." + ); + size_t count = 0; + TrackElement *E = TrackElement::Root(); + while( E->next != CPPAD_NULL ) + { ++count; + E = E->next; + } + return count; +} +// --------------------------------------------------------------------------- + +} // End CppAD namespace + +// preprocessor symbols local to this file +# undef CPPAD_TRACK_DEBUG + +# endif diff -Nru cppad-2015.00.00.9/cppad/utility/vector.hpp cppad-2016.00.00.1/cppad/utility/vector.hpp --- cppad-2015.00.00.9/cppad/utility/vector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility/vector.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,915 @@ +// $Id: vector.hpp 3766 2015-12-08 23:12:56Z bradbell $ +# ifndef CPPAD_VECTOR_HPP +# define CPPAD_VECTOR_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin CppAD_vector$$ +$spell + rvalues + thread_alloc + cppad.hpp + Bool + resize + cout + endl + std + Cpp + const + vec + ostream + elem +$$ + + +$section The CppAD::vector Template Class$$ +$mindex vector CppAD [] push thread_alloc$$ + +$head Syntax$$ +$code%# include $$ + +$head Description$$ +The include file $code cppad/vector.hpp$$ defines the +vector template class $code CppAD::vector$$. +This is a $cref SimpleVector$$ template class and in addition +it has the features listed below: + +$head Include$$ +The file $code cppad/vector.hpp$$ is included by $code cppad/cppad.hpp$$ +but it can also be included separately with out the rest of the +CppAD include files. + +$head capacity$$ +If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$, +and $icode cap$$ is a $code size_t$$ object, +$codei% + %cap% = %x%.capacity() +%$$ +set $icode cap$$ to the number of $icode Scalar$$ objects that +could fit in the memory currently allocated for $icode x$$. +Note that +$codei% + %x%.size() <= %x%.capacity() +%$$ + +$head Assignment$$ +If $icode x$$ and $icode y$$ are +$codei%CppAD::vector<%Scalar%>%$$ objects, +$codei% + %y% = %x% +%$$ +has all the properties listed for a +$cref/simple vector assignment/SimpleVector/Assignment/$$ +plus the following: + +$subhead Check Size$$ +The $code CppAD::vector$$ template class will check that +the size of $icode x$$ is either zero or the size of $icode y$$ +before doing the assignment. +If this is not the case, $code CppAD::vector$$ will use +$cref ErrorHandler$$ +to generate an appropriate error report. +Allowing for assignment to a vector with size zero makes the following +code work: +$codei% + CppAD::vector<%Scalar%> %y%; + %y% = %x%; +%$$ + +$subhead Return Reference$$ +A reference to the vector $icode y$$ is returned. +An example use of this reference is in multiple assignments of the form +$codei% + %z% = %y% = %x% +%$$ + +$subhead Move Semantics$$ +If the C++ compiler supports move semantic rvalues using the $code &&$$ +syntax, then it will be used during the vector assignment statement. +This means that return values and other temporaries are not be copied, +but rather pointers are transferred. + +$head Element Access$$ +If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object +and $code i$$ has type $code size_t$$, +$codei% + %x%[%i%] +%$$ +has all the properties listed for a +$cref/simple vector element access/SimpleVector/Element Access/$$ +plus the following: +$pre + +$$ +The object $icode%x%[%i%]%$$ has type $icode Scalar$$ +(is not possibly a different type that can be converted to $icode Scalar$$). +$pre + +$$ +If $icode i$$ is not less than the size of the $icode x$$, +$code CppAD::vector$$ will use +$cref ErrorHandler$$ +to generate an appropriate error report. + +$head push_back$$ +If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object +with size equal to $icode n$$ and +$icode s$$ has type $icode Scalar$$, +$codei% + %x%.push_back(%s%) +%$$ +extends the vector $icode x$$ so that its new size is $icode n$$ plus one +and $icode%x%[%n%]%$$ is equal to $icode s$$ +(equal in the sense of the $icode Scalar$$ assignment operator). + +$head push_vector$$ +If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object +with size equal to $icode n$$ and +$icode v$$ is a $cref/simple vector/SimpleVector/$$ +with elements of type $icode Scalar$$ and size $icode m$$, +$codei% + %x%.push_vector(%v%) +%$$ +extends the vector $icode x$$ so that its new size is $icode%n%+%m%$$ +and $icode%x%[%n% + %i%]%$$ is equal to $icode%v%[%i%]%$$ +for $icode%i = 1 , ... , m-1%$$ +(equal in the sense of the $icode Scalar$$ assignment operator). + +$head Output$$ +If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object +and $icode os$$ is an $code std::ostream$$, +and the operation +$codei% + %os% << %x% +%$$ +will output the vector $icode x$$ to the standard +output stream $icode os$$. +The elements of $icode x$$ are enclosed at the beginning by a +$code {$$ character, +they are separated by $code ,$$ characters, +and they are enclosed at the end by $code }$$ character. +It is assumed by this operation that if $icode e$$ +is an object with type $icode Scalar$$, +$codei% + %os% << %e% +%$$ +will output the value $icode e$$ to the standard +output stream $icode os$$. + +$head resize$$ +The call $icode%x%.resize(%n%)%$$ set the size of $icode x$$ equal to +$icode n$$. +If $icode%n% <= %x%.capacity()%$$, +no memory is freed or allocated, the capacity of $icode x$$ does not change, +and the data in $icode x$$ is preserved. +If $icode%n% > %x%.capacity()%$$, +new memory is allocated and the data in $icode x$$ is lost +(not copied to the new memory location). + +$head clear$$ +All memory allocated for the vector is freed +and both its size and capacity are set to zero. +The can be useful when using very large vectors +and when checking for memory leaks (and there are global vectors) +see the $cref/memory/CppAD_vector/Memory and Parallel Mode/$$ discussion. + +$head data$$ +If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object +$codei% + %x%.data() +%$$ +returns a pointer to a $icode Scalar$$ object such that for +$codei%0 <= %i% < %x%.size()%$$, +$icode%x%[%i%]%$$ and $icode%x%.data()[%i%]%$$ +are the same $icode Scalar$$ object. +If $icode x$$ is $code const$$, the pointer is $code const$$. +If $icode%x%.capacity()%$$ is zero, the value of the pointer is not defined. +The pointer may no longer be valid after the following operations on +$icode x$$: +its destructor, +$code clear$$, +$code resize$$, +$code push_back$$, +$code push_vector$$, +assignment to another vector when original size of $icode x$$ is zero. + +$head vectorBool$$ +The file $code $$ also defines the class +$code CppAD::vectorBool$$. +This has the same specifications as $code CppAD::vector$$ +with the following exceptions: + +$subhead Memory$$ +The class $code vectorBool$$ conserves on memory +(on the other hand, $code CppAD::vector$$ is expected to be faster +than $code vectorBool$$). + +$subhead bit_per_unit$$ +The static function call +$codei% + %s% = vectorBool::bit_per_unit() +%$$ +returns the $code size_t$$ value $icode s$$ +which is equal to the number of boolean values (bits) that are +packed into one operational unit. +For example, a logical $code or$$ +acts on this many boolean values with one operation. + +$subhead data$$ +The $cref/data/CppAD_vector/data/$$ function is not supported by +$code vectorBool$$. + +$subhead Output$$ +The $code CppAD::vectorBool$$ output operator +prints each boolean value as +a $code 0$$ for false, +a $code 1$$ for true, +and does not print any other output; i.e., +the vector is written a long sequence of zeros and ones with no +surrounding $code {$$, $code }$$ and with no separating commas or spaces. + +$subhead Element Type$$ +If $icode x$$ has type $code vectorBool$$ +and $icode i$$ has type $code size_t$$, +the element access value $icode%x%[%i%]%$$ has an unspecified type, +referred to here as $icode elementType$$, that supports the following +operations: + +$list number$$ +$icode elementType$$ can be converted to $code bool$$; e.g. +the following syntax is supported: +$codei% + static_cast( %x%[%i%] ) +%$$ + +$lnext +$icode elementType$$ supports the assignment operator $code =$$ where the +right hand side is a $code bool$$ or an $icode elementType$$ object; e.g., +if $icode y$$ has type $code bool$$, the following syntax is supported: +$codei% + %x%[%i%] = %y% +%$$ + +$lnext +The result of an assignment to an $icode elementType$$ +also has type $icode elementType$$. +Thus, if $icode z$$ has type $code bool$$, the following syntax is supported: +$codei% + %z% = %x%[%i%] = %y% +%$$ +$lend + +$head Memory and Parallel Mode$$ +These vectors use the multi-threaded fast memory allocator +$cref thread_alloc$$: + +$list number$$ +The routine $cref/parallel_setup/ta_parallel_setup/$$ must +be called before these vectors can be used +$cref/in parallel/ta_in_parallel/$$. +$lnext +Using these vectors affects the amount of memory +$cref/in_use/ta_inuse/$$ and $cref/available/ta_available/$$. +$lnext +Calling $cref/clear/CppAD_vector/clear/$$, +makes the corresponding memory available (though $code thread_alloc$$) +to the current thread. +$lnext +Available memory +can then be completely freed using $cref/free_available/ta_free_available/$$. +$lend + +$head Example$$ +$children% + example/cppad_vector.cpp% + example/vector_bool.cpp +%$$ +The files +$cref cppad_vector.cpp$$ and +$cref vector_bool.cpp$$ each +contain an example and test of this template class. +They return true if they succeed and false otherwise. + +$head Exercise$$ +Create and run a program that contains the following code: +$codep + CppAD::vector x(3); + size_t i; + for(i = 0; i < 3; i++) + x[i] = 4. - i; + std::cout << "x = " << x << std::endl; +$$ + +$end + + +$end + +------------------------------------------------------------------------ +*/ + +# include +# include +# include +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file vector.hpp +File used to define CppAD::vector and CppAD::vectorBool +*/ + +// --------------------------------------------------------------------------- +/*! +The CppAD Simple Vector template class. +*/ +template +class vector { +private: + /// maximum number of Type elements current allocation can hold + size_t capacity_; + /// number of Type elements currently in this vector + size_t length_; + /// pointer to the first type elements + /// (not defined and should not be used when capacity_ = 0) + Type* data_; + /// delete data pointer + void delete_data(Type* data_ptr) + { thread_alloc::delete_array(data_ptr); } +public: + /// type of the elements in the vector + typedef Type value_type; + + /// default constructor sets capacity_ = length_ = data_ = 0 + inline vector(void) + : capacity_(0), length_(0), data_(CPPAD_NULL) + { } + /// sizing constructor + inline vector( + /// number of elements in this vector + size_t n + ) : capacity_(0), length_(0), data_(CPPAD_NULL) + { resize(n); } + + /// copy constructor + inline vector( + /// the *this vector will be a copy of \c x + const vector& x + ) : capacity_(0), length_(0), data_(CPPAD_NULL) + { resize(x.length_); + + // copy the data + for(size_t i = 0; i < length_; i++) + data_[i] = x.data_[i]; + } + /// destructor + ~vector(void) + { if( capacity_ > 0 ) + delete_data(data_); + } + + /// maximum number of elements current allocation can store + inline size_t capacity(void) const + { return capacity_; } + + /// number of elements currently in this vector. + inline size_t size(void) const + { return length_; } + + /// raw pointer to the data + inline Type* data(void) + { return data_; } + + /// const raw pointer to the data + inline const Type* data(void) const + { return data_; } + + /// change the number of elements in this vector. + inline void resize( + /// new number of elements for this vector + size_t n + ) + { length_ = n; + + // check if we can use current memory + if( capacity_ >= length_ ) + return; + + // check if there is old memory to be freed + if( capacity_ > 0 ) + delete_data(data_); + + // get new memory and set capacity + data_ = thread_alloc::create_array(length_, capacity_); + } + + /// free memory and set number of elements to zero + inline void clear(void) + { length_ = 0; + // check if there is old memory to be freed + if( capacity_ > 0 ) + delete_data(data_); + capacity_ = 0; + } + + /// vector assignment operator + inline vector& operator=( + /// right hand size of the assingment operation + const vector& x + ) + { size_t i; + // If original lenght is zero, then resize it. + // Otherwise a length mismatch is an error. + if( length_ == 0 ) + resize( x.length_ ); + CPPAD_ASSERT_KNOWN( + length_ == x.length_ , + "vector: size miss match in assignment operation" + ); + for(i = 0; i < length_; i++) + data_[i] = x.data_[i]; + return *this; + } +# if CPPAD_USE_CPLUSPLUS_2011 + /// vector assignment operator with move semantics + inline vector& operator=( + /// right hand size of the assingment operation + vector&& x + ) + { CPPAD_ASSERT_KNOWN( + length_ == x.length_ || (length_ == 0), + "vector: size miss match in assignment operation" + ); + if( this != &x ) + { clear(); + // + length_ = x.length_; + capacity_ = x.capacity_; + data_ = x.data_; + // + x.length_ = 0; + x.capacity_ = 0; + x.data_ = CPPAD_NULL; + } + return *this; + } +# endif + /// non-constant element access; i.e., we can change this element value + Type& operator[]( + /// element index, must be less than length + size_t i + ) + { CPPAD_ASSERT_KNOWN( + i < length_, + "vector: index greater than or equal vector size" + ); + return data_[i]; + } + /// constant element access; i.e., we cannot change this element value + const Type& operator[]( + /// element index, must be less than length + size_t i + ) const + { CPPAD_ASSERT_KNOWN( + i < length_, + "vector: index greater than or equal vector size" + ); + return data_[i]; + } + /// add an element to the back of this vector + void push_back( + /// value of the element + const Type& s + ) + { // case where no allocation is necessary + if( length_ + 1 <= capacity_ ) + { data_[length_++] = s; + return; + } + CPPAD_ASSERT_UNKNOWN( length_ == capacity_ ); + + // store old length, capacity and data + size_t old_length = length_; + size_t old_capacity = capacity_; + Type* old_data = data_; + + // set the new length, capacity and data + length_ = 0; + capacity_ = 0; + resize(old_length + 1); + + // copy old data values + for(size_t i = 0; i < old_length; i++) + data_[i] = old_data[i]; + + // put the new element in the vector + CPPAD_ASSERT_UNKNOWN( old_length + 1 <= capacity_ ); + data_[old_length] = s; + + // free old data + if( old_capacity > 0 ) + delete_data(old_data); + + CPPAD_ASSERT_UNKNOWN( old_length + 1 == length_ ); + CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); + } + + /*! add vector to the back of this vector + (we could not use push_back becasue MS V++ 7.1 did not resolve + to non-template member function when scalar is used.) + */ + template + void push_vector( + /// value of the vector that we are adding + const Vector& v + ) + { CheckSimpleVector(); + size_t m = v.size(); + + // case where no allcoation is necessary + if( length_ + m <= capacity_ ) + { for(size_t i = 0; i < m; i++) + data_[length_++] = v[i]; + return; + } + + // store old length, capacity and data + size_t old_length = length_; + size_t old_capacity = capacity_; + Type* old_data = data_; + + // set new length, capacity and data + length_ = 0; + capacity_ = 0; + resize(old_length + m); + + // copy old data values + for(size_t i = 0; i < old_length; i++) + data_[i] = old_data[i]; + + // put the new elements in the vector + CPPAD_ASSERT_UNKNOWN( old_length + m <= capacity_ ); + for(size_t i = 0; i < m; i++) + data_[old_length + i] = v[i]; + + // free old data + if( old_capacity > 0 ) + delete_data(old_data); + + CPPAD_ASSERT_UNKNOWN( old_length + m == length_ ); + CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); + } +}; + +/// output a vector +template +inline std::ostream& operator << ( + /// stream to write the vector to + std::ostream& os , + /// vector that is output + const CppAD::vector& vec ) +{ size_t i = 0; + size_t n = vec.size(); + + os << "{ "; + while(i < n) + { os << vec[i++]; + if( i < n ) + os << ", "; + } + os << " }"; + return os; +} + +// --------------------------------------------------------------------------- +/*! +Class that is used to hold a non-constant element of a vector. +*/ +class vectorBoolElement { + /// the boolean data is packed with sizeof(UnitType) bits per value + typedef size_t UnitType; +private: + /// pointer to the UnitType value holding this eleemnt + UnitType* unit_; + /// mask for the bit corresponding to this element + /// (all zero except for bit that corresponds to this element) + UnitType mask_; +public: + /// constructor from member values + vectorBoolElement( + /// unit for this element + UnitType* unit , + /// mask for this element + UnitType mask ) + : unit_(unit) , mask_(mask) + { } + /// constuctor from another element + vectorBoolElement( + /// other element + const vectorBoolElement& e ) + : unit_(e.unit_) , mask_(e.mask_) + { } + /// conversion to a boolean value + operator bool() const + { return (*unit_ & mask_) != 0; } + /// assignment of this element to a bool + vectorBoolElement& operator=( + /// right hand side for assignment + bool bit + ) + { if(bit) + *unit_ |= mask_; + else *unit_ &= ~mask_; + return *this; + } + /// assignment of this element to another element + vectorBoolElement& operator=(const vectorBoolElement& e) + { if( *(e.unit_) & e.mask_ ) + *unit_ |= mask_; + else *unit_ &= ~mask_; + return *this; + } +}; + +class vectorBool { + /// the boolean data is packed with sizeof(UnitType) bits per value + typedef size_t UnitType; +private: + /// number of bits packed into each UnitType value in data_ + static const size_t bit_per_unit_ + = std::numeric_limits::digits; + /// number of UnitType values in data_ + size_t n_unit_; + /// number of bits currently stored in this vector + size_t length_; + /// pointer to where the bits are stored + UnitType *data_; + + /// minimum number of UnitType values that can store length_ bits + /// (note that this is really a function of length_) + size_t unit_min(void) + { if( length_ == 0 ) + return 0; + return (length_ - 1) / bit_per_unit_ + 1; + } +public: + /// type corresponding to the elements of this vector + /// (note that non-const elements actually use vectorBoolElement) + typedef bool value_type; + + // static member function + static size_t bit_per_unit(void) + { return bit_per_unit_; } + + /// default constructor (sets all member data to zero) + inline vectorBool(void) : n_unit_(0), length_(0), data_(CPPAD_NULL) + { } + /// sizing constructor + inline vectorBool( + /// number of bits in this vector + size_t n + ) : n_unit_(0), length_(n), data_(CPPAD_NULL) + { if( length_ > 0 ) + { // set n_unit and data + size_t min_unit = unit_min(); + data_ = thread_alloc::create_array(min_unit, n_unit_); + } + } + /// copy constructor + inline vectorBool( + /// the *this vector will be a copy of \c v + const vectorBool& v + ) : n_unit_(0), length_(v.length_), data_(CPPAD_NULL) + { if( length_ > 0 ) + { // set n_unit and data + size_t min_unit = unit_min(); + data_ = thread_alloc::create_array(min_unit, n_unit_); + + // copy values using UnitType assignment operator + CPPAD_ASSERT_UNKNOWN( min_unit <= v.n_unit_ ); + size_t i; + for(i = 0; i < min_unit; i++) + data_[i] = v.data_[i]; + } + } + /// destructor + ~vectorBool(void) + { if( n_unit_ > 0 ) + thread_alloc::delete_array(data_); + } + + /// number of elements in this vector + inline size_t size(void) const + { return length_; } + + /// maximum number of elements current allocation can store + inline size_t capacity(void) const + { return n_unit_ * bit_per_unit_; } + + /// change number of elements in this vector + inline void resize( + /// new number of elements for this vector + size_t n + ) + { length_ = n; + // check if we can use the current memory + size_t min_unit = unit_min(); + if( n_unit_ >= min_unit ) + return; + // check if there is old memory to be freed + if( n_unit_ > 0 ) + thread_alloc::delete_array(data_); + // get new memory and set n_unit + data_ = thread_alloc::create_array(min_unit, n_unit_); + } + + /// free memory and set number of elements to zero + inline void clear(void) + { length_ = 0; + // check if there is old memory to be freed + if( n_unit_ > 0 ) + thread_alloc::delete_array(data_); + n_unit_ = 0; + } + + /// vector assignment operator + inline vectorBool& operator=( + /// right hand size of the assingment operation + const vectorBool& v + ) + { size_t i; + // If original lenght is zero, then resize it. + // Otherwise a length mismatch is an error. + if( length_ == 0 ) + resize( v.length_ ); + CPPAD_ASSERT_KNOWN( + length_ == v.length_ , + "vectorBool: size miss match in assignment operation" + ); + size_t min_unit = unit_min(); + CPPAD_ASSERT_UNKNOWN( min_unit <= n_unit_ ); + CPPAD_ASSERT_UNKNOWN( min_unit <= v.n_unit_ ); + for(i = 0; i < min_unit; i++) + data_[i] = v.data_[i]; + return *this; + } +# if CPPAD_USE_CPLUSPLUS_2011 + /// vector assignment operator with move semantics + inline vectorBool& operator=( + /// right hand size of the assingment operation + vectorBool&& x + ) + { CPPAD_ASSERT_KNOWN( + length_ == x.length_ || (length_ == 0), + "vectorBool: size miss match in assignment operation" + ); + if( this != &x ) + { clear(); + // + length_ = x.length_; + n_unit_ = x.n_unit_; + data_ = x.data_; + // + x.length_ = 0; + x.n_unit_ = 0; + x.data_ = CPPAD_NULL; + } + return *this; + } +# endif + + + /// non-constant element access; i.e., we can change this element value + vectorBoolElement operator[]( + /// element index, must be less than length + size_t k + ) + { size_t i, j; + CPPAD_ASSERT_KNOWN( + k < length_, + "vectorBool: index greater than or equal vector size" + ); + i = k / bit_per_unit_; + j = k - i * bit_per_unit_; + return vectorBoolElement(data_ + i , UnitType(1) << j ); + } + /// constant element access; i.e., we cannot change this element value + bool operator[](size_t k) const + { size_t i, j; + UnitType unit, mask; + CPPAD_ASSERT_KNOWN( + k < length_, + "vectorBool: index greater than or equal vector size" + ); + i = k / bit_per_unit_; + j = k - i * bit_per_unit_; + unit = data_[i]; + mask = UnitType(1) << j; + return (unit & mask) != 0; + } + /// add an element to the back of this vector + void push_back( + /// value of the element + bool bit + ) + { CPPAD_ASSERT_UNKNOWN( unit_min() <= n_unit_ ); + size_t i, j; + UnitType mask; + if( length_ + 1 > n_unit_ * bit_per_unit_ ) + { CPPAD_ASSERT_UNKNOWN( unit_min() == n_unit_ ); + // store old n_unit and data values + size_t old_n_unit = n_unit_; + UnitType* old_data = data_; + // set new n_unit and data values + data_ = thread_alloc::create_array(n_unit_+1, n_unit_); + // copy old data values + for(i = 0; i < old_n_unit; i++) + data_[i] = old_data[i]; + // free old data + if( old_n_unit > 0 ) + thread_alloc::delete_array(old_data); + } + i = length_ / bit_per_unit_; + j = length_ - i * bit_per_unit_; + mask = UnitType(1) << j; + if( bit ) + data_[i] |= mask; + else data_[i] &= ~mask; + length_++; + } + /// add vector to the back of this vector + template + void push_vector( + /// value of the vector that we are adding + const Vector& v + ) + { CheckSimpleVector(); + size_t min_unit = unit_min(); + CPPAD_ASSERT_UNKNOWN( length_ <= n_unit_ * bit_per_unit_ ); + // some temporaries + size_t i, j, k, ell; + UnitType mask; + bool bit; + // store old length + size_t old_length = length_; + // new length and minium number of units; + length_ = length_ + v.size(); + min_unit = unit_min(); + if( length_ >= n_unit_ * bit_per_unit_ ) + { // store old n_unit and data value + size_t old_n_unit = n_unit_; + UnitType* old_data = data_; + // set new n_unit and data values + data_ = thread_alloc::create_array(min_unit, n_unit_); + // copy old data values + for(i = 0; i < old_n_unit; i++) + data_[i] = old_data[i]; + // free old data + if( old_n_unit > 0 ) + thread_alloc::delete_array(old_data); + } + ell = old_length; + for(k = 0; k < v.size(); k++) + { + i = ell / bit_per_unit_; + j = ell - i * bit_per_unit_; + bit = v[k]; + mask = UnitType(1) << j; + if( bit ) + data_[i] |= mask; + else data_[i] &= ~mask; + ell++; + } + CPPAD_ASSERT_UNKNOWN( length_ == ell ); + CPPAD_ASSERT_UNKNOWN( length_ <= n_unit_ * bit_per_unit_ ); + } +}; + +/// output a vector +inline std::ostream& operator << ( + /// steam to write the vector to + std::ostream& os , + /// vector that is output + const vectorBool& v ) +{ size_t i = 0; + size_t n = v.size(); + + while(i < n) + os << v[i++]; + return os; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2015.00.00.9/cppad/utility.hpp cppad-2016.00.00.1/cppad/utility.hpp --- cppad-2015.00.00.9/cppad/utility.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad/utility.hpp 2016-02-09 08:31:50.000000000 +0000 @@ -0,0 +1,41 @@ +// $Id$ +# ifndef CPPAD_UTILITY_HPP +# define CPPAD_UTILITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif diff -Nru cppad-2015.00.00.9/cppad/vector.hpp cppad-2016.00.00.1/cppad/vector.hpp --- cppad-2015.00.00.9/cppad/vector.hpp 2015-02-24 08:31:37.000000000 +0000 +++ cppad-2016.00.00.1/cppad/vector.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,875 +0,0 @@ -/* $Id: vector.hpp 3232 2014-04-27 15:38:21Z bradbell $ */ -# ifndef CPPAD_VECTOR_INCLUDED -# define CPPAD_VECTOR_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin CppAD_vector$$ -$spell - rvalues - thread_alloc - cppad.hpp - Bool - resize - cout - endl - std - Cpp - const - vec - ostream - elem -$$ - -$index vector, CppAD template class$$ -$index class, template CppAD vector$$ -$index template, CppAD vector class$$ - -$section The CppAD::vector Template Class$$ - -$head Syntax$$ -$code # include $$ - -$head Description$$ -The include file $code cppad/vector.hpp$$ defines the -vector template class $code CppAD::vector$$. -This is a $cref SimpleVector$$ template class and in addition -it has the features listed below: - -$head Include$$ -The file $code cppad/vector.hpp$$ is included by $code cppad/cppad.hpp$$ -but it can also be included separately with out the rest of the -CppAD include files. - -$head capacity$$ -If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$, -and $icode cap$$ is a $code size_t$$ object, -$codei% - %cap% = %x%.capacity() -%$$ -set $icode cap$$ to the number of $icode Scalar$$ objects that -could fit in the memory currently allocated for $icode x$$. -Note that -$codei% - %x%.size() <= %x%.capacity() -%$$ - -$head Assignment$$ -$index assignment, CppAD vector$$ -If $icode x$$ and $icode y$$ are -$codei%CppAD::vector<%Scalar%>%$$ objects, -$codei% - %y% = %x% -%$$ -has all the properties listed for a -$cref/simple vector assignment/SimpleVector/Assignment/$$ -plus the following: - -$subhead Check Size$$ -The $code CppAD::vector$$ template class will check that -the size of $icode x$$ is either zero or the size of $icode y$$ -before doing the assignment. -If this is not the case, $code CppAD::vector$$ will use -$cref ErrorHandler$$ -to generate an appropriate error report. -Allowing for assignment to a vector with size zero makes the following -code work: -$codei% - CppAD::vector<%Scalar%> %y%; - %y% = %x%; -%$$ - -$subhead Return Reference$$ -A reference to the vector $icode y$$ is returned. -An example use of this reference is in multiple assignments of the form -$codei% - %z% = %y% = %x% -%$$ - -$subhead Move Semantics$$ -If the C++ compiler supports move semantic rvalues using the $code &&$$ -syntax, then it will be used during the vector assignment statement. -This means that return values and other temporaries are not be copied, -but rather pointers are transferred. - -$head Element Access$$ -$index [], CppAD vector$$ -$index vector, [] CppAD$$ -If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object -and $code i$$ has type $code size_t$$, -$codei% - %x%[%i%] -%$$ -has all the properties listed for a -$cref/simple vector element access/SimpleVector/Element Access/$$ -plus the following: -$pre - -$$ -The object $icode%x%[%i%]%$$ has type $icode Scalar$$ -(is not possibly a different type that can be converted to $icode Scalar$$). -$pre - -$$ -If $icode i$$ is not less than the size of the $icode x$$, -$code CppAD::vector$$ will use -$cref ErrorHandler$$ -to generate an appropriate error report. - -$head push_back$$ -$index push_back, CppAD vector$$ -$index vector, CppAD push_back$$ -If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object -with size equal to $icode n$$ and -$icode s$$ has type $icode Scalar$$, -$codei% - %x%.push_back(%s%) -%$$ -extends the vector $icode x$$ so that its new size is $icode n$$ plus one -and $icode%x%[%n%]%$$ is equal to $icode s$$ -(equal in the sense of the $icode Scalar$$ assignment operator). - -$head push_vector$$ -$index push_vector, CppAD$$ -$index vector, CppAD push$$ -If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object -with size equal to $icode n$$ and -$icode v$$ is a $cref/simple vector/SimpleVector/$$ -with elements of type $icode Scalar$$ and size $icode m$$, -$codei% - %x%.push_vector(%v%) -%$$ -extends the vector $icode x$$ so that its new size is $icode%n%+%m%$$ -and $icode%x%[%n% + %i%]%$$ is equal to $icode%v%[%i%]%$$ -for $icode%i = 1 , ... , m-1%$$ -(equal in the sense of the $icode Scalar$$ assignment operator). - -$head Output$$ -If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object -and $icode os$$ is an $code std::ostream$$, -and the operation -$codei% - %os% << %x% -%$$ -will output the vector $icode x$$ to the standard -output stream $icode os$$. -The elements of $icode x$$ are enclosed at the beginning by a -$code {$$ character, -they are separated by $code ,$$ characters, -and they are enclosed at the end by $code }$$ character. -It is assumed by this operation that if $icode e$$ -is an object with type $icode Scalar$$, -$codei% - %os% << %e% -%$$ -will output the value $icode e$$ to the standard -output stream $icode os$$. - -$head resize$$ -The call $icode%x%.resize(%n%)%$$ set the size of $icode x$$ equal to -$icode n$$. -If $icode%n% <= %x%.capacity()%$$, -no memory is freed or allocated and the capacity of $icode x$$ does not change. - -$head clear$$ -All memory allocated for the vector is freed -and both its size and capacity are set to zero. -The can be useful when using very large vectors -and when checking for memory leaks (and there are global vectors) -see the $cref/memory/CppAD_vector/Memory and Parallel Mode/$$ discussion. - -$head data$$ -$index data, CppAD vector$$ -$index vector, CppAD data$$ -If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object -$codei% - %x%.data() -%$$ -returns a pointer to a $icode Scalar$$ object such that for -$codei%0 <= %i% < %x%.size()%$$, -$icode%x%[%i%]%$$ and $icode%x%.data()[%i%]%$$ -are the same $icode Scalar$$ object. -If $icode x$$ is $code const$$, the pointer is $code const$$. -If $icode%x%.capacity()%$$ is zero, the value of the pointer is not defined. -The pointer may no longer be valid after the following operations on -$icode x$$: -its destructor, -$code clear$$, -$code resize$$, -$code push_back$$, -$code push_vector$$, -assignment to another vector when original size of $icode x$$ is zero. - -$head vectorBool$$ -$index vectorBool$$ -The file $code $$ also defines the class -$code CppAD::vectorBool$$. -This has the same specifications as $code CppAD::vector$$ -with the following exceptions: - -$subhead Memory$$ -The class $code vectorBool$$ conserves on memory -(on the other hand, $code CppAD::vector$$ is expected to be faster -than $code vectorBool$$). - -$subhead data$$ -The $cref/data/CppAD_vector/data/$$ function is not supported by -$code vectorBool$$. - -$subhead Output$$ -The $code CppAD::vectorBool$$ output operator -prints each boolean value as -a $code 0$$ for false, -a $code 1$$ for true, -and does not print any other output; i.e., -the vector is written a long sequence of zeros and ones with no -surrounding $code {$$, $code }$$ and with no separating commas or spaces. - -$subhead Element Type$$ -If $icode x$$ has type $code vectorBool$$ -and $icode i$$ has type $code size_t$$, -the element access value $icode%x%[%i%]%$$ has an unspecified type, -referred to here as $icode elementType$$, that supports the following -operations: - -$list number$$ -$icode elementType$$ can be converted to $code bool$$; e.g. -the following syntax is supported: -$codei% - static_cast( %x%[%i%] ) -%$$ - -$lnext -$icode elementType$$ supports the assignment operator $code =$$ where the -right hand side is a $code bool$$ or an $icode elementType$$ object; e.g., -if $icode y$$ has type $code bool$$, the following syntax is supported: -$codei% - %x%[%i%] = %y% -%$$ - -$lnext -The result of an assignment to an $icode elementType$$ -also has type $icode elementType$$. -Thus, if $icode z$$ has type $code bool$$, the following syntax is supported: -$codei% - %z% = %x%[%i%] = %y% -%$$ -$lend - -$head Memory and Parallel Mode$$ -$index thread_alloc, vector$$ -$index vector, thread_alloc$$ -These vectors use the multi-threaded fast memory allocator -$cref thread_alloc$$: - -$list number$$ -The routine $cref/parallel_setup/ta_parallel_setup/$$ must -be called before these vectors can be used -$cref/in parallel/ta_in_parallel/$$. -$lnext -Using these vectors affects the amount of memory -$cref/in_use/ta_inuse/$$ and $cref/available/ta_available/$$. -$lnext -Calling $cref/clear/CppAD_vector/clear/$$, -makes the corresponding memory available (though $code thread_alloc$$) -to the current thread. -$lnext -Available memory -can then be completely freed using $cref/free_available/ta_free_available/$$. -$lend - -$head Example$$ -$children% - example/cppad_vector.cpp% - example/vector_bool.cpp -%$$ -The files -$cref cppad_vector.cpp$$ and -$cref vector_bool.cpp$$ each -contain an example and test of this template class. -They return true if they succeed and false otherwise. - -$head Exercise$$ -$index exercise, CppAD::vector$$ -Create and run a program that contains the following code: -$codep - CppAD::vector x(3); - size_t i; - for(i = 0; i < 3; i++) - x[i] = 4. - i; - std::cout << "x = " << x << std::endl; -$$ - -$end - - -$end - ------------------------------------------------------------------------- -*/ - -# include -# include -# include -# include -# include -# include - -namespace CppAD { // BEGIN_CPPAD_NAMESPACE -/*! -\file vector.hpp -File used to define CppAD::vector and CppAD::vectorBool -*/ - -// --------------------------------------------------------------------------- -/*! -The CppAD Simple Vector template class. -*/ -template -class vector { -private: - /// maximum number of Type elements current allocation can hold - size_t capacity_; - /// number of Type elements currently in this vector - size_t length_; - /// pointer to the first type elements - /// (not defined and should not be used when capacity_ = 0) - Type * data_; -public: - /// type of the elements in the vector - typedef Type value_type; - - /// default constructor sets capacity_ = length_ = data_ = 0 - inline vector(void) - : capacity_(0), length_(0), data_(CPPAD_NULL) - { } - /// sizing constructor - inline vector( - /// number of elements in this vector - size_t n - ) : capacity_(0), length_(n), data_(CPPAD_NULL) - { if( length_ > 0 ) - { // set capacity and data - data_ = thread_alloc::create_array(length_, capacity_); - } - } - /// copy constructor - inline vector( - /// the *this vector will be a copy of \c x - const vector& x - ) : capacity_(0), length_(x.length_), data_(CPPAD_NULL) - { if( length_ > 0 ) - { // set capacity and data - data_ = thread_alloc::create_array(length_, capacity_); - - // copy values using assignment operator - size_t i; - for(i = 0; i < length_; i++) - data_[i] = x.data_[i]; - } - } - /// destructor - ~vector(void) - { if( capacity_ > 0 ) - thread_alloc::delete_array(data_); - } - - /// maximum number of elements current allocation can store - inline size_t capacity(void) const - { return capacity_; } - - /// number of elements currently in this vector. - inline size_t size(void) const - { return length_; } - - /// raw pointer to the data - inline Type* data(void) - { return data_; } - - /// const raw pointer to the data - inline const Type* data(void) const - { return data_; } - - /// change the number of elements in this vector. - inline void resize( - /// new number of elements for this vector - size_t n - ) - { length_ = n; - // check if we can use current memory - if( capacity_ >= length_ ) - return; - // check if there is old memory to be freed - if( capacity_ > 0 ) - thread_alloc::delete_array(data_); - // get new memory and set capacity - data_ = thread_alloc::create_array(length_, capacity_); - } - - /// free memory and set number of elements to zero - inline void clear(void) - { length_ = 0; - // check if there is old memory to be freed - if( capacity_ > 0 ) - thread_alloc::delete_array(data_); - capacity_ = 0; - } - - /// vector assignment operator - inline vector& operator=( - /// right hand size of the assingment operation - const vector& x - ) - { size_t i; - // If original lenght is zero, then resize - // otherwise a length mismatch is an error. - if( length_ == 0 ) - resize( x.length_ ); - CPPAD_ASSERT_KNOWN( - length_ == x.length_ , - "vector: size miss match in assignment operation" - ); - for(i = 0; i < length_; i++) - data_[i] = x.data_[i]; - return *this; - } -# if CPPAD_HAS_RVALUE - /// vector assignment operator with move semantics - inline vector& operator=( - /// right hand size of the assingment operation - vector&& x - ) - { CPPAD_ASSERT_KNOWN( - length_ == x.length_ || (length_ == 0), - "vector: size miss match in assignment operation" - ); - if( this != &x ) - { clear(); - // - length_ = x.length_; - capacity_ = x.capacity_; - data_ = x.data_; - // - x.length_ = 0; - x.capacity_ = 0; - x.data_ = CPPAD_NULL; - } - return *this; - } -# endif - /// non-constant element access; i.e., we can change this element value - Type& operator[]( - /// element index, must be less than length - size_t i - ) - { CPPAD_ASSERT_KNOWN( - i < length_, - "vector: index greater than or equal vector size" - ); - return data_[i]; - } - /// constant element access; i.e., we cannot change this element value - const Type& operator[]( - /// element index, must be less than length - size_t i - ) const - { CPPAD_ASSERT_KNOWN( - i < length_, - "vector: index greater than or equal vector size" - ); - return data_[i]; - } - /// add an element to the back of this vector - void push_back( - /// value of the element - const Type& s - ) - { CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); - if( length_ + 1 > capacity_ ) - { // store old capacity and data values - size_t old_capacity = capacity_; - Type* old_data = data_; - // set new capacity and data values - data_ = thread_alloc::create_array(length_ + 1, capacity_); - // copy old data values - size_t i; - for(i = 0; i < length_; i++) - data_[i] = old_data[i]; - // free old data - if( old_capacity > 0 ) - thread_alloc::delete_array(old_data); - } - data_[length_++] = s; - CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); - } - - /*! add vector to the back of this vector - (we could not use push_back becasue MS V++ 7.1 did not resolve - to non-template member function when scalar is used.) - */ - template - void push_vector( - /// value of the vector that we are adding - const Vector& v - ) - { CheckSimpleVector(); - CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); - size_t m = v.size(); - size_t i; - if( length_ + m > capacity_ ) - { // store old capacity and data values - size_t old_capacity = capacity_; - Type* old_data = data_; - // set new capacity and data values - data_ = thread_alloc::create_array(length_ + m, capacity_); - // copy old data values - for(i = 0; i < length_; i++) - data_[i] = old_data[i]; - // free old data - if( old_capacity > 0 ) - thread_alloc::delete_array(old_data); - } - for(i = 0; i < m; i++) - data_[length_++] = v[i]; - CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); - } -}; - -/// output a vector -template -inline std::ostream& operator << ( - /// stream to write the vector to - std::ostream& os , - /// vector that is output - const CppAD::vector& vec ) -{ size_t i = 0; - size_t n = vec.size(); - - os << "{ "; - while(i < n) - { os << vec[i++]; - if( i < n ) - os << ", "; - } - os << " }"; - return os; -} - -// --------------------------------------------------------------------------- -/*! -Class that is used to hold a non-constant element of a vector. -*/ -class vectorBoolElement { - /// the boolean data is packed with sizeof(UnitType) bits per value - typedef size_t UnitType; -private: - /// pointer to the UnitType value holding this eleemnt - UnitType* unit_; - /// mask for the bit corresponding to this element - /// (all zero except for bit that corresponds to this element) - UnitType mask_; -public: - /// constructor from member values - vectorBoolElement( - /// unit for this element - UnitType* unit , - /// mask for this element - UnitType mask ) - : unit_(unit) , mask_(mask) - { } - /// constuctor from another element - vectorBoolElement( - /// other element - const vectorBoolElement& e ) - : unit_(e.unit_) , mask_(e.mask_) - { } - /// conversion to a boolean value - operator bool() const - { return (*unit_ & mask_) != 0; } - /// assignment of this element to a bool - vectorBoolElement& operator=( - /// right hand side for assignment - bool bit - ) - { if(bit) - *unit_ |= mask_; - else *unit_ &= ~mask_; - return *this; - } - /// assignment of this element to another element - vectorBoolElement& operator=(const vectorBoolElement& e) - { if( *(e.unit_) & e.mask_ ) - *unit_ |= mask_; - else *unit_ &= ~mask_; - return *this; - } -}; - -class vectorBool { - /// the boolean data is packed with sizeof(UnitType) bits per value - typedef size_t UnitType; -private: - /// number of bits packed into each UnitType value in data_ - static const size_t bit_per_unit_ - = std::numeric_limits::digits; - /// number of UnitType values in data_ - size_t n_unit_; - /// number of bits currently stored in this vector - size_t length_; - /// pointer to where the bits are stored - UnitType *data_; - - /// minimum number of UnitType values that can store length_ bits - /// (note that this is really a function of length_) - size_t unit_min(void) - { if( length_ == 0 ) - return 0; - return (length_ - 1) / bit_per_unit_ + 1; - } -public: - /// type corresponding to the elements of this vector - /// (note that non-const elements actually use vectorBoolElement) - typedef bool value_type; - - /// default constructor (sets all member data to zero) - inline vectorBool(void) : n_unit_(0), length_(0), data_(CPPAD_NULL) - { } - /// sizing constructor - inline vectorBool( - /// number of bits in this vector - size_t n - ) : n_unit_(0), length_(n), data_(CPPAD_NULL) - { if( length_ > 0 ) - { // set n_unit and data - size_t min_unit = unit_min(); - data_ = thread_alloc::create_array(min_unit, n_unit_); - } - } - /// copy constructor - inline vectorBool( - /// the *this vector will be a copy of \c v - const vectorBool& v - ) : n_unit_(0), length_(v.length_), data_(CPPAD_NULL) - { if( length_ > 0 ) - { // set n_unit and data - size_t min_unit = unit_min(); - data_ = thread_alloc::create_array(min_unit, n_unit_); - - // copy values using UnitType assignment operator - CPPAD_ASSERT_UNKNOWN( min_unit <= v.n_unit_ ); - size_t i; - for(i = 0; i < min_unit; i++) - data_[i] = v.data_[i]; - } - } - /// destructor - ~vectorBool(void) - { if( n_unit_ > 0 ) - thread_alloc::delete_array(data_); - } - - /// number of elements in this vector - inline size_t size(void) const - { return length_; } - - /// maximum number of elements current allocation can store - inline size_t capacity(void) const - { return n_unit_ * bit_per_unit_; } - - /// change number of elements in this vector - inline void resize( - /// new number of elements for this vector - size_t n - ) - { length_ = n; - // check if we can use the current memory - size_t min_unit = unit_min(); - if( n_unit_ >= min_unit ) - return; - // check if there is old memory to be freed - if( n_unit_ > 0 ) - thread_alloc::delete_array(data_); - // get new memory and set n_unit - data_ = thread_alloc::create_array(min_unit, n_unit_); - } - - /// free memory and set number of elements to zero - inline void clear(void) - { length_ = 0; - // check if there is old memory to be freed - if( n_unit_ > 0 ) - thread_alloc::delete_array(data_); - n_unit_ = 0; - } - - /// vector assignment operator - inline vectorBool& operator=( - /// right hand size of the assingment operation - const vectorBool& v - ) - { size_t i; - CPPAD_ASSERT_KNOWN( - length_ == v.length_ , - "vectorBool: size miss match in assignment operation" - ); - size_t min_unit = unit_min(); - CPPAD_ASSERT_UNKNOWN( min_unit <= n_unit_ ); - CPPAD_ASSERT_UNKNOWN( min_unit <= v.n_unit_ ); - for(i = 0; i < min_unit; i++) - data_[i] = v.data_[i]; - return *this; - } -# if CPPAD_HAS_RVALUE - /// vector assignment operator with move semantics - inline vectorBool& operator=( - /// right hand size of the assingment operation - vectorBool&& x - ) - { if( this != &x ) - { clear(); - // - length_ = x.length_; - n_unit_ = x.n_unit_; - data_ = x.data_; - // - x.length_ = 0; - x.n_unit_ = 0; - x.data_ = CPPAD_NULL; - } - return *this; - } -# endif - - - /// non-constant element access; i.e., we can change this element value - vectorBoolElement operator[]( - /// element index, must be less than length - size_t k - ) - { size_t i, j; - CPPAD_ASSERT_KNOWN( - k < length_, - "vectorBool: index greater than or equal vector size" - ); - i = k / bit_per_unit_; - j = k - i * bit_per_unit_; - return vectorBoolElement(data_ + i , UnitType(1) << j ); - } - /// constant element access; i.e., we cannot change this element value - bool operator[](size_t k) const - { size_t i, j; - UnitType unit, mask; - CPPAD_ASSERT_KNOWN( - k < length_, - "vectorBool: index greater than or equal vector size" - ); - i = k / bit_per_unit_; - j = k - i * bit_per_unit_; - unit = data_[i]; - mask = UnitType(1) << j; - return (unit & mask) != 0; - } - /// add an element to the back of this vector - void push_back( - /// value of the element - bool bit - ) - { CPPAD_ASSERT_UNKNOWN( unit_min() <= n_unit_ ); - size_t i, j; - UnitType mask; - if( length_ + 1 > n_unit_ * bit_per_unit_ ) - { CPPAD_ASSERT_UNKNOWN( unit_min() == n_unit_ ); - // store old n_unit and data values - size_t old_n_unit = n_unit_; - UnitType* old_data = data_; - // set new n_unit and data values - data_ = thread_alloc::create_array(n_unit_+1, n_unit_); - // copy old data values - for(i = 0; i < old_n_unit; i++) - data_[i] = old_data[i]; - // free old data - if( old_n_unit > 0 ) - thread_alloc::delete_array(old_data); - } - i = length_ / bit_per_unit_; - j = length_ - i * bit_per_unit_; - mask = UnitType(1) << j; - if( bit ) - data_[i] |= mask; - else data_[i] &= ~mask; - length_++; - } - /// add vector to the back of this vector - template - void push_vector( - /// value of the vector that we are adding - const Vector& v - ) - { CheckSimpleVector(); - size_t min_unit = unit_min(); - CPPAD_ASSERT_UNKNOWN( length_ <= n_unit_ * bit_per_unit_ ); - // some temporaries - size_t i, j, k, ell; - UnitType mask; - bool bit; - // store old length - size_t old_length = length_; - // new length and minium number of units; - length_ = length_ + v.size(); - min_unit = unit_min(); - if( length_ >= n_unit_ * bit_per_unit_ ) - { // store old n_unit and data value - size_t old_n_unit = n_unit_; - UnitType* old_data = data_; - // set new n_unit and data values - data_ = thread_alloc::create_array(min_unit, n_unit_); - // copy old data values - for(i = 0; i < old_n_unit; i++) - data_[i] = old_data[i]; - // free old data - if( old_n_unit > 0 ) - thread_alloc::delete_array(old_data); - } - ell = old_length; - for(k = 0; k < v.size(); k++) - { - i = ell / bit_per_unit_; - j = ell - i * bit_per_unit_; - bit = v[k]; - mask = UnitType(1) << j; - if( bit ) - data_[i] |= mask; - else data_[i] &= ~mask; - ell++; - } - CPPAD_ASSERT_UNKNOWN( length_ == ell ); - CPPAD_ASSERT_UNKNOWN( length_ <= n_unit_ * bit_per_unit_ ); - } -}; - -/// output a vector -inline std::ostream& operator << ( - /// steam to write the vector to - std::ostream& os , - /// vector that is output - const vectorBool& v ) -{ size_t i = 0; - size_t n = v.size(); - - while(i < n) - os << v[i++]; - return os; -} - -} // END_CPPAD_NAMESPACE -# endif diff -Nru cppad-2015.00.00.9/cppad_ipopt/CMakeLists.txt cppad-2016.00.00.1/cppad_ipopt/CMakeLists.txt --- cppad-2015.00.00.9/cppad_ipopt/CMakeLists.txt 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/CMakeLists.txt 2016-02-09 08:31:57.000000000 +0000 @@ -1,32 +1,28 @@ -# $Id: CMakeLists.txt 3120 2014-02-25 14:04:02Z bradbell $ +# $Id: CMakeLists.txt 3754 2015-11-26 22:23:05Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the cppad_ipopt/* directory tests +# Build the cppad_ipopt/* directory tests # Inherit environment from ../CMakeList.txt -# colpack_prefix -SET(sources ../../cppad/local/cppad_colpack.cpp) -sources_libs_define(colpack "${sources}" ColPack "") - # Initialize list of tests as empty SET(check_depends "") # assert ipopt_prefix is defined IF ( NOT ipopt_prefix ) - MESSAGE(FATAL_ERROR + MESSAGE(FATAL_ERROR "cppad_ipopt/CMakeLists.txt: ipopt_prefix = ${ipopt_prefix}" ) ENDIF ( NOT ipopt_prefix ) -# The CMakeLists.txt file in the specified source directory is processed +# The CMakeLists.txt file in the specified source directory is processed # before the current input file continues beyond this command. # add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) ADD_SUBDIRECTORY(src) diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/CMakeLists.txt cppad-2016.00.00.1/cppad_ipopt/example/CMakeLists.txt --- cppad-2015.00.00.9/cppad_ipopt/example/CMakeLists.txt 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/CMakeLists.txt 2016-02-09 08:31:57.000000000 +0000 @@ -1,18 +1,18 @@ -# $Id: CMakeLists.txt 3116 2014-02-24 21:44:26Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the cppad_ipopt/example directory tests +# Build the cppad_ipopt/example directory tests # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) @@ -25,7 +25,7 @@ # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) -ADD_EXECUTABLE(cppad_ipopt_example EXCLUDE_FROM_ALL +ADD_EXECUTABLE(cppad_ipopt_example EXCLUDE_FROM_ALL example.cpp get_started.cpp ode_check.cpp @@ -42,8 +42,9 @@ add_cppad_cxx_flags( cppad_ipopt_example ) # List of libraries to be linked into the specified target -TARGET_LINK_LIBRARIES(cppad_ipopt_example - cppad_ipopt +TARGET_LINK_LIBRARIES(cppad_ipopt_example + cppad_ipopt + ${cppad_lib} ${ipopt_LIBRARIES} ${colpack_libs} ) diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/example.cpp cppad-2016.00.00.1/cppad_ipopt/example/example.cpp --- cppad-2015.00.00.9/cppad_ipopt/example/example.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/example.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: example.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: example.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -51,7 +51,7 @@ ok &= Run( ipopt_get_started, "ipopt_get_started" ); ok &= Run( ode_simple_check, "ode_simple_check" ); ok &= Run( ode_fast_check, "ode_fast_check" ); - + // check for errors using std::cout; using std::endl; diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/get_started.cpp cppad-2016.00.00.1/cppad_ipopt/example/get_started.cpp --- cppad-2015.00.00.9/cppad_ipopt/example/get_started.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/get_started.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: get_started.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: get_started.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,14 +18,12 @@ IpoptDir CppAD $$ -$index example, nonlinear, programming$$ -$index programming, nonlinear example$$ -$index ipopt, AD example$$ $section Nonlinear Programming Using CppAD and Ipopt: Example and Test$$ +$mindex ipopt AD$$ $head Purpose$$ -This example program demonstrates how to use the class cppad_ipopt_nlp to +This example program demonstrates how to use the class cppad_ipopt_nlp to solve the example problem in the Ipopt documentation; i.e., the problem $latex \[ \begin{array}{lc} @@ -35,15 +33,15 @@ \\ & x_1^2 + x_2^2 + x_3^2 + x_4^2 = 40 \\ - & 1 \leq x_1, x_2, x_3, x_4 \leq 5 + & 1 \leq x_1, x_2, x_3, x_4 \leq 5 \end{array} \] $$ $head Configuration Requirement$$ This example will be compiled and tested provided that -a value for $icode ipopt_prefix$$ -is specified on the $cref cmake$$ command line. +a value for $icode ipopt_prefix$$ +is specified on the $cref cmake$$ command line. $code $verbatim%cppad_ipopt/example/get_started.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -72,7 +70,7 @@ ADVector eval_r(size_t k, const ADVector& x) { ADVector fg(3); - // Fortran style indexing + // Fortran style indexing ADNumber x1 = x[0]; ADNumber x2 = x[1]; ADNumber x3 = x[2]; @@ -89,14 +87,14 @@ { return retape_; } }; } - + bool ipopt_get_started(void) { bool ok = true; size_t j; // number of independent variables (domain dimension for f and g) - size_t n = 4; + size_t n = 4; // number of constraints (range dimension for g) size_t m = 2; // initial value of the independent variables @@ -116,12 +114,12 @@ NumberVector g_l(m); NumberVector g_u(m); g_l[0] = 25.0; g_u[0] = 1.0e19; - g_l[1] = 40.0; g_u[1] = 40.0; + g_l[1] = 40.0; g_u[1] = 40.0; size_t icase; for(icase = 0; icase <= 1; icase++) { // Should cppad_ipopt_nlp retape the operation sequence for - // every new x. Can test both true and false cases because + // every new x. Can test both true and false cases because // the operation sequence does not depend on x (for this case). bool retape = icase != 0; @@ -146,7 +144,7 @@ app->Options()->SetIntegerValue("max_iter", 10); // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) app->Options()->SetNumericValue("tol", 1e-9); @@ -166,8 +164,8 @@ ok &= status == Ipopt::Solve_Succeeded; /* - Check some of the solution values - */ + Check some of the solution values + */ ok &= solution.status == cppad_ipopt_solution::success; // double check_x[] = { 1.000000, 4.743000, 3.82115, 1.379408 }; diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/makefile.am cppad-2016.00.00.1/cppad_ipopt/example/makefile.am --- cppad-2015.00.00.9/cppad_ipopt/example/makefile.am 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/makefile.am 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2683 2012-12-30 18:17:03Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ # check_PROGRAMS = example # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ @@ -35,7 +35,7 @@ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) -AM_LDFLAGS = -L../src +AM_LDFLAGS = -L../src # example_SOURCES = \ example.cpp \ diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/makefile.in cppad-2016.00.00.1/cppad_ipopt/example/makefile.in --- cppad-2015.00.00.9/cppad_ipopt/example/makefile.in 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/makefile.in 2016-02-09 08:31:57.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = example$(EXEEXT) subdir = cppad_ipopt/example -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(srcdir)/test.sh.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test.sh CONFIG_CLEAN_VPATH_FILES = @@ -163,6 +172,8 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/test.sh.in \ + $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -193,12 +204,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -279,26 +290,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -342,7 +356,7 @@ ode2.omh # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ @@ -359,7 +373,7 @@ $(PTHREAD_LIB) \ $(DL_LIB) -AM_LDFLAGS = -L../src +AM_LDFLAGS = -L../src # example_SOURCES = \ example.cpp \ @@ -389,7 +403,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cppad_ipopt/example/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu cppad_ipopt/example/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -646,6 +659,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check ./test.sh diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode1.omh cppad-2016.00.00.1/cppad_ipopt/example/ode1.omh --- cppad-2015.00.00.9/cppad_ipopt/example/ode1.omh 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode1.omh 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: ode1.omh 2683 2012-12-30 18:17:03Z bradbell $ +$Id: ode1.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,6 +18,6 @@ cppad_ipopt/example/ode_run.hpp% cppad_ipopt/example/ode_check.cpp %$$ - + $end diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode2.omh cppad-2016.00.00.1/cppad_ipopt/example/ode2.omh --- cppad-2015.00.00.9/cppad_ipopt/example/ode2.omh 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode2.omh 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: ode2.omh 2683 2012-12-30 18:17:03Z bradbell $ +$Id: ode2.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,9 +12,6 @@ $begin ipopt_nlp_ode_problem$$ $section An ODE Inverse Problem Example$$ -$index ode, inverse example$$ -$index inverse, ode example$$ -$index example, ode inverse$$ $head Notation$$ The table below contains @@ -28,14 +25,14 @@ $table $bold Name$$ $cnext $bold Meaning$$ $cnext $bold Value$$ $rnext -$latex Na$$ $cnext number of parameters to fit $cnext 3 +$latex Na$$ $cnext number of parameters to fit $cnext 3 $rnext $latex Ny$$ $cnext number components in ODE $cnext 2 $rnext $latex Nz$$ $cnext number of measurements $cnext 4 $rnext -$latex N(i)$$ $cnext -number of grid points between $th i-1$$ and $th i$$ measurement +$latex N(i)$$ $cnext +number of grid points between $th i-1$$ and $th i$$ measurement $rnext $latex S(i)$$ $cnext number of grid points up to an including the $th i$$ measurement @@ -45,28 +42,28 @@ We consider the following ordinary differential equation: $latex \[ \begin{array}{rcl} - \partial_t y_0 ( t , a ) & = & - a_1 * y_0 (t, a ) + \partial_t y_0 ( t , a ) & = & - a_1 * y_0 (t, a ) \\ \partial_t y_1 (t , a ) & = & + a_1 * y_0 (t, a ) - a_2 * y_1 (t, a ) \end{array} \] $$ with the initial conditions $latex \[ -y_0 (0 , a) = F(a) = \left( \begin{array}{c} a_0 \\ 0 \end{array} \right) +y_0 (0 , a) = F(a) = \left( \begin{array}{c} a_0 \\ 0 \end{array} \right) \] $$ where $latex Na$$ is the number of parameters, $latex a \in \B{R}^{Na} $$ is an unknown parameter vector. -The function and $latex F : \B{R}^{Na} \rightarrow \B{R}^{Ny} $$ +The function and $latex F : \B{R}^{Na} \rightarrow \B{R}^{Ny} $$ is defined by the equation above where $latex Ny$$ is the number of components in $latex y(t, a)$$. Our forward problem is stated as follows: Given $latex a \in \B{R}^{Na}$$ -determine the value of $latex y ( t , a ) $$, for $latex t \in R$$, that -solves the initial value problem above. +determine the value of $latex y ( t , a ) $$, for $latex t \in R$$, that +solves the initial value problem above. $head Measurements$$ We use $latex Nz$$ to denote the number of measurements. Suppose we are also given a measurement vector $latex z \in \B{R}^{Nz}$$ -and for $latex i = 1, \ldots, Nz$$, +and for $latex i = 1, \ldots, Nz$$, we model $latex z_i$$ by $latex \[ z_i = y_1 ( s_i , a) + e_i @@ -82,29 +79,29 @@ \begin{array}{rcl} y_0 (t , a) & = & a_0 * \exp( - a_1 * t ) \\ - y_1 (t , a) & = & + y_1 (t , a) & = & a_0 * a_1 * \frac{\exp( - a_2 * t ) - \exp( -a_1 * t )}{ a_1 - a_2 } \end{array} \] $$ $subhead Simulation Parameter Values$$ $table -$latex \bar{a}_0 = 1$$ $pre $$ $cnext - initial value of $latex y_0 (t, a)$$ +$latex \bar{a}_0 = 1$$ $pre $$ $cnext + initial value of $latex y_0 (t, a)$$ $rnext -$latex \bar{a}_1 = 2$$ $pre $$ $cnext +$latex \bar{a}_1 = 2$$ $pre $$ $cnext transfer rate from compartment zero to compartment one $rnext -$latex \bar{a}_2 = 1$$ $pre $$ $cnext +$latex \bar{a}_2 = 1$$ $pre $$ $cnext transfer rate from compartment one to outside world $rnext -$latex \sigma = 0$$ $pre $$ $cnext +$latex \sigma = 0$$ $pre $$ $cnext standard deviation of measurement noise $rnext $latex e_i = 0$$ $pre $$ $cnext simulated measurement noise, $latex i = 1 , \ldots , Nz$$ $rnext -$latex s_i = i * .5$$ $pre $$ $cnext +$latex s_i = i * .5$$ $pre $$ $cnext time corresponding to the $th i$$ measurement, $latex i = 1 , \ldots , Nz$$ $tend @@ -113,11 +110,11 @@ The simulated measurement values are given by the equation $latex \[ \begin{array}{rcl} -z_i +z_i & = & e_i + y_1 ( s_i , \bar{a} ) \\ -& = & -e_i + \bar{a}_0 * \bar{a}_1 * +& = & +e_i + \bar{a}_0 * \bar{a}_1 * \frac{\exp( - \bar{a}_2 * s_i ) - \exp( -\bar{a}_1 * s_i )} { \bar{a}_1 - \bar{a}_2 } \end{array} @@ -130,8 +127,8 @@ solves the following inverse problem $latex \[ \begin{array}{rcl} -{\rm minimize} \; - & \sum_{i=1}^{Nz} H_i [ y( s_i , a ) , a ] +{\rm minimize} \; + & \sum_{i=1}^{Nz} H_i [ y( s_i , a ) , a ] & \;{\rm w.r.t} \; a \in \B{R}^{Na} \end{array} \] $$ @@ -139,7 +136,7 @@ $latex H_i : \B{R}^{Ny} \times \B{R}^{Na} \rightarrow \B{R}$$ is defined by $latex \[ - H_i (y, a) = ( z_i - y_1 )^2 + H_i (y, a) = ( z_i - y_1 )^2 \] $$ $head Trapezoidal Approximation$$ @@ -153,7 +150,7 @@ the a trapezoidal method approximates $latex y ( t_i , a )$$ (denoted by $latex y^i$$ ) by solving the equation $latex \[ -y^i = y^{i-1} + +y^i = y^{i-1} + \left[ G( y^i , a ) + G( y^{i-1} , a ) \right] * \frac{t_i - t_{i-1} }{ 2 } \] $$ where $latex G : \B{R}^{Ny} \times \B{R}^{Na} \rightarrow \B{R}^{Ny}$$ is the @@ -168,16 +165,16 @@ This $latex G(y, a)$$ is linear with respect to $latex y$$, hence the implicit equation defining $latex y^i $$ can be solved inverting the a set of linear equations. -In the general case, +In the general case, where $latex G(y, a)$$ is non-linear with respect to $latex y$$, an iterative procedure is used to calculate $latex y^i$$ from $latex y^{i-1}$$. $subhead Trapezoidal Time Grid$$ -The discrete time grid, used for the trapezoidal approximation, is +The discrete time grid, used for the trapezoidal approximation, is denoted by $latex \{ t_i \} $$ which is defined by: $latex t_0 = 0$$ and -for $latex i = 1 , \ldots , Nz$$ and for $latex j = 1 , \ldots , N(i)$$, +for $latex i = 1 , \ldots , Nz$$ and for $latex j = 1 , \ldots , N(i)$$, $latex \[ \begin{array}{rcl} \Delta t_i & = & ( s_i - s_{i-1} ) / N(i) @@ -213,26 +210,26 @@ $subhead Derivatives$$ In addition, in the black box approach, differentiating the ODE solution often involves differentiating an iterative procedure. -Direct application of AD to compute these derivatives -requires a huge amount of memory and calculations to differentiate the +Direct application of AD to compute these derivatives +requires a huge amount of memory and calculations to differentiate the iterative procedure. (There are special techniques for applying AD to the solutions of iterative procedures, but that is outside the scope of this presentation). $head Simultaneous Method$$ -The simultaneous forward and inverse method -uses constraints to include the solution of +The simultaneous forward and inverse method +uses constraints to include the solution of the forward problem in the inverse problem. To be specific for our example, $latex \[ \begin{array}{rcl} -{\rm minimize} +{\rm minimize} & \sum_{i=1}^{Nz} H_i ( y^{N(i)} , a ) & \; {\rm w.r.t} \; y^1 \in \B{R}^{Ny} , \ldots , y^{S(Nz)} \in \B{R}^{Ny} , - \; a \in \B{R}^{Na} + \; a \in \B{R}^{Na} \\ {\rm subject \; to} - & y^j = y^{j-1} + + & y^j = y^{j-1} + \left[ G( y^{j-1} , a ) + G( y^j , a ) \right] * \frac{ t_j - t_{j-1} }{ 2 } & \; {\rm for} \; j = 1 , \ldots , S(Nz) \\ @@ -252,7 +249,7 @@ cppad_ipopt/example/ode_problem.hpp %$$ $head Source$$ -The file $cref ipopt_nlp_ode_problem.hpp$$ contains +The file $cref ipopt_nlp_ode_problem.hpp$$ contains source code that defines the example values and functions defined above. $end @@ -263,10 +260,8 @@ $$ $section ODE Fitting Using Simple Representation$$ +$mindex cppad_ipopt_nlp$$ -$index cppad_ipopt_nlp, ode simple representation$$ -$index ode, cppad_ipopt_nlp simple representation$$ -$index simple, cppad_ipopt_nlp ode representation$$ $head Purpose$$ In this section we represent the objective and constraint functions, @@ -280,7 +275,7 @@ has the following structure $latex \[ x = ( y^0 , \cdots , y^{S(Nz)} , a ) -\] $$ +\] $$ Note that $latex x \in \B{R}^{S(Nz) + Na}$$ and $latex \[ \begin{array}{rcl} @@ -295,7 +290,7 @@ ( $latex fg_0 (x)$$ in $cref cppad_ipopt_nlp$$ ) has the following representation, $latex \[ - fg_0 (x) = \sum_{i=1}^{Nz} H_i ( y^{S(i)} , a ) + fg_0 (x) = \sum_{i=1}^{Nz} H_i ( y^{S(i)} , a ) \] $$ $head Initial Condition Constraint$$ @@ -312,8 +307,8 @@ we define the component functions $latex fg_{Ny*i + j} (x)$$, and corresponding constraint equations, by $latex \[ -0 = fg_{Ny*i + j } = y_j^{i} - y_j^{i-1} - - \left[ G_j ( y^i , a ) + G_j ( y^{i-1} , a ) \right] * +0 = fg_{Ny*i + j } = y_j^{i} - y_j^{i-1} - + \left[ G_j ( y^i , a ) + G_j ( y^{i-1} , a ) \right] * \frac{t_i - t_{i-1} }{ 2 } \] $$ @@ -325,7 +320,7 @@ contains source code for this representation of the objective and constraints. -$end +$end ----------------------------------------------------------------------------- $begin ipopt_nlp_ode_fast$$ $spell @@ -334,12 +329,9 @@ $section ODE Fitting Using Fast Representation$$ -$index representation, cppad_ipopt_nlp ode$$ -$index cppad_ipopt_nlp, ode representation$$ -$index ode, cppad_ipopt_nlp representation$$ $head Purpose$$ -In this section we represent a more complex representation of the +In this section we represent a more complex representation of the simultaneous forward and reverse ODE fitting problem (described above). The representation defines the problem using simpler functions that are faster to differentiate @@ -353,7 +345,7 @@ by $latex \[ \begin{array}{rcl} -fg_0 (x) & = & \sum_{i=1}^{Nz} H_i ( y^{S(i)} , a ) +fg_0 (x) & = & \sum_{i=1}^{Nz} H_i ( y^{S(i)} , a ) \\ fg_0 (x) & = & \sum_{k=0}^{Nz-1} r^k ( u^{k,0} ) \end{array} @@ -364,7 +356,7 @@ $subhead Range Indices I(k,0)$$ For $latex k = 0 , \ldots , Nz - 1$$, -the range index in the vector $latex fg (x)$$ +the range index in the vector $latex fg (x)$$ corresponding to $latex r^k ( u^{k,0} ) $$ is 0. Thus, the range indices are given by $latex I(k,0) = \{ 0 \}$$ for $latex k = 0 , \ldots , Nz-1$$. @@ -378,24 +370,24 @@ u^{k,0} & = & ( y^{S(k+1} , a ) \\ & = & -( x_{Ny * S(k+1)} \; , \; +( x_{Ny * S(k+1)} \; , \; \ldots \; , \; - x_{Ny * S(k+1) + Ny - 1} \; , \; - x_{Ny * S(Nz) + Ny } \; , \; + x_{Ny * S(k+1) + Ny - 1} \; , \; + x_{Ny * S(Nz) + Ny } \; , \; \ldots \; , \; - x_{Ny * S(Nz) + Ny + Na - 1} -) + x_{Ny * S(Nz) + Ny + Na - 1} +) \end{array} \] $$ Thus, the domain indices are given by $latex \[ -J(k,0) = \{ - Ny * S(k+1) \; , \; - \ldots \; , \; - Ny * S(k+1) + Ny - 1 \; , \; - Ny * S(Nz) + Ny \; , \; +J(k,0) = \{ + Ny * S(k+1) \; , \; + \ldots \; , \; + Ny * S(k+1) + Ny - 1 \; , \; + Ny * S(Nz) + Ny \; , \; \ldots \; , \; - Ny * S(Nz) + Ny + Na - 1 + Ny * S(Nz) + Ny + Na - 1 \} \] $$ @@ -403,7 +395,7 @@ We use the following representation for the $cref/initial condition constraint/ ipopt_nlp_ode_simple/Initial Condition Constraint/$$: -For $latex k = Nz$$ we define the function +For $latex k = Nz$$ we define the function $latex r^k : \B{R}^{Ny} \times \B{R}^{Na + Ny}$$ by $latex \[ \begin{array}{rcl} @@ -414,11 +406,11 @@ \] $$ where $latex i = 1 , \ldots , Ny$$ and where $latex u^{k,0} \in \B{R}^{Ny + Na}$$ is defined by -$latex u^{k,0} = ( y^0 , a)$$. +$latex u^{k,0} = ( y^0 , a)$$. $subhead Range Indices I(k,0)$$ For $latex k = Nz$$, -the range index in the vector $latex fg (x)$$ +the range index in the vector $latex fg (x)$$ corresponding to $latex r^k ( u^{k,0} ) $$ are $latex I(k,0) = \{ 1 , \ldots , Ny \}$$. @@ -428,27 +420,27 @@ corresponding to the vector $latex u^{k,0}$$ are $latex \[ \begin{array}{rcl} -u^{k,0} & = & ( y^0 , a) +u^{k,0} & = & ( y^0 , a) \\ & = & -( x_0 \; , \; +( x_0 \; , \; \ldots \; , \; - x_{Ny-1} \; , \; - x_{Ny * S(Nz) + Ny } \; , \; + x_{Ny-1} \; , \; + x_{Ny * S(Nz) + Ny } \; , \; \ldots \; , \; - x_{Ny * S(Nz) + Ny + Na - 1} -) + x_{Ny * S(Nz) + Ny + Na - 1} +) \end{array} \] $$ Thus, the domain indices are given by $latex \[ -J(k,0) = \{ - 0 \; , \; - \ldots \; , \; - Ny - 1 \; , \; - Ny * S(Nz) + Ny \; , \; +J(k,0) = \{ + 0 \; , \; + \ldots \; , \; + Ny - 1 \; , \; + Ny * S(Nz) + Ny \; , \; \ldots \; , \; - Ny * S(Nz) + Ny + Na - 1 + Ny * S(Nz) + Ny + Na - 1 \} \] $$ @@ -459,19 +451,19 @@ For $latex k = 1 , \ldots , Nz$$, we define the function $latex r^{Nz+k} : \B{R}^{2*Ny+Na} \rightarrow \B{R}^{Ny}$$ by $latex \[ -r^{Nz+k} ( y , w , a ) -= +r^{Nz+k} ( y , w , a ) += y - w - [ G( y , a ) + G( w , a ) ] * \frac{ \Delta t_k }{ 2 } \] $$ For $latex \ell = 0 , \ldots , N(k)-1$$, using the notation $latex i = Ny * S(k-1) + \ell + 1$$, -the corresponding trapezoidal approximation is represented by +the corresponding trapezoidal approximation is represented by $latex \[ \begin{array}{rcl} -0 & = & fg_{Ny+i} (x) +0 & = & fg_{Ny+i} (x) \\ & = & -y^i - y^{i-1} - +y^i - y^{i-1} - \left[ G( y^i , a ) + G( y^{i-1} , a ) \right] * \frac{\Delta t_k }{ 2 } \\ & = & @@ -479,12 +471,12 @@ \end{array} \] $$ where $latex u^{Nz+k,\ell} \in \B{R}^{2*Ny + Na}$$ is defined by -$latex u^{Nz+k,\ell} = ( y^{i-1} , y^i , a)$$. +$latex u^{Nz+k,\ell} = ( y^{i-1} , y^i , a)$$. $subhead Range Indices I(k,0)$$ For $latex k = Nz + 1, \ldots , 2*Nz$$, and $latex \ell = 0 , \ldots , N(k)-1$$, -the range index in the vector $latex fg (x)$$ +the range index in the vector $latex fg (x)$$ corresponding to $latex r^k ( u^{k,\ell} ) $$ are $latex I(k,\ell) = \{ Ny + i , \ldots , 2*Ny + i - 1 \}$$ where $latex i = Ny * S(k-1) + \ell + 1$$. @@ -501,24 +493,24 @@ u^{k, \ell} & = & ( y^{i-1} , y^i , a ) \\ & = & -( x_{Ny * (i-1)} \; , \; +( x_{Ny * (i-1)} \; , \; \ldots \; , \; - x_{Ny * (i+1) - 1} \; , \; - x_{Ny * S(Nz) + Ny } \; , \; + x_{Ny * (i+1) - 1} \; , \; + x_{Ny * S(Nz) + Ny } \; , \; \ldots \; , \; - x_{Ny * S(Nz) + Ny + Na - 1} + x_{Ny * S(Nz) + Ny + Na - 1} ) \end{array} \] $$ Thus, the domain indices are given by $latex \[ -J(k,\ell) = \{ - Ny * (i-1) \; , \; - \ldots \; , \; - Ny * (i+1) - 1 \; , \; - Ny * S(Nz) + Ny \; , \; +J(k,\ell) = \{ + Ny * (i-1) \; , \; + \ldots \; , \; + Ny * (i+1) - 1 \; , \; + Ny * S(Nz) + Ny \; , \; \ldots \; , \; - Ny * S(Nz) + Ny + Na - 1 + Ny * S(Nz) + Ny + Na - 1 \} \] $$ @@ -530,6 +522,6 @@ contains source code for this representation of the objective and constraints. - -$end + +$end ------------------------------------------------------------------------------ diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode_check.cpp cppad-2016.00.00.1/cppad_ipopt/example/ode_check.cpp --- cppad-2015.00.00.9/cppad_ipopt/example/ode_check.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode_check.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_check.cpp 3624 2015-01-29 11:45:00Z bradbell $ */ +// $Id: ode_check.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -48,7 +48,7 @@ { y_0[j] = x[j]; y_1[j] = x[Ny + j]; y_2[j] = x[2 * Ny + j]; - } + } // Check some of the optimal a value Number rel_tol = max_step * max_step; @@ -56,7 +56,7 @@ Number check_a[] = {a0, a1, a2}; // see the y_one function for(j = 0; j < Na; j++) { - ok &= CppAD::NearEqual( + ok &= CppAD::NearEqual( check_a[j], a[j], rel_tol, abs_tol ); } diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode_check.hpp cppad-2016.00.00.1/cppad_ipopt/example/ode_check.hpp --- cppad-2015.00.00.9/cppad_ipopt/example/ode_check.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode_check.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: ode_check.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_ODE_CHECK_INCLUDED -# define CPPAD_ODE_CHECK_INCLUDED +// $Id: ode_check.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ODE_CHECK_HPP +# define CPPAD_ODE_CHECK_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode_fast_check.cpp cppad-2016.00.00.1/cppad_ipopt/example/ode_fast_check.cpp --- cppad-2015.00.00.9/cppad_ipopt/example/ode_fast_check.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode_fast_check.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_fast_check.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_fast_check.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -32,6 +32,6 @@ ipopt_ode_case(retape, N, x); ok &= ode_check(N, x); } - + return ok; } diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode_fast.hpp cppad-2016.00.00.1/cppad_ipopt/example/ode_fast.hpp --- cppad-2015.00.00.9/cppad_ipopt/example/ode_fast.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode_fast.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: ode_fast.hpp 2683 2012-12-30 18:17:03Z bradbell $ */ -# ifndef CPPAD_ODE_FAST_INCLUDED -# define CPPAD_ODE_FAST_INCLUDED +// $Id: ode_fast.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ODE_FAST_HPP +# define CPPAD_ODE_FAST_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section ODE Fitting Using Fast Representation$$ +$mindex cppad_ipopt_nlp example source$$ -$index cppad_ipopt_nlp, ode example source$$ -$index ode, cppad_ipopt_nlp example source$$ -$index example, cppad_ipopt_nlp ode source$$ -$index source, cppad_ipopt_nlp ode example$$ $code $verbatim%cppad_ipopt/example/ode_fast.hpp%0%// BEGIN C++%// END C++%1%$$ @@ -67,7 +64,7 @@ if( k < Nz ) { // used for measurement with index k+1 ADVector r(1); // return value is a scalar - // u is [y( s[k+1] ) , a] + // u is [y( s[k+1] ) , a] for(j = 0; j < Ny; j++) y[j] = u[j]; for(j = 0; j < Na; j++) @@ -78,24 +75,24 @@ // initial condition --------------------------------- if( k == Nz ) { ADVector r(Ny), F(Ny); - // u is [y(t), a] at t = 0 + // u is [y(t), a] at t = 0 for(j = 0; j < Ny; j++) y[j] = u[j]; for(j = 0; j < Na; j++) a[j] = u[Ny + j]; F = eval_F(a); for(j = 0; j < Ny; j++) - r[j] = y[j] - F[j]; + r[j] = y[j] - F[j]; return r; } // trapezoidal approximation ------------------------- ADVector ym(Ny), G(Ny), Gm(Ny), r(Ny); - // r^k for k = Nz+1, ... , 2*Nz + // r^k for k = Nz+1, ... , 2*Nz // interval between data samples Number T = s[k-Nz] - s[k-Nz-1]; // integration step size Number dt = T / Number( N_[k-Nz] ); - // u = [ y(t[i-1], a) , y(t[i], a), a ) + // u = [ y(t[i-1], a) , y(t[i], a), a ) for(j = 0; j < Ny; j++) { ym[j] = u[j]; y[j] = u[Ny + j]; @@ -124,7 +121,7 @@ size_t range_size(size_t k) { if( k < Nz ) return 1; - return Ny; + return Ny; } // number of terms that use this value of k size_t number_terms(size_t k) @@ -139,17 +136,17 @@ size_t ny_inx = (S_[Nz] + 1) * Ny; // objective function ------------------------------- if( k < Nz ) - { // index in fg corresponding to objective + { // index in fg corresponding to objective I[0] = 0; // u = [ y(t, a) , a ] - // The first Ny components of u is y(t) at - // t = s[k+1] = t[S_[k+1]] + // The first Ny components of u is y(t) at + // t = s[k+1] = t[S_[k+1]] // x indices corresponding to this value of y for(j = 0; j < Ny; j++) J[j] = S_[k + 1] * Ny + j; // components of x correspondig to a for(j = 0; j < Na; j++) - J[Ny + j] = ny_inx + j; + J[Ny + j] = ny_inx + j; return; } // initial conditions -------------------------------- @@ -161,7 +158,7 @@ // x indices corresponding to this value of y for(j = 0; j < Ny; j++) J[j] = j; - // following that, u contains the vector a + // following that, u contains the vector a for(j = 0; j < Na; j++) J[Ny + j] = ny_inx + j; return; @@ -169,7 +166,7 @@ // trapoziodal approximation ------------------------- // index of first grid point in this approximation i = S_[k - Nz - 1] + ell; - // There are Ny difference equations for each time + // There are Ny difference equations for each time // point. Add one for the objective function, and Ny // for the initial value constraints. for(j = 0; j < Ny; j++) @@ -181,7 +178,7 @@ } for(j = 0; j < Na; j++) J[2 * Ny + j] = ny_inx + j; // a indices - } + } }; } diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode_problem.hpp cppad-2016.00.00.1/cppad_ipopt/example/ode_problem.hpp --- cppad-2015.00.00.9/cppad_ipopt/example/ode_problem.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode_problem.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: ode_problem.hpp 2683 2012-12-30 18:17:03Z bradbell $ */ -# ifndef CPPAD_ODE_PROBLEM_INCLUDED -# define CPPAD_ODE_PROBLEM_INCLUDED +// $Id: ode_problem.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ODE_PROBLEM_HPP +# define CPPAD_ODE_PROBLEM_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,10 +21,9 @@ $$ $section ODE Inverse Problem Definitions: Source Code$$ +$mindex example$$ + -$index ode, inverse example$$ -$index inverse, ode example$$ -$index example, ode inverse$$ $code $verbatim%cppad_ipopt/example/ode_problem.hpp%0%// BEGIN C++%// END C++%1%$$ @@ -50,7 +49,7 @@ } // time points were we have data (no data at first point) - double s[] = { 0.0, 0.5, 1.0, 1.5, 2.0 }; + double s[] = { 0.0, 0.5, 1.0, 1.5, 2.0 }; // Simulated data for case with no noise (first point is not used) double z[] = { 0.0, y_one(0.5), y_one(1.0), y_one(1.5), y_one(2.0) }; // Number of measurement values @@ -67,9 +66,9 @@ { Vector F(Ny); // y_0 (t) = a[0]*exp(-a[1] * t) F[0] = a[0]; - // y_1 (t) = + // y_1 (t) = // a[0]*a[1]*(exp(-a[2] * t) - exp(-a[1] * t))/(a[1] - a[2]) - F[1] = 0.; + F[1] = 0.; return F; } // G(y, a) = \partial_t y(t, a); i.e. the differential equation @@ -78,19 +77,19 @@ Vector eval_G(const Vector &y , const Vector &a) { Vector G(Ny); // y_0 (t) = a[0]*exp(-a[1] * t) - G[0] = -a[1] * y[0]; - // y_1 (t) = + G[0] = -a[1] * y[0]; + // y_1 (t) = // a[0]*a[1]*(exp(-a[2] * t) - exp(-a[1] * t))/(a[1] - a[2]) - G[1] = +a[1] * y[0] - a[2] * y[1]; + G[1] = +a[1] * y[0] - a[2] * y[1]; return G; - } + } // H(i, y, a) = contribution to objective at i-th data point // (for this particular example) template Scalar eval_H(size_t i, const Vector &y, const Vector &a) { // This particular H is for a case where y_1 (t) is measured Scalar diff = z[i] - y[1]; - return diff * diff; + return diff * diff; } // function used to count the number of calls to eval_r size_t count_eval_r(void) diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode_run.hpp cppad-2016.00.00.1/cppad_ipopt/example/ode_run.hpp --- cppad-2015.00.00.9/cppad_ipopt/example/ode_run.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode_run.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: ode_run.hpp 2896 2013-09-17 21:23:55Z bradbell $ */ -# ifndef CPPAD_ODE_RUN_INCLUDED -# define CPPAD_ODE_RUN_INCLUDED +// $Id: ode_run.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ODE_RUN_HPP +# define CPPAD_ODE_RUN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -48,14 +48,14 @@ S[0] = 0; for(i = 1; i <= Nz; i++) S[i] = S[i-1] + N[i]; - + // number of components of x corresponding to values for y size_t ny_inx = (S[Nz] + 1) * Ny; // number of constraints (range dimension of g) size_t m = ny_inx; // number of components in x (domain dimension for f and g) size_t n = ny_inx + Na; - // the argument vector for the optimization is + // the argument vector for the optimization is // y(t) at t[0] , ... , t[S[Nz]] , followed by a NumberVector x_i(n), x_l(n), x_u(n); for(j = 0; j < ny_inx; j++) @@ -96,7 +96,7 @@ app->Options()->SetIntegerValue("max_iter", 30); // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) app->Options()->SetNumericValue("tol", 1e-9); diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode_simple_check.cpp cppad-2016.00.00.1/cppad_ipopt/example/ode_simple_check.cpp --- cppad-2015.00.00.9/cppad_ipopt/example/ode_simple_check.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode_simple_check.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_simple_check.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_simple_check.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -32,6 +32,6 @@ ipopt_ode_case(retape, N, x); ok &= ode_check(N, x); } - + return ok; } diff -Nru cppad-2015.00.00.9/cppad_ipopt/example/ode_simple.hpp cppad-2016.00.00.1/cppad_ipopt/example/ode_simple.hpp --- cppad-2015.00.00.9/cppad_ipopt/example/ode_simple.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/example/ode_simple.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: ode_simple.hpp 2683 2012-12-30 18:17:03Z bradbell $ */ -# ifndef CPPAD_ODE_SIMPLE_INCLUDED -# define CPPAD_ODE_SIMPLE_INCLUDED +// $Id: ode_simple.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_ODE_SIMPLE_HPP +# define CPPAD_ODE_SIMPLE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,11 +22,8 @@ $$ $section ODE Fitting Using Simple Representation$$ +$mindex cppad_ipopt_nlp example source$$ -$index cppad_ipopt_nlp, ode example source$$ -$index ode, cppad_ipopt_nlp example source$$ -$index example, cppad_ipopt_nlp ode source$$ -$index source, cppad_ipopt_nlp ode example$$ $code $verbatim%cppad_ipopt/example/ode_simple.hpp%0%// BEGIN C++%// END C++%1%$$ @@ -103,7 +100,7 @@ Number dt = T / Number( N_[k+1] ); for(j = 0; j < N_[k+1]; j++) { size_t Index = (j + S_[k]) * Ny; - // y(t) at end of last step + // y(t) at end of last step ym = y; // G(y, a) at end of last step Gm = G; diff -Nru cppad-2015.00.00.9/cppad_ipopt/speed/CMakeLists.txt cppad-2016.00.00.1/cppad_ipopt/speed/CMakeLists.txt --- cppad-2015.00.00.9/cppad_ipopt/speed/CMakeLists.txt 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/speed/CMakeLists.txt 2016-02-09 08:31:57.000000000 +0000 @@ -1,18 +1,18 @@ -# $Id: CMakeLists.txt 3116 2014-02-24 21:44:26Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the cppad_ipopt/speed directory tests +# Build the cppad_ipopt/speed directory tests # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) @@ -26,8 +26,8 @@ # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) -# Include source for cppad_ipopt library so we build it without debugging -ADD_EXECUTABLE(cppad_ipopt_speed EXCLUDE_FROM_ALL +# Include source for cppad_ipopt library so we build it without debugging +ADD_EXECUTABLE(cppad_ipopt_speed EXCLUDE_FROM_ALL speed.cpp ../src/cppad_ipopt_nlp.cpp ../src/fun_record.hpp @@ -35,7 +35,7 @@ ../src/jac_g_map.cpp ../src/sparse_map2vec.cpp ../src/vec_fun_pattern.cpp - ode_speed.cpp + ode_speed.cpp ) # Add extra compiler flags @@ -43,8 +43,9 @@ # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES( - cppad_ipopt_speed - cppad_ipopt + cppad_ipopt_speed + cppad_ipopt + ${cppad_lib} ${ipopt_LIBRARIES} ${colpack_libs} ) diff -Nru cppad-2015.00.00.9/cppad_ipopt/speed/makefile.am cppad-2016.00.00.1/cppad_ipopt/speed/makefile.am --- cppad-2015.00.00.9/cppad_ipopt/speed/makefile.am 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/speed/makefile.am 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2506 2012-10-24 19:36:49Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -17,7 +17,7 @@ EXTRA_DIST = test.sh.in # check_PROGRAMS = speed -# +# # BEGIN OPTIMIZE AM_CXXFLAGS = -O2 -DNDEBUG $(CXX_FLAGS) # END OPTIMIZE @@ -38,10 +38,10 @@ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) -AM_LDFLAGS = -L../src +AM_LDFLAGS = -L../src # # Cannot use ../src/libcppad_ipopt.a becasue it is compiled for debugging -# so build an optimized version here to use here. +# so build an optimized version here to use here. speed_SOURCES = \ speed.cpp \ ../src/cppad_ipopt_nlp.cpp \ @@ -50,7 +50,7 @@ ../src/jac_g_map.cpp \ ../src/sparse_map2vec.cpp \ ../src/vec_fun_pattern.cpp \ - ode_speed.cpp + ode_speed.cpp test: check ./test.sh diff -Nru cppad-2015.00.00.9/cppad_ipopt/speed/makefile.in cppad-2016.00.00.1/cppad_ipopt/speed/makefile.in --- cppad-2015.00.00.9/cppad_ipopt/speed/makefile.in 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/speed/makefile.in 2016-02-09 08:31:57.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = speed$(EXEEXT) subdir = cppad_ipopt/speed -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(srcdir)/test.sh.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test.sh CONFIG_CLEAN_VPATH_FILES = @@ -165,6 +174,8 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/test.sh.in \ + $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -195,12 +206,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -281,26 +292,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -340,7 +354,7 @@ top_srcdir = @top_srcdir@ # EXTRA_DIST = test.sh.in -# +# # BEGIN OPTIMIZE AM_CXXFLAGS = -O2 -DNDEBUG $(CXX_FLAGS) # END OPTIMIZE @@ -363,10 +377,10 @@ $(PTHREAD_LIB) \ $(DL_LIB) -AM_LDFLAGS = -L../src +AM_LDFLAGS = -L../src # # Cannot use ../src/libcppad_ipopt.a becasue it is compiled for debugging -# so build an optimized version here to use here. +# so build an optimized version here to use here. speed_SOURCES = \ speed.cpp \ ../src/cppad_ipopt_nlp.cpp \ @@ -375,7 +389,7 @@ ../src/jac_g_map.cpp \ ../src/sparse_map2vec.cpp \ ../src/vec_fun_pattern.cpp \ - ode_speed.cpp + ode_speed.cpp all: all-am @@ -393,7 +407,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cppad_ipopt/speed/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu cppad_ipopt/speed/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -671,6 +684,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check ./test.sh diff -Nru cppad-2015.00.00.9/cppad_ipopt/speed/ode_speed.cpp cppad-2016.00.00.1/cppad_ipopt/speed/ode_speed.cpp --- cppad-2015.00.00.9/cppad_ipopt/speed/ode_speed.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/speed/ode_speed.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_speed.cpp 2769 2013-03-05 14:28:47Z bradbell $ */ +// $Id: ode_speed.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/cppad_ipopt/speed/speed.cpp cppad-2016.00.00.1/cppad_ipopt/speed/speed.cpp --- cppad-2015.00.00.9/cppad_ipopt/speed/speed.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/speed/speed.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: speed.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: speed.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,7 +25,7 @@ name = "simple_retape_yes"; seconds = ode_speed(name, count); - printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n", + printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n", name, seconds, int(count) ); name = "simple_retape_no"; @@ -42,6 +42,6 @@ seconds = ode_speed(name, count); printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n", name, seconds, int(count) ); - + return 0; } diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/CMakeLists.txt cppad-2016.00.00.1/cppad_ipopt/src/CMakeLists.txt --- cppad-2015.00.00.9/cppad_ipopt/src/CMakeLists.txt 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/CMakeLists.txt 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: CMakeLists.txt 3116 2014-02-24 21:44:26Z bradbell $ +# $Id: CMakeLists.txt 3754 2015-11-26 22:23:05Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -12,20 +12,19 @@ # Build the cppad_ipopt/src library # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # add_library( [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN) # ) -ADD_LIBRARY(cppad_ipopt +ADD_LIBRARY(cppad_ipopt cppad_ipopt_nlp.cpp hes_fg_map.cpp jac_g_map.cpp sparse_map2vec.cpp - vec_fun_pattern.cpp - ${colpack_sources} + vec_fun_pattern.cpp ) # Add extra compiler flags diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/cppad_ipopt_nlp.cpp cppad-2016.00.00.1/cppad_ipopt/src/cppad_ipopt_nlp.cpp --- cppad-2015.00.00.9/cppad_ipopt/src/cppad_ipopt_nlp.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/cppad_ipopt_nlp.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cppad_ipopt_nlp.cpp 3223 2014-03-19 15:13:26Z bradbell $ */ +// $Id: cppad_ipopt_nlp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,7 +36,7 @@ */ -/*! +/*! Constructor for the \ref Nonlinear_Programming_Problem. \param n @@ -60,8 +60,8 @@ \param g_u upper limit for g(x) (size m). -\param fg_info -pointer to base class version of derived class object used to get +\param fg_info +pointer to base class version of derived class object used to get information about the user's representation for f(x) and g(x). (The object pointed to must not be deleted before this cppad_ipopt_nlp object). @@ -81,16 +81,16 @@ \endverbatim In addition, the function calls fg_info->set_n(n) and fg_info->set_m(m) are used to set the values of \c n -and \c m in \c fg_info. +and \c m in \c fg_info. \par Variables The following arrays have fixed size which is set during this constructor: \li \c tape_ok_ has size \c K_. It is initialized as true for indices -\c k such that retape[k] is false. +\c k such that retape[k] is false. \li \c r_fun_ has size \c K_. It is initilaize with the default -\c ADFun constructor. Then, for indices \c k such that +\c ADFun constructor. Then, for indices \c k such that retape[k] is false, the operation sequence corresponding to \f$ r_k (u) \f$ is stored in r_fun_[k]. @@ -107,7 +107,7 @@ are checked to make sure they hold. */ cppad_ipopt_nlp::cppad_ipopt_nlp( - size_t n , + size_t n , size_t m , const NumberVector &x_i , const NumberVector &x_l , @@ -165,16 +165,16 @@ I_[i] = m+1; // an invalid range index for( j = 0; j < q_[k]; j++) J_[j] = n; // an invalid domain index - fg_info_->index(k, ell, I_, J_); + fg_info_->index(k, ell, I_, J_); for( i = 0; i < p_[k]; i++) if( I_[i] > m ) - { std::cerr << "k=" << k << ", ell=" << ell + { std::cerr << "k=" << k << ", ell=" << ell << ", I[" << i << "]=" << I_[i] << std::endl; - CPPAD_ASSERT_KNOWN( I_[i] <= m, + CPPAD_ASSERT_KNOWN( I_[i] <= m, "cppad_ipopt_nlp: invalid value in index vector I" ); } for( j = 0; j < q_[k]; j++) if( J_[j] >= n ) - { std::cerr << "k=" << k << ", ell=" << ell + { std::cerr << "k=" << k << ", ell=" << ell << ", J[" << j << "]=" << J_[j] << std::endl; CPPAD_ASSERT_KNOWN( J_[j] < n, "cppad_ipopt_nlp: invalid value in index vector J" @@ -186,7 +186,7 @@ for(k = 0; k < K_; k++) { tape_ok_[k] = false; if( ! retape_[k] ) - { // Operation sequence does not depend on value + { // Operation sequence does not depend on value // of u so record it once here in the constructor. fg_info_->index(k, 0, I_, J_); fun_record( @@ -208,7 +208,7 @@ // compute a sparsity patterns for each r_k (u) vec_fun_pattern( - K_, p_, q_, retape_, r_fun_, // inputs + K_, p_, q_, retape_, r_fun_, // inputs pattern_jac_r_, pattern_hes_r_ // outputs ); @@ -225,8 +225,8 @@ I_, J_, // work index_hes_fg_ // outputs ); - - // Compute Ipopt sparsity structure for Jacobian of g + + // Compute Ipopt sparsity structure for Jacobian of g sparse_map2vec( index_jac_g_, // inputs nnz_jac_g_, iRow_jac_g_, jCol_jac_g_ // outputs @@ -270,7 +270,7 @@ nnz_jac_g = nnz_jac_g_; nnz_h_lag = nnz_h_lag_; - // use the fortran index style for row/col entries + // use the fortran index style for row/col entries index_style = C_STYLE; return true; @@ -312,7 +312,7 @@ bool cppad_ipopt_nlp::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u) { size_t i, j; - // here, the n and m we gave IPOPT in get_nlp_info are passed back + // here, the n and m we gave IPOPT in get_nlp_info are passed back CPPAD_ASSERT_UNKNOWN(size_t(n) == n_); CPPAD_ASSERT_UNKNOWN(size_t(m) == m_); @@ -325,7 +325,7 @@ { g_l[i] = g_l_[i]; g_u[i] = g_u_[i]; } - + return true; } @@ -392,19 +392,19 @@ the function f(x). \param[in] new_x -is false if the previous call to any one of the -\ref Evaluation_Methods used the same value for \c x. +is false if the previous call to any one of the +\ref Deprecated_Evaluation_Methods used the same value for \c x. \param[out] obj_value is the value of the objective f(x) at this value of \c x. \return -The return value is always true; see \ref Evaluation_Methods. +The return value is always true; see \ref Deprecated_Evaluation_Methods. \par Efficiency -This routine could be more efficient +This routine could be more efficient (for certain when when L[k] > 1 and retape[k] is true) -if the users also provided a version +if the users also provided a version of the function fg_info->eval_r(k, u) where \c u was of type \c NumberVector. */ @@ -420,7 +420,7 @@ obj_value = 0.; // update tape_ok_ flag - for(k = 0; k < K_; k++) + for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } @@ -478,17 +478,17 @@ the gradient of f(x). \param[in] new_x -is false if the previous call to any one of the -\ref Evaluation_Methods used the same value for \c x. +is false if the previous call to any one of the +\ref Deprecated_Evaluation_Methods used the same value for \c x. \param[out] grad_f is a vector of size \c n. The input value of its elements does not matter. -The output value of its elements is the gradient of f(x) +The output value of its elements is the gradient of f(x) at this value of. \return -The return value is always true; see \ref Evaluation_Methods. +The return value is always true; see \ref Deprecated_Evaluation_Methods. */ bool cppad_ipopt_nlp::eval_grad_f( Index n, const Number* x, bool new_x, Number* grad_f @@ -502,7 +502,7 @@ grad_f[j] = 0.; // update tape_ok_ flag - for(k = 0; k < K_; k++) + for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } @@ -571,8 +571,8 @@ the constraint function g(x). \param[in] new_x -is false if the previous call to any one of the -\ref Evaluation_Methods used the same value for \c x. +is false if the previous call to any one of the +\ref Deprecated_Evaluation_Methods used the same value for \c x. \param[in] m is the dimension of the range space for g(x); i.e., must be equal to \c m_. @@ -580,11 +580,11 @@ \param[out] g is a vector of size \c m. The input value of its elements does not matter. -The output value of its elements is +The output value of its elements is the value of the function g(x) at this value of \c x. \return -The return value is always true; see \ref Evaluation_Methods. +The return value is always true; see \ref Deprecated_Evaluation_Methods. */ bool cppad_ipopt_nlp::eval_g( Index n, const Number* x, bool new_x, Index m, Number* g @@ -598,7 +598,7 @@ g[i] = 0.; // update tape_ok_ flag - for(k = 0; k < K_; k++) + for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } @@ -660,8 +660,8 @@ the gradient of g(x). \param[in] new_x -is false if the previous call to any one of the -\ref Evaluation_Methods used the same value for \c x. +is false if the previous call to any one of the +\ref Deprecated_Evaluation_Methods used the same value for \c x. \param[in] m is the dimension of the range space for g(x); i.e., must be equal to \c m_. @@ -675,9 +675,9 @@ if \c values is \c NULL, \c iRow is a vector with size \c nele_jac. The input value of its elements does not matter. -On output, -For k = 0 , ... , nele_jac-1, iRow[k] is the -base zero row index for the +On output, +For k = 0 , ... , nele_jac-1, iRow[k] is the +base zero row index for the k-th possibly non-zero entry in the Jacobian of g(x). \param jCol @@ -685,22 +685,22 @@ if \c values is \c NULL, \c jCol is a vector with size \c nele_jac. The input value of its elements does not matter. -On output, -For k = 0 , ... , nele_jac-1, jCol[k] is the -base zero column index for the +On output, +For k = 0 , ... , nele_jac-1, jCol[k] is the +base zero column index for the k-th possibly non-zero entry in the Jacobian of g(x). \param values if \c values is not \c NULL, \c values is a vector with size \c nele_jac. The input value of its elements does not matter. -On output, -For k = 0 , ... , nele_jac-1, values[k] is the -value for the +On output, +For k = 0 , ... , nele_jac-1, values[k] is the +value for the k-th possibly non-zero entry in the Jacobian of g(x). \return -The return value is always true; see \ref Evaluation_Methods. +The return value is always true; see \ref Deprecated_Evaluation_Methods. */ bool cppad_ipopt_nlp::eval_jac_g(Index n, const Number* x, bool new_x, Index m, Index nele_jac, Index* iRow, Index *jCol, @@ -713,7 +713,7 @@ std::map::iterator index_ij; - if (values == NULL) + if (values == NULL) { for(k = 0; k < nnz_jac_g_; k++) { iRow[k] = iRow_jac_g_[k]; jCol[k] = jCol_jac_g_[k]; @@ -727,7 +727,7 @@ values[l] = 0.; // update tape_ok_ flag - for(k = 0; k < K_; k++) + for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } @@ -779,16 +779,16 @@ ); # endif - return true; + return true; } /*! Evaluate the Hessian of the Lagragian -\section The_Hessian_of_the_Lagragian The Hessian of the Lagragian +\section Deprecated_Hessian_of_the_Lagragian The Hessian of the Lagragian The Hessian of the Lagragian is defined as \f[ -H(x, \sigma, \lambda ) +H(x, \sigma, \lambda ) = \sigma \nabla^2 f(x) + \sum_{i=0}^{m-1} \lambda_i \nabla^2 g(x)_i \f] @@ -802,12 +802,12 @@ the Hessian of the Lagrangian. \param[in] new_x -is false if the previous call to any one of the -\ref Evaluation_Methods used the same value for \c x. +is false if the previous call to any one of the +\ref Deprecated_Evaluation_Methods used the same value for \c x. \param[in] obj_factor the value \f$ \sigma \f$ multiplying the Hessian of -f(x) in the expression for \ref The_Hessian_of_the_Lagragian. +f(x) in the expression for \ref Deprecated_Hessian_of_the_Lagragian. \param[in] m is the dimension of the range space for g(x); i.e., must be equal to \c m_. @@ -815,7 +815,7 @@ \param[in] lambda if \c values is not \c NULL, \c lambda is a vector of size \c m specifing the value of \f$ \lambda \f$ -in the expression for \ref The_Hessian_of_the_Lagragian. +in the expression for \ref Deprecated_Hessian_of_the_Lagragian. \param[in] new_lambda is true if the previous call to \c eval_h had the same value for @@ -831,9 +831,9 @@ if \c values is \c NULL, \c iRow is a vector with size \c nele_jac. The input value of its elements does not matter. -On output, -For k = 0 , ... , nele_jac-1, iRow[k] is the -base zero row index for the +On output, +For k = 0 , ... , nele_jac-1, iRow[k] is the +base zero row index for the k-th possibly non-zero entry in the Hessian of the Lagragian. \param jCol @@ -841,22 +841,22 @@ if \c values is \c NULL, \c jCol is a vector with size \c nele_jac. The input value of its elements does not matter. -On output, -For k = 0 , ... , nele_jac-1, jCol[k] is the -base zero column index for the +On output, +For k = 0 , ... , nele_jac-1, jCol[k] is the +base zero column index for the k-th possibly non-zero entry in the Hessian of the Lagragian. \param values if \c values is not \c NULL, it is a vector with size \c nele_jac. The input value of its elements does not matter. -On output, -For k = 0 , ... , nele_jac-1, values[k] is the -value for the +On output, +For k = 0 , ... , nele_jac-1, values[k] is the +value for the k-th possibly non-zero entry in the Hessian of the Lagragian. \return -The return value is always true; see \ref Evaluation_Methods. +The return value is always true; see \ref Deprecated_Evaluation_Methods. */ bool cppad_ipopt_nlp::eval_h(Index n, const Number* x, bool new_x, Number obj_factor, Index m, const Number* lambda, @@ -868,7 +868,7 @@ size_t i, j, k, ell, l; std::map::iterator index_ij; - if (values == NULL) + if (values == NULL) { for(k = 0; k < nnz_h_lag_; k++) { iRow[k] = iRow_h_lag_[k]; jCol[k] = jCol_h_lag_[k]; @@ -882,7 +882,7 @@ values[l] = 0.; // update tape_ok_ flag - for(k = 0; k < K_; k++) + for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } @@ -929,8 +929,8 @@ else r_hes = r_fun_[k].SparseHessian( u, w, pattern_hes_r_[k] ); - for(i = 0; i < q_[k]; i++) for(j = 0; j < q_[k]; j++) - if( J_[j] <= J_[i] ) + for(i = 0; i < q_[k]; i++) for(j = 0; j < q_[k]; j++) + if( J_[j] <= J_[i] ) { index_ij = index_hes_fg_[J_[i]].find(J_[j]); if( index_ij != index_hes_fg_[J_[i]].end() ) { l = index_ij->second; @@ -957,7 +957,7 @@ \param[in] status is value that the Ipopt solution status -which gets mapped to a correponding value for +which gets mapped to a correponding value for \n solution_->status. @@ -1021,12 +1021,12 @@ */ void cppad_ipopt_nlp::finalize_solution( Ipopt::SolverReturn status , - Index n , - const Number* x , - const Number* z_L , + Index n , + const Number* x , + const Number* z_L , const Number* z_U , - Index m , - const Number* g , + Index m , + const Number* g , const Number* lambda , Number obj_value , const Ipopt::IpoptData* ip_data , @@ -1040,62 +1040,62 @@ switch(status) { // convert status from Ipopt enum to cppad_ipopt_solution enum case Ipopt::SUCCESS: - solution_->status = + solution_->status = cppad_ipopt_solution::success; break; case Ipopt::MAXITER_EXCEEDED: - solution_->status = + solution_->status = cppad_ipopt_solution::maxiter_exceeded; break; case Ipopt::STOP_AT_TINY_STEP: - solution_->status = + solution_->status = cppad_ipopt_solution::stop_at_tiny_step; break; case Ipopt::STOP_AT_ACCEPTABLE_POINT: - solution_->status = + solution_->status = cppad_ipopt_solution::stop_at_acceptable_point; break; case Ipopt::LOCAL_INFEASIBILITY: - solution_->status = + solution_->status = cppad_ipopt_solution::local_infeasibility; break; case Ipopt::USER_REQUESTED_STOP: - solution_->status = + solution_->status = cppad_ipopt_solution::user_requested_stop; break; case Ipopt::DIVERGING_ITERATES: - solution_->status = + solution_->status = cppad_ipopt_solution::diverging_iterates; break; case Ipopt::RESTORATION_FAILURE: - solution_->status = + solution_->status = cppad_ipopt_solution::restoration_failure; break; case Ipopt::ERROR_IN_STEP_COMPUTATION: - solution_->status = + solution_->status = cppad_ipopt_solution::error_in_step_computation; break; case Ipopt::INVALID_NUMBER_DETECTED: - solution_->status = + solution_->status = cppad_ipopt_solution::invalid_number_detected; break; case Ipopt::INTERNAL_ERROR: - solution_->status = + solution_->status = cppad_ipopt_solution::internal_error; break; default: - solution_->status = + solution_->status = cppad_ipopt_solution::unknown; } @@ -1121,14 +1121,14 @@ // (trying to figure out a problem with Ipopt-3.9.1 and dismod4). bool cppad_ipopt_nlp::intermediate_callback( Ipopt::AlgorithmMode mode, - Index iter, + Index iter, Number obj_value, - Number inf_pr, + Number inf_pr, Number inf_du, - Number mu, + Number mu, Number d_norm, Number regularization_size, - Number alpha_du, + Number alpha_du, Number alpha_pr, Index ls_trials, const Ipopt::IpoptData* ip_data, diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/cppad_ipopt_nlp.hpp cppad-2016.00.00.1/cppad_ipopt/src/cppad_ipopt_nlp.hpp --- cppad-2015.00.00.9/cppad_ipopt/src/cppad_ipopt_nlp.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/cppad_ipopt_nlp.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: cppad_ipopt_nlp.hpp 2936 2013-10-13 11:44:13Z bradbell $ */ -# ifndef CPPAD_CPPAD_IPOPT_NLP_INCLUDED -# define CPPAD_CPPAD_IPOPT_NLP_INCLUDED +// $Id: cppad_ipopt_nlp.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_CPPAD_IPOPT_NLP_HPP +# define CPPAD_CPPAD_IPOPT_NLP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -34,18 +34,13 @@ fg_info.eval retape CppAD - + $$ $section Nonlinear Programming Using the CppAD Interface to Ipopt$$ +$mindex AD$$ -$index nonlinear, programming CppAD$$ -$index deprecated, ipopt interface$$ -$index programming, nonlinear$$ -$index CppAD, nonlinear programming$$ -$index Ipopt, AD$$ -$index AD, Ipopt$$ -$head Deprecated$$ +$head Deprecated 2012-11-28$$ This interface to Ipopt is deprecated, use $cref ipopt_solve$$ instead. $head Syntax$$ @@ -64,19 +59,19 @@ problems of the form $latex \[ \begin{array}{rll} -{\rm minimize} & f(x) +{\rm minimize} & f(x) \\ {\rm subject \; to} & g^l \leq g(x) \leq g^u \\ & x^l \leq x \leq x^u \end{array} \] $$ -This is done using +This is done using $href% http://www.coin-or.org/projects/Ipopt.xml% Ipopt %$$ -optimizer and +optimizer and $href% http://www.coin-or.org/CppAD/% CppAD @@ -85,14 +80,14 @@ $head cppad_ipopt namespace$$ All of the declarations for these routines -are in the $code cppad_ipopt$$ namespace +are in the $code cppad_ipopt$$ namespace (not the $code CppAD$$ namespace). For example; $cref/SizeVector/cppad_ipopt_nlp/SizeVector/$$ below actually denotes the type $code cppad_ipopt::SizeVector$$. $head ipopt_library_paths$$ If you are linking to a shared version of the Ipopt library, -you may have to add some paths the $code LD_LIBRARY_PATH$$ +you may have to add some paths the $code LD_LIBRARY_PATH$$ shell variable using the $code export$$ command in the syntax above. For example, if the file the ipopt library is $codei% @@ -138,8 +133,8 @@ the mapping $latex ( m \otimes I ): \B{R}^{|I|} \rightarrow \B{R}^m$$ defined by $latex \[ [ m \otimes I ] (y)_i = \left\{ \begin{array}{ll} -y_k & {\rm if} \; i = I(k) \; {\rm for \; some} \; - k \in \{ 0 , \cdots, |I|-1 \} +y_k & {\rm if} \; i = I(k) \; {\rm for \; some} \; + k \in \{ 0 , \cdots, |I|-1 \} \\ 0 & {\rm otherwise} \end{array} \right. @@ -155,22 +150,22 @@ $$ We use the functions -$latex r_k : \B{R}^{q(k)} \rightarrow \B{R}^{p(k)}$$ +$latex r_k : \B{R}^{q(k)} \rightarrow \B{R}^{p(k)}$$ for $latex k = 0 , \ldots , K$$ to express our representation of $latex fg(x)$$ in terms of simpler functions as follows $latex \[ -fg(x) = \sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1} +fg(x) = \sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1} [ (m+1) \otimes I_{k,\ell} ] \; \circ \; r_k \; \circ \; [ J_{k,\ell} \otimes n ] \; (x) \] $$ where $latex \circ$$ represents function composition, for $latex k = 0 , \ldots , K - 1$$, and $latex \ell = 0 , \ldots , L(k)$$, $latex I_{k,\ell}$$ and $latex J_{k,\ell}$$ are index vectors with -$latex | J_{k,\ell} | = q(k)$$, +$latex | J_{k,\ell} | = q(k)$$, $latex \| J_{k,\ell} \| < n$$, $latex | I_{k,\ell} | = p(k)$$, and -$latex \| I_{k,\ell} \| \leq m$$. +$latex \| I_{k,\ell} \| \leq m$$. $head Simple Representation$$ In the simple representation, @@ -183,34 +178,34 @@ and $latex J_{0,0} = (0 , \ldots , n-1)$$. $head SizeVector$$ -The type $codei SizeVector$$ is defined by the -$codei cppad_ipopt_nlp.hpp$$ include file to be a +The type $codei SizeVector$$ is defined by the +$codei cppad_ipopt_nlp.hpp$$ include file to be a $cref SimpleVector$$ class with elements of type $code size_t$$. $head NumberVector$$ -The type $codei NumberVector$$ is defined by the -$codei cppad_ipopt_nlp.hpp$$ include file to be a +The type $codei NumberVector$$ is defined by the +$codei cppad_ipopt_nlp.hpp$$ include file to be a $cref SimpleVector$$ class with elements of type $code Ipopt::Number$$. $head ADNumber$$ -The type $codei ADNumber$$ is defined by the -$codei cppad_ipopt_nlp.hpp$$ include file to be a +The type $codei ADNumber$$ is defined by the +$codei cppad_ipopt_nlp.hpp$$ include file to be a an AD type that can be used to compute derivatives. $head ADVector$$ -The type $codei ADVector$$ is defined by the -$codei cppad_ipopt_nlp.hpp$$ include file to be a +The type $codei ADVector$$ is defined by the +$codei cppad_ipopt_nlp.hpp$$ include file to be a $cref SimpleVector$$ class with elements of type -$code ADNumber$$. +$code ADNumber$$. $head n$$ The argument $icode n$$ has prototype $codei% size_t %n% %$$ -It specifies the dimension of the argument space; +It specifies the dimension of the argument space; i.e., $latex x \in \B{R}^n$$. $head m$$ @@ -218,7 +213,7 @@ $codei% size_t %m% %$$ -It specifies the dimension of the range space for $latex g$$; +It specifies the dimension of the range space for $latex g$$; i.e., $latex g : \B{R}^n \rightarrow \B{R}^m$$. $head x_i$$ @@ -270,9 +265,9 @@ $codei% %FG_info fg_info% %$$ -where the class $icode FG_info$$ is derived from the +where the class $icode FG_info$$ is derived from the base class $code cppad_ipopt_fg_info$$. -Certain virtual member functions of $icode fg_info$$ are used to +Certain virtual member functions of $icode fg_info$$ are used to compute the value of $latex fg(x)$$. The specifications for these member functions are given below: @@ -300,7 +295,7 @@ $codei% virtual ADVector cppad_ipopt_fg_info::eval_r(size_t %k%, const ADVector& %u%) = 0; %$$ -Thus it is a pure virtual function and must be defined in the +Thus it is a pure virtual function and must be defined in the derived class $icode FG_info$$. $pre @@ -309,7 +304,7 @@ used in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ for $latex fg(x)$$. If $icode k$$ in $latex \{0 , \ldots , K-1 \}$$ has type $code size_t$$, -$icode u$$ is an $code ADVector$$ of size $icode q(k)$$ +$icode u$$ is an $code ADVector$$ of size $icode q(k)$$ and $icode r$$ is an $code ADVector$$ of size $icode p(k)$$ the syntax $codei% @@ -329,19 +324,19 @@ %retape% = %fg_info%.retape(%k%) %$$ sets $icode retape$$ to true or false. -If $icode retape$$ is true, -$code cppad_ipopt_nlp$$ will retape the operation sequence +If $icode retape$$ is true, +$code cppad_ipopt_nlp$$ will retape the operation sequence corresponding to $latex r_k (u)$$ for -every value of $icode u$$. +every value of $icode u$$. An $code cppad_ipopt_nlp$$ object should use much less memory and run faster if $icode retape$$ is false. -You can test both the true and false cases to make sure +You can test both the true and false cases to make sure the operation sequence does not depend on $icode u$$. $pre $$ The $code cppad_ipopt_fg_info$$ implementation of this function -sets $icode retape$$ to true +sets $icode retape$$ to true (while slower it is also safer to always retape). $subhead fg_info.domain_size$$ @@ -412,38 +407,38 @@ virtual void cppad_ipopt_fg_info::index( size_t %k%, size_t %ell%, SizeVector& %I%, SizeVector& %J% ) -%$$ -The argument -$icode% +%$$ +The argument +$icode% k %$$ has type $codei size_t$$ and is a value between zero and $latex K-1$$ inclusive. -The argument -$icode% +The argument +$icode% ell %$$ has type $codei size_t$$ and is a value between zero and $latex L(k)-1$$ inclusive. -The argument +The argument $icode% I %$$ is a $cref SimpleVector$$ with elements of type $code size_t$$ and size greater than or equal to $latex p(k)$$. The input value of the elements of $icode I$$ does not matter. The output value of -the first $latex p(k)$$ elements of $icode I$$ -must be the corresponding elements of $latex I_{k,ell}$$ +the first $latex p(k)$$ elements of $icode I$$ +must be the corresponding elements of $latex I_{k,ell}$$ in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ above. -The argument +The argument $icode% J %$$ is a $cref SimpleVector$$ with elements of type $code size_t$$ and size greater than or equal to $latex q(k)$$. The input value of the elements of $icode J$$ does not matter. -The output value of -the first $latex q(k)$$ elements of $icode J$$ -must be the corresponding elements of $latex J_{k,ell}$$ +The output value of +the first $latex q(k)$$ elements of $icode J$$ +must be the corresponding elements of $latex J_{k,ell}$$ in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ above. $pre @@ -464,7 +459,7 @@ $codei% cppad_ipopt_solution::solution_status %solution%.status %$$ -It is the final Ipopt status for the optimizer. +It is the final Ipopt status for the optimizer. Here is a list of the possible values for the status: $table @@ -479,7 +474,7 @@ documentation for $code finalize_solution$$. $rnext success $cnext -Algorithm terminated successfully at a point satisfying the convergence +Algorithm terminated successfully at a point satisfying the convergence tolerances (see Ipopt options). $rnext maxiter_exceeded $cnext @@ -489,8 +484,8 @@ Algorithm terminated because progress was very slow. $rnext stop_at_acceptable_point $cnext -Algorithm stopped at a point that was converged, -not to the 'desired' tolerances, but to 'acceptable' tolerances +Algorithm stopped at a point that was converged, +not to the 'desired' tolerances, but to 'acceptable' tolerances (see Ipopt options). $rnext local_infeasibility $cnext @@ -507,11 +502,11 @@ Restoration phase failed, algorithm doesn't know how to proceed. $rnext error_in_step_computation $cnext -An unrecoverable error occurred while Ipopt tried to +An unrecoverable error occurred while Ipopt tried to compute the search direction. $rnext invalid_number_detected $cnext -Algorithm received an invalid number (such as $code nan$$ or $code inf$$) +Algorithm received an invalid number (such as $code nan$$ or $code inf$$) from the users function $icode%fg_info%.eval%$$ or from the CppAD evaluations of its derivatives (see the Ipopt option $code check_derivatives_for_naninf$$). @@ -535,7 +530,7 @@ NumberVector %solution%.z_l %$$ and its size is equal to $latex n$$. -It is the final Lagrange multipliers for the +It is the final Lagrange multipliers for the lower bounds on $latex x$$. $subhead z_u$$ @@ -544,7 +539,7 @@ NumberVector %solution%.z_u %$$ and its size is equal to $latex n$$. -It is the final Lagrange multipliers for the +It is the final Lagrange multipliers for the upper bounds on $latex x$$. $subhead g$$ @@ -561,7 +556,7 @@ NumberVector %solution%.lambda %$$ and its size is equal to $latex m$$. -It is the final value for the +It is the final value for the Lagrange multipliers corresponding to the constraint function. $subhead obj_value$$ @@ -579,21 +574,21 @@ %$$ $head Example$$ -The file -$cref ipopt_nlp_get_started.cpp$$ is an example and test of -$code cppad_ipopt_nlp$$ that uses the +The file +$cref ipopt_nlp_get_started.cpp$$ is an example and test of +$code cppad_ipopt_nlp$$ that uses the $cref/simple representation/cppad_ipopt_nlp/Simple Representation/$$. It returns true if it succeeds and false otherwise. The section $cref ipopt_nlp_ode$$ discusses an example that uses a more complex representation. $head Wish List$$ -This is a list of possible future improvements to +This is a list of possible future improvements to $code cppad_ipopt_nlp$$ that would require changed to the user interface: $list number$$ -The routine $codei%fg_info.eval_r(%k%, %u%)%$$ should also support +The routine $codei%fg_info.eval_r(%k%, %u%)%$$ should also support $codei NumberVector$$ for the type of the argument $code u$$ -(this would certainly be more efficient when +(this would certainly be more efficient when $codei%fg_info.retape(%k%)%$$ is true and $latex L(k) > 1$$). It could be an option for the user to provide this as well as the necessary $code ADVector$$ definition. @@ -690,7 +685,7 @@ Class that contains information about the problem solution \section Nonlinear_Programming_Problem Nonlinear Programming Problem -We are give smooth functions +We are give smooth functions \f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and \f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ @@ -699,7 +694,7 @@ \begin{array}{rcl} {\rm minimize} & f(x) & {\rm w.r.t.} \; x \in {\bf R}^n \\ -{\rm subject \; to} & g^l \leq g(x) \leq g^u +{\rm subject \; to} & g^l \leq g(x) \leq g^u \\ & x^l \leq x \leq x^u \end{array} @@ -707,31 +702,31 @@ \section Users_Representation Users Representation -The functions +The functions \f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and \f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by \f[ \left( \begin{array}{c} f(x) \\ g(x) \end{array} \right) = -\sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1} +\sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1} [ (m+1) \otimes I_{k,\ell} ] \; \circ \; r_k \; \circ \; [ J_{k,\ell} \otimes n ] \; (x) \f] where for \f$ k = 0 , \ldots , K-1\f$, \f$ r_k : {\bf R}^{q(k)} \rightarrow {\bf R}^{p(k)} \f$. -\section Evaluation_Methods Evaluation Methods +\section Deprecated_Evaluation_Methods Evaluation Methods The set of evaluation methods for this class is \verbatim { eval_f, eval_grad_f, eval_g, eval_jac_g, eval_h } \endverbatim -Note that the \c bool return flag for the evaluations methods +Note that the \c bool return flag for the evaluations methods does not appear in the Ipopt documentation. Looking at the code, it seems to be a flag telling Ipopt to abort when the flag is false. */ -class cppad_ipopt_solution +class cppad_ipopt_solution { public: /// possible values for he solution status @@ -769,7 +764,7 @@ { status = not_defined; } }; -/*! +/*! Class connects Ipopt to CppAD for derivative and sparsity pattern calculations. */ class cppad_ipopt_nlp : public Ipopt::TNLP @@ -777,9 +772,9 @@ private: /// A Scalar value used by Ipopt typedef Ipopt::Number Number; - /// An index value used by Ipopt + /// An index value used by Ipopt typedef Ipopt::Index Index; - /// Indexing style used in Ipopt sparsity structure + /// Indexing style used in Ipopt sparsity structure typedef Ipopt::TNLP::IndexStyleEnum IndexStyleEnum; /// A simple vector of boolean values typedef CppAD::vectorBool BoolVector; @@ -792,7 +787,7 @@ typedef CppAD::vector< std::map > IndexMap; // ------------------------------------------------------------------ - // Values directly passed in to constuctor + // Values directly passed in to constuctor // ------------------------------------------------------------------ /// dimension of the domain space for f(x) and g(x) /// (passed to ctor) @@ -803,10 +798,10 @@ /// dimension of the range space for g(x) /// (passed to ctor) const NumberVector x_i_; - /// lower limit for x + /// lower limit for x /// (size n_), (passed to ctor) const NumberVector x_l_; - /// upper limit for x + /// upper limit for x /// (size n_) (passed to ctor) const NumberVector x_u_; /// lower limit for g(x) @@ -815,7 +810,7 @@ /// upper limit for g(x) /// (size m_) (passed to ctor) const NumberVector g_u_; - /// pointer to base class version of derived class object used to get + /// pointer to base class version of derived class object used to get /// information about the user's representation for f(x) and g(x) /// (passed to ctor) cppad_ipopt_fg_info* const fg_info_; @@ -826,7 +821,7 @@ const Number infinity_; // ------------------------------------------------------------------ - // Effectively const values determined during constructor using calls + // Effectively const values determined during constructor using calls // to fg_info: // ------------------------------------------------------------------ /// The value of \f$ K \f$ in the representation. @@ -844,25 +839,25 @@ /// L_[k] is number of times \f$ r_k (u) \f$ appears in /// the representation summation /// (size K_) (effectively const) - SizeVector L_; + SizeVector L_; // ------------------------------------------------------------------- // Other effectively const values determined by the constructor: // ------------------------------------------------------------------- /*! - CppAD sparsity patterns for \f$ \{ r_k^{(1)} (u) \} \f$ (set by ctor). + CppAD sparsity patterns for \f$ \{ r_k^{(1)} (u) \} \f$ (set by ctor). - For k = 0 , ... , K_-1, pattern_jac_r_[k] - is a CppAD sparsity pattern for the Jacobian of \f$ r_k (u) \f$ + For k = 0 , ... , K_-1, pattern_jac_r_[k] + is a CppAD sparsity pattern for the Jacobian of \f$ r_k (u) \f$ and as such it has size p_[k]*q_[k]. (effectively const) */ BoolVectorVector pattern_jac_r_; /*! - CppAD sparsity patterns for \f$ \{ r_k^{(2)} (u) \} \f$ (set by ctor). + CppAD sparsity patterns for \f$ \{ r_k^{(2)} (u) \} \f$ (set by ctor). - For k = 0 , ... , K_-1, pattern_jac_r_[k] - is a CppAD sparsity pattern for the Hessian of + For k = 0 , ... , K_-1, pattern_jac_r_[k] + is a CppAD sparsity pattern for the Hessian of \f[ R(u) = \sum_{i=0}^{p[k]-1} r_k (u)_i \f] @@ -896,8 +891,8 @@ For i = 0 , ... , m_-1, index_jac_g_[i] is a standard map from column index values \c j to the corresponding - index in the Ipopt sparsity structure for the Jacobian of g(x). - */ + index in the Ipopt sparsity structure for the Jacobian of g(x). + */ IndexMap index_jac_g_; /*! @@ -906,21 +901,21 @@ For i = 0 , ... , n_-1, index_hes_fg_[i] is a standard map from column index values \c j to the corresponding index in the Ipopt sparsity structure for the Hessian of the Lagragian. - */ + */ IndexMap index_hes_fg_; // ----------------------------------------------------------------- // Values that are changed by routine other than the constructor: // ----------------------------------------------------------------- - /// For k = 0 , ... , K_-1, r_fun_[k] + /// For k = 0 , ... , K_-1, r_fun_[k] /// is a the CppAD function object corresponding to \f$ r_k (u) \f$. ADFunVector r_fun_; /*! - Is r_fun[k] OK for current x. - - For k = 0 , ... , K_-1, tape_ok_[k] - is true if current operations sequence in r_fun_[k] - OK for this value of \f$ x \f$. + Is r_fun[k] OK for current x. + + For k = 0 , ... , K_-1, tape_ok_[k] + is true if current operations sequence in r_fun_[k] + OK for this value of \f$ x \f$. Note that \f$ u = [ J_{k,\ell} \otimes n ] (x) \f$ may depend on the value of \f$ \ell \f$. */ @@ -929,9 +924,9 @@ /// work space of size equal maximum of q[k] w.r.t \c k. SizeVector J_; /// work space of size equal maximum of p[k] w.r.t \c k. - SizeVector I_; + SizeVector I_; // ------------------------------------------------------------ - // Private Methods + // Private Methods // ------------------------------------------------------------ /// block the default constructor from use cppad_ipopt_nlp(const cppad_ipopt_nlp&); @@ -944,7 +939,7 @@ /// only constructor for cppad_ipopot_nlp cppad_ipopt_nlp( - size_t n , + size_t n , size_t m , const NumberVector &x_i , const NumberVector &x_l , @@ -953,65 +948,65 @@ const NumberVector &g_u , cppad_ipopt_fg_info* fg_info , cppad_ipopt_solution* solution - ); + ); // use virtual so that derived class destructor gets called. virtual ~cppad_ipopt_nlp(); // return info about the nlp virtual bool get_nlp_info( - Index& n , - Index& m , + Index& n , + Index& m , Index& nnz_jac_g , - Index& nnz_h_lag , + Index& nnz_h_lag , IndexStyleEnum& index_style ); - // return bounds for my problem + // return bounds for my problem virtual bool get_bounds_info( - Index n , - Number* x_l , + Index n , + Number* x_l , Number* x_u , - Index m , - Number* g_l , - Number* g_u + Index m , + Number* g_l , + Number* g_u ); - // return the starting point for the algorithm + // return the starting point for the algorithm virtual bool get_starting_point( - Index n , - bool init_x , + Index n , + bool init_x , Number* x , - bool init_z , - Number* z_L , + bool init_z , + Number* z_L , Number* z_U , Index m , bool init_lambda , Number* lambda ); - // return the objective value + // return the objective value virtual bool eval_f( - Index n , - const Number* x , - bool new_x , + Index n , + const Number* x , + bool new_x , Number& obj_value ); - // Method to return the gradient of the objective + // Method to return the gradient of the objective virtual bool eval_grad_f( - Index n , - const Number* x , - bool new_x , + Index n , + const Number* x , + bool new_x , Number* grad_f - ); + ); // return the constraint residuals virtual bool eval_g( - Index n , - const Number* x , - bool new_x , - Index m , + Index n , + const Number* x , + bool new_x , + Index m , Number* g ); @@ -1019,12 +1014,12 @@ // 1) The structure of the jacobian (if "values" is NULL) // 2) The values of the jacobian (if "values" is not NULL) virtual bool eval_jac_g( - Index n , - const Number* x , + Index n , + const Number* x , bool new_x , - Index m , - Index nele_jac , - Index* iRow , + Index m , + Index nele_jac , + Index* iRow , Index* jCol , Number* values ); @@ -1033,29 +1028,29 @@ // 1) structure of hessian of the lagrangian (if "values" is NULL) // 2) values of hessian of the lagrangian (if "values" is not NULL) virtual bool eval_h( - Index n , - const Number* x , + Index n , + const Number* x , bool new_x , - Number obj_factor , - Index m , + Number obj_factor , + Index m , const Number* lambda , - bool new_lambda , - Index nele_hess , + bool new_lambda , + Index nele_hess , Index* iRow , - Index* jCol , + Index* jCol , Number* values ); - // called when the algorithm is completed so the TNLP can - // store/write the solution + // called when the algorithm is completed so the TNLP can + // store/write the solution virtual void finalize_solution( Ipopt::SolverReturn status , - Index n , - const Number* x , - const Number* z_L , + Index n , + const Number* x , + const Number* z_L , const Number* z_U , - Index m , - const Number* g , + Index m , + const Number* g , const Number* lambda , Number obj_value , const Ipopt::IpoptData* ip_data , @@ -1064,14 +1059,14 @@ virtual bool intermediate_callback( Ipopt::AlgorithmMode mode, - Index iter, + Index iter, Number obj_value, - Number inf_pr, + Number inf_pr, Number inf_du, - Number mu, + Number mu, Number d_norm, Number regularization_size, - Number alpha_du, + Number alpha_du, Number alpha_pr, Index ls_trials, const Ipopt::IpoptData* ip_data, diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/fun_record.hpp cppad-2016.00.00.1/cppad_ipopt/src/fun_record.hpp --- cppad-2015.00.00.9/cppad_ipopt/src/fun_record.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/fun_record.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: fun_record.hpp 3223 2014-03-19 15:13:26Z bradbell $ */ -# ifndef CPPAD_FUN_RECORD_INCLUDED -# define CPPAD_FUN_RECORD_INCLUDED +// $Id: fun_record.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_FUN_RECORD_HPP +# define CPPAD_FUN_RECORD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,7 +19,7 @@ /*! \{ \file fun_record.hpp -\brief Records operation sequence for r_k (u) +\brief Records operation sequence for r_k (u) */ /*! @@ -27,7 +27,7 @@ \tparam NumVector is the type of the argumen \c x. It can either be -Ipopt::Number* or +Ipopt::Number* or CppAD::vector; i.e., NumberVector. \param fg_info @@ -35,12 +35,12 @@ \c fg_info returns the value \f$ r_k (u) \in {\bf R}^{p[k]} \f$. using the syntax \verbatim - fg_info->eval_r(k, u); + fg_info->eval_r(k, u); \endverbatim No other use is made of \c fg_info. \param k -is a value less that \c K specifying +is a value less that \c K specifying the index value for \c k in the evaluation eval_r. \param p @@ -55,7 +55,7 @@ is the lenght of the vector \c x. \param x -the length of \c x is equal to \c n and the point +the length of \c x is equal to \c n and the point \f[ u = [ J \circ n ] (x) \f] @@ -63,10 +63,10 @@ \param J is a vector with lenght q[k] that projects from \f$ {\bf R}^n \f$ -to \f$ {\bf R}^{q[k]} \f$ +to \f$ {\bf R}^{q[k]} \f$ by selecting an ordered subset of the possible indices \f$ \{ 0 , \ldots , n-1 \} \f$. -Hence, 0 <= J[j] < n for j = 0 , ... , q[k]-1. +Hence, 0 <= J[j] < n for j = 0 , ... , q[k]-1. \param r_fun is the vector of AD function objects which has size size greater than \c k. @@ -77,7 +77,7 @@ */ template -void fun_record( +void fun_record( cppad_ipopt_fg_info* fg_info , size_t k , const SizeVector& p , @@ -91,7 +91,7 @@ // extract u from x ADVector u(q[k]); for(j = 0; j < q[k]; j++) - { // when NDEBUG is not defined, this error should be caught + { // when NDEBUG is not defined, this error should be caught // during the cppad_ipopt_nlp constructor. CPPAD_ASSERT_UNKNOWN( J[j] < n ); u[j] = x[ J[j] ]; @@ -106,7 +106,7 @@ "cppad_ipopt_nlp: eval_r return value size not equal to p[k]." ); - // stop the recording and store operation sequence in + // stop the recording and store operation sequence in r_fun[k].Dependent(u, r_k); } // --------------------------------------------------------------------------- diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/hes_fg_map.cpp cppad-2016.00.00.1/cppad_ipopt/src/hes_fg_map.cpp --- cppad-2015.00.00.9/cppad_ipopt/src/hes_fg_map.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/hes_fg_map.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: hes_fg_map.cpp 3223 2014-03-19 15:13:26Z bradbell $ */ +// $Id: hes_fg_map.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,18 +18,18 @@ /*! \{ \file hes_fg_map.cpp -\brief Creates a mapping between two representations for Hessian of fg. +\brief Creates a mapping between two representations for Hessian of fg. */ /*! Create mapping from CppAD to Ipopt sparse representations of Hessian of F(x). -The functions +The functions \f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and -\f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by the +\f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by the \ref Users_Representation. -We define the function +We define the function \f$ F : {\bf R}^n \rightarrow {\bf R} \f$ by \f[ F(x) = \sum_{i=0}^m fg(x)_i @@ -38,13 +38,13 @@ \param fg_info For k = 0 , ... , K-1, for ell = 0 , ... , L[k], -the function call +the function call \verbatim - fg_info->index(k, ell, I, J); + fg_info->index(k, ell, I, J); \endverbatim -is made by \c hes_fg_map. +is made by \c hes_fg_map. The values \c k and \c ell are inputs. -The input size of \c I ( \c J ) +The input size of \c I ( \c J ) is greater than or equal p[k] ( q[k] ) and this size is not changed. The input values of the elements of \c I and \c J are not specified. @@ -66,7 +66,7 @@ i.e., \f$ x \in {\bf R}^n \f$. \param K -is the number of functions \f$ r_k ( u ) \f$ used for the representation of +is the number of functions \f$ r_k ( u ) \f$ used for the representation of \f$ f(x) \f$ and \f$ g(x) \f$. \param L @@ -90,7 +90,7 @@ \param pattern_hes_r is a vector with size \c K. For k = 0 , ... , K-1, pattern_jac_r[k] -is a CppAD sparsity pattern for the Hessian of the function +is a CppAD sparsity pattern for the Hessian of the function \f[ R(u) = \sum_{i=0}^{p[k]-1} r_k (u)_i \f] @@ -108,14 +108,14 @@ \param index_hes_fg: On input, this is empty; i.e., index_jac_g.size() == 0. -On output, it is the index mapping from \f$ (i, j) \f$ in the Jacobian of +On output, it is the index mapping from \f$ (i, j) \f$ in the Jacobian of \f$ g(x) \f$ to the corresponding index value used by Ipopt to represent the Jacobian. Furthermore, if index_jac_g[i].find(j) == index_jac_g[i].end(), then the \f$ (i, j)\f$ entry in the Jacobian of \f$ g(x) \f$ is always zero. */ void hes_fg_map( - cppad_ipopt_fg_info* fg_info , + cppad_ipopt_fg_info* fg_info , size_t m , size_t n , size_t K , @@ -141,13 +141,13 @@ CPPAD_ASSERT_UNKNOWN( q[k]*q[k] == pattern_hes_r[k].size() ); } # endif - + // Now compute pattern for fg // (use standard set representation because can be huge). CppAD::vector< std::set > pattern_hes_fg(n); for(k = 0; k < K; k++) for(ell = 0; ell < L[k]; ell++) - { fg_info->index(k, ell, I, J); - for(i = 0; i < q[k]; i++) + { fg_info->index(k, ell, I, J); + for(i = 0; i < q[k]; i++) { for(j = 0; j < q[k]; j++) { ij = i * q[k] + j; if( pattern_hes_r[k][ij] ) @@ -156,14 +156,14 @@ } } - // Now compute the mapping from (i, j) in the Hessian of fg to the + // Now compute the mapping from (i, j) in the Hessian of fg to the // corresponding index value used by Ipopt to represent the Hessian. CPPAD_ASSERT_UNKNOWN( index_hes_fg.size() == 0 ); index_hes_fg.resize(n); std::set::const_iterator itr; ell = 0; for(i = 0; i < n; i++) - { for( itr = pattern_hes_fg[i].begin(); + { for( itr = pattern_hes_fg[i].begin(); itr != pattern_hes_fg[i].end(); itr++) { index_hes_fg[i][*itr] = ell++; diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/hes_fg_map.hpp cppad-2016.00.00.1/cppad_ipopt/src/hes_fg_map.hpp --- cppad-2015.00.00.9/cppad_ipopt/src/hes_fg_map.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/hes_fg_map.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: hes_fg_map.hpp 2622 2012-12-23 11:45:24Z bradbell $ */ -# ifndef CPPAD_HES_FG_MAP_INCLUDED -# define CPPAD_HES_FG_MAP_INCLUDED +// $Id: hes_fg_map.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_HES_FG_MAP_HPP +# define CPPAD_HES_FG_MAP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,7 +24,7 @@ extern void hes_fg_map( - cppad_ipopt_fg_info* fg_info , + cppad_ipopt_fg_info* fg_info , size_t m , size_t n , size_t K , @@ -34,7 +34,7 @@ const CppAD::vector& pattern_hes_r , CppAD::vector& I , CppAD::vector& J , - CppAD::vector< std::map >& index_hes_fg + CppAD::vector< std::map >& index_hes_fg ); // --------------------------------------------------------------------------- diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/jac_g_map.cpp cppad-2016.00.00.1/cppad_ipopt/src/jac_g_map.cpp --- cppad-2015.00.00.9/cppad_ipopt/src/jac_g_map.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/jac_g_map.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: jac_g_map.cpp 3223 2014-03-19 15:13:26Z bradbell $ */ +// $Id: jac_g_map.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,14 +17,14 @@ /*! \{ \file jac_g_map.cpp -\brief Creates a mapping between two representations for Jacobian of g. +\brief Creates a mapping between two representations for Jacobian of g. */ /*! Create mapping from CppAD to Ipopt sparse representations of Jacobian of g. -The functions +The functions \f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and \f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by the \ref Users_Representation. @@ -32,13 +32,13 @@ \param fg_info For k = 0 , ... , K-1, for ell = 0 , ... , L[k], -the function call +the function call \verbatim - fg_info->index(k, ell, I, J); + fg_info->index(k, ell, I, J); \endverbatim -is made by \c jac_g_map. +is made by \c jac_g_map. The values \c k and \c ell are inputs. -The input size of \c I ( \c J ) +The input size of \c I ( \c J ) is greater than or equal p[k] ( q[k] ) and this size is not changed. The input values of the elements of \c I and \c J are not specified. @@ -60,7 +60,7 @@ i.e., \f$ x \in {\bf R}^n \f$. \param K -is the number of functions \f$ r_k ( u ) \f$ used for the representation of +is the number of functions \f$ r_k ( u ) \f$ used for the representation of \f$ f(x) \f$ and \f$ g(x) \f$. \param L @@ -84,7 +84,7 @@ \param pattern_jac_r is a vector with size \c K. For k = 0 , ... , K-1, pattern_jac_r[k] -is a CppAD sparsity pattern for the Jacobian of the function +is a CppAD sparsity pattern for the Jacobian of the function \f$ r_k : {\bf R}^{q(k)} \rightarrow {\bf R}^{p(k)} \f$. As such, pattern_jac_r[k].size() == p[k] * q[k]. @@ -100,14 +100,14 @@ \param index_jac_g: On input, this is empty; i.e., index_jac_g.size() == 0. -On output, it is the index mapping from \f$ (i, j) \f$ in the Jacobian of +On output, it is the index mapping from \f$ (i, j) \f$ in the Jacobian of \f$ g(x) \f$ to the corresponding index value used by Ipopt to represent the Jacobian. Furthermore, if index_jac_g[i].find(j) == index_jac_g[i].end(), then the \f$ (i, j)\f$ entry in the Jacobian of \f$ g(x) \f$ is always zero. */ void jac_g_map( - cppad_ipopt_fg_info* fg_info , + cppad_ipopt_fg_info* fg_info , size_t m , size_t n , size_t K , @@ -137,7 +137,7 @@ // (use standard set representation because can be huge). CppAD::vector< std::set > pattern_jac_g(m); for(k = 0; k < K; k++) for(ell = 0; ell < L[k]; ell++) - { fg_info->index(k, ell, I, J); + { fg_info->index(k, ell, I, J); for(i = 0; i < p[k]; i++) if( I[i] != 0 ) { for(j = 0; j < q[k]; j++) { ij = i * q[k] + j; @@ -147,14 +147,14 @@ } } - // Now compute the mapping from (i, j) in the Jacobian of g to the + // Now compute the mapping from (i, j) in the Jacobian of g to the // corresponding index value used by Ipopt to represent the Jacobian. CPPAD_ASSERT_UNKNOWN( index_jac_g.size() == 0 ); index_jac_g.resize(m); std::set::const_iterator itr; ell = 0; for(i = 0; i < m; i++) - { for( itr = pattern_jac_g[i].begin(); + { for( itr = pattern_jac_g[i].begin(); itr != pattern_jac_g[i].end(); itr++) { index_jac_g[i][*itr] = ell++; diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/jac_g_map.hpp cppad-2016.00.00.1/cppad_ipopt/src/jac_g_map.hpp --- cppad-2015.00.00.9/cppad_ipopt/src/jac_g_map.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/jac_g_map.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: jac_g_map.hpp 2622 2012-12-23 11:45:24Z bradbell $ */ -# ifndef CPPAD_JAC_G_MAP_INCLUDED -# define CPPAD_JAC_G_MAP_INCLUDED +// $Id: jac_g_map.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_JAC_G_MAP_HPP +# define CPPAD_JAC_G_MAP_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,7 +24,7 @@ extern void jac_g_map( - cppad_ipopt_fg_info* fg_info , + cppad_ipopt_fg_info* fg_info , size_t m , size_t n , size_t K , @@ -34,7 +34,7 @@ const CppAD::vector& pattern_jac_r , CppAD::vector& I , CppAD::vector& J , - CppAD::vector< std::map >& index_jac_g + CppAD::vector< std::map >& index_jac_g ); // --------------------------------------------------------------------------- diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/makefile.am cppad-2016.00.00.1/cppad_ipopt/src/makefile.am --- cppad-2015.00.00.9/cppad_ipopt/src/makefile.am 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/makefile.am 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2683 2012-12-30 18:17:03Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -15,7 +15,7 @@ DEFS = # # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = \ -I. \ @@ -38,5 +38,5 @@ sparse_map2vec.cpp \ sparse_map2vec.hpp \ vec_fun_pattern.cpp \ - vec_fun_pattern.hpp + vec_fun_pattern.hpp endif diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/makefile.in cppad-2016.00.00.1/cppad_ipopt/src/makefile.in --- cppad-2015.00.00.9/cppad_ipopt/src/makefile.in 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/makefile.in 2016-02-09 08:31:57.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ build_triplet = @build@ host_triplet = @host@ subdir = cppad_ipopt/src -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -201,6 +210,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -231,12 +241,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -317,26 +327,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -376,7 +389,7 @@ top_srcdir = @top_srcdir@ # # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = \ -I. \ @@ -399,7 +412,7 @@ @CppAD_IPOPT_TRUE@ sparse_map2vec.cpp \ @CppAD_IPOPT_TRUE@ sparse_map2vec.hpp \ @CppAD_IPOPT_TRUE@ vec_fun_pattern.cpp \ -@CppAD_IPOPT_TRUE@ vec_fun_pattern.hpp +@CppAD_IPOPT_TRUE@ vec_fun_pattern.hpp all: all-am @@ -417,7 +430,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cppad_ipopt/src/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu cppad_ipopt/src/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -703,6 +715,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-libLIBRARIES +.PRECIOUS: makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/sparse_map2vec.cpp cppad-2016.00.00.1/cppad_ipopt/src/sparse_map2vec.cpp --- cppad-2015.00.00.9/cppad_ipopt/src/sparse_map2vec.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/sparse_map2vec.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_map2vec.cpp 3223 2014-03-19 15:13:26Z bradbell $ */ +// $Id: sparse_map2vec.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/sparse_map2vec.hpp cppad-2016.00.00.1/cppad_ipopt/src/sparse_map2vec.hpp --- cppad-2015.00.00.9/cppad_ipopt/src/sparse_map2vec.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/sparse_map2vec.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: sparse_map2vec.hpp 2622 2012-12-23 11:45:24Z bradbell $ */ -# ifndef CPPAD_SPARSE_MAP2VEC_INCLUDED -# define CPPAD_SPARSE_MAP2VEC_INCLUDED +// $Id: sparse_map2vec.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_SPARSE_MAP2VEC_HPP +# define CPPAD_SPARSE_MAP2VEC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/vec_fun_pattern.cpp cppad-2016.00.00.1/cppad_ipopt/src/vec_fun_pattern.cpp --- cppad-2015.00.00.9/cppad_ipopt/src/vec_fun_pattern.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/vec_fun_pattern.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: vec_fun_pattern.cpp 3223 2014-03-19 15:13:26Z bradbell $ */ +// $Id: vec_fun_pattern.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -67,7 +67,7 @@ On input, For k = 0 , ... , K-1, pattern_jac_r[k] is a vector of length p[k] * q[k] and the value of its elements does not matter. -On output it is a CppAD sparsity pattern for the Jacobian of +On output it is a CppAD sparsity pattern for the Jacobian of \f$ r_k (u) \f$. \param pattern_hes_r @@ -75,7 +75,7 @@ On input, For k = 0 , ... , K-1, pattern_hes_r[k] is a vector of length q[k] * q[k] and the value of its elements does not matter. -On output it is a CppAD sparsity pattern for the Hessian of +On output it is a CppAD sparsity pattern for the Hessian of \f$ R : {\bf R}^{q[k]} \rightarrow {\bf R} \f$ which is defined by \f[ R(u) = \sum_{i=0}^{p[k]-1} r_k (u)_i @@ -108,14 +108,14 @@ if( retape[k] ) { for(i = 0; i < p[k]; i++) { for(j = 0; j < q[k]; j++) - pattern_jac_r[k][i*q[k] + j] = true; + pattern_jac_r[k][i*q[k] + j] = true; } for(i = 0; i < q[k]; i++) { for(j = 0; j < q[k]; j++) - pattern_hes_r[k][i*q[k] + j] = true; + pattern_hes_r[k][i*q[k] + j] = true; } } - else + else { // check assumptions about r_k CPPAD_ASSERT_UNKNOWN( r_fun[k].Range() == p[k] ); CPPAD_ASSERT_UNKNOWN( r_fun[k].Domain() == q[k] ); @@ -123,11 +123,11 @@ // pattern for the identity matrix CppAD::vectorBool pattern_domain(q[k] * q[k]); for(i = 0; i < q[k]; i++) - { for(j = 0; j < q[k]; j++) + { for(j = 0; j < q[k]; j++) pattern_domain[i*q[k] + j] = (i == j); } // use forward mode to compute Jacobian sparsity - pattern_jac_r[k] = + pattern_jac_r[k] = r_fun[k].ForSparseJac(q[k], pattern_domain); // user reverse mode to compute Hessian sparsity CppAD::vectorBool pattern_ones(p[k]); diff -Nru cppad-2015.00.00.9/cppad_ipopt/src/vec_fun_pattern.hpp cppad-2016.00.00.1/cppad_ipopt/src/vec_fun_pattern.hpp --- cppad-2015.00.00.9/cppad_ipopt/src/vec_fun_pattern.hpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/src/vec_fun_pattern.hpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: vec_fun_pattern.hpp 2622 2012-12-23 11:45:24Z bradbell $ */ -# ifndef CPPAD_VEC_FUN_PATTERN_INCLUDED -# define CPPAD_VEC_FUN_PATTERN_INCLUDED +// $Id: vec_fun_pattern.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_VEC_FUN_PATTERN_HPP +# define CPPAD_VEC_FUN_PATTERN_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -29,7 +29,7 @@ const CppAD::vectorBool& retape , CppAD::vector< CppAD::ADFun >& r_fun , CppAD::vector& pattern_jac_r , - CppAD::vector& pattern_hes_r + CppAD::vector& pattern_hes_r ); // --------------------------------------------------------------------------- diff -Nru cppad-2015.00.00.9/cppad_ipopt/test/CMakeLists.txt cppad-2016.00.00.1/cppad_ipopt/test/CMakeLists.txt --- cppad-2015.00.00.9/cppad_ipopt/test/CMakeLists.txt 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/test/CMakeLists.txt 2016-02-09 08:31:57.000000000 +0000 @@ -1,18 +1,18 @@ -# $Id: CMakeLists.txt 3116 2014-02-24 21:44:26Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the cppad_ipopt/test directory tests +# Build the cppad_ipopt/test directory tests # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) @@ -34,10 +34,11 @@ add_cppad_cxx_flags(cppad_ipopt_test) # List of libraries to be linked into the specified target -TARGET_LINK_LIBRARIES(cppad_ipopt_test - cppad_ipopt - ${ipopt_LIBRARIES} - ${colpack_libs} +TARGET_LINK_LIBRARIES(cppad_ipopt_test + cppad_ipopt + ${cppad_lib} + ${ipopt_LIBRARIES} + ${colpack_libs} ) # Add the check_cppad_ipopt_test target diff -Nru cppad-2015.00.00.9/cppad_ipopt/test/k_gt_one.cpp cppad-2016.00.00.1/cppad_ipopt/test/k_gt_one.cpp --- cppad-2015.00.00.9/cppad_ipopt/test/k_gt_one.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/test/k_gt_one.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: k_gt_one.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: k_gt_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,8 +17,8 @@ // --------------------------------------------------------------------------- /* -This solve the same problem as -../cppad_ipopt/cppad_ipopt_simple.cpp (repository revision +This solve the same problem as +../cppad_ipopt/cppad_ipopt_simple.cpp (repository revision 1276) in a convoluted way in order to test the representation code. */ class FG_K_gt_one : public cppad_ipopt_fg_info @@ -35,7 +35,7 @@ ADVector eval_r(size_t k, const ADVector& u) { - // Fortran style indexing + // Fortran style indexing ADNumber x1 = u[3]; ADNumber x2 = u[2]; ADNumber x3 = u[1]; @@ -72,7 +72,7 @@ I[0] = 0; else { I[0] = 1; - I[1] = 2; + I[1] = 2; } // reverse the order of the variables in u from that in x for(size_t j = 0; j < 4; j++) @@ -80,14 +80,14 @@ } }; } // end empty namespace - + bool k_gt_one(void) { bool ok = true; size_t j; // number of independent variables (domain dimension for f and g) - size_t n = 4; + size_t n = 4; // number of constraints (range dimension for g) size_t m = 2; // initial value of the independent variables @@ -107,7 +107,7 @@ NumberVector g_l(m); NumberVector g_u(m); g_l[0] = 25.0; g_u[0] = 1.0e19; - g_l[1] = 40.0; g_u[1] = 40.0; + g_l[1] = 40.0; g_u[1] = 40.0; // known solution to check against double check_x[] = { 1.000000, 4.743000, 3.82115, 1.379408 }; @@ -115,7 +115,7 @@ size_t icase; for(icase = 0; icase <= 1; icase++) { // Should cppad_ipopt_nlp retape the operation sequence for - // every new x. Can test both true and false cases because + // every new x. Can test both true and false cases because // the operation sequence does not depend on x (for this case). bool retape = bool(icase); @@ -127,7 +127,7 @@ // object in derived class FG_K_gt_one my_fg_info(retape); - cppad_ipopt_fg_info *fg_info = &my_fg_info; + cppad_ipopt_fg_info *fg_info = &my_fg_info; // create the Ipopt interface cppad_ipopt_solution solution; @@ -147,7 +147,7 @@ app->Options()->SetIntegerValue("max_iter", 10); // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) app->Options()->SetNumericValue("tol", 1e-9); @@ -164,8 +164,8 @@ ok &= status == Ipopt::Solve_Succeeded; /* - Check some of the solution values - */ + Check some of the solution values + */ ok &= solution.status == cppad_ipopt_solution::success; // double check_z_l[] = { 1.087871, 0., 0., 0. }; diff -Nru cppad-2015.00.00.9/cppad_ipopt/test/makefile.am cppad-2016.00.00.1/cppad_ipopt/test/makefile.am --- cppad-2015.00.00.9/cppad_ipopt/test/makefile.am 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/test/makefile.am 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2506 2012-10-24 19:36:49Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -18,7 +18,7 @@ # check_PROGRAMS = test_more # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ @@ -33,7 +33,7 @@ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) -AM_LDFLAGS = -L../src +AM_LDFLAGS = -L../src # test_more_SOURCES = \ test_more.cpp \ diff -Nru cppad-2015.00.00.9/cppad_ipopt/test/makefile.in cppad-2016.00.00.1/cppad_ipopt/test/makefile.in --- cppad-2015.00.00.9/cppad_ipopt/test/makefile.in 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/test/makefile.in 2016-02-09 08:31:57.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = test_more$(EXEEXT) subdir = cppad_ipopt/test -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(srcdir)/test.sh.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test.sh CONFIG_CLEAN_VPATH_FILES = @@ -151,6 +160,8 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/test.sh.in \ + $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -181,12 +192,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -267,26 +278,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -327,7 +341,7 @@ # EXTRA_DIST = test.sh.in # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ @@ -344,7 +358,7 @@ $(PTHREAD_LIB) \ $(DL_LIB) -AM_LDFLAGS = -L../src +AM_LDFLAGS = -L../src # test_more_SOURCES = \ test_more.cpp \ @@ -369,7 +383,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cppad_ipopt/test/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu cppad_ipopt/test/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -626,6 +639,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check ./test.sh diff -Nru cppad-2015.00.00.9/cppad_ipopt/test/multiple_solution.cpp cppad-2016.00.00.1/cppad_ipopt/test/multiple_solution.cpp --- cppad-2015.00.00.9/cppad_ipopt/test/multiple_solution.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/test/multiple_solution.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: multiple_solution.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: multiple_solution.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -42,7 +42,7 @@ size_t domain_size(size_t k) { size_t q; switch(k) - { case 0: q = 1; break; + { case 0: q = 1; break; default: assert(0); } return q; @@ -81,7 +81,7 @@ { assert( u.size() == 1 ); ADVector r(1); - r[0] = u[0] ; + r[0] = u[0] ; return r; } }; @@ -93,7 +93,7 @@ // number of independent variables (domain dimension for f and g) size_t n = 2; // number of constraints (range dimension for g) - size_t m = 2; + size_t m = 2; // initial value of the independent variables NumberVector x_i(n); NumberVector x_l(n); diff -Nru cppad-2015.00.00.9/cppad_ipopt/test/retape_k1_l1.cpp cppad-2016.00.00.1/cppad_ipopt/test/retape_k1_l1.cpp --- cppad-2015.00.00.9/cppad_ipopt/test/retape_k1_l1.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/test/retape_k1_l1.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: retape_k1_l1.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: retape_k1_l1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,7 +30,7 @@ // f(x) if( x[0] >= 1. ) fg[0] = .5 * (x[0] * x[0] + x[1] * x[1]); - else fg[0] = x[0] + .5 * x[1] * x[1]; + else fg[0] = x[0] + .5 * x[1] * x[1]; // g (x) fg[1] = x[0]; @@ -38,7 +38,7 @@ } bool retape(size_t k) { return true; } -}; +}; } // end of empty namespace bool retape_k1_l1(void) @@ -47,7 +47,7 @@ // number of independent variables (domain dimension for f and g) - size_t n = 2; + size_t n = 2; // number of constraints (range dimension for g) size_t m = 1; // initial value of the independent variables @@ -67,7 +67,7 @@ // object in derived class FG_retape fg_retape; - cppad_ipopt_fg_info *fg_info = &fg_retape; + cppad_ipopt_fg_info *fg_info = &fg_retape; // create the Ipopt interface cppad_ipopt_solution solution; @@ -87,7 +87,7 @@ app->Options()->SetIntegerValue("max_iter", 10); // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) app->Options()->SetNumericValue("tol", 1e-9); @@ -104,8 +104,8 @@ ok &= status == Ipopt::Solve_Succeeded; /* - Check some of the solution values - */ + Check some of the solution values + */ ok &= solution.status == cppad_ipopt_solution::success; // double check_x[] = { -1., 0. }; diff -Nru cppad-2015.00.00.9/cppad_ipopt/test/retape_k1_l2.cpp cppad-2016.00.00.1/cppad_ipopt/test/retape_k1_l2.cpp --- cppad-2015.00.00.9/cppad_ipopt/test/retape_k1_l2.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/test/retape_k1_l2.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: retape_k1_l2.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: retape_k1_l2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -56,13 +56,13 @@ } }; } // end empty namespace - + bool retape_k1_l2(void) { bool ok = true; size_t j; // number of independent variables (domain dimension for f and g) - size_t n = 2; + size_t n = 2; // no constraints (range dimension for g) size_t m = 0; // initial value of the independent variables @@ -82,7 +82,7 @@ // object in derived class FG_info my_fg_info; - cppad_ipopt_fg_info *fg_info = &my_fg_info; + cppad_ipopt_fg_info *fg_info = &my_fg_info; // create the Ipopt interface cppad_ipopt_solution solution; @@ -102,7 +102,7 @@ app->Options()->SetIntegerValue("max_iter", 10); // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) app->Options()->SetNumericValue("tol", 1e-9); @@ -119,8 +119,8 @@ ok &= status == Ipopt::Solve_Succeeded; /* - Check the solution values - */ + Check the solution values + */ ok &= solution.status == cppad_ipopt_solution::success; // double rel_tol = 1e-6; // relative tolerance diff -Nru cppad-2015.00.00.9/cppad_ipopt/test/test_more.cpp cppad-2016.00.00.1/cppad_ipopt/test/test_more.cpp --- cppad-2015.00.00.9/cppad_ipopt/test/test_more.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/cppad_ipopt/test/test_more.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: test_more.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: test_more.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -53,7 +53,7 @@ ok &= Run( multiple_solution, "multiple_solution" ); ok &= Run( retape_k1_l1, "retape_k1_l1" ); ok &= Run( retape_k1_l2, "retape_k1_l2" ); - + // check for errors using std::cout; using std::endl; diff -Nru cppad-2015.00.00.9/cppad_lib/CMakeLists.txt cppad-2016.00.00.1/cppad_lib/CMakeLists.txt --- cppad-2015.00.00.9/cppad_lib/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad_lib/CMakeLists.txt 2016-02-09 08:31:53.000000000 +0000 @@ -0,0 +1,51 @@ +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +# Build and install the cppad_lib shared library +# +# string(REGEX REPLACE +# +# [...]) +# +# (year - 2000) dot (remove leading 0 from mmdd) dot (release) +# Note that the dot (release) is optional +# Also name that when mmdd is 0000 get (year - 2000) dot dot (release) +STRING(REGEX REPLACE + "20([0-9][0-9])0*([0-9]*)([.]?[0-9]*)" + "\\1.\\2\\3" + soversion + ${cppad_version} +) +# In case where mmdd is 0000, dot (release) is present. Convert to +# (year - 2000) dot 0 dot (release) +STRING(REGEX REPLACE + "([.][.])" + ".0." + soversion + ${soversion} +) +MESSAGE(STATUS "soversion=${soversion}") +# +# add_library( [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] +# source1 source2 ... sourceN) +# ) +ADD_LIBRARY( cppad_lib SHARED + cppad_colpack.cpp +) +# set_target_properties(target1 target2 ... +# PROPERTIES prop1 value1 prop2 value2 ...) +SET_TARGET_PROPERTIES( cppad_lib PROPERTIES SOVERSION ${soversion} ) +# +# install(TARGETS myExe mySharedLib myStaticLib +# RUNTIME DESTINATION bin +# LIBRARY DESTINATION lib +# ARCHIVE DESTINATION lib/static) +INSTALL(TARGETS cppad_lib DESTINATION ${cppad_abs_libdir}) diff -Nru cppad-2015.00.00.9/cppad_lib/cppad_colpack.cpp cppad-2016.00.00.1/cppad_lib/cppad_colpack.cpp --- cppad-2015.00.00.9/cppad_lib/cppad_colpack.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/cppad_lib/cppad_colpack.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -0,0 +1,215 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +# include +# include +# include +# include +# include + +# if CPPAD_HAS_COLPACK == 0 +namespace CppAD { + CPPAD_LIB_EXPORT void this_routine_should_never_get_called(void) + { CPPAD_ASSERT_UNKNOWN(false); } +} +# else // CPPAD_HAS_COLPACK +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +\file cppad_colpack.cpp +The CppAD interface to the Colpack coloring algorithms. +*/ + +/*! +Determine which rows of a general sparse matrix can be computed together. + +\param color +is a vector with color.size() == m. +For i = 0 , ... , m-1, color[i] is the color for the corresponding row +of the matrix. If color[i1]==color[i2], (i1, j1) is in sparsity pattern, +and (i2, j2) is in sparsity pattern, then j1 is not equal to j2. + +\param m +is the number of rows in the matrix. + +\param n +is the number of columns in the matrix. + +\param adolc_pattern +is a vector with adolc_pattern.size() == m. +For i = 0 , ... , m-1, and for k = 1, ... ,adolc_pattern[i][0], +the entry with index (i, adolc_pattern[i][k]) is a non-zero +in the sparsity pattern for the matrix. +*/ +// ---------------------------------------------------------------------- +CPPAD_LIB_EXPORT void cppad_colpack_general( + CppAD::vector& color , + size_t m , + size_t n , + const CppAD::vector& adolc_pattern ) +{ size_t i, k; + CPPAD_ASSERT_UNKNOWN( adolc_pattern.size() == m ); + CPPAD_ASSERT_UNKNOWN( color.size() == m ); + + // Use adolc sparsity pattern to create corresponding bipartite graph + ColPack::BipartiteGraphPartialColoringInterface graph( + SRC_MEM_ADOLC, + adolc_pattern.data(), + m, + n + ); + + // row ordered Partial-Distance-Two-Coloring of the bipartite graph + graph.PartialDistanceTwoColoring( + "SMALLEST_LAST", "ROW_PARTIAL_DISTANCE_TWO" + ); + + // Use coloring information to create seed matrix + int n_seed_row; + int n_seed_col; + double** seed_matrix = graph.GetSeedMatrix(&n_seed_row, &n_seed_col); + CPPAD_ASSERT_UNKNOWN( size_t(n_seed_col) == m ); + + // now return coloring in format required by CppAD + for(i = 0; i < m; i++) + color[i] = m; + for(k = 0; k < size_t(n_seed_row); k++) + { for(i = 0; i < m; i++) + { if( seed_matrix[k][i] != 0.0 ) + { // check that no row appears twice in the coloring + CPPAD_ASSERT_UNKNOWN( color[i] == m ); + color[i] = k; + } + } + } +# ifndef NDEBUG + // check that all non-zero rows appear in the coloring + for(i = 0; i < m; i++) + CPPAD_ASSERT_UNKNOWN(color[i] < m || adolc_pattern[i][0] == 0); + + // check that no rows with the same color have overlapping entries + CppAD::vector found(n); + for(k = 0; k < size_t(n_seed_row); k++) + { size_t j, ell; + for(j = 0; j < n; j++) + found[j] = false; + for(i = 0; i < m; i++) if( color[i] == k ) + { for(ell = 0; ell < adolc_pattern[i][0]; ell++) + { j = adolc_pattern[i][1 + ell]; + CPPAD_ASSERT_UNKNOWN( ! found[j] ); + found[j] = true; + } + } + } +# endif + return; +} +// ---------------------------------------------------------------------- +/*! +Determine which rows of a symmetrix sparse matrix can be computed together. + +\param color +is a vector with color.size() == m. +For i = 0 , ... , m-1, color[i] is the color for the corresponding row +of the matrix. We say that a sparsity pattern entry (i, j) is valid if +for all i1, such that i1 != i and color[i1]==color[i], +and all j1, such that (i1, j1) is in sparsity pattern, j1 != j. +The coloring is chosen so that for all (i, j) in the sparsity pattern; +either (i, j) or (j, i) is valid (possibly both). + +\param m +is the number of rows (and columns) in the matrix. + +\param adolc_pattern +is a vector with adolc_pattern.size() == m. +For i = 0 , ... , m-1, and for k = 1, ... ,adolc_pattern[i][0], +the entry with index (i, adolc_pattern[i][k]) is +in the sparsity pattern for the symmetric matrix. +*/ +CPPAD_LIB_EXPORT void cppad_colpack_symmetric( + CppAD::vector& color , + size_t m , + const CppAD::vector& adolc_pattern ) +{ size_t i; + CPPAD_ASSERT_UNKNOWN( adolc_pattern.size() == m ); + CPPAD_ASSERT_UNKNOWN( color.size() == m ); + + // Use adolc sparsity pattern to create corresponding bipartite graph + ColPack::GraphColoringInterface graph( + SRC_MEM_ADOLC, + adolc_pattern.data(), + m + ); + + // Use STAR coloring because it has a direct recovery scheme; i.e., + // not necessary to solve equations to extract values. + graph.Coloring("SMALLEST_LAST", "STAR"); + + // Use coloring information to create seed matrix + int n_seed_row; + int n_seed_col; + double** seed_matrix = graph.GetSeedMatrix(&n_seed_row, &n_seed_col); + CPPAD_ASSERT_UNKNOWN( size_t(n_seed_row) == m ); + + // now return coloring for each row in format required by CppAD + for(i = 0; i < m; i++) + color[i] = m; + for(i = 0; i < m; i++) + { for(size_t k = 0; k < size_t(n_seed_col); k++) + { if( seed_matrix[i][k] != 0.0 ) + { CPPAD_ASSERT_UNKNOWN( color[i] == m ); + color[i] = k; + } + } + } + +# ifndef NDEBUG + // check that every entry in the symetric matrix can be direclty recovered + size_t i1, i2, j1, j2, k1, k2, nz1, nz2; + for(i1 = 0; i1 < m; i1++) + { nz1 = size_t(adolc_pattern[i1][0]); + for(k1 = 1; k1 <= nz1; k1++) + { j1 = adolc_pattern[i1][k1]; + + // check of a forward on color[i1] followed by a reverse + // can recover entry (i1, j1) + bool color_i1_ok = true; + for(i2 = 0; i2 < m; i2++) if( i1 != i2 && color[i1] == color[i2] ) + { nz2 = adolc_pattern[i2][0]; + for(k2 = 1; k2 <= nz2; k2++) + { j2 = adolc_pattern[i2][k2]; + color_i1_ok &= (j1 != j2); + } + } + + // check of a forward on color[j1] followed by a reverse + // can recover entry (j1, i1) + bool color_j1_ok = true; + for(j2 = 0; j2 < m; j2++) if( j1 != j2 && color[j1] == color[j2] ) + { nz2 = adolc_pattern[j2][0]; + for(k2 = 1; k2 <= nz2; k2++) + { i2 = adolc_pattern[j2][k2]; + color_j1_ok &= (i1 != i2); + } + } + + CPPAD_ASSERT_UNKNOWN( color_i1_ok || color_j1_ok ); + } + } +# endif + return; +} + +} // END_CPPAD_NAMESPACE + +# endif // CPPAD_HAS_COLPACK diff -Nru cppad-2015.00.00.9/debian/changelog cppad-2016.00.00.1/debian/changelog --- cppad-2015.00.00.9/debian/changelog 2015-05-02 08:35:41.000000000 +0000 +++ cppad-2016.00.00.1/debian/changelog 2016-02-15 14:19:03.000000000 +0000 @@ -1,3 +1,10 @@ +cppad (2016.00.00.1-1) unstable; urgency=medium + + * Document upstream repo move to git hosted on github + * New upstream version + + -- Barak A. Pearlmutter Mon, 15 Feb 2016 14:12:34 +0000 + cppad (2015.00.00.9-1) unstable; urgency=medium * New upstream version diff -Nru cppad-2015.00.00.9/debian/copyright cppad-2016.00.00.1/debian/copyright --- cppad-2015.00.00.9/debian/copyright 2015-05-02 08:34:30.000000000 +0000 +++ cppad-2016.00.00.1/debian/copyright 2015-12-04 01:22:20.000000000 +0000 @@ -1,6 +1,7 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: CppAD Source: http://www.coin-or.org/download/source/CppAD + git://github.com/coin-or/CppAD.git Files: * Copyright: 2003-14 Bradley M. Bell diff -Nru cppad-2015.00.00.9/depcomp cppad-2016.00.00.1/depcomp --- cppad-2015.00.00.9/depcomp 2014-11-27 17:04:26.000000000 +0000 +++ cppad-2016.00.00.1/depcomp 2015-08-09 16:12:42.000000000 +0000 @@ -3,7 +3,7 @@ scriptversion=2013-05-30.07; # UTC -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff -Nru cppad-2015.00.00.9/doc/a11c_bthread.cpp.xml cppad-2016.00.00.1/doc/a11c_bthread.cpp.xml --- cppad-2015.00.00.9/doc/a11c_bthread.cpp.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/a11c_bthread.cpp.xml 2016-02-09 08:32:06.000000000 +0000 @@ -6,7 +6,7 @@ A Simple Boost Thread Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +acos_forward + +

+
Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
+
+Derivatives + + + + +acos + +( +1 +) + + +( +x +) + += + +- +1 +/ +1 +- +x +* +x + + + +acosh + +( +1 +) + + +( +x +) + += + ++ +1 +/ +x +* +x +- +1 + + + + + +If + +F +( +x +) + + + is + +acos + +( +x +) + + + or + +acosh + +( +x +) + + + +the corresponding derivative satisfies the equation + + + +( +x +* +x +- +1 +) + + +* +F +( +1 +) + + +( +x +) +- +0 +* +F +( +u +) += + +1 + + +and in the +standard math function differential equation +, + + +A +( +x +) += +0 + + +, + + +B +( +x +) += + +( +x +* +x +- +1 +) + + + + +, +and + +D +( +x +) += + +1 + + +. +We use + +a + + +, + +b + + +, + +d + + + and + +z + + + to denote the +Taylor coefficients for + + +A +[ +X +( +t +) +] + + +, + + +B +[ +X +( +t +) +] + + +, + + +D +[ +X +( +t +) +] + + +, +and + +F +[ +X +( +t +) +] + + + respectively. + +
+
+Taylor Coefficients Recursion +
+We define + +Q +( +x +) += + +( +x +* +x +- +1 +) + + + +and let + +q + + + be the corresponding Taylor coefficients for + + +Q +[ +X +( +t +) +] + + +. +It follows that + + +q +( +j +) + + += +{ + +( +x +( +0 +) + + +* +x +( +0 +) + + +- +1 +) + +if + + +j += +0 + + + +k += +0 + +j + +x +( +k +) + + +x +( +j +- +k +) + + + +otherwise + + + + + +It follows that + + +B +[ +X +( +t +) +] += +Q +[ +X +( +t +) +] + + + + + and +from the equations for the +square root + +that for + +j += +0 +, +1 +, + + + +, + + + +b +( +0 +) + + + += + +q +( +0 +) + + + + + +b +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +(j ++ +1 + +2 + + +q +( +j ++ +1 +) + + +- + +k += +1 + +j + +k +b +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + + +It now follows from the general +Taylor coefficients recursion formula + +that for + +j += +0 +, +1 +, + + + +, + + + +z +( +0 +) + + + += + +F +( +x +( +0 +) + + +) + +e +( +j +) + + + += + +d +( +j +) + + ++ + +k += +0 + +j + + +a +( +j +- +k +) + + +* +z +( +k +) + + + + += + +{ + +1 + +if + + +j += +0 + +0 + +otherwise + + + + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +( +k += +0 + +j + +e +( +k +) + + +( +j ++ +1 +- +k +) +x +( +j ++ +1 +- +k +) + + +- + +k += +1 + +j + +b +( +k +) + + +( +j ++ +1 +- +k +) +z +( +j ++ +1 +- +k +) + + +) + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +( +( +j ++ +1 +) +x +( +j ++ +1 +) + + +- + +k += +1 + +j + +k +z +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + + + +
Input File: omh/theory/acos_forward.omh + + + diff -Nru cppad-2015.00.00.9/doc/acosforward.xml cppad-2016.00.00.1/doc/acosforward.xml --- cppad-2015.00.00.9/doc/acosforward.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/acosforward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,736 +0,0 @@ - - - -Arccosine Function Forward Taylor Polynomial Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -AcosForwardHeadings

-
Arccosine Function Forward Taylor Polynomial Theory
-If - -F -( -x -) -= -arccos -( -x -) - - - it follows that - - -1 -- -x -* -x - - -* -F -( -1 -) - - -( -x -) -- -0 -* -F -( -u -) -= --1 - - -and in the -standard math function differential equation -, - - -A -( -x -) -= -0 - - -, - - -B -( -x -) -= -1 -- -x -* -x - - - - -, -and - -D -( -x -) -= --1 - - -. -We use - -a - - -, - -b - - -, - -d - - - and - -z - - - to denote the -Taylor coefficients for - - -A -[ -X -( -t -) -] - - -, - - -B -[ -X -( -t -) -] - - -, - - -D -[ -X -( -t -) -] - - -, -and - -F -[ -X -( -t -) -] - - - respectively. -
-
-
We define - -Q -( -x -) -= -1 -- -x -* -x - - - -and let - -q - - - be the corresponding Taylor coefficients for - - -Q -[ -X -( -t -) -] - - -. -It follows that - - -q -( -j -) - - -= -{ -1 -- -x -( -0 -) - - -* -x -( -0 -) - - - -if - - -j -= -0 - -- - -k -= -0 - -j - -x -( -k -) - - -x -( -j -- -k -) - - - -otherwise - - - - - -It follows that - - -B -[ -X -( -t -) -] -= -Q -[ -X -( -t -) -] - - - - - and -from the equations for the -square root - -that for - -j -= -0 -, -1 -, - - - -, - - - -b -( -0 -) - - - -= - -q -( -0 -) - - - - - -b -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -(j -+ -1 - -2 - - -q -( -j -+ -1 -) - - -- - -k -= -1 - -j - -k -b -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - - -It now follows from the general -Taylor coefficients recursion formula - -that for - -j -= -0 -, -1 -, - - - -, - - - -z -( -0 -) - - - -= - -arccos -( -x -( -0 -) - - -) - -e -( -j -) - - - -= - -d -( -j -) - - -+ - -k -= -0 - -j - - -a -( -j -- -k -) - - -* -z -( -k -) - - - - -= - -{ --1 - -if - - -j -= -0 - -0 - -otherwise - - - - -z -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -( -k -= -0 - -j - -e -( -k -) - - -( -j -+ -1 -- -k -) -x -( -j -+ -1 -- -k -) - - -- - -k -= -1 - -j - -b -( -k -) - - -( -j -+ -1 -- -k -) -z -( -j -+ -1 -- -k -) - - -) - -z -( -j -+ -1 -) - - - -= - -- -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -(( -j -+ -1 -) -x -( -j -+ -1 -) - - -+ - -k -= -1 - -j - -k -z -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - - - -
Input File: omh/theory/acos_forward.omh - - - diff -Nru cppad-2015.00.00.9/doc/_acos_forward_xml.js cppad-2016.00.00.1/doc/_acos_forward_xml.js --- cppad-2015.00.00.9/doc/_acos_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_acos_forward_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,89 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'forwardtheory.xml', +'acos_forward.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_forward.xml', +'log_forward.xml', +'sqrt_forward.xml', +'sin_cos_forward.xml', +'atan_forward.xml', +'asin_forward.xml', +'acos_forward.xml', +'tan_forward.xml', +'erf_forward.xml' +]; +var list_current0 = [ +'acos_forward.xml#Derivatives', +'acos_forward.xml#Taylor Coefficients Recursion' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_acosforward_xml.js cppad-2016.00.00.1/doc/_acosforward_xml.js --- cppad-2015.00.00.9/doc/_acosforward_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_acosforward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'acosforward.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expforward.xml', -'logforward.xml', -'sqrtforward.xml', -'sincosforward.xml', -'atanforward.xml', -'asinforward.xml', -'acosforward.xml', -'tan_forward.xml', -'erf_forward.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/acosh.cpp.xml cppad-2016.00.00.1/doc/acosh.cpp.xml --- cppad-2015.00.00.9/doc/acosh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/acosh.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,167 @@ + + + +The AD acosh Function: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +acosh.cppHeadings

+ + + +
The AD acosh Function: Example and Test
+
 
+
+# include <cppad/cppad.hpp>
+
+bool acosh(void)
+{	bool ok = true;
+
+	using CppAD::AD;
+	using CppAD::NearEqual;
+
+	// 10 times machine epsilon
+	double eps = 10. * std::numeric_limits<double>::epsilon();
+
+	// domain space vector
+	size_t n  = 1;
+	double x0 = 0.5;
+	CPPAD_TESTVECTOR(AD<double>) x(n);
+	x[0]      = x0;
+
+	// declare independent variables and start tape recording
+	CppAD::Independent(x);
+
+	// a temporary value
+	AD<double> cosh_of_x0 = CppAD::cosh(x[0]);
+
+	// range space vector
+	size_t m = 1;
+	CPPAD_TESTVECTOR(AD<double>) y(m);
+	y[0] = CppAD::acosh(cosh_of_x0);
+
+	// create f: x -> y and stop tape recording
+	CppAD::ADFun<double> f(x, y);
+
+	// check value
+	ok &= NearEqual(y[0] , x0,  eps, eps);
+
+	// forward computation of first partial w.r.t. x[0]
+	CPPAD_TESTVECTOR(double) dx(n);
+	CPPAD_TESTVECTOR(double) dy(m);
+	dx[0] = 1.;
+	dy    = f.Forward(1, dx);
+	ok   &= NearEqual(dy[0], 1., eps, eps);
+
+	// reverse computation of derivative of y[0]
+	CPPAD_TESTVECTOR(double)  w(m);
+	CPPAD_TESTVECTOR(double) dw(n);
+	w[0]  = 1.;
+	dw    = f.Reverse(1, w);
+	ok   &= NearEqual(dw[0], 1., eps, eps);
+
+	// use a VecAD<Base>::reference object with acosh
+	CppAD::VecAD<double> v(1);
+	AD<double> zero(0);
+	v[zero] = cosh_of_x0;
+	AD<double> result = CppAD::acosh(v[zero]);
+	ok     &= NearEqual(result, x0, eps, eps);
+
+	return ok;
+}
+
+
+ +
+ + +
Input File: example/acosh.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_acosh.cpp_xml.js cppad-2016.00.00.1/doc/_acosh.cpp_xml.js --- cppad-2015.00.00.9/doc/_acosh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_acosh.cpp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,92 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'acosh.xml', +'acosh.cpp.xml' +]; +var list_down3 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down2 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down1 = [ +'acosh.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/acosh.xml cppad-2016.00.00.1/doc/acosh.xml --- cppad-2015.00.00.9/doc/acosh.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/acosh.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,204 @@ + + + +The Inverse Hyperbolic Cosine Function: acosh + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + +
The Inverse Hyperbolic Cosine Function: acosh
+
+Syntax + +
+ +y = acosh(x) + + +
+
+Description +
+The inverse hyperbolic cosine function is defined by + +x == cosh(y) +. + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+CPPAD_USE_CPLUSPLUS_2011 + + +
+
+true +
+If this preprocessor symbol is true (1), +and +x + is an AD type, +this is an atomic operation +. + +
+
+false +
+If this preprocessor symbol is false (0), +CppAD uses the representation + + +acosh + +( +x +) += +log +(x ++ +x +2 + +- +1 + + +) + + +to compute this function. + +
+
+Example + +
+The file +acosh.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/acosh.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_acosh_xml.js cppad-2016.00.00.1/doc/_acosh_xml.js --- cppad-2015.00.00.9/doc/_acosh_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_acosh_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,109 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'acosh.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'acosh.cpp.xml' +]; +var list_current0 = [ +'acosh.xml#Syntax', +'acosh.xml#Description', +'acosh.xml#x, y', +'acosh.xml#CPPAD_USE_CPLUSPLUS_2011', +'acosh.xml#CPPAD_USE_CPLUSPLUS_2011.true', +'acosh.xml#CPPAD_USE_CPLUSPLUS_2011.false', +'acosh.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/acos_reverse.xml cppad-2016.00.00.1/doc/acos_reverse.xml --- cppad-2015.00.00.9/doc/acos_reverse.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/acos_reverse.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,1633 @@ + + + +Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +acos_reverseHeadings

+
Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
+We use the reverse theory +standard math function + +definition for the functions + +H + + + and + +G + + +. +In addition, we use the forward mode notation in +acos_forward + for + + + +Q +( +t +) + += + + +( +X +( +t +) +* +X +( +t +) +- +1 +) + +B +( +t +) + += + +Q +( +t +) + + + + + +We use + +q + + + and + +b + + + +for the p-th order Taylor coefficient +row vectors corresponding to these functions +and replace + +z +( +j +) + + + + + by + + +( +z +( +j +) + + +, +b +( +j +) + + +) + + +in the definition for + +G + + + and + +H + + +. +The zero order forward mode formulas for the +acos + +function are + + + +q +( +0 +) + + + += + + +( +x +( +0 +) + + +x +( +0 +) + + +- +1 +) + +b +( +0 +) + + + += + +q +( +0 +) + + + + + +z +( +0 +) + + + += + +F +( +x +( +0 +) + + +) + + + +where + +F +( +x +) += +acos + +( +x +) + + + for + +- + + + +and + +F +( +x +) += +acosh + +( +x +) + + + for + ++ + + +. +For orders + +j + + + greater than zero we have + + + +q +( +j +) + + + += + + + +k += +0 + +j + +x +( +k +) + + +x +( +j +- +k +) + + + +b +( +j +) + + + += + +1 + +j + + +1 + +b +( +0 +) + + + + +(j + +2 + + +q +( +j +) + + +- + +k += +1 + +j +-1 + + +k +b +( +k +) + + +b +( +j +- +k +) + + +) + +z +( +j +) + + + += + +1 + +j + + +1 + +b +( +0 +) + + + + +( +j +x +( +j +) + + +- + +k += +1 + +j +-1 + + +k +z +( +k +) + + +b +( +j +- +k +) + + +) + + + +If + +j += +0 + + +, we note that + + +F +( +1 +) + + +( +x +( +0 +) + + +) += + +1 +/ +b +( +0 +) + + + + + and hence + + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +0 +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +q +( +0 +) + + + + + +q +( +0 +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +j +) + + + + + + +G + + +z +( +j +) + + + + +1 + +b +( +0 +) + + + + + + +G + + +b +( +j +) + + + + +x +( +0 +) + + + +b +( +0 +) + + + + + + + +If + +j +> +0 + + +, then for + +k += +1 +, + +, +j +-1 + + + + + + + + +H + + +b +( +0 +) + + + + + += + + +G + + +b +( +0 +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +b +( +0 +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +b +( +0 +) + + + + + + += + + +G + + +b +( +0 +) + + + + +- + +G + + +z +( +j +) + + + + +z +( +j +) + + + +b +( +0 +) + + + + +- + +G + + +b +( +j +) + + + + +b +( +j +) + + + +b +( +0 +) + + + + + + +H + + +x +( +0 +) + + + + + += + + +G + + +x +( +0 +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +q +( +j +) + + + + + +q +( +j +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +0 +) + + + + + + +G + + +b +( +j +) + + + + +x +( +j +) + + + +b +( +0 +) + + + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +j +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +q +( +j +) + + + + + +q +( +j +) + + + + +x +( +j +) + + + + + + += + + +G + + +x +( +j +) + + + + + + +G + + +z +( +j +) + + + + +1 + +b +( +0 +) + + + + + + +G + + +b +( +j +) + + + + +x +( +0 +) + + + +b +( +0 +) + + + + + + +H + + +b +( +j +- +k +) + + + + + += + + +G + + +b +( +j +- +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +b +( +j +- +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +b +( +j +- +k +) + + + + + + += + + +G + + +b +( +j +- +k +) + + + + +- + +G + + +z +( +j +) + + + + +k +z +( +k +) + + + +j +b +( +0 +) + + + + +- + +G + + +b +( +j +) + + + + +b +( +k +) + + + +b +( +0 +) + + + + + + +H + + +x +( +k +) + + + + + += + + +G + + +x +( +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +q +( +j +) + + + + + +q +( +j +) + + + + +x +( +k +) + + + + + + += + + +G + + +x +( +k +) + + + + + + +G + + +b +( +j +) + + + + +x +( +j +- +k +) + + + +b +( +0 +) + + + + + + +H + + +z +( +k +) + + + + + += + + +G + + +z +( +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +z +( +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +z +( +k +) + + + + + + += + + +G + + +z +( +k +) + + + + +- + +G + + +z +( +j +) + + + + +k +b +( +j +- +k +) + + + +j +b +( +0 +) + + + + + + + + +
Input File: omh/theory/acos_reverse.omh + + + diff -Nru cppad-2015.00.00.9/doc/acosreverse.xml cppad-2016.00.00.1/doc/acosreverse.xml --- cppad-2015.00.00.9/doc/acosreverse.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/acosreverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1566 +0,0 @@ - - - -Arccosine Function Reverse Mode Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -AcosReverseHeadings

-
Arccosine Function Reverse Mode Theory
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. -In addition, - -we use - -q - - - and - -b - - - -for the p-th order Taylor coefficient -row vectors corresponding to functions - - - -Q -( -t -) - -= - -1 -- -X -( -t -) -* -X -( -t -) - -B -( -t -) - -= - -Q -( -t -) - - - - - -and replace - -z -( -j -) - - - - - by - - -( -z -( -j -) - - -, -b -( -j -) - - -) - - -in the definition for - -G - - - and - -H - - -. -The forward mode formulas for the -acos - -function are - - - -q -( -0 -) - - - -= - -1 -- -x -( -0 -) - - -x -( -0 -) - - - -b -( -j -) - - - -= - -q -( -0 -) - - - - - -z -( -j -) - - - -= - -arccos -( -x -( -0 -) - - -) - - - -for the case - -j -= -0 - - -, and for - -j -> -0 - - -, - - - - -q -( -j -) - - - -= - -- - -k -= -0 - -j - -x -( -k -) - - -x -( -j -- -k -) - - - -b -( -j -) - - - -= - -1 - -j - - -1 - -b -( -0 -) - - - - -(j - -2 - - -q -( -j -) - - -- - -k -= -1 - -j --1 - - -k -b -( -k -) - - -b -( -j -- -k -) - - -) - -z -( -j -) - - - -= - -- -1 - -j - - -1 - -b -( -0 -) - - - - -(j -x -( -j -) - - -+ - -k -= -1 - -j --1 - - -k -z -( -k -) - - -b -( -j -- -k -) - - -) - - - -If - -j -= -0 - - -, we have the relation - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -0 -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -q -( -0 -) - - - - - -q -( -0 -) - - - - -x -( -0 -) - - - - - - -= - - -G - - -x -( -j -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -b -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -x -( -0 -) - - - -b -( -0 -) - - - - - - - -If - -j -> -0 - - -, then for - -k -= -1 -, - -, -j --1 - - - - - - - - -H - - -b -( -0 -) - - - - - -= - - -G - - -b -( -0 -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -b -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -b -( -0 -) - - - - - - -= - - -G - - -b -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - -z -( -j -) - - - -b -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -b -( -j -) - - - -b -( -0 -) - - - - - - -H - - -x -( -0 -) - - - - - -= - - -G - - -x -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -q -( -j -) - - - - - -q -( -j -) - - - - -x -( -0 -) - - - - - - -= - - -G - - -x -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -x -( -j -) - - - -b -( -0 -) - - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -j -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -q -( -j -) - - - - - -q -( -j -) - - - - -x -( -j -) - - - - - - -= - - -G - - -x -( -j -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -b -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -x -( -0 -) - - - -b -( -0 -) - - - - - - -H - - -b -( -j -- -k -) - - - - - -= - - -G - - -b -( -j -- -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -b -( -j -- -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -b -( -j -- -k -) - - - - - - -= - - -G - - -b -( -j -- -k -) - - - - -- - -G - - -z -( -j -) - - - - -k -z -( -k -) - - - -j -b -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -b -( -k -) - - - -b -( -0 -) - - - - - - -H - - -x -( -k -) - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -q -( -j -) - - - - - -q -( -j -) - - - - -x -( -k -) - - - - - - -= - - -G - - -x -( -k -) - - - - -- - -G - - -b -( -j -) - - - - -x -( -j -- -k -) - - - -b -( -0 -) - - - - - - -H - - -z -( -k -) - - - - - -= - - -G - - -z -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -z -( -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -z -( -k -) - - - - - - -= - - -G - - -z -( -k -) - - - - -- - -G - - -z -( -j -) - - - - -k -b -( -j -- -k -) - - - -j -b -( -0 -) - - - - - - - - -
Input File: omh/theory/acos_reverse.omh - - - diff -Nru cppad-2015.00.00.9/doc/_acos_reverse_xml.js cppad-2016.00.00.1/doc/_acos_reverse_xml.js --- cppad-2015.00.00.9/doc/_acos_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_acos_reverse_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,85 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'reversetheory.xml', +'acos_reverse.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_reverse.xml', +'log_reverse.xml', +'sqrt_reverse.xml', +'sin_cos_reverse.xml', +'atan_reverse.xml', +'asin_reverse.xml', +'acos_reverse.xml', +'tan_reverse.xml', +'erf_reverse.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_acosreverse_xml.js cppad-2016.00.00.1/doc/_acosreverse_xml.js --- cppad-2015.00.00.9/doc/_acosreverse_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_acosreverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'acosreverse.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expreverse.xml', -'logreverse.xml', -'sqrtreverse.xml', -'sincosreverse.xml', -'atanreverse.xml', -'asinreverse.xml', -'acosreverse.xml', -'tan_reverse.xml', -'erf_reverse.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/acos.xml cppad-2016.00.00.1/doc/acos.xml --- cppad-2015.00.00.9/doc/acos.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/acos.xml 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,188 @@ + + + +Inverse Sine Function: acos + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+
Inverse Sine Function: acos
+
+Syntax + +
+ +y = acos(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +acos + +( +1 +) + + +( +x +) + += + +- +( +1 +- +x +* +x +) +-1 +/ +2 + + + + + +
+Example + +
+The file +acos.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_acos_xml.js cppad-2016.00.00.1/doc/_acos_xml.js --- cppad-2015.00.00.9/doc/_acos_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_acos_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'acos.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'acos.cpp.xml' +]; +var list_current0 = [ +'acos.xml#Syntax', +'acos.xml#x, y', +'acos.xml#Atomic', +'acos.xml#Derivative', +'acos.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/ad_assign.cpp.xml cppad-2016.00.00.1/doc/ad_assign.cpp.xml --- cppad-2015.00.00.9/doc/ad_assign.cpp.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/ad_assign.cpp.xml 2016-02-09 08:32:04.000000000 +0000 @@ -6,7 +6,7 @@ AD Assignment: Example and Test - + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + +addon + +

+ + + + +
CppAD Addons
+
+Name +
+Each CppAD addon has a short name which we denote by +name + below, +a longer name +longer + and a +description +: + + +
+ + +name +    + + +longer +    + + +description + +
+ +cg + + + CppADCodeGen + + C++ Source Code Generation of CppAD Derivative Calculations +
+ +py + + + pycppad + + A Python Interface to CppAD +
+ +tmb + + + adcomp + + An R Interface to CppAD with Random Effects Modeling Utilities +
+ +mixed + + + cppad_mixed + + A C++ Interface to Random Effects Laplace Approximation +
+
+Include Files +
+If +includedir + is the directory where the include files are installed, +the file + +
+     
includedir/cppad/name.hpp
+
+and the directory + +
+     
includedir/cppad/name
+
+are reserved for use by the +name + addon. + +
+
+Library Files +
+If +libdir + is the directory where CppAD library files are installed, +files with the name + +
+     
libdir/libcppad_name.ext
+     
libdir/libcppad_name_anything.ext
+
+where +anything + and +ext + are arbitrary, +are reserved for use by the +name + addon. + +
+
+Preprocessor Symbols +
+C++ preprocessor symbols that begin with + +
+     CPPAD_
NAME_
+
+where +NAME + is a upper-case version of +name +, +are reserved for use by the +name + addon. + +
+
+Namespace +
+The C++ namespace + +
+     CppAD::
name
+
+is reserved for use by the +name + addon. + + + +
Input File: omh/addon.omh + + + diff -Nru cppad-2015.00.00.9/doc/_addon_xml.js cppad-2016.00.00.1/doc/_addon_xml.js --- cppad-2015.00.00.9/doc/_addon_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_addon_xml.js 2016-02-09 08:32:08.000000000 +0000 @@ -0,0 +1,81 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'addon.xml' +]; +var list_down2 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down1 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_current0 = [ +'addon.xml#Name', +'addon.xml#Include Files', +'addon.xml#Library Files', +'addon.xml#Preprocessor Symbols', +'addon.xml#Namespace' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/ad_fun.cpp.xml cppad-2016.00.00.1/doc/ad_fun.cpp.xml --- cppad-2015.00.00.9/doc/ad_fun.cpp.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/ad_fun.cpp.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Creating Your Own Interface to an ADFun Object - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +ad_to_string + +

+ + + +
Convert An AD or Base Type to String
+
+Syntax + +
+ +s = to_string(value) +. + +
+
+See Also + +
+to_string +, base_to_string + + +
+
+value +
+The argument +value + has prototype + +
+     const AD<
Base>& value
+     const 
Base&     value
+
+where +Base + is a type that supports the +base_to_string + type requirement. + +
+
+s +
+The return value has prototype + +
+     std::string 
s
+
+and contains a representation of the specified +value +. +If +value + is an AD type, +the result has the same precision as for the +Base + type. + +
+
+Example +
+The file to_string.cpp + +includes an example and test of to_string with AD types. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/ad_to_string.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_ad_to_string_xml.js cppad-2016.00.00.1/doc/_ad_to_string_xml.js --- cppad-2015.00.00.9/doc/_ad_to_string_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_ad_to_string_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,93 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'convert.xml', +'ad_to_string.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down1 = [ +'value.xml', +'integer.xml', +'ad_to_string.xml', +'ad_input.xml', +'ad_output.xml', +'printfor.xml', +'var2par.xml' +]; +var list_current0 = [ +'ad_to_string.xml#Syntax', +'ad_to_string.xml#See Also', +'ad_to_string.xml#value', +'ad_to_string.xml#s', +'ad_to_string.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/advalued.xml cppad-2016.00.00.1/doc/advalued.xml --- cppad-2015.00.00.9/doc/advalued.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/advalued.xml 2016-02-09 08:32:04.000000000 +0000 @@ -6,7 +6,7 @@ AD Valued Operations and Functions - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +asin_forward + +

+
Inverse Sine and Hyperbolic Sine Forward Mode Theory
+
+Derivatives + + + + +asin + +( +1 +) + + +( +x +) + += + +1 +/ +1 +- +x +* +x + + + +asinh + +( +1 +) + + +( +x +) + += + +1 +/ +1 ++ +x +* +x + + + + + +If + +F +( +x +) + + + is + +asin + +( +x +) + + + or + +asinh + +( +x +) + + + +the corresponding derivative satisfies the equation + + +1 + +x +* +x + + +* +F +( +1 +) + + +( +x +) +- +0 +* +F +( +u +) += +1 + + +and in the +standard math function differential equation +, + + +A +( +x +) += +0 + + +, + + +B +( +x +) += +1 + +x +* +x + + + + +, +and + +D +( +x +) += +1 + + +. +We use + +a + + +, + +b + + +, + +d + + + and + +z + + + to denote the +Taylor coefficients for + + +A +[ +X +( +t +) +] + + +, + + +B +[ +X +( +t +) +] + + +, + + +D +[ +X +( +t +) +] + + +, +and + +F +[ +X +( +t +) +] + + + respectively. + +
+
+Taylor Coefficients Recursion +
+We define + +Q +( +x +) += +1 + +x +* +x + + + +and let + +q + + + be the corresponding Taylor coefficients for + + +Q +[ +X +( +t +) +] + + +. +It follows that + + +q +( +j +) + + += +{ +1 + +x +( +0 +) + + +* +x +( +0 +) + + + +if + + +j += +0 + + + +k += +0 + +j + +x +( +k +) + + +x +( +j +- +k +) + + + +otherwise + + + + + +It follows that + + +B +[ +X +( +t +) +] += +Q +[ +X +( +t +) +] + + + + + and +from the equations for the +square root + +that for + +j += +0 +, +1 +, + + + +, + + + +b +( +0 +) + + + += + +q +( +0 +) + + + + + +b +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +(j ++ +1 + +2 + + +q +( +j ++ +1 +) + + +- + +k += +1 + +j + +k +b +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + + +It now follows from the general +Taylor coefficients recursion formula + +that for + +j += +0 +, +1 +, + + + +, + + + +z +( +0 +) + + + += + +F +( +x +( +0 +) + + +) + +e +( +j +) + + + += + +d +( +j +) + + ++ + +k += +0 + +j + + +a +( +j +- +k +) + + +* +z +( +k +) + + + + += + +{ +1 + +if + + +j += +0 + +0 + +otherwise + + + + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +( +k += +0 + +j + +e +( +k +) + + +( +j ++ +1 +- +k +) +x +( +j ++ +1 +- +k +) + + +- + +k += +1 + +j + +b +( +k +) + + +( +j ++ +1 +- +k +) +z +( +j ++ +1 +- +k +) + + +) + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +(( +j ++ +1 +) +x +( +j ++ +1 +) + + +- + +k += +1 + +j + +k +z +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + + + +
Input File: omh/theory/asin_forward.omh + + + diff -Nru cppad-2015.00.00.9/doc/asinforward.xml cppad-2016.00.00.1/doc/asinforward.xml --- cppad-2015.00.00.9/doc/asinforward.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/asinforward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,735 +0,0 @@ - - - -Arcsine Function Forward Taylor Polynomial Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -AsinForwardHeadings

-
Arcsine Function Forward Taylor Polynomial Theory
-If - -F -( -x -) -= -arcsin -( -x -) - - - it follows that - - -1 -- -x -* -x - - -* -F -( -1 -) - - -( -x -) -- -0 -* -F -( -u -) -= -1 - - -and in the -standard math function differential equation -, - - -A -( -x -) -= -0 - - -, - - -B -( -x -) -= -1 -- -x -* -x - - - - -, -and - -D -( -x -) -= -1 - - -. -We use - -a - - -, - -b - - -, - -d - - - and - -z - - - to denote the -Taylor coefficients for - - -A -[ -X -( -t -) -] - - -, - - -B -[ -X -( -t -) -] - - -, - - -D -[ -X -( -t -) -] - - -, -and - -F -[ -X -( -t -) -] - - - respectively. -
-
-
We define - -Q -( -x -) -= -1 -- -x -* -x - - - -and let - -q - - - be the corresponding Taylor coefficients for - - -Q -[ -X -( -t -) -] - - -. -It follows that - - -q -( -j -) - - -= -{ -1 -- -x -( -0 -) - - -* -x -( -0 -) - - - -if - - -j -= -0 - -- - -k -= -0 - -j - -x -( -k -) - - -x -( -j -- -k -) - - - -otherwise - - - - - -It follows that - - -B -[ -X -( -t -) -] -= -Q -[ -X -( -t -) -] - - - - - and -from the equations for the -square root - -that for - -j -= -0 -, -1 -, - - - -, - - - -b -( -0 -) - - - -= - -q -( -0 -) - - - - - -b -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -(j -+ -1 - -2 - - -q -( -j -+ -1 -) - - -- - -k -= -1 - -j - -k -b -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - - -It now follows from the general -Taylor coefficients recursion formula - -that for - -j -= -0 -, -1 -, - - - -, - - - -z -( -0 -) - - - -= - -arcsin -( -x -( -0 -) - - -) - -e -( -j -) - - - -= - -d -( -j -) - - -+ - -k -= -0 - -j - - -a -( -j -- -k -) - - -* -z -( -k -) - - - - -= - -{ -1 - -if - - -j -= -0 - -0 - -otherwise - - - - -z -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -( -k -= -0 - -j - -e -( -k -) - - -( -j -+ -1 -- -k -) -x -( -j -+ -1 -- -k -) - - -- - -k -= -1 - -j - -b -( -k -) - - -( -j -+ -1 -- -k -) -z -( -j -+ -1 -- -k -) - - -) - -z -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -(( -j -+ -1 -) -x -( -j -+ -1 -) - - -- - -k -= -1 - -j - -k -z -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - - - -
Input File: omh/theory/asin_forward.omh - - - diff -Nru cppad-2015.00.00.9/doc/_asin_forward_xml.js cppad-2016.00.00.1/doc/_asin_forward_xml.js --- cppad-2015.00.00.9/doc/_asin_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_asin_forward_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,89 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'forwardtheory.xml', +'asin_forward.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_forward.xml', +'log_forward.xml', +'sqrt_forward.xml', +'sin_cos_forward.xml', +'atan_forward.xml', +'asin_forward.xml', +'acos_forward.xml', +'tan_forward.xml', +'erf_forward.xml' +]; +var list_current0 = [ +'asin_forward.xml#Derivatives', +'asin_forward.xml#Taylor Coefficients Recursion' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_asinforward_xml.js cppad-2016.00.00.1/doc/_asinforward_xml.js --- cppad-2015.00.00.9/doc/_asinforward_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_asinforward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'asinforward.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expforward.xml', -'logforward.xml', -'sqrtforward.xml', -'sincosforward.xml', -'atanforward.xml', -'asinforward.xml', -'acosforward.xml', -'tan_forward.xml', -'erf_forward.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/asinh.cpp.xml cppad-2016.00.00.1/doc/asinh.cpp.xml --- cppad-2015.00.00.9/doc/asinh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/asinh.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,167 @@ + + + +The AD asinh Function: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +asinh.cppHeadings

+ + + +
The AD asinh Function: Example and Test
+
 
+
+# include <cppad/cppad.hpp>
+
+bool asinh(void)
+{	bool ok = true;
+
+	using CppAD::AD;
+	using CppAD::NearEqual;
+
+	// 10 times machine epsilon
+	double eps = 10. * std::numeric_limits<double>::epsilon();
+
+	// domain space vector
+	size_t n  = 1;
+	double x0 = 0.5;
+	CPPAD_TESTVECTOR(AD<double>) x(n);
+	x[0]      = x0;
+
+	// declare independent variables and start tape recording
+	CppAD::Independent(x);
+
+	// a temporary value
+	AD<double> sinh_of_x0 = CppAD::sinh(x[0]);
+
+	// range space vector
+	size_t m = 1;
+	CPPAD_TESTVECTOR(AD<double>) y(m);
+	y[0] = CppAD::asinh(sinh_of_x0);
+
+	// create f: x -> y and stop tape recording
+	CppAD::ADFun<double> f(x, y);
+
+	// check value
+	ok &= NearEqual(y[0] , x0,  eps, eps);
+
+	// forward computation of first partial w.r.t. x[0]
+	CPPAD_TESTVECTOR(double) dx(n);
+	CPPAD_TESTVECTOR(double) dy(m);
+	dx[0] = 1.;
+	dy    = f.Forward(1, dx);
+	ok   &= NearEqual(dy[0], 1., eps, eps);
+
+	// reverse computation of derivative of y[0]
+	CPPAD_TESTVECTOR(double)  w(m);
+	CPPAD_TESTVECTOR(double) dw(n);
+	w[0]  = 1.;
+	dw    = f.Reverse(1, w);
+	ok   &= NearEqual(dw[0], 1., eps, eps);
+
+	// use a VecAD<Base>::reference object with asinh
+	CppAD::VecAD<double> v(1);
+	AD<double> zero(0);
+	v[zero] = sinh_of_x0;
+	AD<double> result = CppAD::asinh(v[zero]);
+	ok     &= NearEqual(result, x0, eps, eps);
+
+	return ok;
+}
+
+
+ +
+ + +
Input File: example/asinh.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_asinh.cpp_xml.js cppad-2016.00.00.1/doc/_asinh.cpp_xml.js --- cppad-2015.00.00.9/doc/_asinh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_asinh.cpp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,92 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'asinh.xml', +'asinh.cpp.xml' +]; +var list_down3 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down2 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down1 = [ +'asinh.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/asinh.xml cppad-2016.00.00.1/doc/asinh.xml --- cppad-2015.00.00.9/doc/asinh.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/asinh.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,204 @@ + + + +The Inverse Hyperbolic Sine Function: asinh + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + +
The Inverse Hyperbolic Sine Function: asinh
+
+Syntax + +
+ +y = asinh(x) + + +
+
+Description +
+The inverse hyperbolic sine function is defined by + +x == sinh(y) +. + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+CPPAD_USE_CPLUSPLUS_2011 + + +
+
+true +
+If this preprocessor symbol is true (1), +and +x + is an AD type, +this is an atomic operation +. + +
+
+false +
+If this preprocessor symbol is false (0), +CppAD uses the representation + + +asinh + +( +x +) += +log +(x ++ +1 ++ +x +2 + + + +) + + +to compute this function. + +
+
+Example + +
+The file +asinh.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/asinh.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_asinh_xml.js cppad-2016.00.00.1/doc/_asinh_xml.js --- cppad-2015.00.00.9/doc/_asinh_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_asinh_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,109 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'asinh.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'asinh.cpp.xml' +]; +var list_current0 = [ +'asinh.xml#Syntax', +'asinh.xml#Description', +'asinh.xml#x, y', +'asinh.xml#CPPAD_USE_CPLUSPLUS_2011', +'asinh.xml#CPPAD_USE_CPLUSPLUS_2011.true', +'asinh.xml#CPPAD_USE_CPLUSPLUS_2011.false', +'asinh.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/asin_reverse.xml cppad-2016.00.00.1/doc/asin_reverse.xml --- cppad-2015.00.00.9/doc/asin_reverse.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/asin_reverse.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,1624 @@ + + + +Inverse Sine and Hyperbolic Sine Reverse Mode Theory + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +asin_reverseHeadings

+
Inverse Sine and Hyperbolic Sine Reverse Mode Theory
+We use the reverse theory +standard math function + +definition for the functions + +H + + + and + +G + + +. +In addition, we use the forward mode notation in +asin_forward + for + + + +Q +( +t +) + += + +1 + +X +( +t +) +* +X +( +t +) + +B +( +t +) + += + +Q +( +t +) + + + + + +We use + +q + + + and + +b + + + +for the p-th order Taylor coefficient +row vectors corresponding to these functions +and replace + +z +( +j +) + + + + + by + + +( +z +( +j +) + + +, +b +( +j +) + + +) + + +in the definition for + +G + + + and + +H + + +. +The zero order forward mode formulas for the +asin + +function are + + + +q +( +0 +) + + + += + +1 + +x +( +0 +) + + +x +( +0 +) + + + +b +( +0 +) + + + += + +q +( +0 +) + + + + + +z +( +0 +) + + + += + +F +( +x +( +0 +) + + +) + + + +where + +F +( +x +) += +asin + +( +x +) + + + for + +- + + + +and + +F +( +x +) += +asinh + +( +x +) + + + for + ++ + + +. +For the orders + +j + + + greater than zero we have + + + +q +( +j +) + + + += + + + +k += +0 + +j + +x +( +k +) + + +x +( +j +- +k +) + + + +b +( +j +) + + + += + +1 + +j + + +1 + +b +( +0 +) + + + + +(j + +2 + + +q +( +j +) + + +- + +k += +1 + +j +-1 + + +k +b +( +k +) + + +b +( +j +- +k +) + + +) + +z +( +j +) + + + += + +1 + +j + + +1 + +b +( +0 +) + + + + +(j +x +( +j +) + + +- + +k += +1 + +j +-1 + + +k +z +( +k +) + + +b +( +j +- +k +) + + +) + + + +If + +j += +0 + + +, we note that + + +F +( +1 +) + + +( +x +( +0 +) + + +) += +1 +/ +b +( +0 +) + + + + + and hence + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +0 +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +q +( +0 +) + + + + + +q +( +0 +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +b +( +0 +) + + + + + + +G + + +b +( +j +) + + + + +x +( +0 +) + + + +b +( +0 +) + + + + + + + +If + +j +> +0 + + +, then for + +k += +1 +, + +, +j +-1 + + + + + + + + +H + + +b +( +0 +) + + + + + += + + +G + + +b +( +0 +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +b +( +0 +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +b +( +0 +) + + + + + + += + + +G + + +b +( +0 +) + + + + +- + +G + + +z +( +j +) + + + + +z +( +j +) + + + +b +( +0 +) + + + + +- + +G + + +b +( +j +) + + + + +b +( +j +) + + + +b +( +0 +) + + + + + + +H + + +x +( +0 +) + + + + + += + + +G + + +x +( +0 +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +q +( +j +) + + + + + +q +( +j +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +0 +) + + + + + + +G + + +b +( +j +) + + + + +x +( +j +) + + + +b +( +0 +) + + + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +j +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +q +( +j +) + + + + + +q +( +j +) + + + + +x +( +j +) + + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +b +( +0 +) + + + + + + +G + + +b +( +j +) + + + + +x +( +0 +) + + + +b +( +0 +) + + + + + + +H + + +b +( +j +- +k +) + + + + + += + + +G + + +b +( +j +- +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +b +( +j +- +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +b +( +j +- +k +) + + + + + + += + + +G + + +b +( +j +- +k +) + + + + +- + +G + + +z +( +j +) + + + + +k +z +( +k +) + + + +j +b +( +0 +) + + + + +- + +G + + +b +( +j +) + + + + +b +( +k +) + + + +b +( +0 +) + + + + + + +H + + +x +( +k +) + + + + + += + + +G + + +x +( +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +q +( +j +) + + + + + +q +( +j +) + + + + +x +( +k +) + + + + + + += + + +G + + +x +( +k +) + + + + + + +G + + +b +( +j +) + + + + +x +( +j +- +k +) + + + +b +( +0 +) + + + + + + +H + + +z +( +k +) + + + + + += + + +G + + +z +( +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +z +( +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +z +( +k +) + + + + + + += + + +G + + +z +( +k +) + + + + +- + +G + + +z +( +j +) + + + + +k +b +( +j +- +k +) + + + +j +b +( +0 +) + + + + + + + + +
Input File: omh/theory/asin_reverse.omh + + + diff -Nru cppad-2015.00.00.9/doc/asinreverse.xml cppad-2016.00.00.1/doc/asinreverse.xml --- cppad-2015.00.00.9/doc/asinreverse.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/asinreverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1565 +0,0 @@ - - - -Arcsine Function Reverse Mode Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -AsinReverseHeadings

-
Arcsine Function Reverse Mode Theory
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. -In addition, - -we use - -q - - - and - -b - - - -for the p-th order Taylor coefficient -row vectors corresponding to functions - - - -Q -( -t -) - -= - -1 -- -X -( -t -) -* -X -( -t -) - -B -( -t -) - -= - -Q -( -t -) - - - - - -and replace - -z -( -j -) - - - - - by - - -( -z -( -j -) - - -, -b -( -j -) - - -) - - -in the definition for - -G - - - and - -H - - -. -The forward mode formulas for the -asin - -function are - - - -q -( -0 -) - - - -= - -1 -- -x -( -0 -) - - -x -( -0 -) - - - -b -( -j -) - - - -= - -q -( -0 -) - - - - - -z -( -j -) - - - -= - -arcsin -( -x -( -0 -) - - -) - - - -for the case - -j -= -0 - - -, and for - -j -> -0 - - -, - - - - -q -( -j -) - - - -= - -- - -k -= -0 - -j - -x -( -k -) - - -x -( -j -- -k -) - - - -b -( -j -) - - - -= - -1 - -j - - -1 - -b -( -0 -) - - - - -(j - -2 - - -q -( -j -) - - -- - -k -= -1 - -j --1 - - -k -b -( -k -) - - -b -( -j -- -k -) - - -) - -z -( -j -) - - - -= - -1 - -j - - -1 - -b -( -0 -) - - - - -(j -x -( -j -) - - -- - -k -= -1 - -j --1 - - -k -z -( -k -) - - -b -( -j -- -k -) - - -) - - - -If - -j -= -0 - - -, we have the relation - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -0 -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -q -( -0 -) - - - - - -q -( -0 -) - - - - -x -( -0 -) - - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -b -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -x -( -0 -) - - - -b -( -0 -) - - - - - - - -If - -j -> -0 - - -, then for - -k -= -1 -, - -, -j --1 - - - - - - - - -H - - -b -( -0 -) - - - - - -= - - -G - - -b -( -0 -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -b -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -b -( -0 -) - - - - - - -= - - -G - - -b -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - -z -( -j -) - - - -b -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -b -( -j -) - - - -b -( -0 -) - - - - - - -H - - -x -( -0 -) - - - - - -= - - -G - - -x -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -q -( -j -) - - - - - -q -( -j -) - - - - -x -( -0 -) - - - - - - -= - - -G - - -x -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -x -( -j -) - - - -b -( -0 -) - - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -j -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -q -( -j -) - - - - - -q -( -j -) - - - - -x -( -j -) - - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -b -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -x -( -0 -) - - - -b -( -0 -) - - - - - - -H - - -b -( -j -- -k -) - - - - - -= - - -G - - -b -( -j -- -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -b -( -j -- -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -b -( -j -- -k -) - - - - - - -= - - -G - - -b -( -j -- -k -) - - - - -- - -G - - -z -( -j -) - - - - -k -z -( -k -) - - - -j -b -( -0 -) - - - - -- - -G - - -b -( -j -) - - - - -b -( -k -) - - - -b -( -0 -) - - - - - - -H - - -x -( -k -) - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -q -( -j -) - - - - - -q -( -j -) - - - - -x -( -k -) - - - - - - -= - - -G - - -x -( -k -) - - - - -- - -G - - -b -( -j -) - - - - -x -( -j -- -k -) - - - -b -( -0 -) - - - - - - -H - - -z -( -k -) - - - - - -= - - -G - - -z -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -z -( -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -z -( -k -) - - - - - - -= - - -G - - -z -( -k -) - - - - -- - -G - - -z -( -j -) - - - - -k -b -( -j -- -k -) - - - -j -b -( -0 -) - - - - - - - - -
Input File: omh/theory/asin_reverse.omh - - - diff -Nru cppad-2015.00.00.9/doc/_asin_reverse_xml.js cppad-2016.00.00.1/doc/_asin_reverse_xml.js --- cppad-2015.00.00.9/doc/_asin_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_asin_reverse_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,85 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'reversetheory.xml', +'asin_reverse.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_reverse.xml', +'log_reverse.xml', +'sqrt_reverse.xml', +'sin_cos_reverse.xml', +'atan_reverse.xml', +'asin_reverse.xml', +'acos_reverse.xml', +'tan_reverse.xml', +'erf_reverse.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_asinreverse_xml.js cppad-2016.00.00.1/doc/_asinreverse_xml.js --- cppad-2015.00.00.9/doc/_asinreverse_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_asinreverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'asinreverse.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expreverse.xml', -'logreverse.xml', -'sqrtreverse.xml', -'sincosreverse.xml', -'atanreverse.xml', -'asinreverse.xml', -'acosreverse.xml', -'tan_reverse.xml', -'erf_reverse.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/asin.xml cppad-2016.00.00.1/doc/asin.xml --- cppad-2015.00.00.9/doc/asin.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/asin.xml 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,190 @@ + + + +Inverse Sine Function: asin + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
Inverse Sine Function: asin
+
+Syntax + +
+ +y = asin(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +asin + +( +1 +) + + +( +x +) + += + +( +1 +- +x +* +x +) +-1 +/ +2 + + + + + +
+Example + +
+The file +asin.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_asin_xml.js cppad-2016.00.00.1/doc/_asin_xml.js --- cppad-2015.00.00.9/doc/_asin_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_asin_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'asin.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'asin.cpp.xml' +]; +var list_current0 = [ +'asin.xml#Syntax', +'asin.xml#x, y', +'asin.xml#Atomic', +'asin.xml#Derivative', +'asin.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/atan2.cpp.xml cppad-2016.00.00.1/doc/atan2.cpp.xml --- cppad-2015.00.00.9/doc/atan2.cpp.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/atan2.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ The AD atan2 Function: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +atan_forward + +

+ + + +
Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
+
+Derivatives + + + + +atan + +( +1 +) + + +( +x +) + += + +1 +/ +( +1 ++ +x +* +x +) + +atanh + +( +1 +) + + +( +x +) + += + +1 +/ +( +1 +- +x +* +x +) + + + +If + +F +( +x +) + + + is + +atan + +( +x +) + + + or + +atanh + +( +x +) + + +, +the corresponding derivative satisfies the equation + + +( +1 +± +x +* +x +) +* +F +( +1 +) + + +( +x +) +- +0 +* +F +( +x +) += +1 + + +and in the +standard math function differential equation +, + + +A +( +x +) += +0 + + +, + + +B +( +x +) += +1 +± +x +* +x + + +, +and + +D +( +x +) += +1 + + +. +We use + +a + + +, + +b + + +, + +d + + + and + +z + + + to denote the +Taylor coefficients for + + +A +[ +X +( +t +) +] + + +, + + +B +[ +X +( +t +) +] + + +, + + +D +[ +X +( +t +) +] + + +, +and + +F +[ +X +( +t +) +] + + + respectively. + +
+
+Taylor Coefficients Recursion +
+For + +j += +0 +, +1 +, + + + +, + + + +z +( +0 +) + + + += + +F +( +x +( +0 +) + + +) + +b +( +j +) + + + += + +{ +1 +± +x +( +0 +) + + +* +x +( +0 +) + + + +if + + +j += +0 + +± + +k += +0 + +j + +x +( +k +) + + +x +( +j +- +k +) + + + +otherwise + + + + +e +( +j +) + + + += + +d +( +j +) + + ++ + +k += +0 + +j + + +a +( +j +- +k +) + + +* +z +( +k +) + + + + += + +{ +1 + +if + + +j += +0 + +0 + +otherwise + + + + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +( +k += +0 + +j + +e +( +k +) + + +( +j ++ +1 +- +k +) +x +( +j ++ +1 +- +k +) + + +- + +k += +1 + +j + +b +( +k +) + + +( +j ++ +1 +- +k +) +z +( +j ++ +1 +- +k +) + + +) + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +(( +j ++ +1 +) +x +( +j ++ +1 +) + + +- + +k += +1 + +j + +k +z +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + + + +
Input File: omh/theory/atan_forward.omh + + + diff -Nru cppad-2015.00.00.9/doc/atanforward.xml cppad-2016.00.00.1/doc/atanforward.xml --- cppad-2015.00.00.9/doc/atanforward.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/atanforward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,571 +0,0 @@ - - - -Arctangent Function Forward Taylor Polynomial Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -AtanForwardHeadings

- - - - - - - -
Arctangent Function Forward Taylor Polynomial Theory
-If - -F -( -x -) -= -arctan -( -x -) - - - - - -( -1 -+ -x -* -x -) -* -F -( -1 -) - - -( -x -) -- -0 -* -F -( -x -) -= -1 - - -and in the -standard math function differential equation -, - - -A -( -x -) -= -0 - - -, - - -B -( -x -) -= -1 -+ -x -* -x - - -, -and - -D -( -x -) -= -1 - - -. -We use - -a - - -, - -b - - -, - -d - - - and - -z - - - to denote the -Taylor coefficients for - - -A -[ -X -( -t -) -] - - -, - - -B -[ -X -( -t -) -] - - -, - - -D -[ -X -( -t -) -] - - -, -and - -F -[ -X -( -t -) -] - - - respectively. -It now follows from the general -Taylor coefficients recursion formula - -that for - -j -= -0 -, -1 -, - - - -, - - - -z -( -0 -) - - - -= - -arctan -( -x -( -0 -) - - -) - -b -( -j -) - - - -= - -{ -1 -+ -x -( -0 -) - - -* -x -( -0 -) - - - -if - - -j -= -0 - - -k -= -0 - -j - -x -( -k -) - - -x -( -j -- -k -) - - - -otherwise - - - - -e -( -j -) - - - -= - -d -( -j -) - - -+ - -k -= -0 - -j - - -a -( -j -- -k -) - - -* -z -( -k -) - - - - -= - -{ -1 - -if - - -j -= -0 - -0 - -otherwise - - - - -z -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -( -k -= -0 - -j - -e -( -k -) - - -( -j -+ -1 -- -k -) -x -( -j -+ -1 -- -k -) - - -- - -k -= -1 - -j - -b -( -k -) - - -( -j -+ -1 -- -k -) -z -( -j -+ -1 -- -k -) - - -) - -z -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -(( -j -+ -1 -) -x -( -j -+ -1 -) - - -- - -k -= -1 - -j - -k -z -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - - - -
Input File: omh/theory/atan_forward.omh - - - diff -Nru cppad-2015.00.00.9/doc/_atan_forward_xml.js cppad-2016.00.00.1/doc/_atan_forward_xml.js --- cppad-2015.00.00.9/doc/_atan_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_atan_forward_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,89 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'forwardtheory.xml', +'atan_forward.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_forward.xml', +'log_forward.xml', +'sqrt_forward.xml', +'sin_cos_forward.xml', +'atan_forward.xml', +'asin_forward.xml', +'acos_forward.xml', +'tan_forward.xml', +'erf_forward.xml' +]; +var list_current0 = [ +'atan_forward.xml#Derivatives', +'atan_forward.xml#Taylor Coefficients Recursion' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_atanforward_xml.js cppad-2016.00.00.1/doc/_atanforward_xml.js --- cppad-2015.00.00.9/doc/_atanforward_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_atanforward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'atanforward.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expforward.xml', -'logforward.xml', -'sqrtforward.xml', -'sincosforward.xml', -'atanforward.xml', -'asinforward.xml', -'acosforward.xml', -'tan_forward.xml', -'erf_forward.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/atanh.cpp.xml cppad-2016.00.00.1/doc/atanh.cpp.xml --- cppad-2015.00.00.9/doc/atanh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/atanh.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,167 @@ + + + +The AD atanh Function: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +atanh.cppHeadings

+ + + +
The AD atanh Function: Example and Test
+
 
+
+# include <cppad/cppad.hpp>
+
+bool atanh(void)
+{	bool ok = true;
+
+	using CppAD::AD;
+	using CppAD::NearEqual;
+
+	// 10 times machine epsilon
+	double eps = 10. * std::numeric_limits<double>::epsilon();
+
+	// domain space vector
+	size_t n  = 1;
+	double x0 = 0.5;
+	CPPAD_TESTVECTOR(AD<double>) x(n);
+	x[0]      = x0;
+
+	// declare independent variables and start tape recording
+	CppAD::Independent(x);
+
+	// a temporary value
+	AD<double> tanh_of_x0 = CppAD::tanh(x[0]);
+
+	// range space vector
+	size_t m = 1;
+	CPPAD_TESTVECTOR(AD<double>) y(m);
+	y[0] = CppAD::atanh(tanh_of_x0);
+
+	// create f: x -> y and stop tape recording
+	CppAD::ADFun<double> f(x, y);
+
+	// check value
+	ok &= NearEqual(y[0] , x0,  eps, eps);
+
+	// forward computation of first partial w.r.t. x[0]
+	CPPAD_TESTVECTOR(double) dx(n);
+	CPPAD_TESTVECTOR(double) dy(m);
+	dx[0] = 1.;
+	dy    = f.Forward(1, dx);
+	ok   &= NearEqual(dy[0], 1., eps, eps);
+
+	// reverse computation of derivative of y[0]
+	CPPAD_TESTVECTOR(double)  w(m);
+	CPPAD_TESTVECTOR(double) dw(n);
+	w[0]  = 1.;
+	dw    = f.Reverse(1, w);
+	ok   &= NearEqual(dw[0], 1., eps, eps);
+
+	// use a VecAD<Base>::reference object with atanh
+	CppAD::VecAD<double> v(1);
+	AD<double> zero(0);
+	v[zero] = tanh_of_x0;
+	AD<double> result = CppAD::atanh(v[zero]);
+	ok     &= NearEqual(result, x0, eps, eps);
+
+	return ok;
+}
+
+
+ +
+ + +
Input File: example/atanh.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_atanh.cpp_xml.js cppad-2016.00.00.1/doc/_atanh.cpp_xml.js --- cppad-2015.00.00.9/doc/_atanh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_atanh.cpp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,92 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'atanh.xml', +'atanh.cpp.xml' +]; +var list_down3 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down2 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down1 = [ +'atanh.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/atanh.xml cppad-2016.00.00.1/doc/atanh.xml --- cppad-2015.00.00.9/doc/atanh.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/atanh.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,209 @@ + + + +The Inverse Hyperbolic Tangent Function: atanh + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + +
The Inverse Hyperbolic Tangent Function: atanh
+
+Syntax + +
+ +y = atanh(x) + + +
+
+Description +
+The inverse hyperbolic tangent function is defined by + +x == tanh(y) +. + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+CPPAD_USE_CPLUSPLUS_2011 + + +
+
+true +
+If this preprocessor symbol is true (1), +and +x + is an AD type, +this is an atomic operation +. + +
+
+false +
+If this preprocessor symbol is false (0), +CppAD uses the representation + + +atanh + +( +x +) += +1 + +2 + + +log +(1 ++ +x + +1 +- +x + + +) + + +to compute this function. + +
+
+Example + +
+The file +atanh.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/atanh.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_atanh_xml.js cppad-2016.00.00.1/doc/_atanh_xml.js --- cppad-2015.00.00.9/doc/_atanh_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_atanh_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,109 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'atanh.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'atanh.cpp.xml' +]; +var list_current0 = [ +'atanh.xml#Syntax', +'atanh.xml#Description', +'atanh.xml#x, y', +'atanh.xml#CPPAD_USE_CPLUSPLUS_2011', +'atanh.xml#CPPAD_USE_CPLUSPLUS_2011.true', +'atanh.xml#CPPAD_USE_CPLUSPLUS_2011.false', +'atanh.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/atan_reverse.xml cppad-2016.00.00.1/doc/atan_reverse.xml --- cppad-2015.00.00.9/doc/atan_reverse.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/atan_reverse.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,1372 @@ + + + +Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +atan_reverseHeadings

+
Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
+We use the reverse theory +standard math function + +definition for the functions + +H + + + and + +G + + +. +In addition, we use the forward mode notation in +atan_forward + for + + +B +( +t +) += +1 +± +X +( +t +) +* +X +( +t +) + + +We use + +b + + + +for the p-th order Taylor coefficient +row vectors corresponding to + +B +( +t +) + + + +and replace + +z +( +j +) + + + + + by + + +( +z +( +j +) + + +, +b +( +j +) + + +) + + +in the definition for + +G + + + and + +H + + +. +The zero order forward mode formulas for the +atan + +function are + + + +z +( +0 +) + + + += + +F +( +x +( +0 +) + + +) + +b +( +0 +) + + + += + +1 +± +x +( +0 +) + + +x +( +0 +) + + + + + +where + +F +( +x +) += +atan + +( +x +) + + + for + ++ + + + +and + +F +( +x +) += +atanh + +( +x +) + + + for + +- + + +. +For orders + +j + + + greater than zero we have + + + +b +( +j +) + + + += + +± + +k += +0 + +j + +x +( +k +) + + +x +( +j +- +k +) + + + +z +( +j +) + + + += + +1 + +j + + +1 + +b +( +0 +) + + + + +(j +x +( +j +) + + +- + +k += +1 + +j +-1 + + +k +z +( +k +) + + +b +( +j +- +k +) + + +) + + + +If + +j += +0 + + +, we note that + + +F +( +1 +) + + +( +x +( +0 +) + + +) += +1 +/ +b +( +0 +) + + + + + and hence + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +0 +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +b +( +0 +) + + + + +± + +G + + +b +( +j +) + + + + +2 +x +( +0 +) + + + + + +If + +j +> +0 + + +, then for + +k += +1 +, + +, +j +-1 + + + + + + + +H + + +b +( +0 +) + + + + + += + + +G + + +b +( +0 +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +b +( +0 +) + + + + + + += + + +G + + +b +( +0 +) + + + + +- + +G + + +z +( +j +) + + + + +z +( +j +) + + + +b +( +0 +) + + + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +j +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +x +( +j +) + + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +b +( +0 +) + + + + +± + +G + + +b +( +j +) + + + + +2 +x +( +0 +) + + + + +H + + +x +( +0 +) + + + + + += + + +G + + +x +( +0 +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +0 +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +0 +) + + + + +± + +G + + +b +( +j +) + + + + +2 +x +( +j +) + + + + +H + + +x +( +k +) + + + + + += + + +G + + +x +( +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +x +( +k +) + + + + + + += + + +G + + +x +( +k +) + + + + +± + +G + + +b +( +j +) + + + + +2 +x +( +j +- +k +) + + + + +H + + +z +( +k +) + + + + + += + + +G + + +z +( +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +z +( +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +z +( +k +) + + + + + + += + + +G + + +z +( +k +) + + + + +- + +G + + +z +( +j +) + + + + +k +b +( +j +- +k +) + + + +j +b +( +0 +) + + + + + + +H + + +b +( +j +- +k +) + + + + + += + + +G + + +b +( +j +- +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +b +( +j +- +k +) + + + + ++ + +G + + +b +( +j +) + + + + + +b +( +j +) + + + + +b +( +j +- +k +) + + + + + + += + + +G + + +b +( +j +- +k +) + + + + +- + +G + + +z +( +j +) + + + + +k +z +( +k +) + + + +j +b +( +0 +) + + + + + + + + +
Input File: omh/theory/atan_reverse.omh + + + diff -Nru cppad-2015.00.00.9/doc/atanreverse.xml cppad-2016.00.00.1/doc/atanreverse.xml --- cppad-2015.00.00.9/doc/atanreverse.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/atanreverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1301 +0,0 @@ - - - -Arctangent Function Reverse Mode Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -AtanReverseHeadings

-
Arctangent Function Reverse Mode Theory
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. -In addition, - -we use - -b - - - -for the p-th order Taylor coefficient -row vectors corresponding to - - -1 -+ -X -( -t -) -* -X -( -t -) - - - -and replace - -z -( -j -) - - - - - by - - -( -z -( -j -) - - -, -b -( -j -) - - -) - - -in the definition for - -G - - - and - -H - - -. -The forward mode formulas for the -arctangent - -function are - - - -z -( -j -) - - - -= - -arctan -( -x -( -0 -) - - -) - -b -( -j -) - - - -= - -1 -+ -x -( -0 -) - - -x -( -0 -) - - - - - -for the case - -j -= -0 - - -, and for - -j -> -0 - - -, - - - - -b -( -j -) - - - -= - - -k -= -0 - -j - -x -( -k -) - - -x -( -j -- -k -) - - - -z -( -j -) - - - -= - -1 - -j - - -1 - -b -( -0 -) - - - - -(j -x -( -j -) - - -- - -k -= -1 - -j --1 - - -k -z -( -k -) - - -b -( -j -- -k -) - - -) - - - -If - -j -= -0 - - -, we have the relation - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -x -( -0 -) - - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -b -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - -2 -x -( -0 -) - - - - - -If - -j -> -0 - - -, then for - -k -= -1 -, - -, -j --1 - - - - - - - - -H - - -b -( -0 -) - - - - - -= - - -G - - -b -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -b -( -0 -) - - - - - - -= - - -G - - -b -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - -z -( -j -) - - - -b -( -0 -) - - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -j -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -x -( -j -) - - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -b -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - -2 -x -( -0 -) - - - - -H - - -x -( -0 -) - - - - - -= - - -G - - -x -( -0 -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -x -( -0 -) - - - - - - -= - - -G - - -x -( -0 -) - - - - -+ - -G - - -b -( -j -) - - - - -2 -x -( -j -) - - - - -H - - -x -( -k -) - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -x -( -k -) - - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -b -( -j -) - - - - -2 -x -( -j -- -k -) - - - - -H - - -z -( -k -) - - - - - -= - - -G - - -z -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -z -( -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -z -( -k -) - - - - - - -= - - -G - - -z -( -k -) - - - - -- - -G - - -z -( -j -) - - - - -k -b -( -j -- -k -) - - - -j -b -( -0 -) - - - - - - -H - - -b -( -j -- -k -) - - - - - -= - - -G - - -b -( -j -- -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -b -( -j -- -k -) - - - - -+ - -G - - -b -( -j -) - - - - - -b -( -j -) - - - - -b -( -j -- -k -) - - - - - - -= - - -G - - -b -( -j -- -k -) - - - - -- - -G - - -z -( -j -) - - - - -k -z -( -k -) - - - -j -b -( -0 -) - - - - - - - - -
Input File: omh/theory/atan_reverse.omh - - - diff -Nru cppad-2015.00.00.9/doc/_atan_reverse_xml.js cppad-2016.00.00.1/doc/_atan_reverse_xml.js --- cppad-2015.00.00.9/doc/_atan_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_atan_reverse_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,85 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'reversetheory.xml', +'atan_reverse.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_reverse.xml', +'log_reverse.xml', +'sqrt_reverse.xml', +'sin_cos_reverse.xml', +'atan_reverse.xml', +'asin_reverse.xml', +'acos_reverse.xml', +'tan_reverse.xml', +'erf_reverse.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_atanreverse_xml.js cppad-2016.00.00.1/doc/_atanreverse_xml.js --- cppad-2015.00.00.9/doc/_atanreverse_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_atanreverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'atanreverse.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expreverse.xml', -'logreverse.xml', -'sqrtreverse.xml', -'sincosreverse.xml', -'atanreverse.xml', -'asinreverse.xml', -'acosreverse.xml', -'tan_reverse.xml', -'erf_reverse.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/atan.xml cppad-2016.00.00.1/doc/atan.xml --- cppad-2015.00.00.9/doc/atan.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/atan.xml 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,187 @@ + + + +Inverse Tangent Function: atan + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
Inverse Tangent Function: atan
+
+Syntax + +
+ +y = atan(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +atan + +( +1 +) + + +( +x +) + += + +1 + +1 ++ +x +2 + + + + + + +
+Example + +
+The file +atan.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_atan_xml.js cppad-2016.00.00.1/doc/_atan_xml.js --- cppad-2015.00.00.9/doc/_atan_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_atan_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'atan.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'atan.cpp.xml' +]; +var list_current0 = [ +'atan.xml#Syntax', +'atan.xml#x, y', +'atan.xml#Atomic', +'atan.xml#Derivative', +'atan.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/atomic_afun.xml cppad-2016.00.00.1/doc/atomic_afun.xml --- cppad-2015.00.00.9/doc/atomic_afun.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/atomic_afun.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ Using AD Version of Atomic Function - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +atomic_sparsity.cpp + +

+
Atomic Sparsity Patterns: Example and Test
+
+function +
+For this example, the atomic function + + +f +: +R + +3 + + +R + +2 + + + + is defined by + + +f +( +x +0 + +, +x +1 + +, +x +2 + +) += +( +x +2 + + +x +0 + +* +x +1 + + +) + + +
+pack_sparsity_enum +
+This example only uses pack sparsity patterns. + + + +
+
+Start Class Definition + +
 
+# include <cppad/cppad.hpp>
+namespace {                 // isolate items below to this file
+using CppAD::vector;        // abbreviate as vector
+using CppAD::vectorBool;    // abbreviate as vectorBool
+//
+class atomic_sparsity : public CppAD::atomic_base<double> {
+
+
+Constructor + +
 
+     public:
+     // constructor
+     atomic_sparsity(const std::string& name) :
+     // this exampel only uses pack sparsity patterns
+     CppAD::atomic_base<double>(name, pack_sparsity_enum )
+     { }
+     private:
+
+
+forward + +
 
+     // forward
+     virtual bool forward(
+          size_t                    p ,
+          size_t                    q ,
+          const vector<bool>&      vx ,
+          vector<bool>&            vy ,
+          const vector<double>&    tx ,
+          vector<double>&          ty
+     )
+     {    size_t n = tx.size() / (q + 1);
+          size_t m = ty.size() / (q + 1);
+          assert( n == 3 );
+          assert( m == 2 );
+
+          // only order zero
+          bool ok = q == 0;
+          if( ! ok )
+               return ok;
+
+          // check for defining variable information
+          if( vx.size() > 0 )
+          {    ok   &= vx.size() == n;
+               vy[0] = vx[2];
+               vy[1] = vx[0] || vx[1];
+          }
+
+          // Order zero forward mode.
+          // y[0] = x[2], y[1] = x[0] * x[1]
+          if( p <= 0 )
+          {    ty[0] = tx[2];
+               ty[1] = tx[0] * tx[1];
+          }
+          return ok;
+     }
+
+
+for_sparse_jac + +
 
+     // for_sparse_jac
+     virtual bool for_sparse_jac(
+          size_t                          p ,
+          const vectorBool&               r ,
+          vectorBool&                     s )
+     {    // This function needed if using f.ForSparseJac
+          size_t n = r.size() / p;
+          size_t m = s.size() / p;
+          assert( n == 3 );
+          assert( m == 2 );
+
+          // sparsity for S(x) = f'(x) * R  = [ 0,   0, 1 ] * R
+          //                                  [ x1, x0, 0 ]
+          for(size_t j = 0; j < p; j++)
+          {    s[ 0 * p + j] = r[ 2 * p + j];
+               s[ 1 * p + j] = r[ 0 * p + j] || r[ 1 * p + j];
+          }
+          return true;
+     }
+
+
+rev_sparse_jac + +
 
+     virtual bool rev_sparse_jac(
+          size_t                                p  ,
+          const vectorBool&                     rt ,
+          vectorBool&                           st )
+     {    // This function needed if using RevSparseJac or optimize
+          size_t n = st.size() / p;
+          size_t m = rt.size() / p;
+          assert( n == 3 );
+          assert( m == 2 );
+
+          //                                       [ 0, x1 ]
+          // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T
+          //                                       [ 1, 0  ]
+          for(size_t j = 0; j < p; j++)
+          {    st[ 0 * p + j ] = rt[ 1 * m + j ];
+               st[ 1 * p + j ] = rt[ 1 * m + j ];
+               st[ 2 * p + j ] = rt[ 0 * m + j ];
+          }
+          return true;
+     }
+
+
+rev_sparse_hes + +
 
+     virtual bool rev_sparse_hes(
+          const vector<bool>&                   vx,
+          const vector<bool>&                   s ,
+                vector<bool>&                   t ,
+          size_t                                p ,
+          const vectorBool&                     r ,
+          const vectorBool&                     u ,
+          vectorBool&                           v )
+     {    // This function needed if using RevSparseHes
+          size_t m = s.size();
+          size_t n = t.size();
+          assert( r.size() == n * p );
+          assert( u.size() == m * p );
+          assert( v.size() == n * p );
+          assert( n == 3 );
+          assert( m == 2 );
+
+          // sparsity for T(x) = S(x) * f'(x) = S(x) * [  0,  0,  1 ]
+          //                                           [ x1, x0,  0 ]
+          t[0] = s[1];
+          t[1] = s[1];
+          t[2] = s[0];
+
+          // V(x) = f'(x)^T * g''(y) * f'(x) * R  +  g'(y) * f''(x) * R
+          // U(x) = g''(y) * f'(x) * R
+          // S(x) = g'(y)
+
+          //                               [ 0, x1 ]
+          // sparsity for f'(x)^T * U(x) = [ 0, x0 ] * U(x)
+          //                               [ 1, 0  ]
+          size_t j;
+          for(j = 0; j < p; j++)
+          {    v[ 0 * p + j ] = u[ 1 * m + j ];
+               v[ 1 * p + j ] = u[ 1 * m + j ];
+               v[ 2 * p + j ] = u[ 0 * m + j ];
+          }
+
+          // include forward Jacobian sparsity in Hessian sparsity
+          //                                                [ 0, 1, 0 ]
+          // sum_i S_i (x) g'(y) * f_i''(x) * R = S_1 (x) * [ 1, 0, 0 ] * R
+          //                                                [ 0, 0, 0 ]
+          if( s[1] )
+          {    for(j = 0; j < p; j++)
+               {    v[ 0 * p + j ] = bool(v[0 * p + j]) | bool(r[1 * p + j]);
+                    v[ 1 * p + j ] = bool(v[1 * p + j]) | bool(r[0 * p + j]);
+               }
+          }
+          return true;
+     }
+
+
+End Class Definition + +
 
+}; // End of atomic_sparsity class
+}  // End empty namespace
+
+
+Use Atomic Function + +
 
+bool sparsity(void)
+{    bool ok = true;
+     using CppAD::AD;
+     using CppAD::NearEqual;
+     double eps = 10. * std::numeric_limits<double>::epsilon();
+
+
+Constructor + +
 
+     // Create the atomic get_started object
+     atomic_sparsity afun("atomic_sparsity");
+
+
+Recording + +
 
+     size_t n = 3;
+     size_t m = 2;
+     vector< AD<double> > ax(n), ay(m);
+     for(size_t j = 0; j < n; j++)
+          ax[j] = double(j + 1);
+
+     // declare independent variables and start tape recording
+     CppAD::Independent(ax);
+
+     // call user function
+     afun(ax, ay);
+
+     // create f: x -> y and stop tape recording
+     CppAD::ADFun<double> f;
+     f.Dependent (ax, ay);  // f(x) = x
+
+     // check function value
+     ok &= NearEqual(ay[0] , ax[2],  eps, eps);
+     ok &= NearEqual(ay[1] , ax[0] * ax[1],  eps, eps);
+
+
+forsparse_jac and rev_sparse_jac + +
 
+     for(size_t dir = 0; dir < 2; dir++)
+     {    size_t ell;
+          if( dir == 0 )
+               ell = n;
+          else
+               ell = m;
+
+          // identity martrix
+          vectorBool r(ell * ell);
+          for(size_t i = 0; i < ell; i++)
+               for(size_t j = 0; j < ell; j++)
+                    r[i * ell + j] = (i == j);
+
+          vectorBool s;
+          if( dir == 0 )
+               s = f.ForSparseJac(n, r);
+          else
+               s = f.RevSparseJac(m, r);
+
+          // check Jacobian result
+          ok  &= s.size() == m * n;
+          ok  &= s[0 * n + 0] == false;
+          ok  &= s[0 * n + 1] == false;
+          ok  &= s[0 * n + 2] == true;
+          ok  &= s[1 * n + 0] == true;
+          ok  &= s[1 * n + 1] == true;
+          ok  &= s[1 * n + 2] == false;
+     }
+
+
+rev_sparse_hes + +
 
+     vectorBool s(m), h(n * n);
+     s[0] = true;
+     s[1] = true;
+     h    = f.RevSparseHes(n, s);
+     for(size_t i = 0; i < n; i++)
+     {    for(size_t j = 0; j < n; j++)
+          {    bool check = false;
+               check     |= (i == 0) && (j == 1);
+               check     |= (j == 0) && (i == 1);
+               ok        &= h[ i * n + j] == check;
+          }
+     }
+     //
+     return ok;
+}
+
+ +
Input File: example/atomic/sparsity.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_atomic_sparsity.cpp_xml.js cppad-2016.00.00.1/doc/_atomic_sparsity.cpp_xml.js --- cppad-2015.00.00.9/doc/_atomic_sparsity.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_atomic_sparsity.cpp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,104 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'atomic.xml', +'atomic_base.xml', +'atomic_sparsity.cpp.xml' +]; +var list_down3 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down2 = [ +'checkpoint.xml', +'atomic_base.xml' +]; +var list_down1 = [ +'atomic_ctor.xml', +'atomic_option.xml', +'atomic_afun.xml', +'atomic_forward.xml', +'atomic_reverse.xml', +'atomic_for_sparse_jac.xml', +'atomic_rev_sparse_jac.xml', +'atomic_rev_sparse_hes.xml', +'atomic_base_clear.xml', +'atomic_get_started.cpp.xml', +'atomic_norm_sq.cpp.xml', +'atomic_reciprocal.cpp.xml', +'atomic_sparsity.cpp.xml', +'atomic_tangent.cpp.xml', +'atomic_hes_sparse.cpp.xml', +'atomic_mat_mul.cpp.xml' +]; +var list_current0 = [ +'atomic_sparsity.cpp.xml#function', +'atomic_sparsity.cpp.xml#pack_sparsity_enum', +'atomic_sparsity.cpp.xml#Start Class Definition', +'atomic_sparsity.cpp.xml#Constructor', +'atomic_sparsity.cpp.xml#forward', +'atomic_sparsity.cpp.xml#for_sparse_jac', +'atomic_sparsity.cpp.xml#rev_sparse_jac', +'atomic_sparsity.cpp.xml#rev_sparse_hes', +'atomic_sparsity.cpp.xml#End Class Definition', +'atomic_sparsity.cpp.xml#Use Atomic Function', +'atomic_sparsity.cpp.xml#Use Atomic Function.Constructor', +'atomic_sparsity.cpp.xml#Use Atomic Function.Recording', +'atomic_sparsity.cpp.xml#Use Atomic Function.forsparse_jac and rev_sparse_jac', +'atomic_sparsity.cpp.xml#Use Atomic Function.rev_sparse_hes' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/atomic_tangent.cpp.xml cppad-2016.00.00.1/doc/atomic_tangent.cpp.xml --- cppad-2015.00.00.9/doc/atomic_tangent.cpp.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/atomic_tangent.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ Tan and Tanh as User Atomic Operations: Example and Test - + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + +auto_tools + +

+
Auto Tools Unix Test and Installation
+
+Deprecated 2012-12-26 +
+These install instructions have been deprecated and no improvements +have been added since 2012. +For example, this install procedure will not detect any of the +c++11 extensions. +You should use the cmake + instructions to install CppAD. + +
+
+Distribution Directory +
+You must first obtain a copy of the CppAD distribution directory +using the download + instructions. +The install instructions below correspond to the +current version + +which has distribution directory cppad-20121230. + +
+
+Work Directory +
+Create the directory cppad-20121230/build, +which will be referred to as the build directory below. + +
+
+Configure +
+Execute the following command in the build directory: + +
+./configure                                  \
+     --prefix=
prefix_dir                    \
+     --with-Documentation                     \
+     --with-
testvector                      \
+     --with-sparse_
option                   \
+     --with-deprecated                        \
+     MAX_NUM_THREADS=
max_num_threads         \
+     CXX_FLAGS=
cxx_flags                     \
+     OPENMP_FLAGS=
openmp_flags               \
+     POSTFIX_DIR=
postfix_dir                 \
+     ADOLC_DIR=
adolc_dir                     \
+     BOOST_DIR=
boost_dir                     \
+     EIGEN_DIR=
eigen_dir                     \
+     FADBAD_DIR=
fadbad_dir                   \
+     SADADO_DIR=
sacado_dir                   \
+     IPOPT_DIR=
ipopt_dir                     \
+     TAPE_ADDR_TYPE=
tape_addr_type           \
+     TAPE_ID_TYPE=
tape_id_type
+
+where only the configure line need appear; i.e., +the entries in all of the other lines are optional. +The text in italic is replaced values that you choose; +see discussion below. + +
+
+make +
+CppAD has some object libraries that are used for its correctness tests. +(Currently, none of these libraries get installed.) +You can build these libraries by executing the command + +
+     make
+
+in the build directory. + +
+
+Examples and Tests +
+Once you have executed the make command, +you can run the correctness and speed tests. +
+
+
The following command will build all the correctness and speed tests. +In addition, it will run all the correctness tests: +
 
+     make test
+
+
+
+
The following links describe how to build and run subsets of these tests: + +
+ +get_started + + + Getting Started Using CppAD to Compute Derivatives +
+ +exp_apx_main + + + Correctness Tests For Exponential Approximation in Introduction +
+ +example + + + CppAD Examples and Tests +
+ +print_for_cout + + + Printing During Forward Mode: Example and Test +
+ +speed_example + + + Run the Speed Examples +
+ +speed_double + + + Speed Test of Functions in Double +
+ +speed_adolc + + + Speed Test of Derivatives Using Adolc +
+ +speed_cppad + + + Speed Test Derivatives Using CppAD +
+ +speed_fadbad + + + Speed Test Derivatives Using Fadbad +
+ +speed_sacado + + + Speed Test Derivatives Using Sacado +
+In addition, +you can run a large subset of correctness tests +(that are not intended to be examples) +by executing the following commands starting in the build directory: + +
+     cd test_more
+     make test
+
+
+Profiling CppAD +
+The CppAD derivative speed tests mentioned above can be profiled. +You can test that the results computed during this profiling are correct +by executing the following commands starting in the build directory: + +
+     cd speed/profile
+     make test
+
+After executing make test, you can run a profile speed test +by executing the command ./profile; +see speed_main + for the meaning of the command line +options to this program. +
+
+
After you have run a profiling speed test, +you can then obtain the profiling results with + +
+     gprof -b profile
+
+If you are using a windows operating system with Cygwin or MinGW, +you may have to replace profile by profile.exe +in the gprof command above; i.e., +
 
+     gprof -b profile.exe
+
+In C++, template parameters and argument types become part of a +routines's name. +This can make the gprof output hard to read +(the routine names can be very long). +You can remove the template parameters and argument types from the +routine names by executing the following command +
 
+     gprof -b profile | sed -f gprof.sed
+
+If you are using a windows operating system with Cygwin or MinGW, +you would need to use +
 
+     gprof -b profile.exe | sed -f gprof.sed
+
+
+prefix_dir +
+The default value for prefix directory is $HOME +i.e., by default the CppAD include files +will install + below $HOME. +If you want to install elsewhere, you will have to use this option. +As an example of using the +--prefix=prefix_dir + option, +if you specify +
 
+     ./configure --prefix=/usr/local
+
+the CppAD include files will be installed in the directory + +
+     /usr/local/include/cppad
+
+If --with-Documentation + +is specified, the CppAD documentation files will be installed in the directory + +
+     /usr/local/share/doc/cppad-20121230
+
+
+--with-Documentation +
+If the command line argument --with-Documentation is specified, +the CppAD documentation HTML and XML files are copied to the directory + +
+     
prefix_dir/share/doc/postfix_dir/cppad-20121230
+
+(see postfix_dir +). +The top of the CppAD HTML documentation tree +(with mathematics displayed as LaTex command) will be located at + +
+     
prefix_dir/share/doc/postfix_dir/cppad-20121230/cppad.htm
+
+and the top of the XML documentation tree +(with mathematics displayed as MathML) will be located at + +
+     
prefix_dir/share/doc/postfix_dir/cppad-20121230/cppad.xml
+
+
+--with-testvector +
+The CPPAD_TESTVECTOR + +template class is used for many of the CppAD examples and tests. +The default for this template class is +CppAD::vector<Scalar> +. +If one, and only one, of the following command line arguments is specified: +
 
+     --with-stdvector
+     --with-boostvector
+     --with-eigenvector
+
+the corresponding of the following template classes is used + +
+     std::vector<
Scalar>
+     boost::numeric::ublas::vector<
Scalar>
+     Eigen::matrix<
Scalar, Eigen::Dynamic, 1>
+
+See also, +boost_dir + +and +eigen_dir +. + + +
+
+--with-sparse_option +
+There are two options for the preprocessor symbol +CPPAD_INTERNAL_SPARSE_SET. +If --with-sparse_set +(--with-sparse_list) is specified, +this symbol is sparse_set (sparse_list). +This should affect the speed and memory required by the +sparse_jacobian +, sparse_hessian +, and the +sparse drivers +. + +
+
+--with-deprecated +
+If this configure argument is present, then all the +deprecated + features are included in the install. +Otherwise, they are not included. + +
+
+max_num_threads +
+this specifies the value for the default value for the preprocessor symbol +CPPAD_MAX_NUM_THREADS +. +It must be greater than or equal to four; i.e., + +max_num_threads >= 4 +. + +
+
+cxx_flags +
+If the command line argument +CompilerFlags + is present, +it specifies compiler flags. +For example, + +
+     CXX_FLAGS="-Wall -ansi"
+
+would specify that warning flags -Wall +and -ansi should be included +in all the C++ compile commands. +The error and warning flags chosen must be valid options +for the C++ compiler. +The default value for +CompilerFlags + is the +empty string. + +
+
+openmp_flags +
+If the command line argument +OpenmpFlags + is present, +it specifies the necessary flags so that the compiler will +properly interpret OpenMP directives. +For example, when using the GNU g++ compiler, +the following setting includes the OpenMP tests: + +
+     OPENMP_FLAGS=-fopenmp
+
+If you specify configure command, +the CppAD OpenMP correctness and speed tests will be built; see +threading + +multi-threading tests. + +
+
+postfix_dir +
+By default, the postfix directory is empty; i.e., there +is no postfix directory. +As an example of using the +POSTFIX_DIR=postfix_dir + option, +if you specify +
 
+     ./configure --prefix=/usr/local POSTFIX_DIR=coin
+
+the CppAD include files will be +installed + in the directory + +
+     /usr/local/include/coin/cppad
+
+If --with-Documentation + +is specified, the CppAD documentation files will be installed in the directory + +
+     /usr/local/share/doc/coin/cppad-20121230
+
+
+adolc_dir +
+If you have +ADOL-C + +installed on your system, you can +specify a value for +adolc_dir + in the +configure + command line. +The value of +adolc_dir + must be such that + +
+     
adolc_dir/include/adolc/adouble.h
+
+is a valid way to reference adouble.h. +In this case, you can run the Adolc speed correctness tests +by executing the following commands starting in the build directory: + +
+     cd speed/adolc
+     make test
+
+After executing make test, you can run an Adolc speed tests +by executing the command ./adolc; +see speed_main + for the meaning of the command line +options to this program. +Note that these speed tests assume Adolc has been configure with +its sparse matrix computations enabled using + +
+     --with-colpack=
colpack_dir
+
+
+Linux +
+If you are using Linux, +you will have to add +adolc_dir/lib + to LD_LIBRARY_PATH. +For example, if you use the bash shell to run your programs, +you could include + +
+     LD_LIBRARY_PATH=
adolc_dir/lib:${LD_LIBRARY_PATH}
+     export LD_LIBRARY_PATH
+
+in your $HOME/.bash_profile file. + +
+
+Cygwin +
+If you are using Cygwin, +you will have to add to following lines to the file +.bash_profile in your home directory: + +
+     PATH=
adolc_dir/bin:${PATH}
+     export PATH
+
+in order for Adolc to run properly. +If +adolc_dir + begins with a disk specification, +you must use the Cygwin format for the disk specification. +For example, +if d:/adolc_base is the proper directory, +/cygdrive/d/adolc_base should be used for +adolc_dir +. + +
+
+boost_dir +
+If the command line argument + +
+     BOOST_DIR=
boost_dir
+
+is present, it must be such that files + +
+     
boost_dir/include/boost/numeric/ublas/vector.hpp
+     
boost_dir/include/boost/thread.hpp
+
+are present. +In this case, these files will be used by CppAD. +See also, --with-boostvector + + +
+
+eigen_dir +
+If you have +Eigen + +installed on your system, you can +specify a value for +eigen_dir +. +It must be such that + +
+     
eigen_dir/include/Eigen/Core
+
+is a valid include file. +In this case CppAD will compile and test the Eigen examples; e.g., +eigen_array.cpp +. +See also, --with-eigenvector + + +
+
+fadbad_dir +
+If you have +Fadbad 2.1 + +installed on your system, you can +specify a value for +fadbad_dir +. +It must be such that + +
+     
fadbad_dir/include/FADBAD++/badiff.h
+
+is a valid reference to badiff.h. +In this case, you can run the Fadbad speed correctness tests +by executing the following commands starting in the build directory: + +
+     cd speed/fadbad
+     make test
+
+After executing make test, you can run a Fadbad speed tests +by executing the command ./fadbad; +see speed_main + for the meaning of the command line +options to this program. + +
+
+ipopt_dir +
+If you have +Ipopt + +installed on your system, you can +specify a value for +ipopt_dir +. +It must be such that + +
+     
ipopt_dir/include/coin/IpIpoptApplication.hpp
+
+is a valid reference to IpIpoptApplication.hpp. +In this case, the CppAD interface to Ipopt +examples + can be built and tested +by executing the following commands starting in the build directory: + +
+     make
+     #
+     cd cppad_ipopt/example
+     make test
+     #
+     cd ../test
+     make test
+     #
+     cd ../speed
+     make test
+
+Once this has been done, you can execute the program +./speed in the build/cppad_ipopt/speed directory; +see ipopt_ode_speed.cpp +. + +
+
+sacado_dir +
+If you have +Sacado + +installed on your system, you can +specify a value for +sacado_dir +. +It must be such that + +
+     
sacado_dir/include/Sacado.hpp
+
+is a valid reference to Sacado.hpp. +In this case, you can run the Sacado speed correctness tests +by executing the following commands starting in the build directory: + +
+     cd speed/sacado
+     make test
+
+After executing make test, you can run a Sacado speed tests +by executing the command ./sacado; +see speed_main + for the meaning of the command line +options to this program. + + +
+
+tape_addr_type +
+If the command line argument +tape_addr_type + is present, +it specifies the type used for address in the AD recordings (tapes). +The valid values for this argument are +unsigned short int, +unsigned int, +size_t. +The smaller the value of +sizeof(tape_addr_type) +, +the less memory is used. +On the other hand, the value + +
+     std::numeric_limits<
tape_addr_type>::max()
+
+must be larger than any of the following: +size_op +, +size_op_arg +, +size_par +, +size_par +, +size_par +. + + +
+
+tape_id_type +
+If the command line argument +tape_id_type + is present, +it specifies the type used for identifying tapes. +The valid values for this argument are +unsigned short int, +unsigned int, +size_t. +The smaller the value of +sizeof(tape_id_type) +, +the less memory is used. +On the other hand, the value + +
+     std::numeric_limits<
tape_id_type>::max()
+
+must be larger than the maximum number of tapes per thread +times max_num_threads +. + +
+
+make install +
+Once you are satisfied that the tests are giving correct results, +you can install CppAD into easy to use directories by executing the command +
 
+     make install
+
+This will install CppAD in the location specified by +prefix_dir +. +You must have permission to write in the +prefix_dir + +directory to execute this command. +You may optionally specify a destination directory for the install; i.e., + +
+     make install DESTDIR=
DestinationDirectory
+
+ +
Input File: omh/install/auto_tools.omh + + + diff -Nru cppad-2015.00.00.9/doc/_auto_tools_xml.js cppad-2016.00.00.1/doc/_auto_tools_xml.js --- cppad-2015.00.00.9/doc/_auto_tools_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_auto_tools_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,97 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'install.xml', +'auto_tools.xml' +]; +var list_down2 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down1 = [ +'download.xml', +'cmake.xml', +'cmake_check.xml', +'pkgconfig.xml', +'auto_tools.xml' +]; +var list_current0 = [ +'auto_tools.xml#Deprecated 2012-12-26', +'auto_tools.xml#Distribution Directory', +'auto_tools.xml#Work Directory', +'auto_tools.xml#Configure', +'auto_tools.xml#make', +'auto_tools.xml#make.Examples and Tests', +'auto_tools.xml#Profiling CppAD', +'auto_tools.xml#prefix_dir', +'auto_tools.xml#--with-Documentation', +'auto_tools.xml#--with-testvector', +'auto_tools.xml#--with-sparse_option', +'auto_tools.xml#--with-deprecated', +'auto_tools.xml#max_num_threads', +'auto_tools.xml#cxx_flags', +'auto_tools.xml#openmp_flags', +'auto_tools.xml#postfix_dir', +'auto_tools.xml#adolc_dir', +'auto_tools.xml#adolc_dir.Linux', +'auto_tools.xml#adolc_dir.Cygwin', +'auto_tools.xml#boost_dir', +'auto_tools.xml#eigen_dir', +'auto_tools.xml#fadbad_dir', +'auto_tools.xml#ipopt_dir', +'auto_tools.xml#sacado_dir', +'auto_tools.xml#tape_addr_type', +'auto_tools.xml#tape_id_type', +'auto_tools.xml#make install' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/azmul.cpp.xml cppad-2016.00.00.1/doc/azmul.cpp.xml --- cppad-2015.00.00.9/doc/azmul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/azmul.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,147 @@ + + + +AD Absolute Zero Multiplication: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +azmul.cppHeadings

+ + + +
AD Absolute Zero Multiplication: Example and Test
+
 
+
+# include <cppad/cppad.hpp>
+# include <cmath>
+
+bool azmul(void)
+{	bool ok = true;
+
+	using CppAD::AD;
+	using CppAD::NearEqual;
+	double inf = std::numeric_limits<double>::infinity();
+	double eps = 10. * std::numeric_limits<double>::epsilon();
+
+	// domain space vector
+	size_t n  = 2;
+	double x = 0.5;
+	double y = 2.0;
+	CPPAD_TESTVECTOR(AD<double>) axy(n);
+	axy[0]      = x;
+	axy[1]      = y;
+
+	// declare independent variables and start tape recording
+	CppAD::Independent(axy);
+
+	// range space vector
+	size_t m = 5;
+	CPPAD_TESTVECTOR(AD<double>) az(m);
+	az[0] = CppAD::azmul(axy[0], axy[1]); // azmul(variable, variable)
+	az[1] = CppAD::azmul(axy[0], inf);    // azmul(variable, parameter=inf)
+	az[2] = CppAD::azmul(axy[0], 3.0);    // azmul(variable, parameter=3.0)
+	az[3] = CppAD::azmul(0.0, axy[1]);    // azmul(parameter=0.0, variable)
+	az[4] = CppAD::azmul(4.0, axy[1]);    // azmul(parameter=4.0, variable)
+
+	// create f: axy -> az and stop tape recording
+	CppAD::ADFun<double> f(axy, az);
+
+	// check value when x is not zero
+	ok &= NearEqual(az[0] , x * y,  eps, eps);
+	ok &= az[1] == inf;
+	ok &= NearEqual(az[2] , x * 3.0,  eps, eps);
+	ok &= az[3] == 0.0;
+	ok &= NearEqual(az[4] , 4.0 * y,  eps, eps);
+
+
+	// check value x is zero and y is infinity
+	CPPAD_TESTVECTOR(double) xy(n), z(m);
+	xy[0] = 0.0;
+	xy[1] = inf;
+	z     = f.Forward(0, xy);
+	ok &= z[0] == 0.0;
+	ok &= z[1] == 0.0;
+	ok &= z[2] == 0.0;
+	ok &= z[3] == 0.0;
+	ok &= z[4] == inf;
+
+	return ok;
+}
+
+
+ +
+ + +
Input File: example/azmul.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_azmul.cpp_xml.js cppad-2016.00.00.1/doc/_azmul.cpp_xml.js --- cppad-2015.00.00.9/doc/_azmul.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_azmul.cpp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,74 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'binary_math.xml', +'azmul.xml', +'azmul.cpp.xml' +]; +var list_down3 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down2 = [ +'atan2.xml', +'pow.xml', +'azmul.xml' +]; +var list_down1 = [ +'azmul.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/azmul.xml cppad-2016.00.00.1/doc/azmul.xml --- cppad-2015.00.00.9/doc/azmul.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/azmul.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,230 @@ + + + +Absolute Zero Multiplication + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
Absolute Zero Multiplication
+
+Syntax + +
+ +z = azmul(xy) + + +
+
+Purpose +
+Evaluates multiplication with an absolute zero +for any of the possible types listed below. +The result is given by + + +z += +{ +0 + +if + + +x += +0 + +x +· +y + +otherwise + + + + + +Note if +x + is zero and +y + is infinity, +ieee multiplication would result in not a number whereas + +z + would be zero. + +
+
+Base +
+If +Base + satisfies the +base type requirements + +and arguments +x +, +y + have prototypes + +
+     const 
Basex
+     const 
Basey
+
+then the result +z + has prototype + +
+     
Base z
+
+
+AD<Base> +
+If the arguments +x +, +y + have prototype + +
+     const AD<
Base>& x
+     const AD<
Base>& y
+
+then the result +z + has prototype + +
+     AD<
Basez
+
+
+VecAD<Base> +
+If the arguments +x +, +y + have prototype + +
+     const VecAD<
Base>::reference& x
+     const VecAD<
Base>::reference& y
+
+then the result +z + has prototype + +
+     AD<
Basez
+
+
+Example + +
+The file +azmul.cpp + +is an examples and tests of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/azmul.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_azmul_xml.js cppad-2016.00.00.1/doc/_azmul_xml.js --- cppad-2015.00.00.9/doc/_azmul_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_azmul_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,90 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'binary_math.xml', +'azmul.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'atan2.xml', +'pow.xml', +'azmul.xml' +]; +var list_down0 = [ +'azmul.cpp.xml' +]; +var list_current0 = [ +'azmul.xml#Syntax', +'azmul.xml#Purpose', +'azmul.xml#Base', +'azmul.xml#AD<Base>', +'azmul.xml#VecAD<Base>', +'azmul.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/base_adolc.hpp.xml cppad-2016.00.00.1/doc/base_adolc.hpp.xml --- cppad-2015.00.00.9/doc/base_adolc.hpp.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/base_adolc.hpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ Enable use of AD<Base> where Base is Adolc's adouble Type - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +base_limits + +

+ + + +
Base Type Requirements for Numeric Limits
+
+CppAD::numeric_limits +
+A specialization for +CppAD::numeric_limits + +must be defined in order to use the type +AD<Base> +. +CppAD does not use a specialization of + +std::numeric_limits<Base> +. +Since C++11, using a specialization of + +std::numeric_limits<Base> + +would require that +Base + be a literal type. + +
+
+CPPAD_NUMERIC_LIMITS +
+In most cases, this macro can be used to define the specialization where +the numeric limits for the type +Base + +are the same as the standard numeric limits for the type +Other +. +For most +Base + types, +there is a choice of +Other +, +for which the following preprocessor macro invocation suffices: + +
+     namespace CppAD {
+          CPPAD_NUMERIC_LIMITS(
OtherBase)
+     }
+
+where the macro is defined by +
 
+# define CPPAD_NUMERIC_LIMITS(Other, Base) \
+template <> class numeric_limits<Base>\
+{\
+     public:\
+     static Base min(void) \
+     {    return static_cast<Base>( std::numeric_limits<Other>::min() ); }\
+     static Base max(void) \
+     {    return static_cast<Base>( std::numeric_limits<Other>::max() ); }\
+     static Base epsilon(void) \
+     {    return static_cast<Base>( std::numeric_limits<Other>::epsilon() ); }\
+     static Base quiet_NaN(void) \
+     {    return static_cast<Base>( std::numeric_limits<Other>::quiet_NaN() ); }\
+};
+
+ +
Input File: cppad/local/base_limits.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_base_limits_xml.js cppad-2016.00.00.1/doc/_base_limits_xml.js --- cppad-2015.00.00.9/doc/_base_limits_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_base_limits_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,91 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'base_require.xml', +'base_limits.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down1 = [ +'base_member.xml', +'base_cond_exp.xml', +'base_identical.xml', +'base_ordered.xml', +'base_std_math.xml', +'base_limits.xml', +'base_to_string.xml', +'base_example.xml' +]; +var list_current0 = [ +'base_limits.xml#CppAD::numeric_limits', +'base_limits.xml#CPPAD_NUMERIC_LIMITS' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/base_member.xml cppad-2016.00.00.1/doc/base_member.xml --- cppad-2015.00.00.9/doc/base_member.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/base_member.xml 2016-02-09 08:32:05.000000000 +0000 @@ -52,7 +52,7 @@ - + @@ -79,6 +79,8 @@ + + @@ -110,7 +112,7 @@ Base - + The base type corresponding to AD<Base> @@ -197,7 +199,7 @@
     
z = op x
- +

Assignment Operators @@ -216,7 +218,7 @@
     
z op x
- +

Binary Operators @@ -232,7 +234,7 @@
     
z = x op y
- +

Bool Operators @@ -255,10 +257,10 @@
See the heading Class Definition in base_alloc -. +. -
Input File: omh/base_member.omh +
Input File: omh/base_require/base_member.omh diff -Nru cppad-2015.00.00.9/doc/_base_member_xml.js cppad-2016.00.00.1/doc/_base_member_xml.js --- cppad-2015.00.00.9/doc/_base_member_xml.js 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/_base_member_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -18,7 +18,7 @@ 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', -'library.xml', +'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', @@ -39,6 +39,8 @@ 'base_identical.xml', 'base_ordered.xml', 'base_std_math.xml', +'base_limits.xml', +'base_to_string.xml', 'base_example.xml' ]; var list_current0 = [ diff -Nru cppad-2015.00.00.9/doc/base_ordered.xml cppad-2016.00.00.1/doc/base_ordered.xml --- cppad-2015.00.00.9/doc/base_ordered.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/base_ordered.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ Base Type Requirements for Ordered Comparisons - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +base_to_string + +

+
Extending to_string To Another Floating Point Type
+
+Base Requirement +
+If the function to_string + is used by an +AD type above Base +, +A specialization for the template structure +CppAD::to_string_struct must be defined. + +
+
+CPPAD_TO_STRING +
+For most +Base + types, +the following can be used to define the specialization: + +
+     namespace CppAD {
+          CPPAD_TO_STRING(
Base)
+     }
+
+Note that the CPPAD_TO_STRING macro assumes that the +base_limits + and base_std_math + have already been defined +for this type. +This macro is defined as follows: +
 
+# define CPPAD_TO_STRING(Base) \
+template <> struct to_string_struct<Base>\
+{    std::string operator()(const Base& value) \
+     {    std::stringstream os;\
+          Base epsilon    = CppAD::numeric_limits<Base>::epsilon();\
+          Base log10      = CppAD::log( epsilon ) / CppAD::log(Base(10.));\
+          size_t n_digits = 1 - Integer( log10 );\
+          os << std::setprecision(n_digits);\
+          os << value;\
+          return os.str();\
+     }\
+};
+
+ +
Input File: cppad/local/base_to_string.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_base_to_string_xml.js cppad-2016.00.00.1/doc/_base_to_string_xml.js --- cppad-2015.00.00.9/doc/_base_to_string_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_base_to_string_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,91 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'base_require.xml', +'base_to_string.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down1 = [ +'base_member.xml', +'base_cond_exp.xml', +'base_identical.xml', +'base_ordered.xml', +'base_std_math.xml', +'base_limits.xml', +'base_to_string.xml', +'base_example.xml' +]; +var list_current0 = [ +'base_to_string.xml#Base Requirement', +'base_to_string.xml#CPPAD_TO_STRING' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/bender_quad.cpp.xml cppad-2016.00.00.1/doc/bender_quad.cpp.xml --- cppad-2015.00.00.9/doc/bender_quad.cpp.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/bender_quad.cpp.xml 2016-02-09 08:32:08.000000000 +0000 @@ -6,7 +6,7 @@ BenderQuad: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+
The Binary Math Functions
+
+Contents +
+ +
atan2AD Two Argument Inverse Tangent Function
powThe AD Power Function
azmulAbsolute Zero Multiplication
+
Input File: cppad/local/standard_math.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_binary_math_xml.js cppad-2016.00.00.1/doc/_binary_math_xml.js --- cppad-2015.00.00.9/doc/_binary_math_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_binary_math_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,94 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'binary_math.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down1 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down0 = [ +'atan2.xml', +'pow.xml', +'azmul.xml' +]; +var list_current0 = [ +'binary_math.xml#Contents' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/bool_fun.cpp.xml cppad-2016.00.00.1/doc/bool_fun.cpp.xml --- cppad-2015.00.00.9/doc/bool_fun.cpp.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/bool_fun.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ AD Boolean Functions: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +bool_sparsity.cpp + +

+ + + +
Using vectorBool Sparsity To Conserve Memory: Example and Test
+
+Purpose +
+This example show how to conserve memory when computing sparsity patterns. + + +
 
+# include <cppad/cppad.hpp>
+namespace {
+	using CppAD::vector;
+	using std::cout;
+	using CppAD::vectorBool;
+	using CppAD::AD;
+	using CppAD::ADFun;
+
+	// function f(x) that we are computing sparsity patterns for
+	template <class Float>
+	vector<Float> fun(const vector<Float>& x)
+	{	size_t n  = x.size();
+		vector<Float> ret(n + 1);
+		for(size_t j = 0; j < n; j++)
+		{	size_t k = (j + 1) % n;
+			ret[j] = x[j] * x[j] * x[k];
+		}
+		ret[n] = 0.0;
+		return ret;
+	}
+	// check sparsity pattern for f(x)
+	bool check_jac(const vectorBool& pattern, size_t n)
+	{	bool ok = true;
+		for(size_t i = 0; i < n; i++)
+		{	size_t k = (i + 1) % n;
+			for(size_t j = 0; j < n; j++)
+			{	bool non_zero = (i == j) || (j == k);
+				ok &= pattern[ i * n + j] == non_zero;
+			}
+		}
+		for(size_t j = 0; j < n; j++)
+			ok &= pattern[ n * n + j] == false;
+		return ok;
+	}
+	// check sparsity pattern for the Hessian of sum_i f_i(x)
+	bool check_hes(const vectorBool& pattern, size_t n)
+	{	bool ok = true;
+		for(size_t i = 0; i < n; i++)
+		{	size_t k1 = (i + 1) % n;
+			size_t k2 = (n + i - 1) % n;
+			for(size_t j = 0; j < n; j++)
+			{	bool non_zero = (i == j) || (j == k1) || (j == k2);
+				ok &= pattern[ i * n + j] == non_zero;
+			}
+		}
+		return ok;
+	}
+	// compute sparsity for Jacobian of f(x) using forward mode
+	bool for_sparse_jac(ADFun<double>& f)
+	{	bool ok = true;
+		size_t n = f.Domain();
+		size_t m = f.Range();
+		//
+		// number of columns of the sparsity patter to compute at a time
+		size_t n_col = vectorBool::bit_per_unit();
+		vectorBool pattern(m * n), s(m * n_col), r(n * n_col);
+		//
+		size_t n_loop = (n - 1) / n_col + 1;
+		for(size_t i_loop = 0; i_loop < n_loop; i_loop++)
+		{	size_t j_col = i_loop * n_col;
+
+			for(size_t i = 0; i < n; i++)
+			{	for(size_t j = 0; j < n_col; j++)
+					r[i * n_col + j] = (i == j_col + j);
+			}
+			s = f.ForSparseJac(n_col, r);
+			for(size_t i = 0; i < m; i++)
+			{	for(size_t j = 0; j < n_col; j++)
+					if( j_col + j < n )
+						pattern[ i * n + j_col + j ] = s[ i * n_col + j];
+			}
+		}
+		ok &= check_jac(pattern, n);
+		//
+		return ok;
+	}
+	// compute sparsity for Jacobian of f(x) using reverse mode
+	bool rev_sparse_jac(ADFun<double>& f)
+	{	bool ok = true;
+		size_t n = f.Domain();
+		size_t m = f.Range();
+		//
+		// number of rows of the sparsity patter to compute at a time
+		size_t n_row = vectorBool::bit_per_unit();
+		vectorBool pattern(m * n), s(n_row * n), r(n_row * m);
+		//
+		size_t n_loop = (m - 1) / n_row + 1;
+		for(size_t i_loop = 0; i_loop < n_loop; i_loop++)
+		{	size_t i_row = i_loop * n_row;
+
+			for(size_t i = 0; i < n_row; i++)
+			{	for(size_t j = 0; j < m; j++)
+					r[i * m + j] = (i_row + i == j);
+			}
+			s = f.RevSparseJac(n_row, r);
+			for(size_t i = 0; i < n_row; i++)
+			{	for(size_t j = 0; j < n; j++)
+					if( i_row + i < m )
+						pattern[ (i_row + i) * n + j ] = s[ i * n + j];
+			}
+		}
+		ok &= check_jac(pattern, n);
+		//
+		return ok;
+	}
+	// compute sparsity for Hessian of sum_i f_i (x)
+	bool rev_sparse_hes(ADFun<double>& f)
+	{	bool ok = true;
+		size_t n = f.Domain();
+		size_t m = f.Range();
+		//
+		// number of columns of the sparsity patter to compute at a time
+		size_t n_col = vectorBool::bit_per_unit();
+		vectorBool pattern(n * n), r(n * n_col), h(n * n_col);
+
+		// consider case where Hessian for sum of f_i(x) w.r.t i
+		vectorBool s(m);
+		for(size_t i = 0; i < m; i++)
+			s[i] = true;
+		//
+		size_t n_loop = (n - 1) / n_col + 1;
+		for(size_t i_loop = 0; i_loop < n_loop; i_loop++)
+		{	size_t j_col = i_loop * n_col;
+
+			for(size_t i = 0; i < n; i++)
+			{	for(size_t j = 0; j < n_col; j++)
+					r[i * n_col + j] = (i == j_col + j);
+			}
+			//
+			f.ForSparseJac(n_col, r);
+			bool transpose = true;
+			h = f.RevSparseHes(n_col, s, transpose);
+			//
+			for(size_t i = 0; i < n; i++)
+			{	for(size_t j = 0; j < n_col; j++)
+					if( j_col + j < n )
+						pattern[ i * n + j_col + j ] = h[ i * n_col + j];
+			}
+		}
+		ok &= check_hes(pattern, n);
+		//
+		return ok;
+	}
+}
+// driver for all of the cases above
+bool bool_sparsity(void)
+{	bool ok = true;
+	//
+	// record the funcion
+	size_t n = 100;
+	size_t m = n + 1;
+	vector< AD<double> > x(n), y(m);
+	for(size_t j = 0; j < n; j++)
+		x[j] = AD<double>(j+1);
+	CppAD::Independent(x);
+	y = fun(x);
+	ADFun<double> f(x, y);
+	//
+	// run the three example / tests
+	ok &= for_sparse_jac(f);
+	ok &= rev_sparse_jac(f);
+	ok &= rev_sparse_hes(f);
+	return ok;
+}
+
+ +
+ + +
Input File: example/bool_sparsity.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_bool_sparsity.cpp_xml.js cppad-2016.00.00.1/doc/_bool_sparsity.cpp_xml.js --- cppad-2015.00.00.9/doc/_bool_sparsity.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_bool_sparsity.cpp_xml.js 2016-02-09 08:32:06.000000000 +0000 @@ -0,0 +1,83 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'adfun.xml', +'funeval.xml', +'sparse.xml', +'bool_sparsity.cpp.xml' +]; +var list_down3 = [ +'independent.xml', +'funconstruct.xml', +'dependent.xml', +'abort_recording.xml', +'seq_property.xml', +'funeval.xml', +'drivers.xml', +'funcheck.xml', +'optimize.xml', +'check_for_nan.xml' +]; +var list_down2 = [ +'forward.xml', +'reverse.xml', +'sparse.xml' +]; +var list_down1 = [ +'forsparsejac.xml', +'revsparsejac.xml', +'dependency.cpp.xml', +'revsparsehes.xml', +'bool_sparsity.cpp.xml' +]; +var list_current0 = [ +'bool_sparsity.cpp.xml#Purpose' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/boolvalued.xml cppad-2016.00.00.1/doc/boolvalued.xml --- cppad-2015.00.00.9/doc/boolvalued.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/boolvalued.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ Bool Valued Operations and Functions with AD Arguments - + - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -Bugs - -

- - - -
Know Bugs and Problems Using CppAD
-
-gcc 3.4.4 -O2 - - -
-There appears to be a problem with gcc version 3.4.4 -under Cygwin using the compiler option -O2. - -
-
-Example -
-If you are running gcc 3.4.4, try using the -configure - option -
 
-	CPP_ERROR_WARN="-O2 -Wall -ansi -pedantic-errors -std=c++98"
-
- -If the -O2 compiler option is a problem for your compiler, -you will get warnings that do not make sense when executing the -make command in the Example sub-directory. -In addition, the example/Example program will generate a -segmentation fault. - -
-
-Adolc -
-If you are running gcc 3.4.4, try using the -configure - options - -
-     ./configure 
-          ADOLC_DIR=
adolc_dir 
-          CPP_ERROR_WARN="-Wall" 
-          BOOST_DIR=
boost_dir
-
-the following warning occurs during the make command: -
 
-/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82: 
-warning: '__cur' might be used uninitialized in this function
-
- -This appears to be the same problem discussed in -
-     
-http://www.cygwin.com/ml/cygwin-apps/2005-06/msg00159.html - -
-
and its follow up messages. - - - -
Input File: omh/bugs.omh - - - diff -Nru cppad-2015.00.00.9/doc/_bugs_xml.js cppad-2016.00.00.1/doc/_bugs_xml.js --- cppad-2015.00.00.9/doc/_bugs_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_bugs_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'bugs.xml' -]; -var list_down2 = [ -'install.xml', -'introduction.xml', -'ad.xml', -'adfun.xml', -'preprocessor.xml', -'multi_thread.xml', -'library.xml', -'ipopt_solve.xml', -'example.xml', -'speed.xml', -'appendix.xml' -]; -var list_down1 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_current0 = [ -'bugs.xml#gcc 3.4.4 -O2', -'bugs.xml#gcc 3.4.4 -O2.Example', -'bugs.xml#gcc 3.4.4 -O2.Adolc' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/capacity_order.cpp.xml cppad-2016.00.00.1/doc/capacity_order.cpp.xml --- cppad-2015.00.00.9/doc/capacity_order.cpp.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/capacity_order.cpp.xml 2016-02-09 08:32:06.000000000 +0000 @@ -6,7 +6,7 @@ Controlling Taylor Coefficient Memory Allocation: Example and Test - + - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -change_const.cpp - -

- - - -
Computing a Jacobian With Constants that Change
-
-Purpose -
-In this example we use two levels of taping so that a derivative -can have constant parameters that can be changed. To be specific, -we consider the function - -f -: -R - -2 - - -R - -2 - - - - - - -f -( -x -) -= -p -( -sin -( -x -0 - -) - -sin -( -x -1 - -) - -) - - -were - -p - -R - - - - is a parameter. -The Jacobian of this function is - - -g -( -x -, -p -) -= -p -( -cos -( -x -0 - -) - -0 - -0 - -cos -( -x -1 - -) - -) - - -In this example we use two levels of AD to avoid computing -the partial of - -f -( -x -) - - - with respect to - -p - - -, -but still allow for the evaluation of - -g -( -x -, -p -) - - - -at different values of - -p - - -. - - -
Input File: example/change_const.cpp - - - diff -Nru cppad-2015.00.00.9/doc/_change_const.cpp_xml.js cppad-2016.00.00.1/doc/_change_const.cpp_xml.js --- cppad-2015.00.00.9/doc/_change_const.cpp_xml.js 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/_change_const.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'example.xml', -'general.xml', -'mul_level.xml', -'change_const.cpp.xml' -]; -var list_down3 = [ -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml' -]; -var list_down2 = [ -'ad_fun.cpp.xml', -'ad_in_c.cpp.xml', -'conj_grad.cpp.xml', -'cppad_eigen.hpp.xml', -'hes_minor_det.cpp.xml', -'hes_lu_det.cpp.xml', -'interface2c.cpp.xml', -'jac_minor_det.cpp.xml', -'jac_lu_det.cpp.xml', -'mul_level.xml', -'ode_stiff.cpp.xml', -'mul_level_ode.cpp.xml', -'mul_level_adolc_ode.cpp.xml', -'ode_taylor.cpp.xml', -'stack_machine.cpp.xml' -]; -var list_down1 = [ -'mul_level.cpp.xml', -'change_const.cpp.xml' -]; -var list_current0 = [ -'change_const.cpp.xml#Purpose' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/change_param.cpp.xml cppad-2016.00.00.1/doc/change_param.cpp.xml --- cppad-2015.00.00.9/doc/change_param.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/change_param.cpp.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,221 @@ + + + +Computing a Jacobian With Constants that Change + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +change_param.cpp + +

+ + + +
Computing a Jacobian With Constants that Change
+
+Purpose +
+In this example we use two levels of taping so that a derivative +can have constant parameters that can be changed. To be specific, +we consider the function + +f +: +R + +2 + + +R + +2 + + + + + + +f +( +x +) += +p +( +sin +( +x +0 + +) + +sin +( +x +1 + +) + +) + + +were + +p + +R + + + + is a parameter. +The Jacobian of this function is + + +g +( +x +, +p +) += +p +( +cos +( +x +0 + +) + +0 + +0 + +cos +( +x +1 + +) + +) + + +In this example we use two levels of AD to avoid computing +the partial of + +f +( +x +) + + + with respect to + +p + + +, +but still allow for the evaluation of + +g +( +x +, +p +) + + + +at different values of + +p + + +. + + +
Input File: example/change_param.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_change_param.cpp_xml.js cppad-2016.00.00.1/doc/_change_param.cpp_xml.js --- cppad-2015.00.00.9/doc/_change_param.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_change_param.cpp_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,86 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'example.xml', +'general.xml', +'mul_level.xml', +'change_param.cpp.xml' +]; +var list_down3 = [ +'general.xml', +'exampleutility.xml', +'listallexamples.xml', +'testvector.xml' +]; +var list_down2 = [ +'ad_fun.cpp.xml', +'ad_in_c.cpp.xml', +'conj_grad.cpp.xml', +'cppad_eigen.hpp.xml', +'hes_minor_det.cpp.xml', +'hes_lu_det.cpp.xml', +'interface2c.cpp.xml', +'jac_minor_det.cpp.xml', +'jac_lu_det.cpp.xml', +'mul_level.xml', +'ode_stiff.cpp.xml', +'mul_level_ode.cpp.xml', +'mul_level_adolc_ode.cpp.xml', +'ode_taylor.cpp.xml', +'stack_machine.cpp.xml' +]; +var list_down1 = [ +'mul_level.cpp.xml', +'change_param.cpp.xml' +]; +var list_current0 = [ +'change_param.cpp.xml#Purpose' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/check_for_nan.cpp.xml cppad-2016.00.00.1/doc/check_for_nan.cpp.xml --- cppad-2015.00.00.9/doc/check_for_nan.cpp.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/check_for_nan.cpp.xml 2016-02-09 08:32:06.000000000 +0000 @@ -6,7 +6,7 @@ ADFun Checking For Nan: Example and Test - + - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -colpack.cppHeadings

- - - -
Using ColPack: Example and Test
-
 
-
-# include <cppad/cppad.hpp>
-bool colpack(void)
-{	bool ok = true;
-	using CppAD::AD;
-	using CppAD::NearEqual;
-	typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
-	typedef CPPAD_TESTVECTOR(double)     d_vector;
-	typedef CppAD::vector<size_t>        i_vector;
-	size_t i, j, k, ell;
-	double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-	// domain space vector
-	size_t n = 4;
-	a_vector  a_x(n);
-	for(j = 0; j < n; j++)
-		a_x[j] = AD<double> (0);
-
-	// declare independent variables and starting recording
-	CppAD::Independent(a_x);
-
-	size_t m = 3;
-	a_vector  a_y(m);
-	a_y[0] = a_x[0] + a_x[1];
-	a_y[1] = a_x[2] + a_x[3];
-	a_y[2] = a_x[0] + a_x[1] + a_x[2] + a_x[3] * a_x[3] / 2.;
-
-	// create f: x -> y and stop tape recording
-	CppAD::ADFun<double> f(a_x, a_y);
-
-	// new value for the independent variable vector
-	d_vector x(n);
-	for(j = 0; j < n; j++)
-		x[j] = double(j);
-
-	/*
-	      [ 1 1 0 0  ]
-	jac = [ 0 0 1 1  ]
-	      [ 1 1 1 x_3]
-	*/
-	d_vector check(m * n);
-	check[0] = 1.; check[1] = 1.; check[2]  = 0.; check[3]  = 0.;
-	check[4] = 0.; check[5] = 0.; check[6]  = 1.; check[7]  = 1.;
-	check[8] = 1.; check[9] = 1.; check[10] = 1.; check[11] = x[3];
-
-	// Normally one would use f.ForSparseJac or f.RevSparseJac to compute 
-	// sparsity pattern, but for this example we extract it from check.
-	std::vector< std::set<size_t> >  p(m);
-
-	// using row and column indices to compute non-zero in rows 1 and 2
-	i_vector row, col;
-	for(i = 0; i < m; i++)
-	{	for(j = 0; j < n; j++)
-		{	ell = i * n + j;
-			if( check[ell] != 0. )
-			{	row.push_back(i);
-				col.push_back(j);
-				p[i].insert(j);
-			}
-		}
-	} 
-	size_t K = row.size();
-	d_vector jac(K);
-
-	// empty work structure
-	CppAD::sparse_jacobian_work work;
-	ok &= work.color_method == "cppad";
-
-	// choose to use ColPack
-	work.color_method = "colpack";
-
-	// forward mode
-	size_t n_sweep = f.SparseJacobianForward(x, p, row, col, jac, work);
-	for(k = 0; k < K; k++)
-	{	ell = row[k] * n + col[k];
-		ok &= NearEqual(check[ell], jac[k], eps, eps);
-	}
-	ok &= n_sweep == 4;
-
-	// reverse mode
-	work.clear();
-	work.color_method = "colpack";
-	n_sweep = f.SparseJacobianReverse(x, p, row, col, jac, work);
-	for(k = 0; k < K; k++)
-	{	ell = row[k] * n + col[k];
-		ok &= NearEqual(check[ell], jac[k], eps, eps);
-	}
-	ok &= n_sweep == 2;
-
-	return ok;
-}
-
- -
- - -
Input File: example/colpack.cpp - - - diff -Nru cppad-2015.00.00.9/doc/_colpack.cpp_xml.js cppad-2016.00.00.1/doc/_colpack.cpp_xml.js --- cppad-2015.00.00.9/doc/_colpack.cpp_xml.js 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/_colpack.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'install.xml', -'cmake.xml', -'colpack_prefix.xml', -'colpack.cpp.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml', -'installunix.xml' -]; -var list_down2 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_down1 = [ -'colpack.cpp.xml', -'get_colpack.sh.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/colpack_hes.cpp.xml cppad-2016.00.00.1/doc/colpack_hes.cpp.xml --- cppad-2015.00.00.9/doc/colpack_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/colpack_hes.cpp.xml 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,214 @@ + + + +Using ColPack: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +colpack_hes.cppHeadings

+ + + +
Using ColPack: Example and Test
+
 
+
+# include <cppad/cppad.hpp>
+bool colpack_hes(void)
+{	bool ok = true;
+	using CppAD::AD;
+	using CppAD::NearEqual;
+	typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
+	typedef CPPAD_TESTVECTOR(double)     d_vector;
+	typedef CppAD::vector<size_t>        i_vector;
+	size_t i, j, k, ell;
+	double eps = 10. * CppAD::numeric_limits<double>::epsilon();
+
+	// domain space vector
+	size_t n = 5;
+	a_vector  a_x(n);
+	for(j = 0; j < n; j++)
+		a_x[j] = AD<double> (0);
+
+	// declare independent variables and starting recording
+	CppAD::Independent(a_x);
+
+	// colpack example case where hessian is a spear head
+	// i.e, H(i, j) non zero implies i = 0, j = 0, or i = j
+	AD<double> sum = 0.0;
+	// partial_0 partial_j = x[j]
+	// partial_j partial_j = x[0]
+	for(j = 1; j < n; j++)
+		sum += a_x[0] * a_x[j] * a_x[j] / 2.0;
+	//
+	// partial_i partial_i = 2 * x[i]
+	for(i = 0; i < n; i++)
+		sum += a_x[i] * a_x[i] * a_x[i] / 3.0;
+
+	// declare dependent variables
+	size_t m = 1;
+	a_vector  a_y(m);
+	a_y[0] = sum;
+
+	// create f: x -> y and stop tape recording
+	CppAD::ADFun<double> f(a_x, a_y);
+
+	// new value for the independent variable vector
+	d_vector x(n);
+	for(j = 0; j < n; j++)
+		x[j] = double(j + 1);
+
+	/*
+	      [ 2  2  3  4  5 ]
+	hes = [ 2  5  0  0  0 ]
+	      [ 3  0  7  0  0 ]
+	      [ 4  0  0  9  0 ]
+	      [ 5  0  0  0 11 ]
+	*/
+	d_vector check(n * n);
+	for(i = 0; i < n; i++)
+	{	for(j = 0; j < n; j++)
+		{	size_t index = i * n + j;
+			check[index] = 0.0;
+			if( i == 0 && 1 <= j )
+				check[index] += x[j];
+			if( 1 <= i && j == 0 )
+				check[index] += x[i];
+			if( i == j )
+			{	check[index] += 2.0 * x[i];
+				if( i != 0 )
+					check[index] += x[0];
+			}
+		}
+	}
+	// Normally one would use f.RevSparseHes to compute
+	// sparsity pattern, but for this example we extract it from check.
+	std::vector< std::set<size_t> >  p(n);
+	i_vector row, col;
+	for(i = 0; i < n; i++)
+	{	for(j = 0; j < n; j++)
+		{	ell = i * n + j;
+			if( check[ell] != 0. )
+			{	// insert this non-zero entry in sparsity pattern
+				p[i].insert(j);
+
+				// the Hessian is symmetric, so only upper lower triangle
+				if( j <= i )
+				{	row.push_back(i);
+					col.push_back(j);
+				}
+			}
+		}
+	}
+	size_t K = row.size();
+	d_vector hes(K);
+
+	// contrast and check results using both cppad and colpack
+	CppAD::sparse_hessian_work work;
+	for(size_t i_method = 0; i_method < 3; i_method++)
+	{	// empty work structure
+		ok &= work.color_method == "cppad.symmetric";
+		if( i_method == 2 )
+			work.color_method = "colpack.star";
+
+		// compute Hessian
+		d_vector w(m);
+		w[0] = 1.0;
+		size_t n_sweep = f.SparseHessian(x, w, p, row, col, hes, work);
+
+		// check result
+		for(k = 0; k < K; k++)
+		{	ell = row[k] * n + col[k];
+			ok &= NearEqual(check[ell], hes[k], eps, eps);
+		}
+		if( work.color_method != "cppad.general" )
+			ok &= n_sweep == 2;
+		else
+			ok &= n_sweep == 5;
+		//
+		// check that clear resets color_method to cppad.symmetric
+		work.clear();
+		ok &= work.color_method == "cppad.symmetric";
+	}
+
+	return ok;
+}
+
+ +
+ + +
Input File: example/colpack_hes.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_colpack_hes.cpp_xml.js cppad-2016.00.00.1/doc/_colpack_hes.cpp_xml.js --- cppad-2015.00.00.9/doc/_colpack_hes.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_colpack_hes.cpp_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,77 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'install.xml', +'cmake.xml', +'colpack_prefix.xml', +'colpack_hes.cpp.xml' +]; +var list_down3 = [ +'download.xml', +'cmake.xml', +'cmake_check.xml', +'pkgconfig.xml', +'auto_tools.xml' +]; +var list_down2 = [ +'adolc_prefix.xml', +'colpack_prefix.xml', +'eigen_prefix.xml', +'fadbad_prefix.xml', +'ipopt_prefix.xml', +'sacado_prefix.xml', +'cppad_testvector.xml' +]; +var list_down1 = [ +'colpack_jac.cpp.xml', +'colpack_hes.cpp.xml', +'get_colpack.sh.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/colpack_jac.cpp.xml cppad-2016.00.00.1/doc/colpack_jac.cpp.xml --- cppad-2015.00.00.9/doc/colpack_jac.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/colpack_jac.cpp.xml 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,184 @@ + + + +Using ColPack: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +colpack_jac.cppHeadings

+ + + +
Using ColPack: Example and Test
+
 
+
+# include <cppad/cppad.hpp>
+bool colpack_jac(void)
+{	bool ok = true;
+	using CppAD::AD;
+	using CppAD::NearEqual;
+	typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
+	typedef CPPAD_TESTVECTOR(double)     d_vector;
+	typedef CppAD::vector<size_t>        i_vector;
+	size_t i, j, k, ell;
+	double eps = 10. * CppAD::numeric_limits<double>::epsilon();
+
+	// domain space vector
+	size_t n = 4;
+	a_vector  a_x(n);
+	for(j = 0; j < n; j++)
+		a_x[j] = AD<double> (0);
+
+	// declare independent variables and starting recording
+	CppAD::Independent(a_x);
+
+	size_t m = 3;
+	a_vector  a_y(m);
+	a_y[0] = a_x[0] + a_x[1];
+	a_y[1] = a_x[2] + a_x[3];
+	a_y[2] = a_x[0] + a_x[1] + a_x[2] + a_x[3] * a_x[3] / 2.;
+
+	// create f: x -> y and stop tape recording
+	CppAD::ADFun<double> f(a_x, a_y);
+
+	// new value for the independent variable vector
+	d_vector x(n);
+	for(j = 0; j < n; j++)
+		x[j] = double(j);
+
+	/*
+	      [ 1 1 0 0  ]
+	jac = [ 0 0 1 1  ]
+	      [ 1 1 1 x_3]
+	*/
+	d_vector check(m * n);
+	check[0] = 1.; check[1] = 1.; check[2]  = 0.; check[3]  = 0.;
+	check[4] = 0.; check[5] = 0.; check[6]  = 1.; check[7]  = 1.;
+	check[8] = 1.; check[9] = 1.; check[10] = 1.; check[11] = x[3];
+
+	// Normally one would use f.ForSparseJac or f.RevSparseJac to compute
+	// sparsity pattern, but for this example we extract it from check.
+	std::vector< std::set<size_t> >  p(m);
+
+	// using row and column indices to compute non-zero in rows 1 and 2
+	i_vector row, col;
+	for(i = 0; i < m; i++)
+	{	for(j = 0; j < n; j++)
+		{	ell = i * n + j;
+			if( check[ell] != 0. )
+			{	row.push_back(i);
+				col.push_back(j);
+				p[i].insert(j);
+			}
+		}
+	}
+	size_t K = row.size();
+	d_vector jac(K);
+
+	// empty work structure
+	CppAD::sparse_jacobian_work work;
+	ok &= work.color_method == "cppad";
+
+	// choose to use ColPack
+	work.color_method = "colpack";
+
+	// forward mode
+	size_t n_sweep = f.SparseJacobianForward(x, p, row, col, jac, work);
+	for(k = 0; k < K; k++)
+	{	ell = row[k] * n + col[k];
+		ok &= NearEqual(check[ell], jac[k], eps, eps);
+	}
+	ok &= n_sweep == 4;
+
+	// reverse mode
+	work.clear();
+	work.color_method = "colpack";
+	n_sweep = f.SparseJacobianReverse(x, p, row, col, jac, work);
+	for(k = 0; k < K; k++)
+	{	ell = row[k] * n + col[k];
+		ok &= NearEqual(check[ell], jac[k], eps, eps);
+	}
+	ok &= n_sweep == 2;
+
+	return ok;
+}
+
+ +
+ + +
Input File: example/colpack_jac.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_colpack_jac.cpp_xml.js cppad-2016.00.00.1/doc/_colpack_jac.cpp_xml.js --- cppad-2015.00.00.9/doc/_colpack_jac.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_colpack_jac.cpp_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,77 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'install.xml', +'cmake.xml', +'colpack_prefix.xml', +'colpack_jac.cpp.xml' +]; +var list_down3 = [ +'download.xml', +'cmake.xml', +'cmake_check.xml', +'pkgconfig.xml', +'auto_tools.xml' +]; +var list_down2 = [ +'adolc_prefix.xml', +'colpack_prefix.xml', +'eigen_prefix.xml', +'fadbad_prefix.xml', +'ipopt_prefix.xml', +'sacado_prefix.xml', +'cppad_testvector.xml' +]; +var list_down1 = [ +'colpack_jac.cpp.xml', +'colpack_hes.cpp.xml', +'get_colpack.sh.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/colpack_prefix.xml cppad-2016.00.00.1/doc/colpack_prefix.xml --- cppad-2015.00.00.9/doc/colpack_prefix.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/colpack_prefix.xml 2016-02-09 08:32:04.000000000 +0000 @@ -6,7 +6,7 @@ Including the ColPack Sparsity Calculations - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
Comparison Changes Between Taping and Zero Order Forward
+
+Syntax + +
+ +f.compare_change_count(count)
+
+ +number = f.compare_change_number()
+
+ +op_index = f.compare_change_op_index()
+
+
+See Also +FunCheck + + + +
+
+Purpose +
+We use + +F +: +B +n + + +B +m + + + + to denote the +AD function + corresponding to +f +; i.e, +given + +x + +B +n + + + +, + +F +( +x +) + + + is defined by + +
+     
F(x) = f.Forward(0, x)
+
+see forward_zero +. +If + +x + + + is such that +all the algorithm comparison + operations +have the same result as when the algorithm was taped, +The function + +F +( +x +) + + + and the algorithm will have the same values. +(This is a sufficient, but not necessary condition). + + + + + +
+
+f +
+In the compare_change_number and compare_change_op_index +syntax, the object +f + has prototype + +
+     const ADFun<
Basef
+
+In the compare_change_count +syntax, the object +f + has prototype + +
+     ADFun<
Basef
+
+
+count +
+The argument +count + has prototype + +
+     size_t 
count
+
+It specifies which comparison change should correspond to the +information stored in +f + during subsequent calls to +forward_zero +; i.e., + +
+     
f.Forward(0, x)
+
+For example, if +count == 1 +, +the operator index corresponding to the first comparison change +will be stored. +This is the default value used if +count + is not specified. + +
+
+Speed +
+The special case where +count == 0 +, should be faster because +the comparisons are not checked during + +
+     
f.Forward(0, x)
+
+
+number +
+The return value +number + has prototype + +
+     size_t 
number
+
+If +count + is non-zero, + +number + is the number of + +AD<Base> + comparison + operations, +corresponding to the previous call to + +
+     
f.Forward(0, x)
+
+that have a different result for this value of +x + +than the value used when +f + was created by taping an algorithm. +If +count + is zero, +or if no calls to +f.Forward(0, x) + follow the previous +setting of +count +, + +number + is zero. + +
+
+Discussion +
+If +count + and +number + are non-zero, +you may want to re-tape the algorithm with the +independent variables + +equal to the values in +x +, +so the AD operation sequence properly represents the algorithm +for this value of independent variables. +On the other hand, re-taping the AD operation sequence usually takes +significantly more time than evaluation using forward_zero +. +If the functions values have not changed (see FunCheck +) +it may not be worth re-taping a new AD operation sequence. + +
+
+op_index +
+The return value +op_index + has prototype + +
+     size_t 
op_index
+
+If +count + is non-zero, + +op_index + is the operator index corresponding the + +count +-th comparison change during the previous call to + +
+     
f.Forward(0, x)
+
+If +count + is greater than the corresponding + +number +, there is no such comparison change and +op_index + +will also be zero. +If +count + is zero, +if the function +f + has been optimized +, +or if no calls to +f.Forward(0, x) + follow the previous +setting of +count +, + +op_index + is zero. + +
+
+Purpose +
+The operator index can be used to generate an error during the taping +process so that the corresponding algorithm can be inspected. +In some cases, it is possible to re-design this part of the +algorithm to avoid the particular comparison operation. +For example, using an conditional expression + +may be appropriate in some cases. +See abort_op_index + in the syntax + +
+     Independent(
xabort_op_index)
+
+
+Example + +
+compare_change.cpp + +contains an example and test of this operation. +It returns true if they succeed and false otherwise. + + +
Input File: omh/forward/compare_change.omh + + + diff -Nru cppad-2015.00.00.9/doc/comparechange.xml cppad-2016.00.00.1/doc/comparechange.xml --- cppad-2015.00.00.9/doc/comparechange.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/comparechange.xml 2016-02-09 08:32:08.000000000 +0000 @@ -6,7 +6,7 @@ Comparison Changes During Zero Order Forward Mode - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Hyperbolic Cosine Function: cosh
+
+Syntax + +
+ +y = cosh(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +cosh + +( +1 +) + + +( +x +) + += + +sinh +( +x +) + + + +
+Example + +
+The file +cosh.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_cosh_xml.js cppad-2016.00.00.1/doc/_cosh_xml.js --- cppad-2015.00.00.9/doc/_cosh_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_cosh_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'cosh.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'cosh.cpp.xml' +]; +var list_current0 = [ +'cosh.xml#Syntax', +'cosh.xml#x, y', +'cosh.xml#Atomic', +'cosh.xml#Derivative', +'cosh.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/cos.xml cppad-2016.00.00.1/doc/cos.xml --- cppad-2015.00.00.9/doc/cos.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/cos.xml 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,183 @@ + + + +The Cosine Function: cos + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Cosine Function: cos
+
+Syntax + +
+ +y = cos(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +cos + +( +1 +) + + +( +x +) + += + +- +sin +( +x +) + + + +
+Example + +
+The file +cos.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_cos_xml.js cppad-2016.00.00.1/doc/_cos_xml.js --- cppad-2015.00.00.9/doc/_cos_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_cos_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'cos.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'cos.cpp.xml' +]; +var list_current0 = [ +'cos.xml#Syntax', +'cos.xml#x, y', +'cos.xml#Atomic', +'cos.xml#Derivative', +'cos.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/cppad_assert.xml cppad-2016.00.00.1/doc/cppad_assert.xml --- cppad-2015.00.00.9/doc/cppad_assert.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/cppad_assert.xml 2016-02-09 08:32:06.000000000 +0000 @@ -6,7 +6,7 @@ CppAD Assertions During Execution - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +dependency.cpp + +

+ + + +
Computing Dependency: Example and Test
+
+Discussion +
+The partial of an dependent variable with respect to an independent variable +might always be zero even though the dependent variable depends on the +value of the dependent variable. Consider the following case + + +f +( +x +) += +sign + +( +x +) += +{ ++ +1 + +if + + +x +> +0 + +0 + +if + + +x += +0 + +-1 + +if + + +x +< +0 + + + + +In this case the value of + +f +( +x +) + + + depends on the value of + +x + + + +but CppAD always returns zero for the derivative of the sign + function. + +
+
+Dependency Pattern +
+If the i-th dependent variables depends on the +value of the j-th independent variable, +the corresponding entry in the dependency pattern is non-zero (true). +Otherwise it is zero (false). +CppAD uses sparsity patterns + +to represent dependency matrices. +The +dependency + argument to +ForSparseJac + and +RevSparseJac + is a flag that signals +that the dependency pattern (instead of the sparsity pattern) is computed. + + +
 
+# include <cppad/cppad.hpp>
+namespace {
+	double heavyside(const double& x)
+	{	if( x <= 0.0 )
+			return 0.0;
+		return 1.0;
+	}
+	CPPAD_DISCRETE_FUNCTION(double, heavyside)
+}
+
+bool dependency(void)
+{	bool ok = true;
+	using CppAD::AD;
+	using CppAD::NearEqual;
+
+	// VecAD object for use later
+	CppAD::VecAD<double> vec_ad(2);
+	vec_ad[0] = 0.0;
+	vec_ad[1] = 1.0;
+
+	// domain space vector
+	size_t n  = 5;
+	CPPAD_TESTVECTOR(AD<double>) ax(n);
+	for(size_t j = 0; j < n; j++)
+		ax[j] = AD<double>(j + 1);
+
+	// declare independent variables and start tape recording
+	CppAD::Independent(ax);
+
+	// some AD constants
+	AD<double> azero(0.0), aone(1.0);
+
+	// range space vector
+	size_t m  = n;
+	size_t m1 = n - 1;
+	CPPAD_TESTVECTOR(AD<double>) ay(m);
+	ay[m1-0] = sign( ax[0] );
+	ay[m1-1] = CondExpLe( ax[1], azero, azero, aone);
+	ay[m1-2] = CondExpLe( azero, ax[2], azero, aone);
+	ay[m1-3] = heavyside( ax[3] );
+	ay[m1-4] = vec_ad[ ax[4] - AD<double>(4.0) ];
+
+	// create f: x -> y and stop tape recording
+	CppAD::ADFun<double> f(ax, ay);
+
+	// -----------------------------------------------------------
+	// ForSparseJac and bool dependency
+	bool transpose  = false;
+	bool dependency;
+	// could replace CppAD::vectorBooll by CPPAD_TEST_VECTOR<bool>
+	CppAD::vectorBool eye_bool(n * n), depend_bool(m * n);
+	for(size_t i = 0; i < n; i++)
+	{	for(size_t j = 0; j < n; j++)
+			eye_bool[i * n + j] = (i == j);
+	}
+	dependency = true;
+	depend_bool = f.ForSparseJac(n, eye_bool, transpose, dependency);
+	for(size_t i = 0; i < m; i++)
+	{	for(size_t j = 0; j < n; j++)
+			ok &= depend_bool[i * n + j] == (i == (m1-j));
+	}
+	dependency = false;
+	depend_bool = f.ForSparseJac(n, eye_bool, transpose, dependency);
+	for(size_t i = 0; i < m; i++)
+	{	for(size_t j = 0; j < n; j++)
+			ok &= depend_bool[i * n + j] == false;
+	}
+
+	// -----------------------------------------------------------
+	// RevSparseJac and set dependency
+	CppAD::vector<    std::set<size_t> > eye_set(m), depend_set(m);
+	for(size_t i = 0; i < m; i++)
+	{	ok &= eye_set[i].empty();
+		eye_set[i].insert(i);
+	}
+	dependency = true;
+	depend_set = f.RevSparseJac(n, eye_set, transpose, dependency);
+	for(size_t i = 0; i < m; i++)
+	{	std::set<size_t> check;
+		check.insert(m1 - i);
+		ok &= depend_set[i] == check;
+	}
+	dependency = false;
+	depend_set = f.RevSparseJac(n, eye_set, transpose, dependency);
+	for(size_t i = 0; i < m; i++)
+		ok &= depend_set[i].empty();
+	return ok;
+}
+
+
+ +
+ + +
Input File: example/dependency.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_dependency.cpp_xml.js cppad-2016.00.00.1/doc/_dependency.cpp_xml.js --- cppad-2015.00.00.9/doc/_dependency.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_dependency.cpp_xml.js 2016-02-09 08:32:06.000000000 +0000 @@ -0,0 +1,84 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'adfun.xml', +'funeval.xml', +'sparse.xml', +'dependency.cpp.xml' +]; +var list_down3 = [ +'independent.xml', +'funconstruct.xml', +'dependent.xml', +'abort_recording.xml', +'seq_property.xml', +'funeval.xml', +'drivers.xml', +'funcheck.xml', +'optimize.xml', +'check_for_nan.xml' +]; +var list_down2 = [ +'forward.xml', +'reverse.xml', +'sparse.xml' +]; +var list_down1 = [ +'forsparsejac.xml', +'revsparsejac.xml', +'dependency.cpp.xml', +'revsparsehes.xml', +'bool_sparsity.cpp.xml' +]; +var list_current0 = [ +'dependency.cpp.xml#Discussion', +'dependency.cpp.xml#Dependency Pattern' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/dependent.xml cppad-2016.00.00.1/doc/dependent.xml --- cppad-2015.00.00.9/doc/dependent.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/dependent.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ Stop Recording and Store Operation Sequence - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +exp_forward + +

+
Exponential Function Forward Mode Theory
+
+Derivatives +
+If + +F +( +x +) + + + is + +exp + +( +x +) + + + or + +expm +1 + +( +x +) + + + +the corresponding derivative satisfies the equation + + +1 +* +F +( +1 +) + + +( +x +) +- +1 +* +F +( +x +) += +d +( +0 +) + + += +{ +0 + +if + + +F +( +x +) += +exp + +( +x +) + +1 + +if + + +F +( +x +) += +expm +1 + +( +x +) + + + + +where the equation above defines + +d +( +0 +) + + + + +. +In the +standard math function differential equation +, + + +A +( +x +) += +1 + + +, + + +B +( +x +) += +1 + + +, +and + +D +( +x +) += +d +( +0 +) + + + + +. +We use + +a + + +, + +b + + +, + +d + + +, +and + +z + + + to denote the +Taylor coefficients for + + +A +[ +X +( +t +) +] + + +, + + +B +[ +X +( +t +) +] + + +, + + +D +[ +X +( +t +) +] + + +, +and + +F +[ +X +( +t +) +] + + + respectively. + +
+
+Taylor Coefficients Recursion +
+For orders + +j += +0 +, +1 +, + + + +, + + + +z +( +0 +) + + + += + +F +( +x +( +0 +) + + +) + +e +( +0 +) + + + += + +d +( +0 +) + + ++ +z +( +0 +) + + + +e +( +j ++ +1 +) + + + += + +d +( +j ++ +1 +) + + ++ + +k += +0 + +j ++ +1 + + +a +( +j ++ +1 +- +k +) + + +* +z +( +k +) + + + + += + +z +( +j ++ +1 +) + + + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +( +k += +1 + +j ++ +1 + + +k +x +( +k +) + + +e +( +j ++ +1 +- +k +) + + +- + +k += +1 + +j + +k +z +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + += + +x +( +j ++ +1 +) + + +d +( +0 +) + + ++ +1 + +j ++ +1 + + + +k += +1 + +j ++ +1 + + +k +x +( +k +) + + +z +( +j ++ +1 +- +k +) + + + + + + +
Input File: omh/theory/exp_forward.omh + + + diff -Nru cppad-2015.00.00.9/doc/expforward.xml cppad-2016.00.00.1/doc/expforward.xml --- cppad-2015.00.00.9/doc/expforward.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/expforward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,446 +0,0 @@ - - - -Exponential Function Forward Taylor Polynomial Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ExpForwardHeadings

-
Exponential Function Forward Taylor Polynomial Theory
-If - -F -( -x -) -= -exp -( -x -) - - - - - -1 -* -F -( -1 -) - - -( -x -) -- -1 -* -F -( -x -) -= -0 - - -and in the -standard math function differential equation -, - - -A -( -x -) -= -1 - - -, - - -B -( -x -) -= -1 - - -, -and - -D -( -x -) -= -0 - - -. -We use - -a - - -, - -b - - -, - -d - - -, -and - -z - - - to denote the -Taylor coefficients for - - -A -[ -X -( -t -) -] - - -, - - -B -[ -X -( -t -) -] - - -, - - -D -[ -X -( -t -) -] - - -, -and - -F -[ -X -( -t -) -] - - - respectively. -It now follows from the general -Taylor coefficients recursion formula - -that for - -j -= -0 -, -1 -, - - - -, - - - -z -( -0 -) - - - -= - -exp -( -x -( -0 -) - - -) - -e -( -j -) - - - -= - -d -( -j -) - - -+ - -k -= -0 - -j - - -a -( -j -- -k -) - - -* -z -( -k -) - - - - -= - -z -( -j -) - - - -z -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -( -k -= -1 - -j -+ -1 - - -k -x -( -k -) - - -e -( -j -+ -1 -- -k -) - - -- - -k -= -1 - -j - -k -z -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - -= - -1 - -j -+ -1 - - - -k -= -1 - -j -+ -1 - - -k -x -( -k -) - - -z -( -j -+ -1 -- -k -) - - - - - - -
Input File: omh/theory/exp_forward.omh - - - diff -Nru cppad-2015.00.00.9/doc/_exp_forward_xml.js cppad-2016.00.00.1/doc/_exp_forward_xml.js --- cppad-2015.00.00.9/doc/_exp_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_exp_forward_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,89 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'forwardtheory.xml', +'exp_forward.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_forward.xml', +'log_forward.xml', +'sqrt_forward.xml', +'sin_cos_forward.xml', +'atan_forward.xml', +'asin_forward.xml', +'acos_forward.xml', +'tan_forward.xml', +'erf_forward.xml' +]; +var list_current0 = [ +'exp_forward.xml#Derivatives', +'exp_forward.xml#Taylor Coefficients Recursion' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_expforward_xml.js cppad-2016.00.00.1/doc/_expforward_xml.js --- cppad-2015.00.00.9/doc/_expforward_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_expforward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'expforward.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expforward.xml', -'logforward.xml', -'sqrtforward.xml', -'sincosforward.xml', -'atanforward.xml', -'asinforward.xml', -'acosforward.xml', -'tan_forward.xml', -'erf_forward.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/expm1.cpp.xml cppad-2016.00.00.1/doc/expm1.cpp.xml --- cppad-2015.00.00.9/doc/expm1.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/expm1.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,164 @@ + + + +The AD exp Function: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +expm1.cppHeadings

+ + + +
The AD exp Function: Example and Test
+
 
+
+# include <cppad/cppad.hpp>
+# include <cmath>
+
+bool expm1(void)
+{	bool ok = true;
+
+	using CppAD::AD;
+	using CppAD::NearEqual;
+	double eps = 10. * std::numeric_limits<double>::epsilon();
+
+	// domain space vector
+	size_t n  = 1;
+	double x0 = 0.5;
+	CPPAD_TESTVECTOR(AD<double>) ax(n);
+	ax[0]     = x0;
+
+	// declare independent variables and start tape recording
+	CppAD::Independent(ax);
+
+	// range space vector
+	size_t m = 1;
+	CPPAD_TESTVECTOR(AD<double>) ay(m);
+	ay[0] = CppAD::expm1(ax[0]);
+
+	// create f: x -> y and stop tape recording
+	CppAD::ADFun<double> f(ax, ay);
+
+	// expx0 value
+	double expx0 = std::exp(x0);
+	ok &= NearEqual(ay[0], expx0-1.0,  eps, eps);
+
+	// forward computation of first partial w.r.t. x[0]
+	CPPAD_TESTVECTOR(double) dx(n);
+	CPPAD_TESTVECTOR(double) dy(m);
+	dx[0] = 1.;
+	dy    = f.Forward(1, dx);
+	ok   &= NearEqual(dy[0], expx0, eps, eps);
+
+	// reverse computation of derivative of y[0]
+	CPPAD_TESTVECTOR(double)  w(m);
+	CPPAD_TESTVECTOR(double) dw(n);
+	w[0]  = 1.;
+	dw    = f.Reverse(1, w);
+	ok   &= NearEqual(dw[0], expx0, eps, eps);
+
+	// use a VecAD<Base>::reference object with exp
+	CppAD::VecAD<double> v(1);
+	AD<double> zero(0);
+	v[zero]           = x0;
+	AD<double> result = CppAD::expm1(v[zero]);
+	ok   &= NearEqual(result, expx0-1.0, eps, eps);
+
+	return ok;
+}
+
+
+ +
+ + +
Input File: example/expm1.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_expm1.cpp_xml.js cppad-2016.00.00.1/doc/_expm1.cpp_xml.js --- cppad-2015.00.00.9/doc/_expm1.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_expm1.cpp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,92 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'expm1.xml', +'expm1.cpp.xml' +]; +var list_down3 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down2 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down1 = [ +'expm1.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/expm1.xml cppad-2016.00.00.1/doc/expm1.xml --- cppad-2015.00.00.9/doc/expm1.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/expm1.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,200 @@ + + + +The Exponential Function Minus One: expm1 + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + +
The Exponential Function Minus One: expm1
+
+Syntax + +
+ +y = expm1(x) + + +
+
+Description +
+Returns the value of the exponential function minus one which is defined +by +y == exp(x) - 1 +. + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+CPPAD_USE_CPLUSPLUS_2011 + + +
+
+true +
+If this preprocessor symbol is true (1), +and +x + is an AD type, +this is an atomic operation +. + +
+
+false +
+If this preprocessor symbol is false (0), +CppAD uses the representation + + +expm +1 + +( +x +) += +exp +( +x +) +- +1 + + +to compute this function. + +
+
+Example + +
+The file +expm1.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/expm1.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_expm1_xml.js cppad-2016.00.00.1/doc/_expm1_xml.js --- cppad-2015.00.00.9/doc/_expm1_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_expm1_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,109 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'expm1.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'expm1.cpp.xml' +]; +var list_current0 = [ +'expm1.xml#Syntax', +'expm1.xml#Description', +'expm1.xml#x, y', +'expm1.xml#CPPAD_USE_CPLUSPLUS_2011', +'expm1.xml#CPPAD_USE_CPLUSPLUS_2011.true', +'expm1.xml#CPPAD_USE_CPLUSPLUS_2011.false', +'expm1.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/exp_reverse.xml cppad-2016.00.00.1/doc/exp_reverse.xml --- cppad-2015.00.00.9/doc/exp_reverse.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/exp_reverse.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,492 @@ + + + +Exponential Function Reverse Mode Theory + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +exp_reverseHeadings

+
Exponential Function Reverse Mode Theory
+We use the reverse theory +standard math function + +definition for the functions + +H + + + and + +G + + +. +The zero order forward mode formula for the +exponential + is + + +z +( +0 +) + + += +F +( +x +( +0 +) + + +) + + +and for + +j +> +0 + + +, + + +z +( +j +) + + += +x +( +j +) + + +d +( +0 +) + + ++ +1 + +j + + + +k += +1 + +j + + +k +x +( +k +) + + +z +( +j +- +k +) + + + + +where + + +d +( +0 +) + + += +{ +0 + +if + + +F +( +x +) += +exp + +( +x +) + +1 + +if + + +F +( +x +) += +expm +1 + +( +x +) + + + + +For order + +j += +0 +, +1 +, + + + + we note that + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +j +) + + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + +( +d +( +0 +) + + ++ +z +( +0 +) + + +) + + + +If + +j +> +0 + + +, then for + +k += +1 +, + +, +j + + + + + + + +H + + +x +( +k +) + + + + + += + + +G + + +x +( +k +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +j + + +k +z +( +j +- +k +) + + + + +H + + +z +( +j +- +k +) + + + + + += + + +G + + +z +( +j +- +k +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +j + + +k +x +( +k +) + + + + + + +
Input File: omh/theory/exp_reverse.omh + + + diff -Nru cppad-2015.00.00.9/doc/expreverse.xml cppad-2016.00.00.1/doc/expreverse.xml --- cppad-2015.00.00.9/doc/expreverse.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/expreverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,383 +0,0 @@ - - - -Exponential Function Reverse Mode Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ExpReverseHeadings

-
Exponential Function Reverse Mode Theory
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. - -The forward mode formulas for the -exponential - -function are - - -z -( -j -) - - -= -exp -( -x -( -0 -) - - -) - - -if - -j -= -0 - - -, and - - -z -( -j -) - - -= -1 - -j - - - -k -= -1 - -j - - -k -x -( -k -) - - -z -( -j -- -k -) - - - - -for the case - -j -= -0 - - -, and for - -j -> -0 - - -, - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -z -( -j -) - - - - - -If - -j -> -0 - - -, then for - -k -= -1 -, - -, -j - - - - - - - - -H - - -x -( -k -) - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -j - - -k -z -( -j -- -k -) - - - - -H - - -z -( -j -- -k -) - - - - - -= - - -G - - -z -( -j -- -k -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -j - - -k -x -( -k -) - - - - - - -
Input File: omh/theory/exp_reverse.omh - - - diff -Nru cppad-2015.00.00.9/doc/_exp_reverse_xml.js cppad-2016.00.00.1/doc/_exp_reverse_xml.js --- cppad-2015.00.00.9/doc/_exp_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_exp_reverse_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,85 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'reversetheory.xml', +'exp_reverse.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_reverse.xml', +'log_reverse.xml', +'sqrt_reverse.xml', +'sin_cos_reverse.xml', +'atan_reverse.xml', +'asin_reverse.xml', +'acos_reverse.xml', +'tan_reverse.xml', +'erf_reverse.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_expreverse_xml.js cppad-2016.00.00.1/doc/_expreverse_xml.js --- cppad-2015.00.00.9/doc/_expreverse_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_expreverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'expreverse.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expreverse.xml', -'logreverse.xml', -'sqrtreverse.xml', -'sincosreverse.xml', -'atanreverse.xml', -'asinreverse.xml', -'acosreverse.xml', -'tan_reverse.xml', -'erf_reverse.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/exp.xml cppad-2016.00.00.1/doc/exp.xml --- cppad-2015.00.00.9/doc/exp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/exp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,182 @@ + + + +The Exponential Function: exp + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Exponential Function: exp
+
+Syntax + +
+ +y = exp(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +exp + +( +1 +) + + +( +x +) + += + +exp +( +x +) + + + +
+Example + +
+The file +exp.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_exp_xml.js cppad-2016.00.00.1/doc/_exp_xml.js --- cppad-2015.00.00.9/doc/_exp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_exp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'exp.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'exp.cpp.xml' +]; +var list_current0 = [ +'exp.xml#Syntax', +'exp.xml#x, y', +'exp.xml#Atomic', +'exp.xml#Derivative', +'exp.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_external.xml cppad-2016.00.00.1/doc/_external.xml --- cppad-2015.00.00.9/doc/_external.xml 2015-02-24 08:31:55.000000000 +0000 +++ cppad-2016.00.00.1/doc/_external.xml 2016-02-09 08:32:10.000000000 +0000 @@ -48,7 +48,7 @@ - + @@ -64,13 +64,17 @@ Reference Location +http://cscapes.cs.purdue.edu/dox/ColPack/htmlcolpack_prefix#Purpose + +http://cscapes.cs.purdue.edu/dox/ColPack/html/get_colpack.sh#Purpose + http://cygwin.com/setup.html#namingwhats_new_06#11-30 http://eigen.tuxfamily.orgeigen_prefix#Purpose http://eigen.tuxfamily.orgget_eigen.sh#Purpose -http://eigen.tuxfamily.orgInstallUnix#eigen_dir +http://eigen.tuxfamily.orgauto_tools#eigen_dir http://eigen.tuxfamily.orgcppad_eigen.hpp#Purpose @@ -84,12 +88,8 @@ http://en.wikipedia.org/wiki/Automatic_differentiationCppAD#Introduction -http://http://cscapes.cs.purdue.edu/coloringpage/colpack_prefix#Purpose - http://list.coin-or.org/mailman/listinfo/cppadFaq#Bugs -http://list.coin-or.org/mailman/listinfo/cppadFaq#Math Functions - http://list.coin-or.org/pipermail/cppad/2006-February/000020.htmlwhats_new_06#02-21 http://list.coin-or.org/pipermail/cppad/2006q4/000076.htmlwhats_new_06#12-07 @@ -98,6 +98,8 @@ http://lists.fedoraproject.org/pipermail/devel/2011-January/147915.htmlwhats_new_11#01-19 +http://moby.ihme.washington.edu/bradbell/cppad_mixedaddon#Name + http://msdn.microsoft.com/en-us/library/bh44f2cb(v=vs.71).aspxwhats_new_11#04-29 http://opensource.org/licenses/EPL-1.0download#Subversion.Limitations @@ -118,7 +120,7 @@ http://trilinos.sandia.gov/packages/sacado/CppAD#Introduction -http://trilinos.sandia.gov/packages/sacado/InstallUnix#sacado_dir +http://trilinos.sandia.gov/packages/sacado/auto_tools#sacado_dir http://trilinos.sandia.gov/packages/sacado/speed#Purpose @@ -130,7 +132,7 @@ http://valgrind.org/whats_new_06#08-17 -http://www.7-zip.orgdownload#Compressed Archives.Windows File Extraction +http://www.7-zip.orgdownload#Compressed Archives.Windows File Extraction and Testing http://www.7-zip.orgwhats_new_04#09-02 @@ -138,7 +140,7 @@ http://www.autodiff.orgCppAD#Introduction -http://www.boost.org/development/requirements.html#GuidelinesWishList#Software Guidelines.Boost +http://www.boost.org/development/requirements.html#Guidelineswish_list#Software Guidelines http://www.boost.org/doc/libs/1_47_0/doc/html/thread.htmlwhats_new_11#09-06 @@ -172,9 +174,9 @@ http://www.coin-or.org/download/source/CppAD/whats_new_09#06-25 -http://www.coin-or.org/download/source/CppAD/cppad-20150000.9.epl.tgzdownload#Compressed Archives +http://www.coin-or.org/download/source/CppAD/cppad-20160000.1.epl.tgzdownload#Compressed Archives -http://www.coin-or.org/download/source/CppAD/cppad-20150000.9.gpl.tgzdownload#Compressed Archives +http://www.coin-or.org/download/source/CppAD/cppad-20160000.1.gpl.tgzdownload#Compressed Archives http://www.coin-or.org/foundation.htmlCppAD#Introduction @@ -182,29 +184,25 @@ http://www.coin-or.org/projects/Ipopt.xmlget_ipopt.sh#Purpose -http://www.coin-or.org/projects/Ipopt.xmlInstallUnix#ipopt_dir +http://www.coin-or.org/projects/Ipopt.xmlauto_tools#ipopt_dir http://www.coin-or.org/projects/Ipopt.xmlipopt_solve#Purpose http://www.coin-or.org/projects/Ipopt.xmlcppad_ipopt_nlp#Purpose -http://www.cs.odu.edu/~dnguyen/dox/colpack/html/get_colpack.sh#Purpose - -http://www.cygwin.com/ml/cygwin-apps/2005-06/msg00159.htmlBugs#gcc 3.4.4 -O2.Adolc - http://www.fadbad.comfadbad_prefix#Purpose http://www.fadbad.comget_fadbad.sh#Purpose http://www.fadbad.comwhats_new_13#04-26 -http://www.fadbad.com/InstallUnix#fadbad_dir +http://www.fadbad.com/CppAD#Introduction -http://www.imm.dtu.dk/fadbad.html/CppAD#Introduction +http://www.fadbad.com/auto_tools#fadbad_dir -http://www.imm.dtu.dk/fadbad.html/speed#Purpose +http://www.fadbad.com/speed#Purpose -http://www.math.tu-dresden.de/~adol-c/InstallUnix#adolc_dir +http://www.microsoft.com/en-us/download/confirmation.aspx?id=44914download#Compressed Archives.Windows File Extraction and Testing http://www.mingw.orgwhats_new_03#12-22 @@ -216,16 +214,26 @@ http://www.seanet.com/~bradbell/omhelp/download#Subversion.Install Instructions +http://www.seanet.com/~bradbell/pycppad/pycppad.htmaddon#Name + http://www.winzip.comwhats_new_04#09-02 https://github.com/bradbell/cppaddownload#Compressed Archives.Current Version +https://github.com/joaoleal/CppADCodeGen/addon#Name + +https://github.com/kaskr/adcompwhats_new_15#03-06 + +https://github.com/kaskr/adcompaddon#Name + https://projects.coin-or.org/ADOL-CCppAD#Introduction https://projects.coin-or.org/ADOL-Cadolc_prefix#Purpose https://projects.coin-or.org/ADOL-Cget_adolc.sh#Purpose +https://projects.coin-or.org/ADOL-Cauto_tools#adolc_dir + https://projects.coin-or.org/ADOL-Cspeed#Purpose https://projects.coin-or.org/ADOL-Cwhats_new_13#10-14 diff -Nru cppad-2015.00.00.9/doc/__external_xml.js cppad-2016.00.00.1/doc/__external_xml.js --- cppad-2015.00.00.9/doc/__external_xml.js 2015-02-24 08:31:55.000000000 +0000 +++ cppad-2016.00.00.1/doc/__external_xml.js 2016-02-09 08:32:10.000000000 +0000 @@ -16,7 +16,7 @@ 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', -'library.xml', +'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', diff -Nru cppad-2015.00.00.9/doc/fadbad_det_lu.cpp.xml cppad-2016.00.00.1/doc/fadbad_det_lu.cpp.xml --- cppad-2015.00.00.9/doc/fadbad_det_lu.cpp.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/fadbad_det_lu.cpp.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Fadbad Speed: Gradient of Determinant Using Lu Factorization - + - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -InstallUnix - -

-
Deprecated Unix Test and Installation
-
-Deprecated -
-These install instructions have been deprecated and no improvements -have been added since 2012. -For example, this install procedure will not detect any of the -c++11 extensions. -You should use the cmake - instructions to install CppAD. - -
-
-Distribution Directory -
-You must first obtain a copy of the CppAD distribution directory -using the download - instructions. -The install instructions below correspond to the -current version - -which has distribution directory cppad-20121230. - -
-
-Work Directory -
-Create the directory cppad-20121230/build, -which will be referred to as the build directory below. - -
-
-Configure -
-Execute the following command in the build directory: - - -
-./configure                                  \
-     --prefix=
prefix_dir                     \
-     --with-Documentation                    \
-     --with-
testvector                       \  
-     --with-sparse_
option                    \
-     --with-implicit_ctor                    \
-     MAX_NUM_THREADS=
max_num_threads         \
-     CXX_FLAGS=
cxx_flags                     \
-     OPENMP_FLAGS=
openmp_flags               \
-     POSTFIX_DIR=
postfix_dir                 \
-     ADOLC_DIR=
adolc_dir                     \
-     BOOST_DIR=
boost_dir                     \
-     EIGEN_DIR=
eigen_dir                     \
-     FADBAD_DIR=
fadbad_dir                   \
-     SADADO_DIR=
sacado_dir                   \
-     IPOPT_DIR=
ipopt_dir                     \
-     TAPE_ADDR_TYPE=
tape_addr_type           \
-     TAPE_ID_TYPE=
tape_id_type
-
-where only the configure line need appear; i.e., -the entries in all of the other lines are optional. -The text in italic is replaced values that you choose; -see discussion below. - -
-
-make -
-CppAD has some object libraries that are used for its correctness tests. -(Currently, none of these libraries get installed.) -You can build these libraries by executing the command - -
-     make 
-
-in the build directory. - -
-
-Examples and Tests -
-Once you have executed the make command, -you can run the correctness and speed tests. -
-
-
The following command will build all the correctness and speed tests. -In addition, it will run all the correctness tests: -
 
-	make test
-
- -
-
-
The following links describe how to build and run subsets of these tests: - -
- -get_started - - - Getting Started Using CppAD to Compute Derivatives -
- -exp_apx_main - - - Correctness Tests For Exponential Approximation in Introduction -
- -example - - - CppAD Examples and Tests -
- -print_for_cout - - - Printing During Forward Mode: Example and Test -
- -speed_example - - - Run the Speed Examples -
- -speed_double - - - Speed Test of Functions in Double -
- -speed_adolc - - - Speed Test of Derivatives Using Adolc -
- -speed_cppad - - - Speed Test Derivatives Using CppAD -
- -speed_fadbad - - - Speed Test Derivatives Using Fadbad -
- -speed_sacado - - - Speed Test Derivatives Using Sacado -
-In addition, -you can run a large subset of correctness tests -(that are not intended to be examples) -by executing the following commands starting in the build directory: - -
-     cd test_more
-     make test
-
-
-Profiling CppAD - - - -
-The CppAD derivative speed tests mentioned above can be profiled. -You can test that the results computed during this profiling are correct -by executing the following commands starting in the build directory: - -
-     cd speed/profile
-     make test
-
-After executing make test, you can run a profile speed test -by executing the command ./profile; -see speed_main - for the meaning of the command line -options to this program. -
-
-
After you have run a profiling speed test, -you can then obtain the profiling results with - -
-     gprof -b profile
-
-If you are using a windows operating system with Cygwin or MinGW, -you may have to replace profile by profile.exe -in the gprof command above; i.e., -
 
-	gprof -b profile.exe
-
- -In C++, template parameters and argument types become part of a -routines's name. -This can make the gprof output hard to read -(the routine names can be very long). -You can remove the template parameters and argument types from the -routine names by executing the following command -
 
-	gprof -b profile | sed -f gprof.sed
-
- -If you are using a windows operating system with Cygwin or MinGW, -you would need to use -
 
-	gprof -b profile.exe | sed -f gprof.sed
-
- - -
-
-prefix_dir - - - -
-The default value for prefix directory is $HOME -i.e., by default the CppAD include files -will install - below $HOME. -If you want to install elsewhere, you will have to use this option. -As an example of using the ---prefix=prefix_dir - option, -if you specify -
 
-	./configure --prefix=/usr/local
-
- -the CppAD include files will be installed in the directory - -
-     /usr/local/include/cppad
-
-If --with-Documentation - -is specified, the CppAD documentation files will be installed in the directory - -
-     /usr/local/share/doc/cppad-20121230
-
-
---with-Documentation - - -
-If the command line argument --with-Documentation is specified, -the CppAD documentation HTML and XML files are copied to the directory - -
-     
prefix_dir/share/doc/postfix_dir/cppad-20121230
-
-(see postfix_dir -). -The top of the CppAD HTML documentation tree -(with mathematics displayed as LaTex command) will be located at - -
-     
prefix_dir/share/doc/postfix_dir/cppad-20121230/cppad.htm
-
-and the top of the XML documentation tree -(with mathematics displayed as MathML) will be located at - -
-     
prefix_dir/share/doc/postfix_dir/cppad-20121230/cppad.xml
-
-
---with-testvector - - - - - -
-The CPPAD_TESTVECTOR - -template class is used for many of the CppAD examples and tests. -The default for this template class is -CppAD::vector<Scalar> -. -If one, and only one, of the following command line arguments is specified: -
 
-	--with-stdvector
-	--with-boostvector
-	--with-eigenvector
-
- -the corresponding of the following template classes is used - -
-     std::vector<
Scalar>
-     boost::numeric::ublas::vector<
Scalar>
-     Eigen::matrix<
Scalar, Eigen::Dynamic, 1>
-
-See also, -boost_dir - -and -eigen_dir -. - - -
-
---with-sparse_option - - - -
-There are two options for the preprocessor symbol -CPPAD_INTERNAL_SPARSE_SET. -If --with-sparse_set -(--with-sparse_list) is specified, -this symbol is sparse_set (sparse_list). -This should affect the speed and memory required by the -sparse_jacobian -, sparse_hessian -, and the -sparse drivers -. - -
-
---with-implicit_ctor - - - -
-If this configure argument is present, there is a -deprecated - -implicit type constructor (type conversion) -from any type to -AD<Base> -. -Otherwise this constructor is -explicit -. - - -
-
-max_num_threads -
-this specifies the value for the default value for the preprocessor symbol -CPPAD_MAX_NUM_THREADS -. -It must be greater than or equal to four; i.e., - -max_num_threads >= 4 -. - -
-
-cxx_flags - - -
-If the command line argument -CompilerFlags - is present, -it specifies compiler flags. -For example, - -
-     CXX_FLAGS="-Wall -ansi"
-
-would specify that warning flags -Wall -and -ansi should be included -in all the C++ compile commands. -The error and warning flags chosen must be valid options -for the C++ compiler. -The default value for -CompilerFlags - is the -empty string. - -
-
-openmp_flags - - - -
-If the command line argument -OpenmpFlags - is present, -it specifies the necessary flags so that the compiler will -properly interpret OpenMP directives. -For example, when using the GNU g++ compiler, -the following setting includes the OpenMP tests: - -
-     OPENMP_FLAGS=-fopenmp
-
-If you specify configure command, -the CppAD OpenMP correctness and speed tests will be built; see -threading - -multi-threading tests. - -
-
-postfix_dir - - - -
-By default, the postfix directory is empty; i.e., there -is no postfix directory. -As an example of using the -POSTFIX_DIR=postfix_dir - option, -if you specify -
 
-	./configure --prefix=/usr/local POSTFIX_DIR=coin
-
- -the CppAD include files will be -installed - in the directory - -
-     /usr/local/include/coin/cppad
-
-If --with-Documentation - -is specified, the CppAD documentation files will be installed in the directory - -
-     /usr/local/share/doc/coin/cppad-20121230
-
-
-adolc_dir - -
-If you have -Adolc 1.10.2 - -installed on your system, you can -specify a value for -adolc_dir - in the -configure - command line. -The value of -adolc_dir - must be such that - -
-     
adolc_dir/include/adolc/adouble.h
-
-is a valid way to reference adouble.h. -In this case, you can run the Adolc speed correctness tests -by executing the following commands starting in the build directory: - -
-     cd speed/adolc
-     make test
-
-After executing make test, you can run an Adolc speed tests -by executing the command ./adolc; -see speed_main - for the meaning of the command line -options to this program. -Note that these speed tests assume Adolc has been configure with -its sparse matrix computations enabled using - -
-     --with-colpack=
colpack_dir
-
-
-Linux -
-If you are using Linux, -you will have to add -adolc_dir/lib - to LD_LIBRARY_PATH. -For example, if you use the bash shell to run your programs, -you could include - -
-     LD_LIBRARY_PATH=
adolc_dir/lib:${LD_LIBRARY_PATH}
-     export LD_LIBRARY_PATH
-
-in your $HOME/.bash_profile file. - -
-
-Cygwin -
-If you are using Cygwin, -you will have to add to following lines to the file -.bash_profile in your home directory: - -
-     PATH=
adolc_dir/bin:${PATH}
-     export PATH
-
-in order for Adolc to run properly. -If -adolc_dir - begins with a disk specification, -you must use the Cygwin format for the disk specification. -For example, -if d:/adolc_base is the proper directory, -/cygdrive/d/adolc_base should be used for -adolc_dir -. - -
-
-boost_dir - -
-If the command line argument - -
-     BOOST_DIR=
boost_dir
-
-is present, it must be such that files - -
-     
boost_dir/include/boost/numeric/ublas/vector.hpp
-     
boost_dir/include/boost/thread.hpp
-
-are present. -In this case, these files will be used by CppAD. -See also, --with-boostvector - - -
-
-eigen_dir - -
-If you have -Eigen - -installed on your system, you can -specify a value for -eigen_dir -. -It must be such that - -
-     
eigen_dir/include/Eigen/Core
-
-is a valid include file. -In this case CppAD will compile and test the Eigen examples; e.g., -eigen_array.cpp -. -See also, --with-eigenvector - - -
-
-fadbad_dir - -
-If you have -Fadbad 2.1 - -installed on your system, you can -specify a value for -fadbad_dir -. -It must be such that - -
-     
fadbad_dir/include/FADBAD++/badiff.h
-
-is a valid reference to badiff.h. -In this case, you can run the Fadbad speed correctness tests -by executing the following commands starting in the build directory: - -
-     cd speed/fadbad
-     make test
-
-After executing make test, you can run a Fadbad speed tests -by executing the command ./fadbad; -see speed_main - for the meaning of the command line -options to this program. - -
-
-ipopt_dir - -
-If you have -Ipopt - -installed on your system, you can -specify a value for -ipopt_dir -. -It must be such that - -
-     
ipopt_dir/include/coin/IpIpoptApplication.hpp
-
-is a valid reference to IpIpoptApplication.hpp. -In this case, the CppAD interface to Ipopt -examples - can be built and tested -by executing the following commands starting in the build directory: - -
-     make
-     #
-     cd cppad_ipopt/example
-     make test
-     #
-     cd ../test
-     make test
-     #
-     cd ../speed
-     make test
-
-Once this has been done, you can execute the program -./speed in the build/cppad_ipopt/speed directory; -see ipopt_ode_speed.cpp -. - -
-
-sacado_dir - -
-If you have -Sacado - -installed on your system, you can -specify a value for -sacado_dir -. -It must be such that - -
-     
sacado_dir/include/Sacado.hpp
-
-is a valid reference to Sacado.hpp. -In this case, you can run the Sacado speed correctness tests -by executing the following commands starting in the build directory: - -
-     cd speed/sacado
-     make test
-
-After executing make test, you can run a Sacado speed tests -by executing the command ./sacado; -see speed_main - for the meaning of the command line -options to this program. - - -
-
-tape_addr_type - - - -
-If the command line argument -tape_addr_type - is present, -it specifies the type used for address in the AD recordings (tapes). -The valid values for this argument are -unsigned short int, -unsigned int, -size_t. -The smaller the value of -sizeof(tape_addr_type) -, -the less memory is used. -On the other hand, the value - -
-     std::numeric_limits<
tape_addr_type>::max()
-
-must be larger than any of the following: -size_op -, -size_op_arg -, -size_par -, -size_par -, -size_par -. - - -
-
-tape_id_type - - - -
-If the command line argument -tape_id_type - is present, -it specifies the type used for identifying tapes. -The valid values for this argument are -unsigned short int, -unsigned int, -size_t. -The smaller the value of -sizeof(tape_id_type) -, -the less memory is used. -On the other hand, the value - -
-     std::numeric_limits<
tape_id_type>::max()
-
-must be larger than the maximum number of tapes per thread -times max_num_threads -. - -
-
-make install -
-Once you are satisfied that the tests are giving correct results, -you can install CppAD into easy to use directories by executing the command -
 
-	make install
-
- -This will install CppAD in the location specified by -prefix_dir -. -You must have permission to write in the -prefix_dir - -directory to execute this command. -You may optionally specify a destination directory for the install; i.e., - -
-     make install DESTDIR=
DestinationDirectory
-
- -
Input File: omh/install/unix.omh - - - diff -Nru cppad-2015.00.00.9/doc/_installunix_xml.js cppad-2016.00.00.1/doc/_installunix_xml.js --- cppad-2015.00.00.9/doc/_installunix_xml.js 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/_installunix_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'install.xml', -'installunix.xml' -]; -var list_down2 = [ -'install.xml', -'introduction.xml', -'ad.xml', -'adfun.xml', -'preprocessor.xml', -'multi_thread.xml', -'library.xml', -'ipopt_solve.xml', -'example.xml', -'speed.xml', -'appendix.xml' -]; -var list_down1 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml', -'installunix.xml' -]; -var list_current0 = [ -'installunix.xml#Deprecated', -'installunix.xml#Distribution Directory', -'installunix.xml#Work Directory', -'installunix.xml#Configure', -'installunix.xml#make', -'installunix.xml#make.Examples and Tests', -'installunix.xml#Profiling CppAD', -'installunix.xml#prefix_dir', -'installunix.xml#--with-Documentation', -'installunix.xml#--with-testvector', -'installunix.xml#--with-sparse_option', -'installunix.xml#--with-implicit_ctor', -'installunix.xml#max_num_threads', -'installunix.xml#cxx_flags', -'installunix.xml#openmp_flags', -'installunix.xml#postfix_dir', -'installunix.xml#adolc_dir', -'installunix.xml#adolc_dir.Linux', -'installunix.xml#adolc_dir.Cygwin', -'installunix.xml#boost_dir', -'installunix.xml#eigen_dir', -'installunix.xml#fadbad_dir', -'installunix.xml#ipopt_dir', -'installunix.xml#sacado_dir', -'installunix.xml#tape_addr_type', -'installunix.xml#tape_id_type', -'installunix.xml#make install' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/install.xml cppad-2016.00.00.1/doc/install.xml --- cppad-2015.00.00.9/doc/install.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/install.xml 2016-02-09 08:32:04.000000000 +0000 @@ -6,7 +6,7 @@ CppAD Download, Test, and Install Instructions - + - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

- - - - - - - - -
The CppAD General Purpose Library
-
-Error Handler -
-All of the routines in the CppAD namespace use the following -general purpose error handler: - - -
- -ErrorHandler -Replacing the CppAD Error Handler
- -
-
-Testing Utilities -
-The routines listed below support numerical correctness and speed testing: - - - - - -
- -NearEqual -Determine if Two Values Are Nearly Equal
- -time_test -Determine Amount of Time to Execute a Test
- -speed_test -Run One Speed Test and Return Results
- -SpeedTest -Run One Speed Test and Print Results
- -
-
-C++ Concepts - -
-We refer to a the set of classes that satisfy certain conditions -as a C++ concept. -The following concepts are used by the CppAD Template library: - - - - - -
- -NumericType -Definition of a Numeric Type
- -CheckNumericType -Check NumericType Class Concept
- -SimpleVector -Definition of a Simple Vector
- -CheckSimpleVector -Check Simple Vector Concept
- -
-
-CppAD Numerical Template Library -
-The routines listed below are general purpose numerical routines -written with the floating point type a C++ template parameter. -This enables them to be used with algorithmic differentiation types, -as well as for other purposes. - - - - - - - - - - - - -
- -nan -Obtain Nan or Determine if a Value is Nan
- -pow_int -The Integer Power Function
- -Poly -Evaluate a Polynomial or its Derivative
- -LuDetAndSolve -Compute Determinants and Solve Equations by LU Factorization
- -RombergOne -One DimensionalRomberg Integration
- -RombergMul -Multi-dimensional Romberg Integration
- -Runge45 -An Embedded 4th and 5th Order Runge-Kutta ODE Solver
- -Rosen34 -A 3rd and 4th Order Rosenbrock ODE Solver
- -OdeErrControl -An Error Controller for ODE Solvers
- -OdeGear -An Arbitrary Order Gear Method
- -OdeGearControl -An Error Controller for Gear's Ode Solvers
- -
-
-General Purpose Utilities -
-The classes and routines below are of general use -(not necessarily AD related). - - - - -
- -CppAD_vector -The CppAD::vector Template Class
- -thread_alloc -A Fast Multi-Threading Memory Allocator
- -index_sort -Returns Indices that Sort a Vector
- -
-
-Numerical AD Library -
-The routines listed below are numerical routines that are specially -designed to work with CppAD in particular. - - - - -
- -BenderQuad -Computing Jacobian and Hessian of Bender's Reduced Objective
- -opt_val_hes -Jacobian and Hessian of Optimal Values
- -LuRatio -LU Factorization of A Square Matrix and Stability Calculation
- -
- -
Input File: omh/library.omh - - - diff -Nru cppad-2015.00.00.9/doc/_library_xml.js cppad-2016.00.00.1/doc/_library_xml.js --- cppad-2015.00.00.9/doc/_library_xml.js 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/_library_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'library.xml' -]; -var list_down1 = [ -'install.xml', -'introduction.xml', -'ad.xml', -'adfun.xml', -'preprocessor.xml', -'multi_thread.xml', -'library.xml', -'ipopt_solve.xml', -'example.xml', -'speed.xml', -'appendix.xml' -]; -var list_down0 = [ -'errorhandler.xml', -'nearequal.xml', -'speed_test.xml', -'speedtest.xml', -'time_test.xml', -'numerictype.xml', -'checknumerictype.xml', -'simplevector.xml', -'checksimplevector.xml', -'nan.xml', -'pow_int.xml', -'poly.xml', -'ludetandsolve.xml', -'rombergone.xml', -'rombergmul.xml', -'runge45.xml', -'rosen34.xml', -'odeerrcontrol.xml', -'odegear.xml', -'odegearcontrol.xml', -'cppad_vector.xml', -'thread_alloc.xml', -'index_sort.xml', -'benderquad.xml', -'opt_val_hes.xml', -'luratio.xml' -]; -var list_current0 = [ -'library.xml#Error Handler', -'library.xml#Testing Utilities', -'library.xml#C++ Concepts', -'library.xml#CppAD Numerical Template Library', -'library.xml#General Purpose Utilities', -'library.xml#Numerical AD Library' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/license.xml cppad-2016.00.00.1/doc/license.xml --- cppad-2015.00.00.9/doc/license.xml 2015-02-24 08:31:54.000000000 +0000 +++ cppad-2016.00.00.1/doc/license.xml 2016-02-09 08:32:08.000000000 +0000 @@ -6,7 +6,7 @@ Your License for the CppAD Software - + - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -limits.cppHeadings

- - - -
Numeric Limits: Example and Test
-
 
-
-# ifdef _MSC_VER
-// Supress Microsoft compiler warning about possible loss of precision,
-// in the constructors (when converting to std::complex<float>)
-//	Float one = 1
-//	Float two = 2
-// 1 and 2 are small enough so no loss of precision when converting to float.
-# pragma warning(disable:4244)
-# endif
-
-# include <cppad/cppad.hpp>
-# include <complex>
-
-namespace {
-	typedef CppAD::AD<double> Float;
-	//
-	// -----------------------------------------------------------------
-	bool check_epsilon(void)
-	{	bool ok    = true;
-		Float eps   = CppAD::numeric_limits<Float>::epsilon();
-		Float eps2  = eps / 2.0; 
-		Float check = 1.0 + eps;
-		ok         &= 1.0 !=  check;
-		check       = 1.0 + eps2;
-		ok         &= 1.0 == check;
-		return ok;
-	}
-	// -----------------------------------------------------------------
-	bool check_min(void)
-	{	bool ok     = true;
-		Float min   = CppAD::numeric_limits<Float>::min();
-		Float eps   = CppAD::numeric_limits<Float>::epsilon();
-		//
-		Float match = (min / 100. ) * 100.;
-		ok         &= abs(match/min - 1.0) > 3.0 * eps;
-		//
-		match       = (min * 100.) / (100. * (1.0 - eps));
-		ok         &= abs(match / min - 1.0) < 3.0 * eps;
-		return ok;
-	}
-	// -----------------------------------------------------------------
-	bool check_max(void)
-	{	bool ok     = true;
-		Float max   = CppAD::numeric_limits<Float>::max();
-		Float eps   = CppAD::numeric_limits<Float>::epsilon();
-		//
-		Float match = (max * 100.) / 100.;
-		ok         &= abs(match / max - 1.0) > 3.0 * eps;
-		//
-		match       = (max / 100. ) * (100. * (1.0 - eps));
-		ok         &= abs(match/max - 1.0) < 3.0 * eps;
-		return ok;
-	}
-}
-
-bool limits(void)
-{	bool ok = true;
-
-	ok &= check_epsilon();
-	ok &= check_max();
-	ok &= check_min();
-
-	return ok;
-}
-
- -
- - -
Input File: example/limits.cpp - - - diff -Nru cppad-2015.00.00.9/doc/_limits.cpp_xml.js cppad-2016.00.00.1/doc/_limits.cpp_xml.js --- cppad-2015.00.00.9/doc/_limits.cpp_xml.js 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/_limits.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'advalued.xml', -'mathother.xml', -'limits.xml', -'limits.cpp.xml' -]; -var list_down3 = [ -'arithmetic.xml', -'std_math_ad.xml', -'mathother.xml', -'condexp.xml', -'discrete.xml', -'atomic.xml' -]; -var list_down2 = [ -'abs.xml', -'sign.xml', -'atan2.xml', -'erf.xml', -'pow.xml', -'limits.xml' -]; -var list_down1 = [ -'limits.cpp.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/limits.xml cppad-2016.00.00.1/doc/limits.xml --- cppad-2015.00.00.9/doc/limits.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/limits.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,249 +0,0 @@ - - - -Numeric Limits For an AD and Base Types - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - - - - - - -
Numeric Limits For an AD and Base Types
-
-Syntax - -
- -eps = numeric_limits<Float>::epsilon()
-
- -min = numeric_limits<Float>::min()
-
- -max = numeric_limits<Float>::max()
-
-
-Purpose -
-Obtain the value of some of the C++ standard numeric limits -using the CppAD namespace version of numeric_limits. -These are all functions and have the prototype - -
-     
Float numeric_limits<Float>::fun(void)
-
-where -fun - is epsilon, min, or max. -
-
-
Note that C++ standard specifies that Non-fundamental standard -types, such as -std::complex<T> - shall not have specializations -of std::numeric_limits; see Section 18.2 of -ISO/IEC 14882:1998(E). - -
-
-Float -
-These functions are defined for all -AD<Base> -, -and for all corresponding -Base - types; -see -Base - type limits -. - -
-
-eps -
-The result -eps - is equal to machine epsilon and has prototype - -
-     
Float eps
-
-CppAD tests the value -eps - by checking that the following are true - -
-     1 != 1 + 
eps
-     1 == 1 + 
eps / 2
-
-where all the values, and calculations, are done with the precision -corresponding to -Float -. - - -
-
-min -
-The result -min - is equal to -the minimum positive normalized value and has prototype - -
-     
Float min
-
-CppAD tests the value -min - by checking that the following are true - -
-     abs( ((
min / 100) * 100) / min - 1 ) > 3 * eps
-     abs( ((
min * 100) / (100 * (1 - eps)) / min - 1 ) < 3 * eps
-
-where all the values, and calculations, are done with the precision -corresponding to -Float -. - -
-
-max -
-The result -max - is equal to -the maximum finite value and has prototype - -
-     
Float max
-
-CppAD tests the value -max - by checking that the following are true - -
-     abs( ((
max * 100) / 100) / max - 1 ) > 3 * eps
-     abs( ((
max / 100) * (100 * (1 - eps)) / max - 1 ) < 3 * eps
-
-where all the values, and calculations, are done with the precision -corresponding to -Float -. - -
-
-Example - -
-The file -limits.cpp - -contains an example and test of these functions. - - -
Input File: cppad/local/limits.hpp - - - diff -Nru cppad-2015.00.00.9/doc/_limits_xml.js cppad-2016.00.00.1/doc/_limits_xml.js --- cppad-2015.00.00.9/doc/_limits_xml.js 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/_limits_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'advalued.xml', -'mathother.xml', -'limits.xml' -]; -var list_down3 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down2 = [ -'arithmetic.xml', -'std_math_ad.xml', -'mathother.xml', -'condexp.xml', -'discrete.xml', -'atomic.xml' -]; -var list_down1 = [ -'abs.xml', -'sign.xml', -'atan2.xml', -'erf.xml', -'pow.xml', -'limits.xml' -]; -var list_down0 = [ -'limits.cpp.xml' -]; -var list_current0 = [ -'limits.xml#Syntax', -'limits.xml#Purpose', -'limits.xml#Float', -'limits.xml#eps', -'limits.xml#min', -'limits.xml#max', -'limits.xml#Example' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/link_det_lu.xml cppad-2016.00.00.1/doc/link_det_lu.xml --- cppad-2015.00.00.9/doc/link_det_lu.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/link_det_lu.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Speed Testing Gradient of Determinant Using Lu Factorization - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Base 10 Logarithm Function: log10
+
+Syntax + +
+ +y = log10(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Method +
+CppAD uses the representation + + + +log +10 + +( +x +) + += + +log +( +x +) +/ +log +( +10 +) + + + +
+Example + +
+The file +log10.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_log10_xml.js cppad-2016.00.00.1/doc/_log10_xml.js --- cppad-2015.00.00.9/doc/_log10_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_log10_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,106 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'log10.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'log10.cpp.xml' +]; +var list_current0 = [ +'log10.xml#Syntax', +'log10.xml#x, y', +'log10.xml#Method', +'log10.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/log1p.cpp.xml cppad-2016.00.00.1/doc/log1p.cpp.xml --- cppad-2015.00.00.9/doc/log1p.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/log1p.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,167 @@ + + + +The AD log1p Function: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +log1p.cppHeadings

+ + + +
The AD log1p Function: Example and Test
+
 
+
+# include <cppad/cppad.hpp>
+
+bool log1p(void)
+{	bool ok = true;
+
+	using CppAD::AD;
+	using CppAD::NearEqual;
+
+	// 10 times machine epsilon
+	double eps = 10. * std::numeric_limits<double>::epsilon();
+
+	// domain space vector
+	size_t n  = 1;
+	double x0 = 0.5;
+	CPPAD_TESTVECTOR(AD<double>) x(n);
+	x[0]      = x0;
+
+	// declare independent variables and start tape recording
+	CppAD::Independent(x);
+
+	// a temporary value
+	AD<double> expm1_of_x0 = CppAD::expm1(x[0]);
+
+	// range space vector
+	size_t m = 1;
+	CPPAD_TESTVECTOR(AD<double>) y(m);
+	y[0] = CppAD::log1p(expm1_of_x0);
+
+	// create f: x -> y and stop tape recording
+	CppAD::ADFun<double> f(x, y);
+
+	// check value
+	ok &= NearEqual(y[0] , x0,  eps, eps);
+
+	// forward computation of first partial w.r.t. x[0]
+	CPPAD_TESTVECTOR(double) dx(n);
+	CPPAD_TESTVECTOR(double) dy(m);
+	dx[0] = 1.;
+	dy    = f.Forward(1, dx);
+	ok   &= NearEqual(dy[0], 1., eps, eps);
+
+	// reverse computation of derivative of y[0]
+	CPPAD_TESTVECTOR(double)  w(m);
+	CPPAD_TESTVECTOR(double) dw(n);
+	w[0]  = 1.;
+	dw    = f.Reverse(1, w);
+	ok   &= NearEqual(dw[0], 1., eps, eps);
+
+	// use a VecAD<Base>::reference object with log1p
+	CppAD::VecAD<double> v(1);
+	AD<double> zero(0);
+	v[zero] = expm1_of_x0;
+	AD<double> result = CppAD::log1p(v[zero]);
+	ok     &= NearEqual(result, x0, eps, eps);
+
+	return ok;
+}
+
+
+ +
+ + +
Input File: example/log1p.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_log1p.cpp_xml.js cppad-2016.00.00.1/doc/_log1p.cpp_xml.js --- cppad-2015.00.00.9/doc/_log1p.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_log1p.cpp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,92 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'log1p.xml', +'log1p.cpp.xml' +]; +var list_down3 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down2 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down1 = [ +'log1p.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/log1p.xml cppad-2016.00.00.1/doc/log1p.xml --- cppad-2015.00.00.9/doc/log1p.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/log1p.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,202 @@ + + + +The Logarithm of One Plus Argument: log1p + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Logarithm of One Plus Argument: log1p
+
+Syntax + +
+ +y = log1p(x) + + +
+
+Description +
+Returns the value of the logarithm of one plus argument which is defined +by +y == log(1 + x) +. + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+CPPAD_USE_CPLUSPLUS_2011 + + +
+
+true +
+If this preprocessor symbol is true (1), +and +x + is an AD type, +this is an atomic operation +. + +
+
+false +
+If this preprocessor symbol is false (0), +CppAD uses the representation + + +log +1 +p + +( +x +) += +log +( +1 ++ +x +) + + +to compute this function. + +
+
+Example + +
+The file +log1p.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/log1p.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_log1p_xml.js cppad-2016.00.00.1/doc/_log1p_xml.js --- cppad-2015.00.00.9/doc/_log1p_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_log1p_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,109 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'log1p.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'log1p.cpp.xml' +]; +var list_current0 = [ +'log1p.xml#Syntax', +'log1p.xml#Description', +'log1p.xml#x, y', +'log1p.xml#CPPAD_USE_CPLUSPLUS_2011', +'log1p.xml#CPPAD_USE_CPLUSPLUS_2011.true', +'log1p.xml#CPPAD_USE_CPLUSPLUS_2011.false', +'log1p.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/log.cpp.xml cppad-2016.00.00.1/doc/log.cpp.xml --- cppad-2015.00.00.9/doc/log.cpp.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/log.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ The AD log Function: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +log_forward + +

+
Logarithm Function Forward Mode Theory
+
+Derivatives +
+If + +F +( +x +) + + + is + +log + +( +x +) + + + or + +log +1 +p + +( +x +) + + + +the corresponding derivative satisfies the equation + + +( +b + +¯ ++ +x +) +* +F +( +1 +) + + +( +x +) +- +0 +* +F +( +x +) += +1 + + +where + + +b + +¯ += +{ +0 + +if + + +F +( +x +) += +log + +( +x +) + +1 + +if + + +F +( +x +) += +log +1 +p + +( +x +) + + + + +In the +standard math function differential equation +, + + +A +( +x +) += +0 + + +, + + +B +( +x +) += +b + +¯ ++ +x + + +, +and + +D +( +x +) += +1 + + +. +We use + +a + + +, + +b + + +, + +d + + +, +and + +z + + + to denote the +Taylor coefficients for + + +A +[ +X +( +t +) +] + + +, + + +B +[ +X +( +t +) +] + + +, + + +D +[ +X +( +t +) +] + + +, +and + +F +[ +X +( +t +) +] + + + respectively. + +
+
+Taylor Coefficients Recursion +
+For orders + +j += +0 +, +1 +, + + + +, + + + +z +( +0 +) + + + += + +F +( +x +( +0 +) + + +) + +e +( +j +) + + + += + +d +( +j +) + + ++ + +k += +0 + +j + + +a +( +j +- +k +) + + +* +z +( +k +) + + + + += + +{ +1 + +if + + +j += +0 + +0 + +otherwise + + + + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +( +k += +1 + +j ++ +1 + + +k +x +( +k +) + + +e +( +j ++ +1 +- +k +) + + +- + +k += +1 + +j + +k +z +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + += + +1 + +j ++ +1 + + +1 + +b + +¯ ++ +x +( +0 +) + + + + +(( +j ++ +1 +) +x +( +j ++ +1 +) + + +- + +k += +1 + +j + +k +z +( +k +) + + +x +( +j ++ +1 +- +k +) + + +) + + + + +
Input File: omh/theory/log_forward.omh + + + diff -Nru cppad-2015.00.00.9/doc/logforward.xml cppad-2016.00.00.1/doc/logforward.xml --- cppad-2015.00.00.9/doc/logforward.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/logforward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,478 +0,0 @@ - - - -Logarithm Function Forward Taylor Polynomial Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -LogForwardHeadings

-
Logarithm Function Forward Taylor Polynomial Theory
-If - -F -( -x -) -= -log -( -x -) - - - - - -x -* -F -( -1 -) - - -( -x -) -- -0 -* -F -( -x -) -= -1 - - -and in the -standard math function differential equation -, - - -A -( -x -) -= -0 - - -, - - -B -( -x -) -= -x - - -, -and - -D -( -x -) -= -1 - - -. -We use - -a - - -, - -b - - -, - -d - - -, -and - -z - - - to denote the -Taylor coefficients for - - -A -[ -X -( -t -) -] - - -, - - -B -[ -X -( -t -) -] - - -, - - -D -[ -X -( -t -) -] - - -, -and - -F -[ -X -( -t -) -] - - - respectively. -It now follows from the general -Taylor coefficients recursion formula - -that for - -j -= -0 -, -1 -, - - - -, - - - -z -( -0 -) - - - -= - -log -( -x -( -0 -) - - -) - -e -( -j -) - - - -= - -d -( -j -) - - -+ - -k -= -0 - -j - - -a -( -j -- -k -) - - -* -z -( -k -) - - - - -= - -{ -1 - -if - - -j -= -0 - -0 - -otherwise - - - - -z -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -( -k -= -1 - -j -+ -1 - - -k -x -( -k -) - - -e -( -j -+ -1 -- -k -) - - -- - -k -= -1 - -j - -k -z -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - -= - -1 - -j -+ -1 - - -1 - -x -( -0 -) - - - - -(( -j -+ -1 -) -x -( -j -+ -1 -) - - -- - -k -= -1 - -j - -k -z -( -k -) - - -x -( -j -+ -1 -- -k -) - - -) - - - - -
Input File: omh/theory/log_forward.omh - - - diff -Nru cppad-2015.00.00.9/doc/_log_forward_xml.js cppad-2016.00.00.1/doc/_log_forward_xml.js --- cppad-2015.00.00.9/doc/_log_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_log_forward_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,89 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'forwardtheory.xml', +'log_forward.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_forward.xml', +'log_forward.xml', +'sqrt_forward.xml', +'sin_cos_forward.xml', +'atan_forward.xml', +'asin_forward.xml', +'acos_forward.xml', +'tan_forward.xml', +'erf_forward.xml' +]; +var list_current0 = [ +'log_forward.xml#Derivatives', +'log_forward.xml#Taylor Coefficients Recursion' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_logforward_xml.js cppad-2016.00.00.1/doc/_logforward_xml.js --- cppad-2015.00.00.9/doc/_logforward_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_logforward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'logforward.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expforward.xml', -'logforward.xml', -'sqrtforward.xml', -'sincosforward.xml', -'atanforward.xml', -'asinforward.xml', -'acosforward.xml', -'tan_forward.xml', -'erf_forward.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/log_reverse.xml cppad-2016.00.00.1/doc/log_reverse.xml --- cppad-2015.00.00.9/doc/log_reverse.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/log_reverse.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,849 @@ + + + +Logarithm Function Reverse Mode Theory + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +log_reverseHeadings

+
Logarithm Function Reverse Mode Theory
+We use the reverse theory +standard math function + +definition for the functions + +H + + + and + +G + + +. + +The zero order forward mode formula for the +logarithm + is + + +z +( +0 +) + + += +F +( +x +( +0 +) + + +) + + +and for + +j +> +0 + + +, + + +z +( +j +) + + += +1 + +b + +¯ ++ +x +( +0 +) + + + + +1 + +j + + +(j +x +( +j +) + + +- + +k += +1 + +j +-1 + + +k +z +( +k +) + + +x +( +j +- +k +) + + +) + + +where + + +b + +¯ += +{ +0 + +if + + +F +( +x +) += +log + +( +x +) + +1 + +if + + +F +( +x +) += +log +1 +p + +( +x +) + + + + +We note that for + +j +> +0 + + + + + + + +z +( +j +) + + + + +x +( +0 +) + + + + + += + +- +1 + +b + +¯ ++ +x +( +0 +) + + + + +1 + +b + +¯ ++ +x +( +0 +) + + + + +1 + +j + + +(j +x +( +j +) + + +- + +k += +1 + +j +-1 + + +k +z +( +k +) + + +x +( +j +- +k +) + + +) + + += + +- +z +( +j +) + + + +b + +¯ ++ +x +( +0 +) + + + + + + + +Removing the zero order partials are given by + + + + +H + + +x +( +0 +) + + + + + += + + +G + + +x +( +0 +) + + + + ++ + +G + + +z +( +0 +) + + + + + +z +( +0 +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +0 +) + + + + ++ + +G + + +z +( +0 +) + + + + +1 + +b + +¯ ++ +x +( +0 +) + + + + + + + +For orders + +j +> +0 + + + and for + +k += +1 +, + +, +j +-1 + + + + + + + +H + + +x +( +0 +) + + + + + += + + +G + + +x +( +0 +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +0 +) + + + + +- + +G + + +z +( +j +) + + + + +z +( +j +) + + + +b + +¯ ++ +x +( +0 +) + + + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +j +) + + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +b + +¯ ++ +x +( +0 +) + + + + + + +H + + +x +( +j +- +k +) + + + + + += + + +G + + +x +( +j +- +k +) + + + + +- + +G + + +z +( +j +) + + + + +1 + +b + +¯ ++ +x +( +0 +) + + + + +k + +j + + +z +( +k +) + + + + +H + + +z +( +k +) + + + + + += + + +G + + +z +( +k +) + + + + +- + +G + + +z +( +j +) + + + + +1 + +b + +¯ ++ +x +( +0 +) + + + + +k + +j + + +x +( +j +- +k +) + + + + + + +
Input File: omh/theory/log_reverse.omh + + + diff -Nru cppad-2015.00.00.9/doc/logreverse.xml cppad-2016.00.00.1/doc/logreverse.xml --- cppad-2015.00.00.9/doc/logreverse.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/logreverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,620 +0,0 @@ - - - -Logarithm Function Reverse Mode Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -LogReverseHeadings

-
Logarithm Function Reverse Mode Theory
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. - -The forward mode formulas for the -logarithm - -function are - - -z -( -j -) - - -= -log -( -x -( -0 -) - - -) - - -for the case - -j -= -0 - - -, and for - -j -> -0 - - -, - - - -z -( -j -) - - -= -1 - -x -( -0 -) - - - - -1 - -j - - -(j -x -( -j -) - - -- - -k -= -1 - -j --1 - - -k -z -( -k -) - - -x -( -j -- -k -) - - -) - - -otherwise. -If - -j -= -0 - - -, we have the relation - - - -H - - -x -( -j -) - - - - -= - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -x -( -0 -) - - - - - - -If - -j -> -0 - - -, then for - -k -= -1 -, - -, -j --1 - - - - - - - - -H - - -x -( -0 -) - - - - - -= - - -G - - -x -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -x -( -0 -) - - - - -1 - -x -( -0 -) - - - - -1 - -j - - -(j -x -( -j -) - - -- - -m -= -1 - -j --1 - - -m -z -( -m -) - - -x -( -j -- -m -) - - -) - - -= - - -G - - -x -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -x -( -0 -) - - - - -z -( -j -) - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -x -( -0 -) - - - - - - -H - - -x -( -j -- -k -) - - - - - -= - - -G - - -x -( -j -- -k -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -x -( -0 -) - - - - -1 - -j - - -k -z -( -k -) - - - - -H - - -z -( -k -) - - - - - -= - - -G - - -z -( -k -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -x -( -0 -) - - - - -1 - -j - - -k -x -( -j -- -k -) - - - - - - -
Input File: omh/theory/log_reverse.omh - - - diff -Nru cppad-2015.00.00.9/doc/_log_reverse_xml.js cppad-2016.00.00.1/doc/_log_reverse_xml.js --- cppad-2015.00.00.9/doc/_log_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_log_reverse_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,85 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'reversetheory.xml', +'log_reverse.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_reverse.xml', +'log_reverse.xml', +'sqrt_reverse.xml', +'sin_cos_reverse.xml', +'atan_reverse.xml', +'asin_reverse.xml', +'acos_reverse.xml', +'tan_reverse.xml', +'erf_reverse.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_logreverse_xml.js cppad-2016.00.00.1/doc/_logreverse_xml.js --- cppad-2015.00.00.9/doc/_logreverse_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_logreverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'logreverse.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expreverse.xml', -'logreverse.xml', -'sqrtreverse.xml', -'sincosreverse.xml', -'atanreverse.xml', -'asinreverse.xml', -'acosreverse.xml', -'tan_reverse.xml', -'erf_reverse.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/log.xml cppad-2016.00.00.1/doc/log.xml --- cppad-2015.00.00.9/doc/log.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/log.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,183 @@ + + + +The Exponential Function: log + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Exponential Function: log
+
+Syntax + +
+ +y = log(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +log + +( +1 +) + + +( +x +) + += + +1 + +x + + + + + +
+Example + +
+The file +log.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_log_xml.js cppad-2016.00.00.1/doc/_log_xml.js --- cppad-2015.00.00.9/doc/_log_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_log_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'log.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'log.cpp.xml' +]; +var list_current0 = [ +'log.xml#Syntax', +'log.xml#x, y', +'log.xml#Atomic', +'log.xml#Derivative', +'log.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/ludetandsolve.xml cppad-2016.00.00.1/doc/ludetandsolve.xml --- cppad-2015.00.00.9/doc/ludetandsolve.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/ludetandsolve.xml 2016-02-09 08:32:06.000000000 +0000 @@ -6,7 +6,7 @@ Compute Determinants and Solve Equations by LU Factorization - + - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - - - -
Other AD Math Functions
-
-Contents -
- -
absAD Absolute Value Function
signSign Function
atan2AD Two Argument Inverse Tangent Function
erfThe AD Error Function
powThe AD Power Function
limitsNumeric Limits For an AD and Base Types
-
Input File: cppad/local/math_other.hpp - - - diff -Nru cppad-2015.00.00.9/doc/_mathother_xml.js cppad-2016.00.00.1/doc/_mathother_xml.js --- cppad-2015.00.00.9/doc/_mathother_xml.js 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/_mathother_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'advalued.xml', -'mathother.xml' -]; -var list_down3 = [ -'install.xml', -'introduction.xml', -'ad.xml', -'adfun.xml', -'preprocessor.xml', -'multi_thread.xml', -'library.xml', -'ipopt_solve.xml', -'example.xml', -'speed.xml', -'appendix.xml' -]; -var list_down2 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down1 = [ -'arithmetic.xml', -'std_math_ad.xml', -'mathother.xml', -'condexp.xml', -'discrete.xml', -'atomic.xml' -]; -var list_down0 = [ -'abs.xml', -'sign.xml', -'atan2.xml', -'erf.xml', -'pow.xml', -'limits.xml' -]; -var list_current0 = [ -'mathother.xml#Contents' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/mat_sum_sq.cpp.xml cppad-2016.00.00.1/doc/mat_sum_sq.cpp.xml --- cppad-2015.00.00.9/doc/mat_sum_sq.cpp.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/mat_sum_sq.cpp.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Sum of the Elements of the Square of a Matrix: Example and Test - + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + +

+
Some Numerical AD Utilities
+The routines listed below are numerical utilities that are +designed to work with CppAD in particular. + +
+
+Contents +
+ +
BenderQuadComputing Jacobian and Hessian of Bender's Reduced Objective
opt_val_hesJacobian and Hessian of Optimal Values
LuRatioLU Factorization of A Square Matrix and Stability Calculation
+
Input File: omh/numeric_ad.omh + + + diff -Nru cppad-2015.00.00.9/doc/_numeric_ad_xml.js cppad-2016.00.00.1/doc/_numeric_ad_xml.js --- cppad-2015.00.00.9/doc/_numeric_ad_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_numeric_ad_xml.js 2016-02-09 08:32:08.000000000 +0000 @@ -0,0 +1,82 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'numeric_ad.xml' +]; +var list_down2 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down1 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down0 = [ +'benderquad.xml', +'opt_val_hes.xml', +'luratio.xml' +]; +var list_current0 = [ +'numeric_ad.xml#Contents' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/numeric_limits.xml cppad-2016.00.00.1/doc/numeric_limits.xml --- cppad-2015.00.00.9/doc/numeric_limits.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/numeric_limits.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,283 @@ + + + +Numeric Limits For an AD and Base Types + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
Numeric Limits For an AD and Base Types
+
+Syntax + +
+ +eps = numeric_limits<Float>::epsilon()
+
+ +min = numeric_limits<Float>::min()
+
+ +max = numeric_limits<Float>::max()
+
+ +nan = numeric_limits<Float>::quiet_NaN()
+
+
+CppAD::numeric_limits +
+These functions and have the prototype + +
+     static 
Float CppAD::numeric_limits<Float>::fun(void)
+
+where +fun + is +epsilon, min, max, and quiet_NaN. + +
+
+std::numeric_limits +
+CppAD does not use a specialization of std::numeric_limits +because this would be to restrictive. +The C++ standard specifies that Non-fundamental standard +types, such as +std::complex<double> + shall not have specializations +of std::numeric_limits; see Section 18.2 of +ISO/IEC 14882:1998(E). +In addition, since C++11, a only literal types can have a specialization +of std::numeric_limits. + +
+
+Float +
+These functions are defined for all +AD<Base> +, +and for all corresponding +Base + types; +see +Base + type base_limits +. + +
+
+epsilon +
+The result +eps + is equal to machine epsilon and has prototype + +
+     
Float eps
+
+The file num_limits.cpp + +tests the value +eps + by checking that the following are true + +
+     1 != 1 + 
eps
+     1 == 1 + 
eps / 2
+
+where all the values, and calculations, are done with the precision +corresponding to +Float +. + +
+
+min +
+The result +min + is equal to +the minimum positive normalized value and has prototype + +
+     
Float min
+
+The file num_limits.cpp + +tests the value +min + by checking that the following are true + +
+     abs( ((
min / 100) * 100) / min - 1 ) > 3 * eps
+     abs( ((
min * 100) / 100) / min - 1 ) < 3 * eps
+
+where all the values, and calculations, are done with the precision +corresponding to +Float +. + +
+
+max +
+The result +max + is equal to +the maximum finite value and has prototype + +
+     
Float max
+
+The file num_limits.cpp + +tests the value +max + by checking that the following are true + +
+     abs( ((
max * 100) / 100) / max - 1 ) > 3 * eps
+     abs( ((
max / 100) * 100) / max - 1 ) < 3 * eps
+
+where all the values, and calculations, are done with the precision +corresponding to +Float +. + +
+
+quiet_NaN +
+The result +nan + is not a number and has prototype + +
+     
Float nan
+
+The file num_limits.cpp + +tests the value +nan + by checking that the following is true + +
+     
nan != nan
+
+
+Example + +
+The file +num_limits.cpp + +contains an example and test of these functions. + + +
Input File: cppad/local/numeric_limits.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_numeric_limits_xml.js cppad-2016.00.00.1/doc/_numeric_limits_xml.js --- cppad-2015.00.00.9/doc/_numeric_limits_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_numeric_limits_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,100 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'numeric_limits.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down1 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down0 = [ +'num_limits.cpp.xml' +]; +var list_current0 = [ +'numeric_limits.xml#Syntax', +'numeric_limits.xml#CppAD::numeric_limits', +'numeric_limits.xml#std::numeric_limits', +'numeric_limits.xml#Float', +'numeric_limits.xml#epsilon', +'numeric_limits.xml#min', +'numeric_limits.xml#max', +'numeric_limits.xml#quiet_NaN', +'numeric_limits.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/numeric_type.cpp.xml cppad-2016.00.00.1/doc/numeric_type.cpp.xml --- cppad-2015.00.00.9/doc/numeric_type.cpp.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/numeric_type.cpp.xml 2016-02-09 08:32:06.000000000 +0000 @@ -6,7 +6,7 @@ The NumericType: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +num_limits.cppHeadings

+ + + +
Numeric Limits: Example and Test
+
 
+
+# ifdef _MSC_VER
+// Supress Microsoft compiler warning about possible loss of precision,
+// in the constructors (when converting to std::complex<float>)
+//	Float one = 1
+//	Float two = 2
+// 1 and 2 are small enough so no loss of precision when converting to float.
+# pragma warning(disable:4244)
+# endif
+
+# include <cppad/cppad.hpp>
+# include <complex>
+
+namespace {
+	typedef CppAD::AD<double> Float;
+	//
+	// -----------------------------------------------------------------
+	bool check_epsilon(void)
+	{	bool ok    = true;
+		Float eps   = CppAD::numeric_limits<Float>::epsilon();
+		Float eps2  = eps / 2.0;
+		Float check = 1.0 + eps;
+		ok         &= 1.0 !=  check;
+		check       = 1.0 + eps2;
+		ok         &= 1.0 == check;
+		return ok;
+	}
+	// -----------------------------------------------------------------
+	bool check_min(void)
+	{	bool ok     = true;
+		Float min   = CppAD::numeric_limits<Float>::min();
+		Float eps   = CppAD::numeric_limits<Float>::epsilon();
+		//
+		Float match = (min / 100.) * 100.;
+		ok         &= abs(match / min - 1.0)  > 3.0 * eps;
+		//
+		match       = (min * 100.) / 100.;
+		ok         &= abs(match / min - 1.0)  < 3.0 * eps;
+		return ok;
+	}
+	// -----------------------------------------------------------------
+	bool check_max(void)
+	{	bool ok     = true;
+		Float max   = CppAD::numeric_limits<Float>::max();
+		Float eps   = CppAD::numeric_limits<Float>::epsilon();
+		//
+		Float match = (max * 100.) / 100.;
+		ok         &= abs(match / max - 1.0) > 3.0 * eps;
+		//
+		match       = (max / 100.) * 100.;
+		ok         &= abs(match / max - 1.0) < 3.0 * eps;
+		return ok;
+	}
+	// -----------------------------------------------------------------
+	bool check_nan(void)
+	{	bool ok     = true;
+		Float nan   = CppAD::numeric_limits<Float>::quiet_NaN();
+		ok         &= nan != nan;
+		return ok;
+	}
+}
+
+bool num_limits(void)
+{	bool ok = true;
+
+	ok &= check_epsilon();
+	ok &= check_min();
+	ok &= check_max();
+	ok &= check_nan();
+
+	return ok;
+}
+
+ +
+ + +
Input File: example/num_limits.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_num_limits.cpp_xml.js cppad-2016.00.00.1/doc/_num_limits.cpp_xml.js --- cppad-2015.00.00.9/doc/_num_limits.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_num_limits.cpp_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,77 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'numeric_limits.xml', +'num_limits.cpp.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'num_limits.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/ode_err_control.cpp.xml cppad-2016.00.00.1/doc/ode_err_control.cpp.xml --- cppad-2015.00.00.9/doc/ode_err_control.cpp.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/ode_err_control.cpp.xml 2016-02-09 08:32:06.000000000 +0000 @@ -6,7 +6,7 @@ OdeErrControl: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +sin_cos_forward + +

+
Trigonometric and Hyperbolic Sine and Cosine Forward Theory
+
+Differential Equation +
+The +standard math function differential equation + +is + + +B +( +u +) +* +F +( +1 +) + + +( +u +) +- +A +( +u +) +* +F +( +u +) += +D +( +u +) + + +In this sections we consider forward mode for the following choices: + + +
+ +     + + + + +F +( +u +) + + + + + + + +sin +( +u +) + + + + + + + +cos +( +u +) + + + + + + + +sinh +( +u +) + + + + + + + +cosh +( +u +) + + + +
+ + + + + +A +( +u +) + + + + + + + +0 + + + + + + + +0 + + + + + + + +0 + + + + + + + +0 + + + +
+ + + + + +B +( +u +) + + + + + + + +1 + + + + + + + +1 + + + + + + + +1 + + + + + + + +1 + + + +
+ + + + + +D +( +u +) + + + + + + + +cos +( +u +) + + + + + + + +- +sin +( +u +) + + + + + + + +cosh +( +u +) + + + + + + + +sinh +( +u +) + + + +
+We use + +a + + +, + +b + + +, + +d + + + and + +f + + + for the +Taylor coefficients of + + +A +[ +X +( +t +) +] + + +, + + +B +[ +X +( +t +) +] + + +, + + +D +[ +X +( +t +) +] + + +, +and + +F +[ +X +( +t +) +] + + + respectively. +It now follows from the general +Taylor coefficients recursion formula + +that for + +j += +0 +, +1 +, + + + +, + + + +f +( +0 +) + + + += + +D +( +x +( +0 +) + + +) + +e +( +j +) + + + += + +d +( +j +) + + ++ + +k += +0 + +j + + +a +( +j +- +k +) + + +* +f +( +k +) + + + + += + +d +( +j +) + + + +f +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +( +k += +1 + +j ++ +1 + + +k +x +( +k +) + + +e +( +j ++ +1 +- +k +) + + +- + +k += +1 + +j + +k +f +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + += + +1 + +j ++ +1 + + + +k += +1 + +j ++ +1 + + +k +x +( +k +) + + +d +( +j ++ +1 +- +k +) + + + + + +The formula above generates the +order + +j ++ +1 + + + coefficient of + +F +[ +X +( +t +) +] + + + from the +lower order coefficients for + +X +( +t +) + + + and + +D +[ +X +( +t +) +] + + +. + + +
Input File: omh/theory/sin_cos_forward.omh + + + diff -Nru cppad-2015.00.00.9/doc/sincosforward.xml cppad-2016.00.00.1/doc/sincosforward.xml --- cppad-2015.00.00.9/doc/sincosforward.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/sincosforward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,667 +0,0 @@ - - - -Trigonometric and Hyperbolic Sine and Cosine Forward Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -SinCosForward - -

-
Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-
-Differential Equation -
-The -standard math function differential equation - -is - - -B -( -u -) -* -F -( -1 -) - - -( -u -) -- -A -( -u -) -* -F -( -u -) -= -D -( -u -) - - -In this sections we consider forward mode for the following choices: - - -
- -     - - - - -F -( -u -) - - - - - - - -sin -( -u -) - - - - - - - -cos -( -u -) - - - - - - - -sinh -( -u -) - - - - - - - -cosh -( -u -) - - - -
- - - - - -A -( -u -) - - - - - - - -0 - - - - - - - -0 - - - - - - - -0 - - - - - - - -0 - - - -
- - - - - -B -( -u -) - - - - - - - -1 - - - - - - - -1 - - - - - - - -1 - - - - - - - -1 - - - -
- - - - - -D -( -u -) - - - - - - - -cos -( -u -) - - - - - - - -- -sin -( -u -) - - - - - - - -cosh -( -u -) - - - - - - - -sinh -( -u -) - - - -
-We use - -a - - -, - -b - - -, - -d - - - and - -f - - - for the -Taylor coefficients of - - -A -[ -X -( -t -) -] - - -, - - -B -[ -X -( -t -) -] - - -, - - -D -[ -X -( -t -) -] - - -, -and - -F -[ -X -( -t -) -] - - - respectively. -It now follows from the general -Taylor coefficients recursion formula - -that for - -j -= -0 -, -1 -, - - - -, - - - -f -( -0 -) - - - -= - -D -( -x -( -0 -) - - -) - -e -( -j -) - - - -= - -d -( -j -) - - -+ - -k -= -0 - -j - - -a -( -j -- -k -) - - -* -f -( -k -) - - - - -= - -d -( -j -) - - - -f -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -( -k -= -1 - -j -+ -1 - - -k -x -( -k -) - - -e -( -j -+ -1 -- -k -) - - -- - -k -= -1 - -j - -k -f -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - -= - -1 - -j -+ -1 - - - -k -= -1 - -j -+ -1 - - -k -x -( -k -) - - -d -( -j -+ -1 -- -k -) - - - - - -The formula above generates the -order - -j -+ -1 - - - coefficient of - -F -[ -X -( -t -) -] - - - from the -lower order coefficients for - -X -( -t -) - - - and - -D -[ -X -( -t -) -] - - -. - - -
Input File: omh/theory/sin_cos_forward.omh - - - diff -Nru cppad-2015.00.00.9/doc/_sin_cos_forward_xml.js cppad-2016.00.00.1/doc/_sin_cos_forward_xml.js --- cppad-2015.00.00.9/doc/_sin_cos_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sin_cos_forward_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,88 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'forwardtheory.xml', +'sin_cos_forward.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_forward.xml', +'log_forward.xml', +'sqrt_forward.xml', +'sin_cos_forward.xml', +'atan_forward.xml', +'asin_forward.xml', +'acos_forward.xml', +'tan_forward.xml', +'erf_forward.xml' +]; +var list_current0 = [ +'sin_cos_forward.xml#Differential Equation' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_sincosforward_xml.js cppad-2016.00.00.1/doc/_sincosforward_xml.js --- cppad-2015.00.00.9/doc/_sincosforward_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sincosforward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'sincosforward.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expforward.xml', -'logforward.xml', -'sqrtforward.xml', -'sincosforward.xml', -'atanforward.xml', -'asinforward.xml', -'acosforward.xml', -'tan_forward.xml', -'erf_forward.xml' -]; -var list_current0 = [ -'sincosforward.xml#Differential Equation' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/sin_cos_reverse.xml cppad-2016.00.00.1/doc/sin_cos_reverse.xml --- cppad-2015.00.00.9/doc/sin_cos_reverse.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/sin_cos_reverse.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,748 @@ + + + +Trigonometric and Hyperbolic Sine and Cosine Reverse Theory + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +sin_cos_reverseHeadings

+
Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
+We use the reverse theory +standard math function + +definition for the functions + +H + + + and + +G + + +. +In addition, +we use the following definitions for + +s + + + and + +c + + + +and the integer + + + + + + + +
+ +Coefficients + + + + +s + + + + + + + +c + + + + + + + + + + + +
+ +Trigonometric Case + + + + +sin +[ +X +( +t +) +] + + + + + + + +cos +[ +X +( +t +) +] + + + + + + 1 +
+ +Hyperbolic Case + + + + +sinh +[ +X +( +t +) +] + + + + + + + +cosh +[ +X +( +t +) +] + + + + + + -1 +
+We use the value + + +z +( +j +) + + += +( +s +( +j +) + + +, +c +( +j +) + + +) + + +in the definition for + +G + + + and + +H + + +. +The forward mode formulas for the +sine and cosine + functions are + + + +s +( +j +) + + + += + +1 ++ + + +2 + + +sin +( +x +( +0 +) + + +) ++ +1 +- + + +2 + + +sinh +( +x +( +0 +) + + +) + +c +( +j +) + + + += + +1 ++ + + +2 + + +cos +( +x +( +0 +) + + +) ++ +1 +- + + +2 + + +cosh +( +x +( +0 +) + + +) + + + +for the case + +j += +0 + + +, and for + +j +> +0 + + +, + + + + +s +( +j +) + + + += + +1 + +j + + + +k += +1 + +j + + +k +x +( +k +) + + +c +( +j +- +k +) + + + +c +( +j +) + + + += + + +1 + +j + + + +k += +1 + +j + + +k +x +( +k +) + + +s +( +j +- +k +) + + + + + +If + +j += +0 + + +, we have the relation + + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +s +( +j +) + + + + +c +( +0 +) + + ++ + + +G + + +c +( +j +) + + + + +s +( +0 +) + + + + + +If + +j +> +0 + + +, then for + +k += +1 +, + +, +j +-1 + + + + + + + + +H + + +x +( +k +) + + + + + += + + +G + + +x +( +k +) + + + + ++ + +G + + +s +( +j +) + + + + +1 + +j + + +k +c +( +j +- +k +) + + ++ + + +G + + +c +( +j +) + + + + +1 + +j + + +k +s +( +j +- +k +) + + + + +H + + +s +( +j +- +k +) + + + + + += + + +G + + +s +( +j +- +k +) + + + + ++ + + +G + + +c +( +j +) + + + + +k +x +( +k +) + + + + +H + + +c +( +j +- +k +) + + + + + += + + +G + + +c +( +j +- +k +) + + + + ++ + +G + + +s +( +j +) + + + + +k +x +( +k +) + + + + + + +
Input File: omh/theory/sin_cos_reverse.omh + + + diff -Nru cppad-2015.00.00.9/doc/sincosreverse.xml cppad-2016.00.00.1/doc/sincosreverse.xml --- cppad-2015.00.00.9/doc/sincosreverse.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/sincosreverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,747 +0,0 @@ - - - -Trigonometric and Hyperbolic Sine and Cosine Reverse Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -SinCosReverseHeadings

-
Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. -In addition, -we use the following definitions for - -s - - - and - -c - - - -and the integer - - - - - - - -
- -Coefficients - - - - -s - - - - - - - -c - - - - - - - - - - - -
- -Trigonometric Case - - - - -sin -[ -X -( -t -) -] - - - - - - - -cos -[ -X -( -t -) -] - - - - - - 1 -
- -Hyperbolic Case - - - - -sinh -[ -X -( -t -) -] - - - - - - - -cosh -[ -X -( -t -) -] - - - - - - -1 -
-We use the value - - -z -( -j -) - - -= -( -s -( -j -) - - -, -c -( -j -) - - -) - - -in the definition for - -G - - - and - -H - - -. -The forward mode formulas for the -sine and cosine - functions are - - - -s -( -j -) - - - -= - -1 -+ - - -2 - - -sin -( -x -( -0 -) - - -) -+ -1 -- - - -2 - - -sinh -( -x -( -0 -) - - -) - -c -( -j -) - - - -= - -1 -+ - - -2 - - -cos -( -x -( -0 -) - - -) -+ -1 -- - - -2 - - -cosh -( -x -( -0 -) - - -) - - - -for the case - -j -= -0 - - -, and for - -j -> -0 - - -, - - - - -s -( -j -) - - - -= - -1 - -j - - - -k -= -1 - -j - - -k -x -( -k -) - - -c -( -j -- -k -) - - - -c -( -j -) - - - -= - - -1 - -j - - - -k -= -1 - -j - - -k -x -( -k -) - - -s -( -j -- -k -) - - - - - -If - -j -= -0 - - -, we have the relation - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -s -( -j -) - - - - -c -( -0 -) - - -+ - - -G - - -c -( -j -) - - - - -s -( -0 -) - - - - - -If - -j -> -0 - - -, then for - -k -= -1 -, - -, -j --1 - - - - - - - - -H - - -x -( -k -) - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -s -( -j -) - - - - -1 - -j - - -k -c -( -j -- -k -) - - -+ - - -G - - -c -( -j -) - - - - -1 - -j - - -k -s -( -j -- -k -) - - - - -H - - -s -( -j -- -k -) - - - - - -= - - -G - - -s -( -j -- -k -) - - - - -+ - - -G - - -c -( -j -) - - - - -k -x -( -k -) - - - - -H - - -c -( -j -- -k -) - - - - - -= - - -G - - -c -( -j -- -k -) - - - - -+ - -G - - -s -( -j -) - - - - -k -x -( -k -) - - - - - - -
Input File: omh/theory/sin_cos_reverse.omh - - - diff -Nru cppad-2015.00.00.9/doc/_sin_cos_reverse_xml.js cppad-2016.00.00.1/doc/_sin_cos_reverse_xml.js --- cppad-2015.00.00.9/doc/_sin_cos_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sin_cos_reverse_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,85 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'reversetheory.xml', +'sin_cos_reverse.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_reverse.xml', +'log_reverse.xml', +'sqrt_reverse.xml', +'sin_cos_reverse.xml', +'atan_reverse.xml', +'asin_reverse.xml', +'acos_reverse.xml', +'tan_reverse.xml', +'erf_reverse.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_sincosreverse_xml.js cppad-2016.00.00.1/doc/_sincosreverse_xml.js --- cppad-2015.00.00.9/doc/_sincosreverse_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sincosreverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'sincosreverse.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expreverse.xml', -'logreverse.xml', -'sqrtreverse.xml', -'sincosreverse.xml', -'atanreverse.xml', -'asinreverse.xml', -'acosreverse.xml', -'tan_reverse.xml', -'erf_reverse.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/sin.cpp.xml cppad-2016.00.00.1/doc/sin.cpp.xml --- cppad-2015.00.00.9/doc/sin.cpp.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/sin.cpp.xml 2016-02-09 08:32:05.000000000 +0000 @@ -6,7 +6,7 @@ The AD sin Function: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Hyperbolic Sine Function: sinh
+
+Syntax + +
+ +y = sinh(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +sinh + +( +1 +) + + +( +x +) + += + +cosh +( +x +) + + + +
+Example + +
+The file +sinh.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_sinh_xml.js cppad-2016.00.00.1/doc/_sinh_xml.js --- cppad-2015.00.00.9/doc/_sinh_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sinh_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'sinh.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'sinh.cpp.xml' +]; +var list_current0 = [ +'sinh.xml#Syntax', +'sinh.xml#x, y', +'sinh.xml#Atomic', +'sinh.xml#Derivative', +'sinh.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/sin.xml cppad-2016.00.00.1/doc/sin.xml --- cppad-2015.00.00.9/doc/sin.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/sin.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,182 @@ + + + +The Sine Function: sin + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Sine Function: sin
+
+Syntax + +
+ +y = sin(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +sin + +( +1 +) + + +( +x +) + += + +cos +( +x +) + + + +
+Example + +
+The file +sin.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_sin_xml.js cppad-2016.00.00.1/doc/_sin_xml.js --- cppad-2015.00.00.9/doc/_sin_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sin_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'sin.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'sin.cpp.xml' +]; +var list_current0 = [ +'sin.xml#Syntax', +'sin.xml#x, y', +'sin.xml#Atomic', +'sin.xml#Derivative', +'sin.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/size_order.xml cppad-2016.00.00.1/doc/size_order.xml --- cppad-2015.00.00.9/doc/size_order.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/size_order.xml 2016-02-09 08:32:06.000000000 +0000 @@ -23,7 +23,7 @@ Prev -Next +Next @@ -124,8 +124,8 @@ Determine the number of Taylor coefficient orders, per variable,direction, currently calculated and stored in the ADFun object f -. -See the discussion under +. +See the discussion under Constructor , Forward @@ -156,7 +156,7 @@
     size_t 
s
-and is the number of Taylor coefficient orders, +and is the number of Taylor coefficient orders, per variable,direction in the AD operation sequence, currently calculated and stored in the ADFun object f @@ -191,7 +191,7 @@
the value of s - returned by size_order + returned by size_order would be q @@ -201,7 +201,7 @@ . The call to Forward above -uses the lower order Taylor coefficients to compute and store +uses the lower order Taylor coefficients to compute and store the q-th order Taylor coefficients for all the variables in the operation sequence corresponding to f @@ -230,7 +230,7 @@ f is less than or equal c -, +, a call to capacity_order with the syntax @@ -253,7 +253,7 @@ -1 - + have been retained).
diff -Nru cppad-2015.00.00.9/doc/_size_order_xml.js cppad-2016.00.00.1/doc/_size_order_xml.js --- cppad-2015.00.00.9/doc/_size_order_xml.js 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/_size_order_xml.js 2016-02-09 08:32:06.000000000 +0000 @@ -36,7 +36,7 @@ 'forward_order.xml', 'forward_dir.xml', 'size_order.xml', -'comparechange.xml', +'compare_change.xml', 'capacity_order.xml', 'number_skip.xml' ]; diff -Nru cppad-2015.00.00.9/doc/sparse_hes_fun.cpp.xml cppad-2016.00.00.1/doc/sparse_hes_fun.cpp.xml --- cppad-2015.00.00.9/doc/sparse_hes_fun.cpp.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/sparse_hes_fun.cpp.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ sparse_hes_fun: Example and test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +sparse_sub_hes.cpp + +

+ + + +
Sparse Hessian on Subset of Variables: Example and Test
+
+Purpose +
+This example uses a subset of the sparsity pattern, +to compute the Hessian for a subset of the variables, +without having to compute the sparsity pattern for the entire function. + +
+
+See Also + +
+sub_sparse_hes.cpp + + + +
 
+# include <cppad/cppad.hpp>
+bool sparse_sub_hes(void)
+{	bool ok = true;
+	using CppAD::AD;
+	typedef CppAD::vector< double >                   d_vector;
+	typedef CppAD::vector< AD<double> >               a_vector;
+	typedef CppAD::vector<size_t>                     i_vector;
+	typedef CppAD::vector< std::set<size_t> >         s_vector;
+
+	// domain space vector
+	size_t n = 12;  // must be greater than or equal 3; see n_sweep below
+	a_vector a_x(n);
+	for(size_t j = 0; j < n; j++)
+		a_x[j] = AD<double> (0);
+
+	// declare independent variables and starting recording
+	CppAD::Independent(a_x);
+
+	// range space vector
+	size_t m = 1;
+	a_vector a_y(m);
+	a_y[0] = 0.0;
+	for(size_t j = 1; j < n; j++)
+		a_y[0] += a_x[j-1] * a_x[j] * a_x[j];
+
+	// create f: x -> y and stop tape recording
+	// (without executing zero order forward calculation)
+	CppAD::ADFun<double> f;
+	f.Dependent(a_x, a_y);
+
+	// sparsity patteren for the sub-set of variables we are computing
+	// the hessian w.r.t.
+	size_t n_sub = 4;
+	s_vector r(n);
+	for(size_t j = 0; j < n_sub; j++)
+	{	assert(  r[j].empty() );
+		r[j].insert(j);
+	}
+
+	// store forward sparsity for J(x) = F^{(1)} (x) * R
+	f.ForSparseJac(n_sub, r);
+
+	// compute sparsity pattern for H(x) = (S * F)^{(2)} ( x ) * R
+	s_vector s(1);
+	assert(  s[0].empty() );
+	s[0].insert(0);
+	bool transpose = true;
+	s_vector h = f.RevSparseHes(n_sub, s, transpose);
+
+	// check sparsity pattern
+	for(size_t i = 0; i < n; i++)
+	{	std::set<size_t> check;
+		assert( check.empty() );
+		if( i <= n_sub )
+		{	if( i == 0 )
+				check.insert(1);
+			else
+			{	check.insert(i-1);
+				if( i < n_sub )
+					check.insert(i);
+				if( i + 1 < n_sub)
+					check.insert(i+1);
+			}
+		}
+		ok &= h[i] == check;
+	}
+
+	// set the row and column indices that correspond to lower triangle
+	i_vector row, col;
+	for(size_t i = 0; i < n_sub; i++)
+	{	std::set<size_t>::iterator itr;
+		for(itr = h[i].begin(); itr != h[i].end(); itr++)
+		{	if( *itr <= i )
+			{	row.push_back( i );
+				col.push_back( *itr );
+			}
+		}
+	}
+
+	// weighting for the Hessian
+	d_vector w(1);
+	w[0] = 1.0;
+
+	// compute Hessian
+	CppAD::sparse_hessian_work work;
+	d_vector x(n), hes( row.size() );
+	for(size_t j = 0; j < n; j++)
+		x[j] = double(j+1);
+	f.SparseHessian(x, w, h, row, col, hes, work);
+
+	// check the values in the sparse hessian
+	for(size_t ell = 0; ell < row.size(); ell++)
+	{	size_t i = row[ell];
+		size_t j = col[ell];
+		if( i == j )
+			ok &= hes[ell] == 2.0 * x[i-1];
+		else
+		{	ok &= j+1 == i;
+			ok &= hes[ell] == 2.0 * x[i];
+		}
+		ell++;
+	}
+	return ok;
+}
+
+ +
+ + +
Input File: example/sparse_sub_hes.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_sparse_sub_hes.cpp_xml.js cppad-2016.00.00.1/doc/_sparse_sub_hes.cpp_xml.js --- cppad-2015.00.00.9/doc/_sparse_sub_hes.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sparse_sub_hes.cpp_xml.js 2016-02-09 08:32:06.000000000 +0000 @@ -0,0 +1,87 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'adfun.xml', +'drivers.xml', +'sparse_hessian.xml', +'sparse_sub_hes.cpp.xml' +]; +var list_down3 = [ +'independent.xml', +'funconstruct.xml', +'dependent.xml', +'abort_recording.xml', +'seq_property.xml', +'funeval.xml', +'drivers.xml', +'funcheck.xml', +'optimize.xml', +'check_for_nan.xml' +]; +var list_down2 = [ +'jacobian.xml', +'forone.xml', +'revone.xml', +'hessian.xml', +'fortwo.xml', +'revtwo.xml', +'sparse_jacobian.xml', +'sparse_hessian.xml' +]; +var list_down1 = [ +'sparse_hessian.cpp.xml', +'sub_sparse_hes.cpp.xml', +'sparse_sub_hes.cpp.xml' +]; +var list_current0 = [ +'sparse_sub_hes.cpp.xml#Purpose', +'sparse_sub_hes.cpp.xml#See Also' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/sparse.xml cppad-2016.00.00.1/doc/sparse.xml --- cppad-2015.00.00.9/doc/sparse.xml 2015-02-24 08:31:51.000000000 +0000 +++ cppad-2016.00.00.1/doc/sparse.xml 2016-02-09 08:32:06.000000000 +0000 @@ -6,7 +6,7 @@ Calculating Sparsity Patterns - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +sparsity_sub.cpp + +

+ + + +
Sparsity Patterns For a Subset of Variables: Example and Test
+
+See Also + +
+sparse_sub_hes.cpp +, sub_sparse_hes.cpp +. + +
+
+ForSparseJac +
+The routine ForSparseJac + is used to compute the +sparsity for both the full Jacobian (see +s +) +and a subset of the Jacobian (see +s2 +). + +
+
+RevSparseHes +
+The routine RevSparseHes + is used to compute both +sparsity for both the full Hessian (see +h +) +and a subset of the Hessian (see +h2 +). + + +
 
+# include <cppad/cppad.hpp>
+
+bool sparsity_sub(void)
+{	// C++ source code
+	bool ok = true;
+	//
+	using std::cout;
+	using CppAD::vector;
+	using CppAD::AD;
+	using CppAD::vectorBool;
+
+	size_t n = 4;
+	size_t m = n-1;
+	vector< AD<double> > ax(n), ay(m);
+	for(size_t j = 0; j < n; j++)
+		ax[j] = double(j+1);
+	CppAD::Independent(ax);
+	for(size_t i = 0; i < m; i++)
+		ay[i] = (ax[i+1] - ax[i]) * (ax[i+1] - ax[i]);
+	CppAD::ADFun<double> f(ax, ay);
+
+	// Evaluate the full Jacobian sparsity pattern for f
+	vectorBool r(n * n), s(m * n);
+	for(size_t j = 0 ; j < n; j++)
+	{	for(size_t i = 0; i < n; i++)
+			r[i * n + j] = (i == j);
+	}
+	s = f.ForSparseJac(n, r);
+
+	// evaluate the sparsity for the Hessian of f_0 + ... + f_{m-1}
+	vectorBool t(m), h(n * n);
+	for(size_t i = 0; i < m; i++)
+		t[i] = true;
+	h = f.RevSparseHes(n, t);
+
+	// evaluate the Jacobian sparsity pattern for first n/2 components of x
+	size_t n2 = n / 2;
+	vectorBool r2(n * n2), s2(m * n2);
+	for(size_t j = 0 ; j < n2; j++)
+	{	for(size_t i = 0; i < n; i++)
+			r2[i * n2 + j] = (i == j);
+	}
+	s2 = f.ForSparseJac(n2, r2);
+
+	// evaluate the sparsity for the subset of Hessian of
+	// f_0 + ... + f_{m-1} where first partial has only first n/2 components
+	vectorBool h2(n2 * n);
+	h2 = f.RevSparseHes(n2, t);
+
+	// check sparsity pattern for Jacobian
+	for(size_t i = 0; i < m; i++)
+	{	for(size_t j = 0; j < n2; j++)
+			ok &= s2[i * n2 + j] == s[i * n + j];
+	}
+
+	// check sparsity pattern for Hessian
+	for(size_t i = 0; i < n2; i++)
+	{	for(size_t j = 0; j < n; j++)
+			ok &= h2[i * n + j] == h[i * n + j];
+	}
+	return ok;
+}
+
+ +
+ + +
Input File: example/sparsity_sub.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_sparsity_sub.cpp_xml.js cppad-2016.00.00.1/doc/_sparsity_sub.cpp_xml.js --- cppad-2015.00.00.9/doc/_sparsity_sub.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sparsity_sub.cpp_xml.js 2016-02-09 08:32:06.000000000 +0000 @@ -0,0 +1,78 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'adfun.xml', +'funeval.xml', +'sparse.xml', +'revsparsehes.xml', +'sparsity_sub.cpp.xml' +]; +var list_down3 = [ +'forward.xml', +'reverse.xml', +'sparse.xml' +]; +var list_down2 = [ +'forsparsejac.xml', +'revsparsejac.xml', +'dependency.cpp.xml', +'revsparsehes.xml', +'bool_sparsity.cpp.xml' +]; +var list_down1 = [ +'rev_sparse_hes.cpp.xml', +'sparsity_sub.cpp.xml' +]; +var list_current0 = [ +'sparsity_sub.cpp.xml#See Also', +'sparsity_sub.cpp.xml#ForSparseJac', +'sparsity_sub.cpp.xml#RevSparseHes' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/speed_adolc.xml cppad-2016.00.00.1/doc/speed_adolc.xml --- cppad-2015.00.00.9/doc/speed_adolc.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/speed_adolc.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Speed Test of Derivatives Using Adolc - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +sqrt_forwardHeadings

+
Square Root Function Forward Mode Theory
+If + +F +( +x +) += +x + + + + + + + +F +( +x +) +* +F +( +1 +) + + +( +x +) +- +0 +* +F +( +x +) += +1 +/ +2 + + +and in the +standard math function differential equation +, + + +A +( +x +) += +0 + + +, + + +B +( +x +) += +F +( +x +) + + +, +and + +D +( +x +) += +1 +/ +2 + + +. +We use + +a + + +, + +b + + +, + +d + + +, +and + +z + + + to denote the +Taylor coefficients for + + +A +[ +X +( +t +) +] + + +, + + +B +[ +X +( +t +) +] + + +, + + +D +[ +X +( +t +) +] + + +, +and + +F +[ +X +( +t +) +] + + + respectively. +It now follows from the general +Taylor coefficients recursion formula + +that for + +j += +0 +, +1 +, + + + +, + + + +z +( +0 +) + + + += + +x +( +0 +) + + + + + +e +( +j +) + + + += + +d +( +j +) + + ++ + +k += +0 + +j + + +a +( +j +- +k +) + + +* +z +( +k +) + + + + += + +{ +1 +/ +2 + +if + + +j += +0 + +0 + +otherwise + + + + +z +( +j ++ +1 +) + + + += + +1 + +j ++ +1 + + +1 + +b +( +0 +) + + + + +( +k += +1 + +j ++ +1 + + +k +x +( +k +) + + +e +( +j ++ +1 +- +k +) + + +- + +k += +1 + +j + +k +z +( +k +) + + +b +( +j ++ +1 +- +k +) + + +) + + += + +1 + +j ++ +1 + + +1 + +z +( +0 +) + + + + +(j ++ +1 + +2 + + +x +( +j ++ +1 +) + + +- + +k += +1 + +j + +k +z +( +k +) + + +z +( +j ++ +1 +- +k +) + + +) + + + + +
Input File: omh/theory/sqrt_forward.omh + + + diff -Nru cppad-2015.00.00.9/doc/sqrtforward.xml cppad-2016.00.00.1/doc/sqrtforward.xml --- cppad-2015.00.00.9/doc/sqrtforward.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/sqrtforward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,490 +0,0 @@ - - - -Square Root Function Forward Taylor Polynomial Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -SqrtForwardHeadings

-
Square Root Function Forward Taylor Polynomial Theory
-If - -F -( -x -) -= -x - - - - - - - -F -( -x -) -* -F -( -1 -) - - -( -x -) -- -0 -* -F -( -x -) -= -1 -/ -2 - - -and in the -standard math function differential equation -, - - -A -( -x -) -= -0 - - -, - - -B -( -x -) -= -F -( -x -) - - -, -and - -D -( -x -) -= -1 -/ -2 - - -. -We use - -a - - -, - -b - - -, - -d - - -, -and - -z - - - to denote the -Taylor coefficients for - - -A -[ -X -( -t -) -] - - -, - - -B -[ -X -( -t -) -] - - -, - - -D -[ -X -( -t -) -] - - -, -and - -F -[ -X -( -t -) -] - - - respectively. -It now follows from the general -Taylor coefficients recursion formula - -that for - -j -= -0 -, -1 -, - - - -, - - - -z -( -0 -) - - - -= - -x -( -0 -) - - - - - -e -( -j -) - - - -= - -d -( -j -) - - -+ - -k -= -0 - -j - - -a -( -j -- -k -) - - -* -z -( -k -) - - - - -= - -{ -1 -/ -2 - -if - - -j -= -0 - -0 - -otherwise - - - - -z -( -j -+ -1 -) - - - -= - -1 - -j -+ -1 - - -1 - -b -( -0 -) - - - - -( -k -= -1 - -j -+ -1 - - -k -x -( -k -) - - -e -( -j -+ -1 -- -k -) - - -- - -k -= -1 - -j - -k -z -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - -= - -1 - -j -+ -1 - - -1 - -z -( -0 -) - - - - -(j -+ -1 - -2 - - -x -( -j -+ -1 -) - - -- - -k -= -1 - -j - -k -z -( -k -) - - -z -( -j -+ -1 -- -k -) - - -) - - - - -
Input File: omh/theory/sqrt_forward.omh - - - diff -Nru cppad-2015.00.00.9/doc/_sqrt_forward_xml.js cppad-2016.00.00.1/doc/_sqrt_forward_xml.js --- cppad-2015.00.00.9/doc/_sqrt_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sqrt_forward_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,85 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'forwardtheory.xml', +'sqrt_forward.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_forward.xml', +'log_forward.xml', +'sqrt_forward.xml', +'sin_cos_forward.xml', +'atan_forward.xml', +'asin_forward.xml', +'acos_forward.xml', +'tan_forward.xml', +'erf_forward.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_sqrtforward_xml.js cppad-2016.00.00.1/doc/_sqrtforward_xml.js --- cppad-2015.00.00.9/doc/_sqrtforward_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sqrtforward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'sqrtforward.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expforward.xml', -'logforward.xml', -'sqrtforward.xml', -'sincosforward.xml', -'atanforward.xml', -'asinforward.xml', -'acosforward.xml', -'tan_forward.xml', -'erf_forward.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/sqrt_reverse.xml cppad-2016.00.00.1/doc/sqrt_reverse.xml --- cppad-2015.00.00.9/doc/sqrt_reverse.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/sqrt_reverse.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,652 @@ + + + +Square Root Function Reverse Mode Theory + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +sqrt_reverseHeadings

+
Square Root Function Reverse Mode Theory
+We use the reverse theory +standard math function + +definition for the functions + +H + + + and + +G + + +. + +The forward mode formulas for the +square root + +function are + + +z +( +j +) + + += +x +( +0 +) + + + + + + +for the case + +j += +0 + + +, and for + +j +> +0 + + +, + + + +z +( +j +) + + += +1 + +j + + +1 + +z +( +0 +) + + + + +(j + +2 + + +x +( +j +) + + +- + + += +1 + +j +-1 + + + +z +( + +) + + +z +( +j +- + +) + + +) + + +If + +j += +0 + + +, we have the relation + + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +0 +) + + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +2 +z +( +0 +) + + + + + + + +If + +j +> +0 + + +, then for + +k += +1 +, + +, +j +-1 + + + + + + + + +H + + +z +( +0 +) + + + + + += + + +G + + +z +( +0 +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +z +( +0 +) + + + + + + += + + +G + + +z +( +0 +) + + + + +- + +G + + +z +( +j +) + + + + +z +( +j +) + + + +z +( +0 +) + + + + + + +H + + +x +( +j +) + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +x +( +j +) + + + + + + += + + +G + + +x +( +j +) + + + + ++ + +G + + +z +( +j +) + + + + +1 + +2 +z +( +0 +) + + + + + + +H + + +z +( +k +) + + + + + += + + +G + + +z +( +k +) + + + + ++ + +G + + +z +( +j +) + + + + + +z +( +j +) + + + + +z +( +k +) + + + + + + += + + +G + + +z +( +k +) + + + + +- + +G + + +z +( +j +) + + + + +z +( +j +- +k +) + + + +z +( +0 +) + + + + + + + + +
Input File: omh/theory/sqrt_reverse.omh + + + diff -Nru cppad-2015.00.00.9/doc/sqrtreverse.xml cppad-2016.00.00.1/doc/sqrtreverse.xml --- cppad-2015.00.00.9/doc/sqrtreverse.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/sqrtreverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,651 +0,0 @@ - - - -Square Root Function Reverse Mode Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -SqrtReverseHeadings

-
Square Root Function Reverse Mode Theory
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. - -The forward mode formulas for the -square root - -function are - - -z -( -j -) - - -= -x -( -0 -) - - - - - - -for the case - -j -= -0 - - -, and for - -j -> -0 - - -, - - - -z -( -j -) - - -= -1 - -j - - -1 - -z -( -0 -) - - - - -(j - -2 - - -x -( -j -) - - -- - - -= -1 - -j --1 - - - -z -( - -) - - -z -( -j -- - -) - - -) - - -If - -j -= -0 - - -, we have the relation - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -0 -) - - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -2 -z -( -0 -) - - - - - - - -If - -j -> -0 - - -, then for - -k -= -1 -, - -, -j --1 - - - - - - - - -H - - -z -( -0 -) - - - - - -= - - -G - - -z -( -0 -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -z -( -0 -) - - - - - - -= - - -G - - -z -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - -z -( -j -) - - - -z -( -0 -) - - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -j -) - - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -2 -z -( -0 -) - - - - - - -H - - -z -( -k -) - - - - - -= - - -G - - -z -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -z -( -k -) - - - - - - -= - - -G - - -z -( -k -) - - - - -- - -G - - -z -( -j -) - - - - -z -( -j -- -k -) - - - -z -( -0 -) - - - - - - - - -
Input File: omh/theory/sqrt_reverse.omh - - - diff -Nru cppad-2015.00.00.9/doc/_sqrt_reverse_xml.js cppad-2016.00.00.1/doc/_sqrt_reverse_xml.js --- cppad-2015.00.00.9/doc/_sqrt_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sqrt_reverse_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,85 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'theory.xml', +'reversetheory.xml', +'sqrt_reverse.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'forwardtheory.xml', +'reversetheory.xml', +'reverse_identity.xml' +]; +var list_down1 = [ +'exp_reverse.xml', +'log_reverse.xml', +'sqrt_reverse.xml', +'sin_cos_reverse.xml', +'atan_reverse.xml', +'asin_reverse.xml', +'acos_reverse.xml', +'tan_reverse.xml', +'erf_reverse.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_sqrtreverse_xml.js cppad-2016.00.00.1/doc/_sqrtreverse_xml.js --- cppad-2015.00.00.9/doc/_sqrtreverse_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sqrtreverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'sqrtreverse.xml' -]; -var list_down3 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_down2 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down1 = [ -'expreverse.xml', -'logreverse.xml', -'sqrtreverse.xml', -'sincosreverse.xml', -'atanreverse.xml', -'asinreverse.xml', -'acosreverse.xml', -'tan_reverse.xml', -'erf_reverse.xml' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/sqrt.xml cppad-2016.00.00.1/doc/sqrt.xml --- cppad-2015.00.00.9/doc/sqrt.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/sqrt.xml 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,188 @@ + + + +The Square Root Function: sqrt + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Square Root Function: sqrt
+
+Syntax + +
+ +y = sqrt(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +sqrt + +( +1 +) + + +( +x +) + += + +1 + +2 +sqrt + +( +x +) + + + + + +
+Example + +
+The file +sqrt.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_sqrt_xml.js cppad-2016.00.00.1/doc/_sqrt_xml.js --- cppad-2015.00.00.9/doc/_sqrt_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sqrt_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'sqrt.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'sqrt.cpp.xml' +]; +var list_current0 = [ +'sqrt.xml#Syntax', +'sqrt.xml#x, y', +'sqrt.xml#Atomic', +'sqrt.xml#Derivative', +'sqrt.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/stack_machine.cpp.xml cppad-2016.00.00.1/doc/stack_machine.cpp.xml --- cppad-2015.00.00.9/doc/stack_machine.cpp.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/stack_machine.cpp.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Example Differentiating a Stack Machine Interpreter - + - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - -
AD Standard Math Unary Functions
-
-Syntax - -
- -y = fun(x) - - - -
-
-Purpose -
-Evaluates the one argument standard math function - -fun - where its argument is an -AD of - -Base - object. - -
-
-x -
-The argument -x - has one of the following prototypes - -
-     const AD<
Base>               &x
-     const VecAD<
Base>::reference &x
-
-
-y -
-The result -y - has prototype - -
-     AD<
Basey
-
-
-Operation Sequence -
-Most of these functions are AD of -Base - -atomic operations -. -In all cases, -The AD of -Base - -operation sequence used to calculate -y - is -independent - -of -x -. - -
-
-fun -
-A definition of -fun - is included -for each of the following functions: -acos, -asin, -atan, -cos, -cosh, -exp, -fabs, -log, -log10, -sin, -sinh, -sqrt, -tan, -tanh. - - -
-
-Examples -
-The following files -contain examples and tests of these functions. -Each test returns true if it succeeds and false otherwise. - - - - - - - - - - - - - - - - -
- -abs.cpp -AD Absolute Value Function: Example and Test
- -Acos.cpp -The AD acos Function: Example and Test
- -Asin.cpp -The AD asin Function: Example and Test
- -atan.cpp -The AD atan Function: Example and Test
- -cos.cpp -The AD cos Function: Example and Test
- -cosh.cpp -The AD cosh Function: Example and Test
- -exp.cpp -The AD exp Function: Example and Test
- -log.cpp -The AD log Function: Example and Test
- -log10.cpp -The AD log10 Function: Example and Test
- -sin.cpp -The AD sin Function: Example and Test
- -sinh.cpp -The AD sinh Function: Example and Test
- -sqrt.cpp -The AD sqrt Function: Example and Test
- -tan.cpp -The AD tan Function: Example and Test
- -tanh.cpp -The AD tanh Function: Example and Test
- -
-
-Derivatives -
-Each of these functions satisfy a standard math function differential equation. -Calculating derivatives using this differential equation -is discussed for -both forward - -and reverse - mode. -The exact form of the differential equation -for each of these functions is listed below: - -
-
-acos - - - - - -[ -acos - -( -x -) -] - - -x - - - -= - -- -( -1 -- -x -* -x -) --1 -/ -2 - - - - - -
-asin - - - - - -[ -asin - -( -x -) -] - - -x - - - -= - -( -1 -- -x -* -x -) --1 -/ -2 - - - - - -
-atan - - - - - -[ -atan - -( -x -) -] - - -x - - - -= - -1 - -1 -+ -x -2 - - - - - - -
-cos - - - - - -[ -cos -( -x -) -] - - -x - - - -= - -- -sin -( -x -) - - -[ -sin -( -x -) -] - - -x - - - -= - -cos -( -x -) - - - -
-cosh - - - - - -[ -cosh -( -x -) -] - - -x - - - -= - -sinh -( -x -) - - -[ -sin -( -x -) -] - - -x - - - -= - -cosh -( -x -) - - - -
-exp - - - - - -[ -exp -( -x -) -] - - -x - - - -= - -exp -( -x -) - - - -
-log - - - - - -[ -log -( -x -) -] - - -x - - - -= - -1 - -x - - - - - -
-log10 -
-This function is special in that it's derivatives are calculated -using the relation - - - -log -10 - -( -x -) - -= - -log -( -x -) -/ -log -( -10 -) - - - -
-sin - - - - - -[ -sin -( -x -) -] - - -x - - - -= - -cos -( -x -) - - -[ -cos -( -x -) -] - - -x - - - -= - -- -sin -( -x -) - - - -
-sinh - - - - - -[ -sinh -( -x -) -] - - -x - - - -= - -cosh -( -x -) - - -[ -cosh -( -x -) -] - - -x - - - -= - -sinh -( -x -) - - - -
-sqrt - - - - - -[ -sqrt - -( -x -) -] - - -x - - - -= - -1 - -2 -sqrt - -( -x -) - - - - - -
-tan - - - - - -[ -tan -( -x -) -] - - -x - - - -= - -1 -+ -tan -( -x -) -2 - - - - -
-tanh - - - - - -[ -tanh -( -x -) -] - - -x - - - -= - -1 -- -tanh -( -x -) -2 - - - - - -
Input File: cppad/local/std_math_ad.hpp - - - diff -Nru cppad-2015.00.00.9/doc/_std_math_ad_xml.js cppad-2016.00.00.1/doc/_std_math_ad_xml.js --- cppad-2015.00.00.9/doc/_std_math_ad_xml.js 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/_std_math_ad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'advalued.xml', -'std_math_ad.xml' -]; -var list_down3 = [ -'install.xml', -'introduction.xml', -'ad.xml', -'adfun.xml', -'preprocessor.xml', -'multi_thread.xml', -'library.xml', -'ipopt_solve.xml', -'example.xml', -'speed.xml', -'appendix.xml' -]; -var list_down2 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down1 = [ -'arithmetic.xml', -'std_math_ad.xml', -'mathother.xml', -'condexp.xml', -'discrete.xml', -'atomic.xml' -]; -var list_down0 = [ -'acos.cpp.xml', -'asin.cpp.xml', -'atan.cpp.xml', -'cos.cpp.xml', -'cosh.cpp.xml', -'exp.cpp.xml', -'log.cpp.xml', -'log10.cpp.xml', -'sin.cpp.xml', -'sinh.cpp.xml', -'sqrt.cpp.xml', -'tan.cpp.xml', -'tanh.cpp.xml' -]; -var list_current0 = [ -'std_math_ad.xml#Syntax', -'std_math_ad.xml#Purpose', -'std_math_ad.xml#x', -'std_math_ad.xml#y', -'std_math_ad.xml#Operation Sequence', -'std_math_ad.xml#fun', -'std_math_ad.xml#Examples', -'std_math_ad.xml#Derivatives', -'std_math_ad.xml#Derivatives.acos', -'std_math_ad.xml#Derivatives.asin', -'std_math_ad.xml#Derivatives.atan', -'std_math_ad.xml#Derivatives.cos', -'std_math_ad.xml#Derivatives.cosh', -'std_math_ad.xml#Derivatives.exp', -'std_math_ad.xml#Derivatives.log', -'std_math_ad.xml#Derivatives.log10', -'std_math_ad.xml#Derivatives.sin', -'std_math_ad.xml#Derivatives.sinh', -'std_math_ad.xml#Derivatives.sqrt', -'std_math_ad.xml#Derivatives.tan', -'std_math_ad.xml#Derivatives.tanh' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down3(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down3[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/sub.cpp.xml cppad-2016.00.00.1/doc/sub.cpp.xml --- cppad-2015.00.00.9/doc/sub.cpp.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/sub.cpp.xml 2016-02-09 08:32:04.000000000 +0000 @@ -6,7 +6,7 @@ AD Binary Subtraction: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +sub_sparse_hes.cpp + +

+ + +
Computing Sparse Hessian for a Subset of Variables
+
+Purpose +
+This example uses +multiple levels of AD + +to compute the Hessian for a subset of the variables +without having to compute the sparsity pattern for the entire function. + +
+
+See Also + +
+sparse_sub_hes.cpp +, sparsity_sub.cpp +, + +
+
+Function +
+We consider the function + + +f +: +R + +nu + + +× +R + +nv + + + +R + + + + defined by + + +f +( +u +, +v +) += +( +j += +0 + +nu +-1 + + +u +j +3 + +) +( +j += +0 + +nv +-1 + + +v +j + +) + + +
+Subset +
+Suppose that we are only interested computing the function + + +H +( +u +, +v +) += + +u + + +u + +f +( +u +, +v +) + + +where this Hessian is sparse. + +
+
+Example +
+The following code shows one way to compute this subset of the +Hessian of + +f + + +. + +
 
+# include <cppad/cppad.hpp>
+
+namespace {
+	using CppAD::vector;
+	template <class Scalar>
+	Scalar f(const vector<Scalar>& u,const vector<Scalar>& v)
+	{	size_t i;
+		Scalar sum_v = Scalar(0);
+		for(i = 0; i < v.size(); i++)
+			sum_v += v[i];
+		Scalar sum_cube_u = Scalar(0);
+		for(i = 0; i < u.size(); i++)
+			sum_cube_u += u[i] * u[i] * u[i] / 6.0;
+		return sum_v * sum_cube_u;
+	}
+}
+
+bool sub_sparse_hes(void)
+{	bool ok = true;
+	using CppAD::AD;
+	typedef AD<double>   adouble;
+	typedef AD<adouble> a2double;
+	typedef vector< std::set<size_t> > pattern;
+	double eps = 10. * std::numeric_limits<double>::epsilon();
+	size_t i, j;
+
+	// start recording with x = (u , v)
+	size_t nu = 10;
+	size_t nv = 5;
+	size_t n  = nu + nv;
+	vector<adouble> ax(n);
+	for(j = 0; j < n; j++)
+		ax[j] = adouble(j + 2);
+	CppAD::Independent(ax);
+
+	// extract u as independent variables
+	vector<a2double> a2u(nu);
+	for(j = 0; j < nu; j++)
+		a2u[j] = a2double(j + 2);
+	CppAD::Independent(a2u);
+
+	// extract v as parameters
+	vector<a2double> a2v(nv);
+	for(j = 0; j < nv; j++)
+		a2v[j] = ax[nu+j];
+
+	// record g(u)
+	vector<a2double> a2y(1);
+	a2y[0] = f(a2u, a2v);
+	CppAD::ADFun<adouble> g;
+	g.Dependent(a2u, a2y);
+
+	// compue sparsity pattern for Hessian of g(u)
+	pattern r(nu), s(1);
+	for(j = 0; j < nu; j++)
+		r[j].insert(j);
+	g.ForSparseJac(nu, r);
+	s[0].insert(0);
+	pattern p = g.RevSparseHes(nu, s);
+
+	// Row and column indices for non-zeros in lower triangle of Hessian
+	vector<size_t> row, col;
+	for(i = 0; i < nu; i++)
+	{	std::set<size_t>::const_iterator itr;
+		for(itr = p[i].begin(); itr != p[i].end(); itr++)
+		{	j = *itr;
+			if( j <= i )
+			{	row.push_back(i);
+				col.push_back(j);
+			}
+		}
+	}
+	size_t K = row.size();
+	CppAD::sparse_hessian_work work;
+	vector<adouble> au(nu), ahes(K), aw(1);
+	aw[0] = 1.0;
+	for(j = 0; j < nu; j++)
+		au[j] = ax[j];
+	size_t n_sweep = g.SparseHessian(au, aw, p, row, col, ahes, work);
+
+	// The Hessian w.r.t u is diagonal
+	ok &= n_sweep == 1;
+
+	// record H(u, v) = Hessian of f w.r.t u
+	CppAD::ADFun<double> H(ax, ahes);
+
+	// remove unecessary operations
+	H.optimize();
+
+	// Now evaluate the Hessian at a particular value for u, v
+	vector<double> u(nu), v(nv), x(n);
+	for(j = 0; j < n; j++)
+		x[j] = double(j + 2);
+	vector<double> hes = H.Forward(0, x);
+
+	// Now check the Hessian
+	double sum_v = 0.0;
+	for(j = 0; j < nv; j++)
+		sum_v += x[nu + j];
+	for(size_t k = 0; k < K; k++)
+	{	i     = row[k];
+		j     = col[k];
+		ok   &= i == j;
+		double check = sum_v * x[i];
+		ok &= CppAD::NearEqual(hes[k], check, eps, eps);
+	}
+	return ok;
+}
+
+ +
+ + +
Input File: example/sub_sparse_hes.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_sub_sparse_hes.cpp_xml.js cppad-2016.00.00.1/doc/_sub_sparse_hes.cpp_xml.js --- cppad-2015.00.00.9/doc/_sub_sparse_hes.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_sub_sparse_hes.cpp_xml.js 2016-02-09 08:32:06.000000000 +0000 @@ -0,0 +1,90 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'adfun.xml', +'drivers.xml', +'sparse_hessian.xml', +'sub_sparse_hes.cpp.xml' +]; +var list_down3 = [ +'independent.xml', +'funconstruct.xml', +'dependent.xml', +'abort_recording.xml', +'seq_property.xml', +'funeval.xml', +'drivers.xml', +'funcheck.xml', +'optimize.xml', +'check_for_nan.xml' +]; +var list_down2 = [ +'jacobian.xml', +'forone.xml', +'revone.xml', +'hessian.xml', +'fortwo.xml', +'revtwo.xml', +'sparse_jacobian.xml', +'sparse_hessian.xml' +]; +var list_down1 = [ +'sparse_hessian.cpp.xml', +'sub_sparse_hes.cpp.xml', +'sparse_sub_hes.cpp.xml' +]; +var list_current0 = [ +'sub_sparse_hes.cpp.xml#Purpose', +'sub_sparse_hes.cpp.xml#See Also', +'sub_sparse_hes.cpp.xml#Function', +'sub_sparse_hes.cpp.xml#Subset', +'sub_sparse_hes.cpp.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/ta_available.xml cppad-2016.00.00.1/doc/ta_available.xml --- cppad-2015.00.00.9/doc/ta_available.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/ta_available.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Amount of Memory Available for Quick Use by a Thread - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Hyperbolic Tangent Function: tanh
+
+Syntax + +
+ +y = tanh(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +tanh + +( +1 +) + + +( +x +) + += + +1 +- +tanh +( +x +) +2 + + + + +
+Example + +
+The file +tanh.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_tanh_xml.js cppad-2016.00.00.1/doc/_tanh_xml.js --- cppad-2015.00.00.9/doc/_tanh_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_tanh_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'tanh.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'tanh.cpp.xml' +]; +var list_current0 = [ +'tanh.xml#Syntax', +'tanh.xml#x, y', +'tanh.xml#Atomic', +'tanh.xml#Derivative', +'tanh.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/tan_reverse.xml cppad-2016.00.00.1/doc/tan_reverse.xml --- cppad-2015.00.00.9/doc/tan_reverse.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/tan_reverse.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Tangent and Hyperbolic Tangent Reverse Mode Theory - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Tangent Function: tan
+
+Syntax + +
+ +y = tan(x) + + +
+
+x, y +
+See the possible types + +for a unary standard math function. + +
+
+Atomic +
+This is an atomic operation +. + +
+
+Derivative + + + + +tan + +( +1 +) + + +( +x +) + += + +1 ++ +tan +( +x +) +2 + + + + +
+Example + +
+The file +tan.cpp + +contains an example and test of this function. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/std_math_98.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_tan_xml.js cppad-2016.00.00.1/doc/_tan_xml.js --- cppad-2015.00.00.9/doc/_tan_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_tan_xml.js 2016-02-09 08:32:05.000000000 +0000 @@ -0,0 +1,107 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml', +'tan.xml' +]; +var list_down3 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down2 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down1 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_down0 = [ +'tan.cpp.xml' +]; +var list_current0 = [ +'tan.xml#Syntax', +'tan.xml#x, y', +'tan.xml#Atomic', +'tan.xml#Derivative', +'tan.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/ta_parallel_setup.xml cppad-2016.00.00.1/doc/ta_parallel_setup.xml --- cppad-2015.00.00.9/doc/ta_parallel_setup.xml 2015-02-24 08:31:52.000000000 +0000 +++ cppad-2016.00.00.1/doc/ta_parallel_setup.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Setup thread_alloc For Use in Multi-Threading Environment - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +to_string.cppHeadings

+ + +
to_string: Example and Test
+
 
+
+// Examples with fundamental types
+# include <cppad/utility/to_string.hpp>
+namespace {
+	template <class Integer>
+	Integer string2int(const std::string& s)
+	{	Integer result = 0;
+		size_t index   = 0;
+		if( s[0] == '-' )
+			++index;
+		while( index < s.size() )
+			result = 10 * result + Integer( s[index++] - '0');
+		if( s[0] == '-' )
+			return - result;
+		return result;
+	}
+	template <class Integer>
+	bool integer(void)
+	{	bool ok = true;
+		//
+		Integer max    = std::numeric_limits<Integer>::max();
+		std::string s  = CppAD::to_string(max);
+		Integer check  = string2int<Integer>(s);
+		ok            &= max == check;
+		//
+		Integer min       = std::numeric_limits<Integer>::min();
+		s              = CppAD::to_string(min);
+		check          = string2int<Integer>(s);
+		ok            &= min == check;
+		//
+		return ok;
+	}
+	template <class Float>
+	bool floating(void)
+	{	bool  ok  = true;
+		Float eps = std::numeric_limits<Float>::epsilon();
+		Float pi  = 4.0 * std::atan(1.);
+		//
+		std::string s = CppAD::to_string( pi );
+		Float check    = std::atof( s.c_str() );
+		ok           &= std::fabs( check - pi ) <= 2.0 * eps;
+		//
+		return ok;
+	}
+}
+
+// Examples with AD types
+# include <cppad/cppad.hpp>
+namespace {
+	template <class Base>
+	bool ad_floating(void)
+	{	bool  ok  = true;
+		Base eps = std::numeric_limits<Base>::epsilon();
+		Base pi  = 4.0 * std::atan(1.);
+		//
+		std::string s = CppAD::to_string( CppAD::AD<Base>( pi ) );
+		Base check    = std::atof( s.c_str() );
+		ok           &= std::fabs( check - pi ) <= 2.0 * eps;
+		//
+		return ok;
+	}
+}
+
+// Test driver
+bool to_string(void)
+{	bool ok = true;
+
+	ok &= integer<unsigned short>();
+	ok &= integer<signed int>();
+	ok &= integer<unsigned long>();
+# if CPPAD_USE_CPLUSPLUS_2011
+	ok &= integer<signed long long>();
+# endif
+	//
+	ok &= floating<float>();
+	ok &= floating<double>();
+	ok &= floating<long double>();
+	//
+	ok &= ad_floating<float>();
+	ok &= ad_floating<double>();
+	//
+	return ok;
+}
+
+
+ +
+ + +
Input File: example/to_string.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_to_string.cpp_xml.js cppad-2016.00.00.1/doc/_to_string.cpp_xml.js --- cppad-2015.00.00.9/doc/_to_string.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_to_string.cpp_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,97 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'utility.xml', +'to_string.xml', +'to_string.cpp.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'errorhandler.xml', +'nearequal.xml', +'speed_test.xml', +'speedtest.xml', +'time_test.xml', +'numerictype.xml', +'checknumerictype.xml', +'simplevector.xml', +'checksimplevector.xml', +'nan.xml', +'pow_int.xml', +'poly.xml', +'ludetandsolve.xml', +'rombergone.xml', +'rombergmul.xml', +'runge45.xml', +'rosen34.xml', +'odeerrcontrol.xml', +'odegear.xml', +'odegearcontrol.xml', +'cppad_vector.xml', +'thread_alloc.xml', +'index_sort.xml', +'to_string.xml' +]; +var list_down1 = [ +'to_string.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/to_string.xml cppad-2016.00.00.1/doc/to_string.xml --- cppad-2015.00.00.9/doc/to_string.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/to_string.xml 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,258 @@ + + + +Convert Certain Types to a String + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + +

+ + + +
Convert Certain Types to a String
+
+Syntax + +
+ +# include <cppad/utility/to_string.hpp>
+
+ +s = to_string(value) +. + +
+
+See Also + +
+base_to_string +, ad_to_string + + +
+
+Purpose +
+This routine is similar to the C++11 routine std::to_string +with the following differences: +
  1. +It works with C++98. +
  2. + +It has been extended to the fundamental floating point types. +
  3. + +It has specifications for extending to an arbitrary type; see +base_to_string +. +
  4. + +If <cppad/cppad.hpp> is included, +and it has been extended to a +Base + type, +it automatically extends to the +AD types above Base +. +
+ + +
+
+value + + +
+
+Integer +
+The argument +value + can have the following prototype + +
+     const 
Integer&  value
+
+where +Integer + is any of the fundamental integer types; e.g., +short int and unsigned long. +Note that if C++11 is supported by this compilation, +unsigned long long is also a fundamental integer type. + +
+
+Float +
+The argument +value + can have the following prototype + +
+     const 
Float&  value
+
+where +Float + is any of the fundamental floating point types; i.e., +float, double, and long double. + +
+
+s +
+The return value has prototype + +
+     std::string 
s
+
+and contains a representation of the specified +value +. + +
+
+Integer +
+If +value + is an +Integer +, +the representation is equivalent to +os << value + +where +os + is an std::ostringstream. + +
+
+Float +
+If +value + is a +Float +, +enough digits are used in the representation so that +the result is accurate to withing round off error. + + +
+
+Example +
+The file to_string.cpp + +contains an example and test of this routine. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/utility/to_string.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_to_string_xml.js cppad-2016.00.00.1/doc/_to_string_xml.js --- cppad-2015.00.00.9/doc/_to_string_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_to_string_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,102 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'utility.xml', +'to_string.xml' +]; +var list_down2 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down1 = [ +'errorhandler.xml', +'nearequal.xml', +'speed_test.xml', +'speedtest.xml', +'time_test.xml', +'numerictype.xml', +'checknumerictype.xml', +'simplevector.xml', +'checksimplevector.xml', +'nan.xml', +'pow_int.xml', +'poly.xml', +'ludetandsolve.xml', +'rombergone.xml', +'rombergmul.xml', +'runge45.xml', +'rosen34.xml', +'odeerrcontrol.xml', +'odegear.xml', +'odegearcontrol.xml', +'cppad_vector.xml', +'thread_alloc.xml', +'index_sort.xml', +'to_string.xml' +]; +var list_down0 = [ +'to_string.cpp.xml' +]; +var list_current0 = [ +'to_string.xml#Syntax', +'to_string.xml#See Also', +'to_string.xml#Purpose', +'to_string.xml#value', +'to_string.xml#value.Integer', +'to_string.xml#value.Float', +'to_string.xml#s', +'to_string.xml#s.Integer', +'to_string.xml#s.Float', +'to_string.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/tracknewdel.cpp.xml cppad-2016.00.00.1/doc/tracknewdel.cpp.xml --- cppad-2015.00.00.9/doc/tracknewdel.cpp.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/tracknewdel.cpp.xml 2016-02-09 08:32:08.000000000 +0000 @@ -6,7 +6,7 @@ Tracking Use of New and Delete: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+ + + +
The Unary Standard Math Functions
+
+Syntax + +
+ +y = fun(x) + + +
+
+Purpose +
+Evaluates the standard math function +fun +. + +
+
+Possible Types + + +
+
+Base +
+If +Base + satisfies the +base type requirements + +and argument +x + has prototype + +
+     const 
Basex
+
+then the result +y + has prototype + +
+     
Base y
+
+
+AD<Base> +
+If the argument +x + has prototype + +
+     const AD<
Base>& x
+
+then the result +y + has prototype + +
+     AD<
Basey
+
+
+VecAD<Base> +
+If the argument +x + has prototype + +
+     const VecAD<
Base>::reference& x
+
+then the result +y + has prototype + +
+     AD<
Basey
+
+
+fun +
+The possible values for +fun + are + +
+ + + fun +    + Description
+ +abs + + AD Absolute Value Functions: abs, fabs
+ +acos + + Inverse Sine Function: acos
+ +acosh + + The Inverse Hyperbolic Cosine Function: acosh
+ +asin + + Inverse Sine Function: asin
+ +asinh + + The Inverse Hyperbolic Sine Function: asinh
+ +atan + + Inverse Tangent Function: atan
+ +atanh + + The Inverse Hyperbolic Tangent Function: atanh
+ +cos + + The Cosine Function: cos
+ +cosh + + The Hyperbolic Cosine Function: cosh
+ +erf + + The Error Function
+ +exp + + The Exponential Function: exp
+ +expm1 + + The Exponential Function Minus One: expm1
+ +fabs + + AD Absolute Value Functions: abs, fabs
+ +log10 + + The Base 10 Logarithm Function: log10
+ +log1p + + The Logarithm of One Plus Argument: log1p
+ +log + + The Exponential Function: log
+ +sign + + The Sign: sign
+ +sin + + The Sine Function: sin
+ +sinh + + The Hyperbolic Sine Function: sinh
+ +sqrt + + The Square Root Function: sqrt
+ +tan + + The Tangent Function: tan
+ +tanh + + The Hyperbolic Tangent Function: tanh +
+ +
Input File: cppad/local/standard_math.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_unary_standard_math_xml.js cppad-2016.00.00.1/doc/_unary_standard_math_xml.js --- cppad-2015.00.00.9/doc/_unary_standard_math_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_unary_standard_math_xml.js 2016-02-09 08:32:04.000000000 +0000 @@ -0,0 +1,118 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'ad.xml', +'advalued.xml', +'unary_standard_math.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'ad_ctor.xml', +'ad_assign.xml', +'convert.xml', +'advalued.xml', +'boolvalued.xml', +'vecad.xml', +'base_require.xml' +]; +var list_down1 = [ +'arithmetic.xml', +'unary_standard_math.xml', +'binary_math.xml', +'condexp.xml', +'discrete.xml', +'numeric_limits.xml', +'atomic.xml' +]; +var list_down0 = [ +'acos.xml', +'asin.xml', +'atan.xml', +'cos.xml', +'cosh.xml', +'exp.xml', +'log.xml', +'log10.xml', +'sin.xml', +'sinh.xml', +'sqrt.xml', +'tan.xml', +'tanh.xml', +'abs.xml', +'acosh.xml', +'asinh.xml', +'atanh.xml', +'erf.xml', +'expm1.xml', +'log1p.xml', +'sign.xml' +]; +var list_current0 = [ +'unary_standard_math.xml#Syntax', +'unary_standard_math.xml#Purpose', +'unary_standard_math.xml#Possible Types', +'unary_standard_math.xml#Possible Types.Base', +'unary_standard_math.xml#Possible Types.AD<Base>', +'unary_standard_math.xml#Possible Types.VecAD<Base>', +'unary_standard_math.xml#fun' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/uniform_01_c.xml cppad-2016.00.00.1/doc/uniform_01_c.xml --- cppad-2015.00.00.9/doc/uniform_01_c.xml 2015-02-24 08:31:54.000000000 +0000 +++ cppad-2016.00.00.1/doc/uniform_01_c.xml 2016-02-09 08:32:08.000000000 +0000 @@ -6,7 +6,7 @@ Simulate a [0,1] Uniform Random Variate - + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +

+ + + + +
Some General Purpose Utilities
+These routines can be include individually; for example, +
 
+     # include <cppad/utility/vector.hpp>
+
+only includes the definitions necessary for the CppAD::vector class. +They can also be included as a group, separate from the rest of CppAD, using +
 
+     # include <cppad/utility.hpp>
+
+They will also be included, along with the rest of CppAD, using +
 
+     # include <cppad/cppad.hpp>
+
+
+Testing +
+The routines listed below support numerical correctness and speed testing: + + + + + +
+ +NearEqual +Determine if Two Values Are Nearly Equal
+ +time_test +Determine Amount of Time to Execute a Test
+ +speed_test +Run One Speed Test and Return Results
+ +SpeedTest +Run One Speed Test and Print Results
+ +
+
+C++ Concepts +
+We refer to a the set of classes that satisfy certain conditions +as a C++ concept. +The following concepts are used by the CppAD Template library: + + + + + +
+ +NumericType +Definition of a Numeric Type
+ +CheckNumericType +Check NumericType Class Concept
+ +SimpleVector +Definition of a Simple Vector
+ +CheckSimpleVector +Check Simple Vector Concept
+ +
+
+General Numerical Routines +
+The routines listed below are general purpose numerical routines +written with the floating point type a C++ template parameter. +This enables them to be used with algorithmic differentiation types, +as well as for other purposes. + + + + + + + + + + + + +
+ +nan +Obtain Nan or Determine if a Value is Nan
+ +pow_int +The Integer Power Function
+ +Poly +Evaluate a Polynomial or its Derivative
+ +LuDetAndSolve +Compute Determinants and Solve Equations by LU Factorization
+ +RombergOne +One DimensionalRomberg Integration
+ +RombergMul +Multi-dimensional Romberg Integration
+ +Runge45 +An Embedded 4th and 5th Order Runge-Kutta ODE Solver
+ +Rosen34 +A 3rd and 4th Order Rosenbrock ODE Solver
+ +OdeErrControl +An Error Controller for ODE Solvers
+ +OdeGear +An Arbitrary Order Gear Method
+ +OdeGearControl +An Error Controller for Gear's Ode Solvers
+ +
+
+Miscellaneous + + +
+
+Error Handler +
+All of the routines in the CppAD namespace use the following +general purpose error handler: + + +
+ +ErrorHandler +Replacing the CppAD Error Handler
+ +
+
+Simple Vector Template Class +
+A simple implementation of a template vector class +(that is easy to view in a C++ debugger): + + +
+ +CppAD_vector +The CppAD::vector Template Class
+ +
+
+Multi-Threading Memory Allocation + + + +
+ +thread_alloc +A Fast Multi-Threading Memory Allocator
+ +
+
+Sorting Indices + + + +
+ +index_sort +Returns Indices that Sort a Vector
+ +
+
+to_string + + + +
+ +to_string +Convert Certain Types to a String
+ +
+ +
Input File: omh/utility.omh + + + diff -Nru cppad-2015.00.00.9/doc/_utility_xml.js cppad-2016.00.00.1/doc/_utility_xml.js --- cppad-2015.00.00.9/doc/_utility_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_utility_xml.js 2016-02-09 08:32:06.000000000 +0000 @@ -0,0 +1,91 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'utility.xml' +]; +var list_down1 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down0 = [ +'errorhandler.xml', +'nearequal.xml', +'speed_test.xml', +'speedtest.xml', +'time_test.xml', +'numerictype.xml', +'checknumerictype.xml', +'simplevector.xml', +'checksimplevector.xml', +'nan.xml', +'pow_int.xml', +'poly.xml', +'ludetandsolve.xml', +'rombergone.xml', +'rombergmul.xml', +'runge45.xml', +'rosen34.xml', +'odeerrcontrol.xml', +'odegear.xml', +'odegearcontrol.xml', +'cppad_vector.xml', +'thread_alloc.xml', +'index_sort.xml', +'to_string.xml' +]; +var list_current0 = [ +'utility.xml#Testing', +'utility.xml#C++ Concepts', +'utility.xml#General Numerical Routines', +'utility.xml#Miscellaneous', +'utility.xml#Miscellaneous.Error Handler', +'utility.xml#Miscellaneous.Simple Vector Template Class', +'utility.xml#Miscellaneous.Multi-Threading Memory Allocation', +'utility.xml#Miscellaneous.Sorting Indices', +'utility.xml#Miscellaneous.to_string' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/value.cpp.xml cppad-2016.00.00.1/doc/value.cpp.xml --- cppad-2015.00.00.9/doc/value.cpp.xml 2015-02-24 08:31:50.000000000 +0000 +++ cppad-2016.00.00.1/doc/value.cpp.xml 2016-02-09 08:32:04.000000000 +0000 @@ -6,7 +6,7 @@ Convert From AD to its Base Type: Example and Test - + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +whats_new_15 + +

+ + + + +
CppAD Changes and Additions During 2015
+
+Introduction +
+This section contains a list of the changes to CppAD during 2015 +(in reverse order by date). +The purpose of this section is to +assist you in learning about changes between various versions of CppAD. + +
+
+12-29 +
+Separate to_string + from ad_to_string + so that it +can be used without the rest of CppAD; i.e., +by including + +
+     # include <cppad/utility/to_string.hpp>
+
+
+12-28 + +
  1. +Add the to_string + utility. +
  2. + +Add base_to_string + to the Base type requirements. +
  3. + +A Base requirements + item +was added to the wish list. +
  4. + +The wish_list + item to +reorganize the include directory has been removed. +It was completed when the utilities was moved to cppad/utility; see +11-30 +. +
+ + +
+
+12-08 + +
  1. +A convention was included for addon +library files +. +
  2. + +Change new utility + specifications to allow for individual file +includes; e.g., <cppad/utility/vector.hpp>. +
+ + +
+
+12-01 +
+Fix problem with auto_tools + install handling of the +deprecated files. +This included changing the auto-tools +--with-implicit_ctor option to +--with-deprecated +. + +
+
+11-30 + +
  1. +The library section has been moved to the +utilities + section. +In addition, the corresponding source code files in cppad +have been moved to cppad/utility. +
  2. + +The individual utility + include files have been deprecated; see +include_deprecated +. +For example, +
     
    +     # include <cppad/runge_45.hpp>
    +
    +You should us the utility include instead; i.e., +
     
    +     # include <cppad/utility.hpp>
    +
    +
  3. +The numeric_ad + routines where moved from the library +the a separate documentation section. +
  4. + +Change cmake_install_prefix to +cppad_prefix + and +Change cmake_install_postfix to +cppad_postfix +. +
  5. + +Change cppad_implicit_ctor_from_any_type to +cppad_deprecated + and +change its specifications to refer to all deprecated features. +
+ + +
+
+11-25 + +
  1. +CppAD now installs the object library +
     
    +     -lcppad_lib
    +
    +to be included when linking. +Currently, it is only required when +colpack_prefix + is specified on the +cmake command +. +
  2. + +It is no longer necessary to compile and link the file +
     
    +     cppad_colpack.cpp
    +
    +when colpack_prefix + +is specified during the install process; see +cmake command +. +(It is included in cppad_lib). +
+ + +
+
+11-24 + +
  1. +The check_for_nan output now includes the first dependent +variable +index + +that is nan in its error message. +
  2. + +Change the +deprecated include + reference pow_int.h +to pow_int.hpp in pow_int +. +
+ + +
+
+11-14 +
+There was a bug in the new +get_check_for_nan + +feature that writes independent variable values to a temporary file; +see 11-06 + below. +This has been fixed. + + +
+
+11-08 + +
  1. +Fixed a bug in the RevSparseJac + routine. +To be specific, the argument r + +was transposed from what the documentation said. +(This has no effect in the usual case where +r + is the identity.) +
  2. + +Added the bool_sparsity.cpp + examples which show how +to conserve memory when computing sparsity patterns. +
  3. + +Modified the ipopt_solve + procedure to take +advantage of the memory conserving sparsity pattern calculations +when retape + is false. +
  4. + +Added the bit_per_unit + +function to the vectorBool class. +(This aids the memory conservation mentioned above.) +
+ + + +
+
+11-06 +
+It is often difficult to determine what cause a nan result +during an operation with an ADFun + object. +The new feature +get_check_for_nan + was +added to make this easier. + +
+
+10-21 +
+There was a mistake in the documentation for index_sort +, +the argument ind + is not const. + +
+
+10-16 +
+Add a PrintFor optimization + +item to the wish list. + +
+
+10-06 + +
  1. +Add +CPPAD_USE_CPLUSPLUS_2011 +, +CPPAD_NUMERIC_LIMITS, and +CPPAD_STANDARD_MATH_UNARY, to +the preprocessor + section. +In addition, remove checking that all user API preprocessor symbols +are in this section form the wish_list +. +
  2. + +Alphabetize and make some corrections to +list of examples +. +
  3. + +The documentation for some of the deprecated + features +was missing the date when they were deprecated. +This has been fixed; e.g., see +Deprecated 2012-12-26 +. +
+ + + +
+
+10-04 + +
  1. +base_require +: +Add the macro +CPPAD_NUMERIC_LIMITS + +to aid in setting the numeric limits for a user defined +Base + class. +
  2. + +base_require +: +The quiet_NaN + function has been added +to the CppAD numeric_limits. +Note the reason for not using +std::numeric_limits +. +
  3. + +The nan(zero) + function computes a nan by +dividing zero by zero which results in a warning when using some compilers. +This function has been deprecated and the corresponding +wish_list + item has been removed. +
  4. + +Move documentation for zdouble + to deprecated + section +and documentation for numeric_limits + to ADValued +. +
  5. + +Remove all uses of, and references to, +zdouble + from the examples +. +
+ + +
+
+10-03 + +
+base_require +: +It is no longer necessary to define the specialization for + +CppAD::epsilon<Base>() + for each +Base + type. + +
+
+10-02 +
+There was a bug in test_more/azmul.cpp whereby the vector +z had the wrong dimension (in two places). This has been fixed. + +
+
+09-28 + +
  1. +Use the current atomic_option + setting to determine +which type of sparsity patterns to use for +dependency + calculations during +optimize + procedure. +It used to be that the +bool_sparsity_enum + +was used when +pack_sparsity_enum + +was specified. +
  2. + +It is not longer an error to take the derivative of the square root function, +because the result may be the part of a +conditional expression + that is not used. +
  3. + +Update the wish_list + section. +
+ + + +
+
+09-27 + +
  1. +It is no longer necessary to use the zdouble + class when +computing with multiple levels of AD + +conditional expressions + and +reverse mode +. +
  2. + +The zdouble class has been deprecated. +Use the azmul + function for absolute zero (when it is needed). +
+ + +
+
+09-25 + +
+base_require +: +absolute zero multiplication + +is now required for user defined base types. +This makes it possible to combine +conditional expression +, +multiple levels +, +reverse +, and +a base type that has standard ieee multiplication; e.g., double. +In other words, not all multiplications will need to have an +absolute zero (as is the case with the zdouble + base class. + +
+
+09-24 +
+Fix some Visual Studio 2013 C++ level four /W4 warnings +(previous warnings were are level 3). +In addition, disable warning +4100 unreferenced formal parameter, +and warning +4127 conditional expression is constant. + +
+
+09-23 +
+CppAD can optionally test its use with the external packages +eigen +, +ipopt +, and +colpack +. +In addition, it can compare its speed + with the external AD packages +adolc +, +fadbad +, and +sacado +. +The scripts that download and install a local copy of these external packages +have been modified to automatically skip installation +when it has already been done. + +
+
+09-21 +
+Improve discussion of +windows download and testing +. + +
+
+09-20 + +
  1. +Add the cppad_profile_flag + +to the list of possible cmake command arguments. +
  2. + +More of the warnings generated by Visual Studio 2013 have been fixed. +One remaining warning is about asctime and gmtime not being +thread safe. +
+ + +
+
+09-19 + +
  1. +There was a bug in the numeric_limits + +section of the example user defined base type. +This has been fixed. +
  2. + +There were some compile and link errors when +running the tests using Visual Studio 2013. +These have been fixed. +
  3. + +Many of the warnings generated by Visual Studio 2013 have been fixed. +
+ + +
+
+09-16 +
+The conditional expressions, CondExp +, were not working +for the type < CppAD::AD<adouble> > where adouble +is the ADOL-C AD type. +This has been fixed by adding a call to +CPPAD_COND_EXP_REL + in +base_adolc.hpp. + +
+
+09-03 + +
  1. +There was a bug in the vectorBool + +assignment +. +To be specific, +it not allow a size zero vector to be assigned using a vector any other size. +This has been fixed. +
  2. + +The addition of the +pack + option +on 08-31 introduced a bug in the calculation of RevSparseHes +. +The checkpoint.cpp + example was changed to demonstrate this +problem and the bug was fixed. +
+ + +
+
+09-02 +
+The dependency pattern + +was not being computed correctly for the +sign +, Discrete +, and VecAD + operations. +This has been fixed. +This could have caused problems using +checkpoint + functions that used any of these operations. + +
+
+08-31 + +
  1. +Mention the fact that using checkpoint functions can make +recordings faster +. +
  2. + +Add the +pack + +sparsity option for atomic_base + operations. +
  3. + +Add the pack sparsity option to +checkpoint + functions. +
  4. + +Added the atomic_sparsity.cpp + example. +
  5. + +Remove mention of OpenMP from thread_alloc::thread_num + +(thread_alloc + never was OpenMP specific). +
+ + +
+
+08-30 + +
  1. +The sparsity + +argument was added to the atomic_base constructor and the +checkpoint + constructor. +
  2. + +Make atomic_norm_sq.cpp + an example with no set sparsity +and atomic_reciprocal.cpp + an example with no bool sparsity. +
  3. + +Improve discussion of Independent and +parallel mode +. +
+ + +
+
+08-29 +
+Some asserts in the checkpoint + implementation were not using +the CppAD ErrorHandler +. This has been fixed. + +
+
+08-28 +
+Free checkpoint + function sparsity patters during +forward + operations that use its atomic operation. +(They kept between sparsity calculations because they do not change.) + +
+
+08-26 +
+Fix a bug in RevSparseJac + when used to compute sparsity pattern +for a subset of the rows in a checkpoint + function. + +
+
+08-25 +
+Reduce the amount of memory required for checkpoint + functions +(since sparsity patterns are now being held so they do not need to be +recalculated). + +
+
+08-20 +
+Added an example that computes the sparsity pattern for a subset +of the Jacobian + and a subset +of the Hessian +. + +
+
+08-17 + +
  1. +Do some optimization of the +checkpoint + feature so that sparsity patterns are +stored and not recalculated. +
  2. + +Fix a warning (introduced on 08-11) where the CppAD::vector +data + function was being shadowed by +a local variable. +
  3. + +The source code control for CppAD has a link to compile, +instead of real file. +This sometimes caused problems with the +deprecated auto_tools + install procedure and has been fixed. +
+ + +
+
+08-16 + +
  1. +Improve the documentation for checkpoint functions. +To be specific, change the syntax + to use +the name +atom_fun +. +In addition, include the fact that +atom_fun + must not +be destructed for as along as the corresponding atomic operations are used. +
  2. + +Add the size_var + function +to the checkpoint objects. +
+ + + +
+
+08-09 +
+Add the preservation of data to the specifications of a CppAD::vector +during a resize + when the +capacity of the vector does not change. +In addition, added and example of this to cppad_vector.cpp +. + +
+
+08-06 +
+The zdouble + +numeric_limits + +were not being computed properly. +This has been fixed. + +
+
+07-31 +
+Added the sparse_sub_hes.cpp + example, +a way to compute the sparsity for a subset of variables without +using multiple levels of AD +. + +
+
+06-16 + +
  1. +There were some +unknown + asserts +when the sparsity pattern +p + in +sparse_jacobian + and +sparse_hessian + was not properly dimensioned. +These have been changed to +known + asserts to give better +error reporting. +
  2. + +In the special case where sparse Hessian work + or +sparse Jacobian work + was specified and the +set of elements to be computed was empty, the work vector is empty after +the call (and it appears to need to be calculated on subsequent calls). +This resulted in a bug when the sparsity pattern was not provided +on subsequent calls (and has been fixed). +
+ + +
+
+06-11 + +
  1. +Some C++11 features were not being taken advantage of after the change on +05-10 +. To be specific, move semantics, +the high resolution clock, and null pointers. +This has been fixed. +
  2. + +In the example zdouble.cpp +, the vector a1z was not +properly dimensioned. +This has been fixed and the dimensions of all the variables have been +clarified. +
+ + + +
+
+06-09 +
+Add an abort_op_index + +item to the wish list. It has since been removed +(domain errors may not affect the results due to +conditional expressions +). + + +
+
+06-07 +
+Add a absolute zero + item +and a numeric_limits + item to the wish list. +The absolute zero item has been completed and the +numeric limit item was modified on implementation. +Remove the multiple directions with list item. + +
+
+05-26 + + +
+
+cond_exp_1 +
+There was a problem using +conditional expressions + +with multiple levels of AD + where +the result of the conditional expression might not be determined +during forward mode. +This would generate an assert of the form: + +
+     Error detected by false result for
+          IdenticalPar(
side)
+    at line 
number in the file
+          
.../cppad/local/cskip_op.hpp
+
+where +side + was left or right +and +number + was the line number of an assert in cskip_op.hpp. +This has been fixed. + +
+
+cond_exp_2 +
+There was a problem with using +conditional expressions + and reverse mode + +with multiple levels of AD +. +This was problem was represented by the file bug/cond_exp_2.sh. + +
  1. +The problem above has been fixed by adding the base type zdouble, see +CppAD motivation + for this new type. +(It is no longer necessary to use zdouble to get an absolute zero +because CppAD now uses azmul + where an absolute zero is required.) +
  2. + +The sections +mul_level +, +change_param.cpp +, +mul_level.cpp +, +and mul_level_ode.cpp + were changed to use zdouble +. +
  3. + +The adolc + multi-level examples +mul_level_adolc.cpp + and mul_level_adolc_ode.cpp + +were changed to mention the limitations because Adolc does not have an +absolute zero +. +
  4. + +The example above were also changed so that AD variable names that +indicated the level of AD for the variable. +
  5. + +base_require +: +The base type requirements were modified to include mention of +absolute zero +. +In addition, the base type requirements +API warning + is now more informative. +
+ + +
+
+05-11 +
+Reorganize the unary_standard_math + documentation. + +
+
+05-10 + +
  1. +Add the exponential minus one function log1p +. +
  2. + +base_require +: +If you are defining your own base type, +note that log1p + +was added to the base type requirements. +
  3. + +Use the single preprocessor flag +CPPAD_USE_CPLUSPLUS_2011 to signal that the functions +erf, asinh, acosh, atanh, expm1, log1p + +are part of the base type requirements. +
+ + +
+
+05-09 + +
  1. +Add the exponential minus one function expm1 +. +If you are defining your own base type, +note that expm1 + +was added to the base type requirements. +
  2. + +Fix some warnings about comparing signed and unsigned integers +when using eigen + for the CppAD test vector. +(The eigen vector size() function returns an int instead of a +size_t.) +
+ + +
+
+05-08 + +
  1. +Add the inverse hyperbolic sine function atanh +. +If you are defining your own base type, +note that atanh + +was added to the base type requirements. +
  2. + +Fix a bug in the implementation of the acosh +multiple direction forward mode forward_dir + +(when compiler has acosh +). +
+ + +
+
+05-07 +
+Add the inverse hyperbolic sine function acosh +. +If you are defining your own base type, +note that acosh + +was added to the base type requirements. + +
+
+05-05 +
+Add the inverse hyperbolic sine function asinh +. +If you are defining your own base type, +note that asinh + +was added to the base type requirements. + +
+
+04-18 +
+In the sparse jacobian and sparse hessian calculations, +If +work + is present, and has already been computed, +the sparsity pattern +p + is not used. +This has been added to the documentation; see +sparse jacobian + and +sparse hessian + documentation +for +work + and +p +. + +
+
+03-13 +
+Remove the syntax + +
+     AD<
Basey = x
+
+for the AD constructor + documentation because it does not +work when the constructor is explicit +. +Also document the restriction that the constructor in the +assignment + must be implicit. + +
+
+03-06 +
+The developers of the +TMB + package reported that +for large ADFun + tapes, the optimize + routine uses +a large amount of memory because it allocates a standard set for +each variable on the tape. These sets are only necessary for variables in +conditional expressions + that can be skipped once +the independent variables have a set value. +The problem has been reduced by using a NULL pointer for the empty set +and similar changes. It still needs more work. + +
+
+02-28 +
+It used to be the case that the +Reverse mode + would propagate nan + +through the conditional expression + +case that is not used. +For example, if +
 
+     Independent(ax);
+     AD<double> aeps = 1e-10;
+     ay[0] = CondExpGt( ax[0], aeps, 1.0/ax[0], 1.0/aeps );
+     ADFun<double> f(ax, ay);
+
+The corresponding reverse mode calculation, +at x[0] = 0.0, would result in +
 
+     Error detected by false result for
+     ! ( hasnan(value) && check_for_nan_ )
+
+This has been fixed so that only the conditional expression case that is used +affects the reverse mode results. +The example cond_exp.cpp + was changed to reflect this +(a check for nan was changed to a check for zero). +Note that this fix only works when +IdenticalPar + is true for the +base type of the result in the conditional expression; e.g., +one can still get a nan effect from the case that is not selected +when using AD< AD<double> > conditional expressions. + +
+
+02-18 +
+If the compiler supports the c++11 feature +std::chrono:high_resolution_clock then use it for +the elapsed_seconds + function. + +
+
+02-16 +
+The new example sub_sparse_hes.cpp + shows one way to +compute a Hessian for a subset of variables without having to compute +the sparsity pattern for the entire functions. + +
+
+02-14 +
+Fix another bug in the derivative calculations for the +c++11 version of the error function; see +CPPAD_USE_CPLUSPLUS_2011 +. + +
+
+02-11 +
+Fix a bug in the optimization of conditional expressions. To be specific, +if NDEBUG + is not defined, one could get +an assert with the message: +
 
+     Error detected by false result for
+          var_index_ >= NumRes(op_)
+
+
+02-10 +
+The change on 2014-12-23 + introduced a +bug when the c++11 version of the error function was used with +an optimized + function. see +CPPAD_USE_CPLUSPLUS_2011 +. +There was also a bug in the sparsity calculations for when +this erf function was included. +These bugs have been fixed. + +
+
+02-09 +
+The test test_more/optimize.cpp was failing on some systems +because an exactly equality check should have been a near equal check. +This has been fixed. + +
+
+02-07 +
+On some systems, the library +corresponding to speed/src could not be found. +This library is only used for testing and so has been changed to always be +static (hence does not need to be found at run time). + +
+
+02-06 +
+There was a bug in the coloring method change on +2015-01-07 +. +To be specific, +work.color_method + was not being set +to "cppad.symmetric" after +work.color_method.clear() +. +This has been fixed. + +
+
+02-04 + +
  1. +Enable the same install of CppAD to be used both with and without C++11 +features; e.g., with both g++ --std=c++11 and with +g++ --std=c++98. Previously if the +cppad_cxx_flags + specified C++11, +then it could only be used in that way. +
  2. + +The cmake command + now requires the version +of cmake to be greater than or equal 2.8 +(due a bug in cmake version 2.6). +
+ + +
+
+02-03 +
+Improved the searching for the boost multi-threading library +which is used for by the team_bthread.cpp + case of the +thread_test.cpp + example and test. + +
+
+02-02 +
+Improve the documentation for the +cmake command + line options + +
+     cmake_install_
dir
+
+for +dir + equal to +prefix, postfix, includedirs, libdirs, +datadir, and docdir. + +
+
+01-30 +
+Fix bug in link_sparse_hessian + speed test introduced on +01-09 + below. + +
+
+01-29 +
+Fix some warnings generated by g++ 4.9.2. + +
+
+01-26 +
+The change of global variables to local in +cppad/local/op_code.hpp on 2014-50-14 + +created a bug in parallel_ad + (some local statics needed to +be initialized). This has been fixed. + +
+
+01-23 +
+There was a bug in the cmake + install detection of compiler features. +One symptom of this bug was that on systems that had the gettimeofday +function, the cmake install would sometimes report + +
+     cppad_has_gettimeofday = 0
+
+This has been fixed. + +
+
+01-21 +
+The deprecated auto_tools + procedure had a bug in the +detection of when the size of an unsigned int +was the same as the size of a size_t. This has been fixed. + +
+
+01-20 + +
  1. +The new compare_change + interface has been created +and the old CompareChange + function has been deprecated; +see the compare_change.cpp + example. +This enables one to determine the source code during taping +that corresponds to changes in the comparisons during +zero order forward + operations; see +abort_op_index +. + +
  2. + +This new compare_change + interface can detect comparison changes +even if NDEBUG + is defined and +even if f.optimize() + has been called. +The deprecated function CompareChange used to always return zero after + +
    +     
    f.optimize()
    +
    +and was not even defined when NDEBUG was defined. +There was a resulting speed effect for this; see the wish list +compare change + entry. + +
  3. + +The date when some features where deprecated has been added to the +documentation. For example, see +Deprecated 2006-12-17 +. +
+ + +
+
+01-09 + +
  1. +The change 01-07 below included (but did not mention) using +a sparse, instead of full, structure for the Hessian in the test. +This has also been done for the +sparse Jacobian + test. +
  2. + +For both the +sparse_jacobian + and +sparse_hessian + tests, +the sparse function is only chosen once +(it used to be different for every repeat). +This reduced the amount of computation not connected what is being tested. +It also make the onetape + a valid +option for these tests. +
  3. + +There was a bug in the +multiple direction forward + routine. +Results for function values that are +parameter + were not being computed properly +(all the derivatives are zero in this case). +This has been fixed. +
+ + + +
+
+01-07 +
+The following changes were merged in from the color_hes branch: +
  1. +Specify the type of +coloring + +for the sparse hessian calculations. +To be specific, instead of "cppad" and "colpack", +the choices are "cppad.symmetric", "cppad.general", +and "colpack.star". +This is not compatible with the change on +01-02 +, which was so recent +that this should not be a problem. +
  2. + +The n_sweep + values were +not being returned properly by +cppad_sparse_hessian.cpp + and +adolc_sparse_hessian.cpp +. +The CppAD version has been fixed and the ADOL-C version +has been set to zero. +
  3. + +The link_sparse_hessian + example case was to sparse for good +testing (by mistake). +This has been fixed. +
  4. + +Add +n_sweep + to +link_sparse_hessian + and +speed_main +. +
  5. + +Change the cppad sparse Hessian +color_method + +to take advantage of the symmetry of the Hessian +(in a similar fashion to the colpack coloring method). +
+ + +
+
+01-02 +
+Added to option to uses +colpack + for the sparse Hessian +coloring method +; +see the example colpack_hes.cpp +. + + +
Input File: omh/whats_new/whats_new_15.omh + + + diff -Nru cppad-2015.00.00.9/doc/_whats_new_15_xml.js cppad-2016.00.00.1/doc/_whats_new_15_xml.js --- cppad-2015.00.00.9/doc/_whats_new_15_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_whats_new_15_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,175 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'whats_new.xml', +'whats_new_15.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down1 = [ +'whats_new_15.xml', +'whats_new_14.xml', +'whats_new_13.xml', +'whats_new_12.xml', +'whats_new_11.xml', +'whats_new_10.xml', +'whats_new_09.xml', +'whats_new_08.xml', +'whats_new_07.xml', +'whats_new_06.xml', +'whats_new_05.xml', +'whats_new_04.xml', +'whats_new_03.xml' +]; +var list_current0 = [ +'whats_new_15.xml#Introduction', +'whats_new_15.xml#12-29', +'whats_new_15.xml#12-28', +'whats_new_15.xml#12-08', +'whats_new_15.xml#12-01', +'whats_new_15.xml#11-30', +'whats_new_15.xml#11-25', +'whats_new_15.xml#11-24', +'whats_new_15.xml#11-14', +'whats_new_15.xml#11-08', +'whats_new_15.xml#11-06', +'whats_new_15.xml#10-21', +'whats_new_15.xml#10-16', +'whats_new_15.xml#10-06', +'whats_new_15.xml#10-04', +'whats_new_15.xml#10-03', +'whats_new_15.xml#10-02', +'whats_new_15.xml#09-28', +'whats_new_15.xml#09-27', +'whats_new_15.xml#09-25', +'whats_new_15.xml#09-24', +'whats_new_15.xml#09-23', +'whats_new_15.xml#09-21', +'whats_new_15.xml#09-20', +'whats_new_15.xml#09-19', +'whats_new_15.xml#09-16', +'whats_new_15.xml#09-03', +'whats_new_15.xml#09-02', +'whats_new_15.xml#08-31', +'whats_new_15.xml#08-30', +'whats_new_15.xml#08-29', +'whats_new_15.xml#08-28', +'whats_new_15.xml#08-26', +'whats_new_15.xml#08-25', +'whats_new_15.xml#08-20', +'whats_new_15.xml#08-17', +'whats_new_15.xml#08-16', +'whats_new_15.xml#08-09', +'whats_new_15.xml#08-06', +'whats_new_15.xml#07-31', +'whats_new_15.xml#06-16', +'whats_new_15.xml#06-11', +'whats_new_15.xml#06-09', +'whats_new_15.xml#06-07', +'whats_new_15.xml#05-26', +'whats_new_15.xml#05-26.cond_exp_1', +'whats_new_15.xml#05-26.cond_exp_2', +'whats_new_15.xml#05-11', +'whats_new_15.xml#05-10', +'whats_new_15.xml#05-09', +'whats_new_15.xml#05-08', +'whats_new_15.xml#05-07', +'whats_new_15.xml#05-05', +'whats_new_15.xml#04-18', +'whats_new_15.xml#03-13', +'whats_new_15.xml#03-06', +'whats_new_15.xml#02-28', +'whats_new_15.xml#02-18', +'whats_new_15.xml#02-16', +'whats_new_15.xml#02-14', +'whats_new_15.xml#02-11', +'whats_new_15.xml#02-10', +'whats_new_15.xml#02-09', +'whats_new_15.xml#02-07', +'whats_new_15.xml#02-06', +'whats_new_15.xml#02-04', +'whats_new_15.xml#02-03', +'whats_new_15.xml#02-02', +'whats_new_15.xml#01-30', +'whats_new_15.xml#01-29', +'whats_new_15.xml#01-26', +'whats_new_15.xml#01-23', +'whats_new_15.xml#01-21', +'whats_new_15.xml#01-20', +'whats_new_15.xml#01-09', +'whats_new_15.xml#01-07', +'whats_new_15.xml#01-02' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/whats_new.xml cppad-2016.00.00.1/doc/whats_new.xml --- cppad-2015.00.00.9/doc/whats_new.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/whats_new.xml 2016-02-09 08:32:07.000000000 +0000 @@ -6,7 +6,7 @@ Changes and Additions to CppAD - + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + +wish_list + +

+ + + +
The CppAD Wish List
+
+Base Requirements +
+Change the Base requirements + to use template +specialization instead of functions so that there is a default value +for each function. The default would result in a +known + assert when the operation is used and not +defined by the base class. +An example of this type of template specialization can be found in +the implementation of to_string +. + +
+
+PrintFor Optimization +
+Do not remove PrintFor + operations during optimize + because +they are very useful when debugging expected calculations on the tape. +If not this, we at least need to disable optimization of checkpoint + +functions. + +
+
+checkpoint +
+There should be some examples and tests for both speed and memory use +that demonstrate that checkpointing is useful. + +
+
+Machine Epsilon in Examples +
+Use a multiple of std::numeric_limits<double>::epsilon() instead +1e-10 for a small number in correctness checks; e.g., +see sqrt.cpp +. + +
+
+Adolc +
+Create a documentation page that shows how to convert Adolc commands to +CppAD commands. + +
+
+Optimizing Nested Conditional Expressions +
+If one optimizes + the code +
 
+     x = CondExpLt(left_x, right_x, true_x, false_x)
+     y = CondExpGt(left_y, right_y, true_y, false_y)
+     z = CondExpEq(left_z, right_z, x, y)
+
+only two of the expressions +true_x, false_x, true_y, false_y +will be evaluated +(two will be skipped depending on the result of left_z == right_z). +Not all of the expressions corresponding to +left_x, right_x, left_y, right_y need to be +evaluate, but they are. +The optimizer could be improved to skip two more expressions +(depending on the result of left_z == right_z). + +
+
+Forward Mode Recomputation +
+If the results of forward_order + have already been computed and are still +stored in the ADFun + object (see size_order +), +then they do not need to be recomputed and the results can just be returned. + +
+
+Iterator Interface +
+All of the CppAD simple vector interfaces should also have an +iterator version for the following reasons: +
  1. +It would not be necessary to copy information to simple vectors +when it was originally stored in a different type of container. +
  2. + +It would not be necessary to reallocate memory for a result that is +repeatedly calculated +(because an iterator for the result container would be passed in). +
+ + +
+
+Compilation Speed +
+One could build a CppAD library for use with the type AD<double>. +This would speed up compilation for the most common usage where +the +Base + type is double. + + +
+
+Operation Sequence +
+It is possible to detect if the +AD of +Base + +operation sequence + +does not depend on any of the +independent variable + values. +This could be returned as an extra +seq_property +. + +
+
+Comparison Changes and Optimization +
+The comparison operators used to not be taped when +NDEBUG + was defined. +They are now taped so that the compare_change + interface +works even for compiler optimize code. +This caused a significant slow down in the +cppad_det_lu.cpp + speed test (with no options specified). +Perhaps there should be an option to skip the comparison taping. + +
+
+Software Guidelines +
+The following is a list of some software guidelines taken from +boost +. +These guidelines are not followed by the current CppAD source code, +but perhaps they should be: + +
  1. +Names (except as noted below) +should be all lowercase, with words separated by underscores. +For example, acronyms should be treated as ordinary names +(xml_parser instead of XML_parser). + +
  2. + +Template parameter names should begin with an uppercase letter. + +
  3. + +Use spaces rather than tabs. +Currently, CppAD uses a tabs stops at column multiples of 5. +Five columns were chosen to avoid high levels of indenting and to allow for +
     
    +     if( expression )
    +          statement
    +     else statement
    +
    +with a tab after the else. +Automatic conversion to actual spaces should be easy. + +
+ + +
+
+Tracing +
+Add tracing the operation sequence to the user API and documentation. +Tracing the operation sequence is currently done by changing the CppAD +source code. Use the command +
 
+     grep '^# *define *CPPAD_.*_TRACE' cppad/local/*.hpp
+
+to find all the possible tracing flags. + + +
+
+atan2 +
+The atan2 + function could be made faster by adding +a special operator for it. + + +
+
+BenderQuad +
+See the problem + with the +current BenderQuad specifications. + + +
Input File: omh/wish_list.omh + + + diff -Nru cppad-2015.00.00.9/doc/wishlist.xml cppad-2016.00.00.1/doc/wishlist.xml --- cppad-2015.00.00.9/doc/wishlist.xml 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/wishlist.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,442 +0,0 @@ - - - -The CppAD Wish List - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -WishList - -

- - - -
The CppAD Wish List
-
-Adolc - -
-Create a documentation page that shows how to convert Adolc commands to -CppAD commands. - -
-
-Atan2 - -
-The atan2 - function could be made faster by adding -a special operator for it. - -
-
-BenderQuad -
-See the problem - with the -current BenderQuad specifications. - -
-
-Checkpointing - -
-It would be more flexible to also have a -checkpoint constructor - -that passed in an ADFun - object instead of a algorithm. -Perhaps the syntax would be - -
-     checkpoint 
afun(namead_funcopy)
-
-where -copy - would determine if a separate copy of -ad_fun - -was made or if a pointer was used. -Note that if a pointer is used, it becomes invalid when the destructor -for -ad_fun - is called. - -
-
-Conditional Expressions - - -
-
-Nesting -
-If one optimizes - the code -
 
-	x = CondExpLt(left_x, right_x, true_x, false_x)
-	y = CondExpGt(left_y, right_y, true_y, false_y)
-	z = CondExpEq(left_z, right_z, x, y)
-
- -only two of the expressions -true_x, false_x, true_y, false_y -will be evaluated -(two will be skipped depending on the result of left_z == right_z). -Not all of the expressions corresponding to -left_x, right_x, left_y, right_y need to be -evaluate, but they are. -The optimizer could be improved to skip two more expressions -(depending on the result of left_z == right_z). - -
-
-Sparsity -
-The optimizer - uses -atomic reverse jacobian sparsity - -to determine which arguments affect the value of the results -for the atomic functions (which include checkpoint - functions). -While the partials of - -
-     
z = CondExpRelleftrightif_trueif_false )
-
-with respect to -left - and -right - always evaluates to zero, -the value of -z - does depend on the value of -left - and - -right -. -The checkpoint - functions use the value true for -nz_compare - when computing -reverse jacobian sparsity patterns. -This enables the optimizer to properly track the dependencies. -An atomic_option - should be added so this is only -done when the optimizer is using the sparsity pattern for this purpose. - -
-
-Forward Mode Recomputation - -
-If the results of forward_order - have already been computed and are still -stored in the ADFun - object (see size_order -), -then they do not need to be recomputed and the results can just be returned. - -
-
-Iterator Interface - -
-All of the CppAD simple vector interfaces should also have an -iterator version for the following reasons: -
  1. -It would not be necessary to copy information to simple vectors -when it was originally stored in a different type of container. -
  2. - -It would not be necessary to reallocate memory for a result that is -repeatedly calculated -(because an iterator for the result container would be passed in). -
- - -
-
-Library - - - -
-One could build a CppAD library for use with the type AD<double>. -This would speed up compilation for the most common usage where -the -Base - type is double. - -
-
-Multiple Directions - - - -
  1. -Extend the forward_dir - routine so they can do multiple orders -as well as multiple directions at the same time. -
  2. - -Extend the atomic - functions so they can use multiple directions -and multiple orders at the same time -(currently they compute one direction and one order at a time). -
  3. - -Extend the Reverse - routines so they can handle one reverse direction -for multiple forward directions, or multiple reverse directions for -one forward direction. -
- - -
-
-Numeric Limits - - -
-Use a multiple of std::numeric_limits<double>::epsilon() instead -1e-10 for a small number in correctness checks; e.g., -see tan.cpp -. - -
-
-Operation Sequence - - -
-It is possible to detect if the -AD of -Base - -operation sequence - -does not depend on any of the -independent variable - values. -This could be returned as an extra -seq_property -. - -
-
-Optimization - - - - -
-
-Expression Hashing -
-During expression sequence optimization -, -hash codes are used to detect expressions that have already -been computed. -Perhaps this should be done during the original forward mode recording. - -
-
-Variable Pairs -
-Suppose that -x - is a variable -and -sin(x) - is used in an expression. -The extra expression -cos(x) - is also computed -during a Forward - calculation. -This is because the derivative of the original expression -is expressed in terms of the values of the other expression. -In general, -the representation of the derivative of an expression to order -p - -may include the derivative of another expression to order -p-1 -. -In our example, if only the value -sin(x) - -is requested, it is not necessary to compute -cos(x) -. -We should remove the computation of extra expressions derivatives that are -not need to compute the requested derivative of the original expression. - -
-
-Preprocessor Symbols - -
-Make sure all the user API preprocessor symbols are list in -the preprocessor - section. - -
-
-Software Guidelines - - -
-
-Boost -
-The following is a list of some software guidelines taken from -boost -. -These guidelines are not followed by the current CppAD source code, -but perhaps they should be: - -
  1. -Names (except as noted below) -should be all lowercase, with words separated by underscores. -For example, acronyms should be treated as ordinary names -(xml_parser instead of XML_parser). - -
  2. - -Template parameter names should begin with an uppercase letter. - -
  3. - -Use spaces rather than tabs. -Currently, CppAD uses a tabs stops at column multiples of 5. -Five columns were chosen to avoid high levels of indenting and to allow for -
     
    -	if( expression )
    -		statement
    -	else	statement
    -
    - -with a tab after the else. -Automatic conversion to actual spaces should be easy. - -
- - -
-
-Tracing - - - -
-Add tracing the operation sequence to the user API and documentation. -Tracing the operation sequence is currently done by changing the CppAD -source code. Use the command -
 
-	grep '^# *define *CPPAD_.*_TRACE' cppad/local/*.hpp
-
- -to find all the possible tracing flags. - - -
Input File: omh/wish_list.omh - - - diff -Nru cppad-2015.00.00.9/doc/_wish_list_xml.js cppad-2016.00.00.1/doc/_wish_list_xml.js --- cppad-2015.00.00.9/doc/_wish_list_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_wish_list_xml.js 2016-02-09 08:32:07.000000000 +0000 @@ -0,0 +1,91 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'wish_list.xml' +]; +var list_down2 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down1 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_current0 = [ +'wish_list.xml#Base Requirements', +'wish_list.xml#PrintFor Optimization', +'wish_list.xml#checkpoint', +'wish_list.xml#Machine Epsilon in Examples', +'wish_list.xml#Adolc', +'wish_list.xml#Optimizing Nested Conditional Expressions', +'wish_list.xml#Forward Mode Recomputation', +'wish_list.xml#Iterator Interface', +'wish_list.xml#Compilation Speed', +'wish_list.xml#Operation Sequence', +'wish_list.xml#Comparison Changes and Optimization', +'wish_list.xml#Software Guidelines', +'wish_list.xml#Tracing', +'wish_list.xml#atan2', +'wish_list.xml#BenderQuad' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/_wishlist_xml.js cppad-2016.00.00.1/doc/_wishlist_xml.js --- cppad-2015.00.00.9/doc/_wishlist_xml.js 2015-02-24 08:31:53.000000000 +0000 +++ cppad-2016.00.00.1/doc/_wishlist_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'wishlist.xml' -]; -var list_down2 = [ -'install.xml', -'introduction.xml', -'ad.xml', -'adfun.xml', -'preprocessor.xml', -'multi_thread.xml', -'library.xml', -'ipopt_solve.xml', -'example.xml', -'speed.xml', -'appendix.xml' -]; -var list_down1 = [ -'faq.xml', -'theory.xml', -'glossary.xml', -'bib.xml', -'bugs.xml', -'wishlist.xml', -'whats_new.xml', -'deprecated.xml', -'compare_c.xml', -'license.xml' -]; -var list_current0 = [ -'wishlist.xml#Adolc', -'wishlist.xml#Atan2', -'wishlist.xml#BenderQuad', -'wishlist.xml#Checkpointing', -'wishlist.xml#Conditional Expressions', -'wishlist.xml#Conditional Expressions.Nesting', -'wishlist.xml#Conditional Expressions.Sparsity', -'wishlist.xml#Forward Mode Recomputation', -'wishlist.xml#Iterator Interface', -'wishlist.xml#Library', -'wishlist.xml#Multiple Directions', -'wishlist.xml#Numeric Limits', -'wishlist.xml#Operation Sequence', -'wishlist.xml#Optimization', -'wishlist.xml#Optimization.Expression Hashing', -'wishlist.xml#Optimization.Variable Pairs', -'wishlist.xml#Preprocessor Symbols', -'wishlist.xml#Software Guidelines', -'wishlist.xml#Software Guidelines.Boost', -'wishlist.xml#Tracing' -]; -function choose_across0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_across0[index-1]; -} -function choose_up0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_up0[index-1]; -} -function choose_down2(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down2[index-1]; -} -function choose_down1(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down1[index-1]; -} -function choose_down0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_down0[index-1]; -} -function choose_current0(item) -{ var index = item.selectedIndex; - item.selectedIndex = 0; - if(index > 0) - document.location = list_current0[index-1]; -} diff -Nru cppad-2015.00.00.9/doc/zdouble.cpp.xml cppad-2016.00.00.1/doc/zdouble.cpp.xml --- cppad-2015.00.00.9/doc/zdouble.cpp.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/zdouble.cpp.xml 2016-02-09 08:32:08.000000000 +0000 @@ -0,0 +1,196 @@ + + + +zdouble: Example and Test + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + +zdouble.cppHeadings

+ + + +
zdouble: Example and Test
+
 
+# include <cppad/cppad.hpp>
+
+namespace {
+	template <class Base> bool test(bool is_double)
+	{	bool ok = true;
+		Base eps = 10. * std::numeric_limits<double>::epsilon();
+
+		typedef CppAD::AD<Base>   a1type;
+		typedef CppAD::AD<a1type> a2type;
+
+		// value during taping
+		size_t n = 2;
+		CPPAD_TESTVECTOR(Base) x(n);
+		x[0] = 0.0;
+		x[1] = 0.0;
+
+		// declare independent variable
+		CPPAD_TESTVECTOR(a2type) a2x(n);
+		for (size_t j = 0; j < n; j++)
+			a2x[j] = a2type( a1type(x[j]) );
+		Independent(a2x);
+
+		// zero and one as a2type values
+		a2type a2zero = a2type(0.0);
+		a2type a2one  = a2type(1.0);
+
+		// h(x) = x[0] / x[1] if x[1] > x[0] else 1.0
+		a2type h_x = CondExpGt(a2x[1], a2x[0], a2x[0] / a2x[1], a2one);
+
+		// f(x) = h(x) if x[0] > 0.0 else 0.0
+		//      = x[0] / x[1] if x[1] > x[0]  and x[0] > 0.0
+		//      = 1.0         if x[0] >= x[1] and x[0] > 0.0
+		//      = 0.0         if x[0] <= 0.0
+		a2type f_x = CondExpGt(a2x[0], a2zero, h_x, a2one);
+
+		// define the function f(x)
+		size_t m = 1;
+		CPPAD_TESTVECTOR(a2type) a2y(m);
+		a2y[0] = f_x;
+		CppAD::ADFun<a1type> af1;
+		af1.Dependent(a2x, a2y);
+
+		// Define function g(x) = gradient of f(x)
+		CPPAD_TESTVECTOR(a1type) a1x(n), a1z(n), a1w(m);
+		for (size_t j = 0; j < n; j++)
+			a1x[j] = a1type(x[j]);
+		a1w[0] = a1type(1.0);
+		Independent(a1x);
+		af1.Forward(0, a1x);
+		a1z = af1.Reverse(1, a1w);
+		CppAD::ADFun<Base> g;
+		g.Dependent(a1x, a1z);
+
+		// check result for a case where f(x) = 0.0;
+		CPPAD_TESTVECTOR(Base) z(2);
+		x[0] = 0.0;
+		x[1] = 0.0;
+		z    = g.Forward(0, x);
+		ok &= z[0] == 0.0;
+		ok &= z[1] == 0.0;
+
+		// check result for a case where f(x) = 1.0;
+		x[0] = 1.0;
+		x[1] = 0.5;
+		z    = g.Forward(0, x);
+		ok &= z[0] == 0.0;
+		ok &= z[1] == 0.0;
+
+		// check result for a case where f(x) = x[0] / x[1];
+		x[0] = 1.0;
+		x[1] = 2.0;
+		z    = g.Forward(0, x);
+		ok &= CppAD::NearEqual(z[0], 1.0/x[1], eps, eps);
+		ok &= CppAD::NearEqual(z[1], - x[0]/(x[1]*x[1]), eps, eps);
+
+		return ok;
+	}
+}
+
+bool zdouble(void)
+{	bool ok = true;
+	using CppAD::AD;
+	using CppAD::NearEqual;
+	using CppAD::zdouble;
+	//
+	bool is_double = false;
+	ok &= test<zdouble>(is_double);
+	//
+	is_double = true;
+	ok &= test<double>(is_double);
+	//
+	return ok;
+}
+
+
+ +
+ + +
Input File: test_more/zdouble.cpp + + + diff -Nru cppad-2015.00.00.9/doc/_zdouble.cpp_xml.js cppad-2016.00.00.1/doc/_zdouble.cpp_xml.js --- cppad-2015.00.00.9/doc/_zdouble.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_zdouble.cpp_xml.js 2016-02-09 08:32:08.000000000 +0000 @@ -0,0 +1,86 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'deprecated.xml', +'zdouble.xml', +'zdouble.cpp.xml' +]; +var list_down3 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down2 = [ +'include_deprecated.xml', +'fundeprecated.xml', +'comparechange.xml', +'omp_max_thread.xml', +'tracknewdel.xml', +'omp_alloc.xml', +'memory_leak.xml', +'epsilon.xml', +'test_vector.xml', +'cppad_ipopt_nlp.xml', +'old_atomic.xml', +'zdouble.xml' +]; +var list_down1 = [ +'zdouble.cpp.xml' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc/zdouble.xml cppad-2016.00.00.1/doc/zdouble.xml --- cppad-2015.00.00.9/doc/zdouble.xml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/zdouble.xml 2016-02-09 08:32:08.000000000 +0000 @@ -0,0 +1,327 @@ + + + +zdouble: An AD Base Type With Absolute Zero + + + + + + + + + + + + + + + + +
+ +Prev +Next + + + + + + + + + + + + + + +

+
zdouble: An AD Base Type With Absolute Zero
+
+Deprecated 2015-09-26 +
+Use the function azmul + instead. + +
+
+Absolute Zero +
+The zdouble class acts like the double type +with the added property that zero times any value is zero. +This includes zero time nan + and zero times infinity. +In addition, zero divided by any value and any value times zero +are also zero. + +
+
+Syntax + + +
+
+Constructor and Assignment + +
+ +    zdouble z
+
+ +    zdouble z(x)
+
+ +    z1 op x
+
+where +x + is a double or zdouble object +and +op + is =, +=, -=, *= +or /=-. + +
+
+Comparison Operators + +
+ +    b = z op x
+
+ +    b = x op z
+
+where +b + is a bool object, + +z + is a zdouble object, + +x + is a double or zdouble object, and + +op + is ==, !=, <=, >=, +< or >. + +
+
+Arithmetic Operators + +
+ +    z2 = z1 op x
+
+ +    z2 = x op z1
+
+where +z1 +, +z2 + are zdouble objects, + +x + is a double or zdouble object, and + +op + is +, -, * or /. + + +
+
+Standard Math + +
+ +    z2 = fun(z1)
+
+ +    z3 = pow(z1z2)
+
+where +z1 +, +z2 +, +z3 + are zdouble objects and + +fun + is a unary_standard_math + function. + +
+
+Nan +
+There is a specialization of nan + so that + +
+    z2
 = nan(z1)
+
+returns 'not a number' when +z1 + has type zdouble. +Note that this template function needs to be specialized because + + zdouble(0.0) ==  zdouble(0.0) / zdouble(0.0)
+
+
+Motivation + + +
+
+General +
+Often during computing (and more so in parallel computing) alternative +values for an expression are computed and one of the alternatives +is chosen using some boolean variable. +This is often represented by + +
+     
result = flag * value_if_true + (1 - flag) * value_if_false
+
+where +flag + is one for true and zero for false. +This representation does not work for double when the value +being multiplied by zero is +inf, -inf, or nan. + +
+
+CppAD +
+In CppAD one can use +conditional expressions + to achieve the representation + +
+     
result = flag * value_if_true + (1 - flag) * value_if_false
+
+This works fine except when there are +multiple levels of AD +; e.g., +when using +AD< AD<double> > +. +In this case the corresponding AD function objects have type +ADFun< AD<double> > +. +When these AD function objects compute derivatives using +reverse + mode, the conditional expressions are represented use +zeros to multiply the expression that is not used. +Using +AD< AD<zdouble> > + instead of AD< AD<double> > +makes this representation work and fixes the problem. + +
+
+Base Type Requirements +
+The type zdouble satisfies all of the CppAD +base type requirements +. + + +
+
+Example +
+The file zdouble.cpp + +contains an example and test of this class. +It returns true if it succeeds and false otherwise. + + +
Input File: cppad/local/zdouble.hpp + + + diff -Nru cppad-2015.00.00.9/doc/_zdouble_xml.js cppad-2016.00.00.1/doc/_zdouble_xml.js --- cppad-2015.00.00.9/doc/_zdouble_xml.js 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/doc/_zdouble_xml.js 2016-02-09 08:32:08.000000000 +0000 @@ -0,0 +1,113 @@ +var list_across0 = [ +'_contents_xml.htm', +'_reference.xml', +'_index.xml', +'_search_xml.htm', +'_external.xml' +]; +var list_up0 = [ +'cppad.xml', +'appendix.xml', +'deprecated.xml', +'zdouble.xml' +]; +var list_down3 = [ +'install.xml', +'introduction.xml', +'ad.xml', +'adfun.xml', +'preprocessor.xml', +'multi_thread.xml', +'utility.xml', +'ipopt_solve.xml', +'example.xml', +'speed.xml', +'appendix.xml' +]; +var list_down2 = [ +'faq.xml', +'theory.xml', +'glossary.xml', +'bib.xml', +'wish_list.xml', +'whats_new.xml', +'deprecated.xml', +'compare_c.xml', +'numeric_ad.xml', +'addon.xml', +'license.xml' +]; +var list_down1 = [ +'include_deprecated.xml', +'fundeprecated.xml', +'comparechange.xml', +'omp_max_thread.xml', +'tracknewdel.xml', +'omp_alloc.xml', +'memory_leak.xml', +'epsilon.xml', +'test_vector.xml', +'cppad_ipopt_nlp.xml', +'old_atomic.xml', +'zdouble.xml' +]; +var list_down0 = [ +'zdouble.cpp.xml' +]; +var list_current0 = [ +'zdouble.xml#Deprecated 2015-09-26', +'zdouble.xml#Absolute Zero', +'zdouble.xml#Syntax', +'zdouble.xml#Syntax.Constructor and Assignment', +'zdouble.xml#Syntax.Comparison Operators', +'zdouble.xml#Syntax.Arithmetic Operators', +'zdouble.xml#Syntax.Standard Math', +'zdouble.xml#Syntax.Nan', +'zdouble.xml#Motivation', +'zdouble.xml#Motivation.General', +'zdouble.xml#Motivation.CppAD', +'zdouble.xml#Base Type Requirements', +'zdouble.xml#Example' +]; +function choose_across0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_across0[index-1]; +} +function choose_up0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_up0[index-1]; +} +function choose_down3(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down3[index-1]; +} +function choose_down2(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down2[index-1]; +} +function choose_down1(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down1[index-1]; +} +function choose_down0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_down0[index-1]; +} +function choose_current0(item) +{ var index = item.selectedIndex; + item.selectedIndex = 0; + if(index > 0) + document.location = list_current0[index-1]; +} diff -Nru cppad-2015.00.00.9/doc.omh cppad-2016.00.00.1/doc.omh --- cppad-2015.00.00.9/doc.omh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/doc.omh 2016-02-09 08:31:59.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: doc.omh 3661 2015-02-23 22:19:20Z bradbell $ +$Id: doc.omh 3786 2016-02-08 13:14:26Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -68,6 +68,7 @@ %.%Reverse%(% Reverse %$$ $spell + Jax cppad.hpp cppad namespaces @@ -86,17 +87,13 @@ initializes $$ -$index AD$$, -$index algorithmic differentiation$$ -$index automatic differentiation$$ -$index C++, algorithm derivative$$ -$index CppAD$$ -$index version, CppAD$$ +, $comment bin/version assumes that : follows cppad version number here$$ -$section -cppad-20150000.9: A Package for Differentiation of C++ Algorithms -$$ +$section +cppad-20160000.1: A Package for Differentiation of C++ Algorithms +$$ +$mindex AD algorithmic differentiation automatic C++ algorithm derivative CppAD version cppad.hpp$$ $comment This comment is used to remove the table below$$ $table @@ -108,7 +105,7 @@ (fast to load) $pre $$ $cnext (slow to load) $rnext -Math displayed using Latex $pre $$ $cnext +Math displayed using MathJax $pre $$ $cnext $href%cppad.htm%$$ $pre $$ $cnext $href%_printable.htm%$$ @@ -123,26 +120,25 @@ $code # include $$ $head Introduction$$ -$index introduction$$ We refer to the step by step conversion from an algorithm that computes function values to an algorithm that computes derivative values as $italic Algorithmic Differentiation$$ -(often referred to as $italic Automatic Differentiation$$.) +(often referred to as $italic Automatic Differentiation$$.) Given a C++ algorithm that computes function values, CppAD generates an algorithm that computes its derivative values. A brief introduction to Algorithmic Differentiation can be found in $href%http://en.wikipedia.org/wiki/Automatic_differentiation%wikipedia%$$. -The web site +The web site $href%http://www.autodiff.org%autodiff.org%$$ is dedicated to research about, and promoting the use of, AD. $list number$$ $href%http://www.coin-or.org/CppAD/%CppAD%$$ uses operator overloading to compute derivatives of algorithms defined in C++. -It is distributed by the +It is distributed by the $href%http://www.coin-or.org/foundation.html%COIN-OR Foundation%$$ -with the Eclipse Public License +with the Eclipse Public License $href%http://www.opensource.org/licenses/EPL-1.0%EPL-1.0%$$ or the GNU General Public License $href%http://www.opensource.org/licenses/AGPL-3.0%GPL-3.0%$$. @@ -153,16 +149,16 @@ $lnext An AD of $italic Base$$ $xref/glossary/Operation/Sequence/operation sequence/1/$$ -is stored as an -$xref/ADFun//AD function object/$$ +is stored as an +$xref/ADFun//AD function object/$$ which can evaluate function values and derivatives. -Arbitrary order +Arbitrary order $xref/Forward//forward/$$ and $xref/Reverse//reverse/$$ mode derivative calculations can be preformed on the operation sequence. Logical comparisons can be included in an operation sequence using AD $xref/CondExp//conditional expressions/$$. -Evaluation of user defined unary +Evaluation of user defined unary $xref/Discrete//discrete functions/$$ can also be included in the sequence of operations; i.e., functions that depend on the @@ -182,20 +178,20 @@ A set of programs for doing $cref/speed/$$ comparisons between $href%https://projects.coin-or.org/ADOL-C%Adolc%$$, CppAD, -$href%http://www.imm.dtu.dk/fadbad.html/%Fadbad%$$, +$href%http://www.fadbad.com/%Fadbad%$$, and $href%http://trilinos.sandia.gov/packages/sacado/%Sacado%$$ are included. $lnext -Includes a C++ $xref/library/$$ that is useful +Includes a set of C++ $cref/utilities/utility/$$ that are useful for general operator overloaded numerical method. Allows for replacement of the -$cref/testvector/$$ -template vector class which is used for extensive testing; +$cref/testvector/$$ +template vector class which is used for extensive testing; for example, you can do your testing with the -$href%http://www.boost.org/libs/numeric/ublas/doc/index.htm%uBlas%$$ +$href%http://www.boost.org/libs/numeric/ublas/doc/index.htm%uBlas%$$ template vector class. $lnext @@ -213,12 +209,10 @@ $xref/get_started.cpp/$$ contains an example and test of using CppAD to compute the derivative of a polynomial. -There are many other +There are many other $xref/Example//examples/$$. $head Include File$$ -$index include, cppad.hpp$$ -$index cppad.hpp, include$$ The following include directive $syntax% # include @@ -226,33 +220,28 @@ includes the CppAD package for the rest of the current compilation unit. $head Preprocessor Symbols$$ -$index symbol, preprocessor CppAD$$ -$index preprocessor, symbol CppAD$$ -$index CppAD, preprocessor symbol$$ All the $cref preprocessor$$ symbols used by CppAD begin with eight $code CppAD$$ or $code CPPAD_$$. $head Namespace$$ -$index CppAD, namespace$$ -$index namespace, CppAD$$ All of the functions and objects defined by CppAD are in the -$code CppAD$$ namespace; for example, you can access the $xref/AD/$$ types as +$code CppAD$$ namespace; for example, you can access the $xref/AD/$$ types as $syntax% size_t n = 2; CppAD::vector< CppAD::AD<%Base%> > %x%(%n%) -%$$ -You can abbreviate access to one object or function a $code using$$ +%$$ +You can abbreviate access to one object or function a $code using$$ command of the form $syntax% using CppAD::AD CppAD::vector< AD<%Base%> > %x%(%n%) -%$$ -You can abbreviate access to all CppAD objects and functions +%$$ +You can abbreviate access to all CppAD objects and functions with a command of the form $syntax% using namespace CppAD vector< AD<%Base%> > %x%(%n%) -%$$ +%$$ If you include other namespaces in a similar manner, this can cause naming conflicts. @@ -264,7 +253,7 @@ cppad/local/ad_fun.hpp% omh/preprocessor.omh% omh/multi_thread.omh% - omh/library.omh% + omh/utility.omh% cppad/ipopt/solve.hpp% omh/example.omh% omh/speed/speed.omh% diff -Nru cppad-2015.00.00.9/example/abort_recording.cpp cppad-2016.00.00.1/example/abort_recording.cpp --- cppad-2015.00.00.9/example/abort_recording.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/abort_recording.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: abort_recording.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: abort_recording.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,12 +16,8 @@ $$ $section Abort Current Recording: Example and Test$$ +$mindex recording$$ -$index abort, example$$ -$index example, abort$$ -$index test, abort$$ -$index recording, abort$$ -$index abort, recording$$ $code $verbatim%example/abort_recording.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -40,7 +36,7 @@ using CppAD::AD; - try + try { // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) x(n); @@ -61,23 +57,23 @@ AD::abort_recording(); } /* - Now make sure that we can start another recording + Now make sure that we can start another recording */ // declare independent variables and start tape recording size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + x[0] = x0; CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = 2 * x[0]; // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); // forward computation of partials w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); diff -Nru cppad-2015.00.00.9/example/abs.cpp cppad-2016.00.00.1/example/abs.cpp --- cppad-2015.00.00.9/example/abs.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/abs.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: abs.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: abs.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,13 +18,8 @@ $$ $section AD Absolute Value Function: Example and Test$$ +$mindex abs fabs$$ -$index abs, example$$ -$index fabs, example$$ -$index example, abs$$ -$index example, fabs$$ -$index test, abs$$ -$index test, fabs$$ $code $verbatim%example/abs.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -97,19 +92,19 @@ ok &= (dy[4] == 0. ); // used to be (dy[1] == - dx[0]); ok &= (dy[5] == + dx[0]); - // reverse computation of derivative of y[0] + // reverse computation of derivative of y[0] p = 1; CPPAD_TESTVECTOR(double) w(m), dw(n); 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] + // reverse computation of derivative of y[1] w[0] = 0.; w[1] = 1.; dw = f.Reverse(p, w); ok &= (dw[0] == 0.); - // reverse computation of derivative of y[5] + // reverse computation of derivative of y[5] w[1] = 0.; w[5] = 1.; dw = f.Reverse(p, w); ok &= (dw[0] == 1.); diff -Nru cppad-2015.00.00.9/example/acos.cpp cppad-2016.00.00.1/example/acos.cpp --- cppad-2015.00.00.9/example/acos.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/acos.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: acos.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: acos.cpp 3680 2015-05-07 19:17:37Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,7 +11,7 @@ -------------------------------------------------------------------------- */ /* -$begin Acos.cpp$$ +$begin acos.cpp$$ $spell cos acos @@ -19,10 +19,6 @@ $section The AD acos Function: Example and Test$$ -$index acos, AD example$$ -$index example, AD acos$$ -$index test, AD acos$$ - $code $verbatim%example/acos.cpp%0%// BEGIN C++%// END C++%1%$$ $$ @@ -33,12 +29,15 @@ # include -bool Acos(void) +bool acos(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + // domain space vector size_t n = 1; double x0 = 0.5; @@ -51,37 +50,37 @@ // a temporary value AD cos_of_x0 = CppAD::cos(x[0]); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::acos(cos_of_x0); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value - ok &= NearEqual(y[0] , x0, 1e-10 , 1e-10); + // check value + ok &= NearEqual(y[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], 1., 1e-10, 1e-10); + ok &= NearEqual(dy[0], 1., eps, eps); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 1., 1e-10, 1e-10); + ok &= NearEqual(dw[0], 1., eps, eps); // use a VecAD::reference object with acos CppAD::VecAD v(1); AD zero(0); v[zero] = cos_of_x0; AD result = CppAD::acos(v[zero]); - ok &= NearEqual(result, x0, 1e-10, 1e-10); + ok &= NearEqual(result, x0, eps, eps); return ok; } diff -Nru cppad-2015.00.00.9/example/acosh.cpp cppad-2016.00.00.1/example/acosh.cpp --- cppad-2015.00.00.9/example/acosh.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/acosh.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,88 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin acosh.cpp$$ +$spell + cosh + acosh +$$ + +$section The AD acosh Function: Example and Test$$ + +$code +$verbatim%example/acosh.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# include + +bool acosh(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // a temporary value + AD cosh_of_x0 = CppAD::cosh(x[0]); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = CppAD::acosh(cosh_of_x0); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 1., eps, eps); + + // use a VecAD::reference object with acosh + CppAD::VecAD v(1); + AD zero(0); + v[zero] = cosh_of_x0; + AD result = CppAD::acosh(v[zero]); + ok &= NearEqual(result, x0, eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/example/ad_assign.cpp cppad-2016.00.00.1/example/ad_assign.cpp --- cppad-2015.00.00.9/example/ad_assign.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ad_assign.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ad_assign.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ad_assign.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,8 @@ $$ $section AD Assignment: Example and Test$$ +$mindex assign object$$ -$index assign, AD object$$ -$index example, assign AD object$$ -$index test, assign AD object$$ $code $verbatim%example/ad_assign.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -36,12 +34,12 @@ using CppAD::AD; // so can use AD in place of CppAD::AD // assignment to base value - AD a; + AD a; a = 1.; ok &= a == 1.; // assignment to a value that converts to the base type - a = 2; + a = 2; ok &= a == 2.; // assignment to an AD diff -Nru cppad-2015.00.00.9/example/ad_ctor.cpp cppad-2016.00.00.1/example/ad_ctor.cpp --- cppad-2015.00.00.9/example/ad_ctor.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ad_ctor.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ad_ctor.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ad_ctor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,8 @@ $$ $section AD Constructors: Example and Test$$ +$mindex constructor object$$ -$index constructor, AD object$$ -$index example, constructor AD object$$ -$index test, constructor AD object$$ $code $verbatim%example/ad_ctor.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -41,7 +39,7 @@ ok &= a == 0.; // constructor from base type - AD b(1.); + AD b(1.); ok &= b == 1.; // constructor from another type that converts to the base type @@ -49,7 +47,7 @@ ok &= c == 2.; // constructor from AD - AD d(c); + AD d(c); ok &= d == 2.; // constructor from a VecAD element diff -Nru cppad-2015.00.00.9/example/add.cpp cppad-2016.00.00.1/example/add.cpp --- cppad-2015.00.00.9/example/add.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/add.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: add.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: add.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,12 +14,8 @@ $begin add.cpp$$ $section AD Binary Addition: Example and Test$$ +$mindex + add plus$$ -$index +, AD example$$ -$index add, AD example$$ -$index plus, AD example$$ -$index example, AD add$$ -$index test, AD add$$ $code $verbatim%example/add.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -39,7 +35,7 @@ size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); @@ -47,18 +43,18 @@ // some binary addition operations AD a = x[0] + 1.; // AD + double AD b = a + 2; // AD + int - AD c = 3. + b; // double + AD - AD d = 4 + c; // int + AD + AD c = 3. + b; // double + AD + AD d = 4 + c; // int + AD - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); - y[0] = d + x[0]; // AD + AD + y[0] = d + x[0]; // AD + AD // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , 2. * x0 + 10, 1e-10 , 1e-10); // forward computation of partials w.r.t. x[0] diff -Nru cppad-2015.00.00.9/example/add_eq.cpp cppad-2016.00.00.1/example/add_eq.cpp --- cppad-2015.00.00.9/example/add_eq.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/add_eq.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: add_eq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: add_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,17 +14,9 @@ $begin AddEq.cpp$$ $section AD Computed Assignment Addition: Example and Test$$ +$mindex += add assign plus$$ + -$index +=, AD example$$ -$index computed, AD assignment add example$$ -$index assignment, AD computed add example$$ -$index example, AD computed assignment add$$ -$index test, AD computed assignment add$$ - -$index computed, += example$$ -$index assign, += example$$ -$index plus, += example$$ -$index add, += example$$ $code $verbatim%example/add_eq.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -44,12 +36,12 @@ size_t n = 1; double x0 = .5; CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 2; CPPAD_TESTVECTOR(AD) y(m); y[0] = x[0]; // initial value @@ -58,9 +50,9 @@ y[1] = y[0] += x[0]; // use the result of a computed assignment // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0+2.+4.+x0, 1e-10 , 1e-10); ok &= NearEqual(y[1] , y[0], 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/ad_fun.cpp cppad-2016.00.00.1/example/ad_fun.cpp --- cppad-2015.00.00.9/example/ad_fun.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/ad_fun.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ad_fun.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ad_fun.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,10 +16,8 @@ $$ $section Creating Your Own Interface to an ADFun Object$$ +$mindex example test$$ -$index ADFun, example$$ -$index example, ADFun$$ -$index test, ADFun$$ $code $verbatim%example/ad_fun.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -36,37 +34,37 @@ // This class is an example of a different interface to an AD function object template class my_ad_fun { - + private: CppAD::ADFun f; - + public: // default constructor my_ad_fun(void) { } - + // destructor ~ my_ad_fun(void) { } - + // Construct an my_ad_fun object with an operation sequence. - // This is the same as for ADFun except that no zero - // order forward sweep is done. Note Hessian and Jacobian do - // their own zero order forward mode sweep. + // This is the same as for ADFun except that no zero + // order forward sweep is done. Note Hessian and Jacobian do + // their own zero order forward mode sweep. template my_ad_fun(const ADvector& x, const ADvector& y) { f.Dependent(x, y); } - + // same as ADFun::Jacobian template - VectorBase jacobian(const VectorBase& x) + VectorBase jacobian(const VectorBase& x) { return f.Jacobian(x); } // same as ADFun::Hessian template VectorBase hessian(const VectorBase &x, const VectorBase &w) { return f.Hessian(x, w); } - }; + }; } // End empty namespace diff -Nru cppad-2015.00.00.9/example/ad_in_c.cpp cppad-2016.00.00.1/example/ad_in_c.cpp --- cppad-2015.00.00.9/example/ad_in_c.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/ad_in_c.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ad_in_c.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: ad_in_c.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,16 +17,9 @@ $$ $section Example and Test Linking CppAD to Languages Other than C++$$ +$mindex C AD algorithmic differentiation automatic link$$ -$index C, AD$$ -$index C, algorithmic differentiation$$ -$index algorithmic, C differentiation$$ -$index automatic, C differentiation$$ -$index example, C AD$$ -$index test, C AD$$ -$index link, CppAD to language$$ -$index language, link CppAD$$ $code $verbatim%example/ad_in_c.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -54,18 +47,18 @@ } */ -// type in C corresponding to an AD object +// type in C corresponding to an AD object typedef struct { void* p_void; } cad; -// type in C corresponding to a an ADFun +// type in C corresponding to a an ADFun typedef struct { void* p_void; } cad_fun; // type in C corresponding to a C AD binary operator typedef enum { op_add, op_sub, op_mul, op_div } cad_binary_op; // type in C corresponding to a C AD unary operator -typedef enum { - op_abs, op_acos, op_asin, op_atan, op_cos, op_cosh, +typedef enum { + op_abs, op_acos, op_asin, op_atan, op_cos, op_cosh, op_exp, op_log, op_sin, op_sinh, op_sqrt } cad_unary_op; @@ -79,7 +72,7 @@ void cad2vector(size_t n, cad* p_cad, vector< AD >& v) { assert( n == v.size() ); for(size_t j = 0; j < n; j++) - { AD* p_ad = + { AD* p_ad = reinterpret_cast< AD* > (p_cad[j].p_void); v[j] = *p_ad; } @@ -88,7 +81,7 @@ void vector2cad(size_t n, vector< AD >& v, cad* p_cad) { assert( n == v.size() ); for(size_t j = 0; j < n; j++) - { AD* p_ad = + { AD* p_ad = reinterpret_cast< AD* > (p_cad[j].p_void); *p_ad = v[j]; } @@ -142,12 +135,12 @@ // create a C++ AD object // value is the value that the C++ AD object will have // p_cad->p_void: on input is 0, on output points to C++ AD object -extern "C" +extern "C" void cad_new_ad(cad *p_cad, double value) { // make sure pointer is not currently allocated assert( p_cad->p_void == 0 ); - AD* p_ad = new AD(value); + AD* p_ad = new AD(value); p_cad->p_void = reinterpret_cast(p_ad); // put in list of allocate pointers @@ -157,7 +150,7 @@ // delete a C++ AD object // p_cad->value: not used // p_cad->p_void: on input points to C++ AD object, on output is 0 -extern "C" +extern "C" void cad_del_ad(cad* p_cad) { // make sure that p_cad has been allocated pop_allocated( p_cad->p_void ); @@ -178,7 +171,7 @@ // preform a C AD unary operation extern "C" -void cad_unary(cad_unary_op op, cad* p_operand, cad* p_result) +void cad_unary(cad_unary_op op, cad* p_operand, cad* p_result) { AD *operand, *result; result = reinterpret_cast< AD* > (p_result->p_void); operand = reinterpret_cast< AD* > (p_operand->p_void); @@ -197,7 +190,7 @@ break; case op_atan: - *result = atan( *operand ); + *result = atan( *operand ); break; case op_cos: @@ -240,14 +233,14 @@ // perform a C AD binary operation extern "C" void cad_binary(cad_binary_op op, cad* p_left, cad* p_right, cad* p_result) -{ AD *result, *left, *right; +{ AD *result, *left, *right; result = reinterpret_cast< AD* > (p_result->p_void); left = reinterpret_cast< AD* > (p_left->p_void); right = reinterpret_cast< AD* > (p_right->p_void); assert( result != 0 ); assert( left != 0 ); assert( right != 0 ); - + switch(op) { case op_add: *result = *left + (*right); @@ -293,7 +286,7 @@ cad2vector(m, py_cad, y); p_adfun->Dependent(x, y); - fun.p_void = reinterpret_cast( p_adfun ); + fun.p_void = reinterpret_cast( p_adfun ); // put in list of allocate pointers push_allocated( fun.p_void ); @@ -307,7 +300,7 @@ { // make sure this pointer has been allocated pop_allocated( fun->p_void ); - ADFun* p_adfun + ADFun* p_adfun = reinterpret_cast< ADFun* > (fun->p_void); delete p_adfun; @@ -317,11 +310,11 @@ // evaluate the Jacobian corresponding to a function object extern "C" -void cad_jacobian(cad_fun fun, +void cad_jacobian(cad_fun fun, size_t n, size_t m, double* px, double* pjac ) { assert( fun.p_void != 0 ); - ADFun* p_adfun = + ADFun* p_adfun = reinterpret_cast< ADFun* >(fun.p_void); vector x(n), jac(n * m); @@ -332,11 +325,11 @@ // forward mode extern "C" -void cad_forward(cad_fun fun, +void cad_forward(cad_fun fun, size_t order, size_t n, size_t m, double* px, double* py ) { assert( fun.p_void != 0 ); - ADFun* p_adfun = + ADFun* p_adfun = reinterpret_cast< ADFun* >(fun.p_void); vector x(n), y(m); @@ -384,7 +377,7 @@ cad_new_ad(Y + i, value); } - // declare X as the independent variable vector + // declare X as the independent variable vector cad_independent(n, X); // y[0] = x[0] + x[1] @@ -412,8 +405,8 @@ cad asin_sin_x0 = { 0 }; // initialize p_void as zero cad_new_ad( &asin_sin_x0, 0.); cad_unary(op_asin, &sin_x0, &asin_sin_x0); - ok &= cad_near_equal( - cad_value(&asin_sin_x0), + ok &= cad_near_equal( + cad_value(&asin_sin_x0), asin( cad_value(&sin_x0) ) ); @@ -422,7 +415,7 @@ cad_value(Y+4), cad_value(&sin_x0) + cad_value(&asin_sin_x0) ); - + // declare y as the dependent variable vector and stop recording // and store function object in f cad_fun f = cad_new_fun(n, m, X, Y); @@ -463,7 +456,7 @@ double y[M]; x[0] = .5; x[1] = 1.; - cad_forward(f, order, n, m, x, y); + cad_forward(f, order, n, m, x, y); // check the function values ok &= cad_near_equal(y[0] , x[0] + x[1] ); @@ -477,7 +470,7 @@ cad_del_ad( &sin_x0 ); cad_del_ad( &asin_sin_x0 ); for(j = 0; j < n; j++) - cad_del_ad(X + j); + cad_del_ad(X + j); for(i = 0; i < m; i++) cad_del_ad(Y + i); diff -Nru cppad-2015.00.00.9/example/ad_input.cpp cppad-2016.00.00.1/example/ad_input.cpp --- cppad-2015.00.00.9/example/ad_input.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ad_input.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ad_input.cpp 2693 2012-12-31 02:59:12Z bradbell $ */ +// $Id: ad_input.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section AD Output Operator: Example and Test$$ +$mindex << input$$ -$index <<, AD example$$ -$index input, AD example$$ -$index example, AD input$$ -$index test, AD input$$ $code $verbatim%example/ad_input.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -51,14 +48,14 @@ CppAD::AD z = x[0]; ok &= Variable(z); - // read first number into z and second into y[0] + // read first number into z and second into y[0] is >> z >> y[0]; ok &= Parameter(z); ok &= (z == 123.); ok &= Parameter(y[0]); ok &= (y[0] == 456.); // - // terminate recording starting by call to Independent + // terminate recording starting by call to Independent CppAD::ADFun f(x, y); return ok; diff -Nru cppad-2015.00.00.9/example/ad_output.cpp cppad-2016.00.00.1/example/ad_output.cpp --- cppad-2015.00.00.9/example/ad_output.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ad_output.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ad_output.cpp 2692 2012-12-31 01:27:34Z bradbell $ */ +// $Id: ad_output.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section AD Output Operator: Example and Test$$ +$mindex <<$$ -$index <<, AD example$$ -$index output, AD example$$ -$index example, AD output$$ -$index test, AD output$$ $code $verbatim%example/ad_output.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -41,7 +38,7 @@ namespace { template void set_ostream(S &os) - { os + { os << std::setprecision(4) // 4 digits of precision << std::setw(6) // 6 characters per field << std::setfill(' ') // fill with spaces @@ -65,7 +62,7 @@ CppAD::VecAD v(1); CppAD::AD zero(0); v[zero] = exp(1.); // 2.7182818285 - set_ostream(stream); + set_ostream(stream); stream << v[zero]; // convert output from stream to string diff -Nru cppad-2015.00.00.9/example/asin.cpp cppad-2016.00.00.1/example/asin.cpp --- cppad-2015.00.00.9/example/asin.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/asin.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: asin.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: asin.cpp 3675 2015-05-05 14:26:18Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,7 +11,7 @@ -------------------------------------------------------------------------- */ /* -$begin Asin.cpp$$ +$begin asin.cpp$$ $spell sin asin @@ -19,10 +19,6 @@ $section The AD asin Function: Example and Test$$ -$index asin, AD example$$ -$index example, AD asin$$ -$index test, AD asin$$ - $code $verbatim%example/asin.cpp%0%// BEGIN C++%// END C++%1%$$ $$ @@ -33,12 +29,15 @@ # include -bool Asin(void) +bool asin(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + // domain space vector size_t n = 1; double x0 = 0.5; @@ -51,37 +50,37 @@ // a temporary value AD sin_of_x0 = CppAD::sin(x[0]); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::asin(sin_of_x0); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value - ok &= NearEqual(y[0] , x0, 1e-10 , 1e-10); + // check value + ok &= NearEqual(y[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], 1., 1e-10, 1e-10); + ok &= NearEqual(dy[0], 1., eps, eps); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 1., 1e-10, 1e-10); + ok &= NearEqual(dw[0], 1., eps, eps); // use a VecAD::reference object with asin CppAD::VecAD v(1); AD zero(0); v[zero] = sin_of_x0; AD result = CppAD::asin(v[zero]); - ok &= NearEqual(result, x0, 1e-10, 1e-10); + ok &= NearEqual(result, x0, eps, eps); return ok; } diff -Nru cppad-2015.00.00.9/example/asinh.cpp cppad-2016.00.00.1/example/asinh.cpp --- cppad-2015.00.00.9/example/asinh.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/asinh.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,88 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin asinh.cpp$$ +$spell + sinh + asinh +$$ + +$section The AD asinh Function: Example and Test$$ + +$code +$verbatim%example/asinh.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# include + +bool asinh(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // a temporary value + AD sinh_of_x0 = CppAD::sinh(x[0]); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = CppAD::asinh(sinh_of_x0); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 1., eps, eps); + + // use a VecAD::reference object with asinh + CppAD::VecAD v(1); + AD zero(0); + v[zero] = sinh_of_x0; + AD result = CppAD::asinh(v[zero]); + ok &= NearEqual(result, x0, eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/example/atan2.cpp cppad-2016.00.00.1/example/atan2.cpp --- cppad-2015.00.00.9/example/atan2.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atan2.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: atan2.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: atan2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $section The AD atan2 Function: Example and Test$$ -$index atan2, AD example$$ -$index example, AD atan2$$ -$index test, AD atan2$$ $code $verbatim%example/atan2.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -33,7 +30,7 @@ # include -bool Atan2(void) +bool atan2(void) { bool ok = true; using CppAD::AD; @@ -52,15 +49,15 @@ AD sin_of_x0 = CppAD::sin(x[0]); AD cos_of_x0 = CppAD::cos(x[0]); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::atan2(sin_of_x0, cos_of_x0); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0, 1e-10 , 1e-10); // forward computation of first partial w.r.t. x[0] diff -Nru cppad-2015.00.00.9/example/atan.cpp cppad-2016.00.00.1/example/atan.cpp --- cppad-2015.00.00.9/example/atan.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/atan.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: atan.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: atan.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $section The AD atan Function: Example and Test$$ -$index atan, AD example$$ -$index example, AD atan$$ -$index test, AD atan$$ $code $verbatim%example/atan.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -33,7 +30,7 @@ # include -bool Atan(void) +bool atan(void) { bool ok = true; using CppAD::AD; @@ -51,15 +48,15 @@ // a temporary value AD tan_of_x0 = CppAD::tan(x[0]); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::atan(tan_of_x0); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0, 1e-10 , 1e-10); // forward computation of first partial w.r.t. x[0] diff -Nru cppad-2015.00.00.9/example/atanh.cpp cppad-2016.00.00.1/example/atanh.cpp --- cppad-2015.00.00.9/example/atanh.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/atanh.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,88 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin atanh.cpp$$ +$spell + tanh + atanh +$$ + +$section The AD atanh Function: Example and Test$$ + +$code +$verbatim%example/atanh.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# include + +bool atanh(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // a temporary value + AD tanh_of_x0 = CppAD::tanh(x[0]); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = CppAD::atanh(tanh_of_x0); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 1., eps, eps); + + // use a VecAD::reference object with atanh + CppAD::VecAD v(1); + AD zero(0); + v[zero] = tanh_of_x0; + AD result = CppAD::atanh(v[zero]); + ok &= NearEqual(result, x0, eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/example/atomic/atomic.cpp cppad-2016.00.00.1/example/atomic/atomic.cpp --- cppad-2015.00.00.9/example/atomic/atomic.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/atomic.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: atomic.cpp 3505 2014-12-26 15:06:54Z bradbell $ */ +// $Id: atomic.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,7 +17,7 @@ # include // for thread_alloc -# include +# include // external complied tests extern bool checkpoint(void); @@ -26,12 +26,8 @@ extern bool mat_mul(void); extern bool norm_sq(void); extern bool reciprocal(void); +extern bool sparsity(void); extern bool tangent(void); -extern bool old_mat_mul(void); -extern bool old_reciprocal(void); -extern bool old_tan(void); -extern bool old_usead_1(void); -extern bool old_usead_2(void); namespace { // function that runs one test @@ -65,12 +61,8 @@ ok &= Run( mat_mul, "mat_mul" ); ok &= Run( norm_sq, "norm_sq" ); ok &= Run( reciprocal, "reciprocal" ); + ok &= Run( sparsity, "sparsity" ); ok &= Run( tangent, "tangent" ); - ok &= Run( old_mat_mul, "old_mat_mul" ); - ok &= Run( old_reciprocal, "old_reciprocal" ); - ok &= Run( old_tan, "old_tan" ); - ok &= Run( old_usead_1, "old_usead_1" ); - ok &= Run( old_usead_2, "old_usead_2" ); // check for errors using std::cout; diff -Nru cppad-2015.00.00.9/example/atomic/checkpoint.cpp cppad-2016.00.00.1/example/atomic/checkpoint.cpp --- cppad-2015.00.00.9/example/atomic/checkpoint.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/checkpoint.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: checkpoint.cpp 3160 2014-03-05 17:04:14Z bradbell $ */ +/* $Id: checkpoint.cpp 3721 2015-09-04 03:15:40Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,32 +19,28 @@ $section Simple Checkpointing: Example and Test$$ -$index checkpoint, example$$ -$index example, checkpoint$$ -$index test, checkpoint$$ - $head Purpose$$ -Break a large computation into pieces and only store values at the +Break a large computation into pieces and only store values at the interface of the pieces. -In actual applications, there may be many functions, but +In actual applications, there may be many functions, but for this example there are only two. -The functions -$latex F : \B{R}^2 \rightarrow \B{R}^2$$ +The functions +$latex F : \B{R}^2 \rightarrow \B{R}^2$$ and -$latex G : \B{R}^2 \rightarrow \B{R}^2$$ +$latex G : \B{R}^2 \rightarrow \B{R}^2$$ defined by $latex \[ - F(x) = \left( \begin{array}{c} - x_0 \cdot x_0 \cdot x_0 \cdot x_0 \cdot x_0 + F(y) = \left( \begin{array}{c} + y_0 + y_0 + y_0 \\ - x_1 \cdot x_1 \cdot x_1 \cdot x_1 \cdot x_1 - \end{array} \right) + y_1 + y_1 + y_1 + \end{array} \right) \; , \; - G(y) = \left( \begin{array}{c} - y_0 + y_0 + y_0 - \\ - y_1 + y_1 + y_1 - \end{array} \right) + G(x) = \left( \begin{array}{c} + \cdot x_0 \cdot x_0 \cdot x_0 + \\ + \cdot x_1 \cdot x_1 \cdot x_1 + \end{array} \right) \] $$ $code @@ -60,119 +56,137 @@ namespace { using CppAD::AD; - typedef CPPAD_TESTVECTOR(AD) ADVector; + typedef CPPAD_TESTVECTOR(AD) ADVector; + typedef CppAD::atomic_base::option_enum option_enum; - void f_algo(const ADVector& x, ADVector& y) + void f_algo(const ADVector& y, ADVector& z) + { z[0] = 0.0; + z[1] = 0.0; + for(size_t k = 0; k < 3; k++) + { z[0] += y[0]; + z[1] += y[1]; + } + return; + } + void g_algo(const ADVector& x, ADVector& y) { y[0] = 1.0; y[1] = 1.0; - for(size_t k = 0; k < 5; k++) + for(size_t k = 0; k < 3; k++) { y[0] *= x[0]; y[1] *= x[1]; } return; } - void g_algo(const ADVector& y, ADVector& z) - { z[0] = 0.0; - z[1] = 0.0; - for(size_t k = 0; k < 3; k++) - { z[0] += y[0]; - z[1] += y[1]; + bool test_case(option_enum f_sparsity, option_enum g_sparsity) + { bool ok = true; + using CppAD::checkpoint; + using CppAD::ADFun; + using CppAD::NearEqual; + size_t i, j, k, n = 2, m = n; + double eps = 10. * std::numeric_limits::epsilon(); + + // checkpoint version of the function F(x) + ADVector ax(n), ay(n), az(m); + for(j = 0; j < n; j++) + ax[j] = double(j + 1); + // could also use bool_sparsity_enum or set_sparsity_enum + checkpoint atom_f("atom_f", f_algo, ax, ay, f_sparsity); + checkpoint atom_g("atom_g", g_algo, ay, az, g_sparsity); + + // Record a version of z = g[f(x)] without checkpointing + Independent(ax); + f_algo(ax, ay); + g_algo(ay, az); + ADFun check_not(ax, az); + + // Record a version of z = g[f(x)] with checkpointing + Independent(ax); + atom_f(ax, ay); + atom_g(ay, az); + ADFun check_yes(ax, az); + + // checkpointing should use fewer operations + ok &= check_yes.size_var() < check_not.size_var(); + + // this does not really save space becasue f and g are only used once + ok &= check_not.size_var() <= + check_yes.size_var() + atom_f.size_var() + atom_g.size_var(); + + // compare forward mode results for orders 0, 1, 2 + size_t q = 2; + CPPAD_TESTVECTOR(double) x_q(n*(q+1)), z_not(m*(q+1)), z_yes(m*(q+1)); + for(j = 0; j < n; j++) + { for(k = 0; k <= q; k++) + x_q[ j * (q+1) + k ] = 1.0 / (q + 1 - k); } - return; + z_not = check_not.Forward(q, x_q); + z_yes = check_yes.Forward(q, x_q); + for(i = 0; i < m; i++) + { for(k = 0; k <= q; k++) + { double zik_not = z_not[ i * (q+1) + k]; + double zik_yes = z_yes[ i * (q+1) + k]; + ok &= NearEqual(zik_not, zik_yes, eps, eps); + } + } + + // compare reverse mode results + CPPAD_TESTVECTOR(double) w(m*(q+1)), dw_not(n*(q+1)), dw_yes(n*(q+1)); + dw_not = check_not.Reverse(q+1, w); + dw_yes = check_yes.Reverse(q+1, w); + for(j = 0; j < n; j++) + { for(k = 0; k <= q; k++) + { double dwjk_not = dw_not[ j * (q+1) + k]; + double dwjk_yes = dw_yes[ j * (q+1) + k]; + ok &= NearEqual(dwjk_not, dwjk_yes, eps, eps); + } + } + + // compare forward mode Jacobian sparsity patterns + CppAD::vector< std::set > r(n), s_not(m), s_yes(m); + for(j = 0; j < n; j++) + r[j].insert(j); + s_not = check_not.ForSparseJac(n, r); + s_yes = check_yes.ForSparseJac(n, r); + for(i = 0; i < m; i++) + ok &= s_not[i] == s_yes[i]; + + // compare reverse mode Jacobian sparsity patterns + CppAD::vector< std::set > s(m), r_not(m), r_yes(m); + for(i = 0; i < m; i++) + s[i].insert(i); + r_not = check_not.RevSparseJac(m, s); + r_yes = check_yes.RevSparseJac(m, s); + for(i = 0; i < m; i++) + ok &= s_not[i] == s_yes[i]; + + + // compare reverse mode Hessian sparsity patterns + CppAD::vector< std::set > s_one(1), h_not(n), h_yes(n); + for(i = 0; i < m; i++) + s_one[0].insert(i); + h_not = check_not.RevSparseHes(n, s_one); + h_yes = check_yes.RevSparseHes(n, s_one); + for(i = 0; i < n; i++) + ok &= h_not[i] == h_yes[i]; + + return ok; } } bool checkpoint(void) { bool ok = true; - using CppAD::checkpoint; - using CppAD::ADFun; - using CppAD::NearEqual; - size_t i, j, k, n = 2, m = n; - double eps = 10. * std::numeric_limits::epsilon(); - - // checkpoint version of the function F(x) - ADVector ax(n), ay(n), az(m); - for(j = 0; j < n; j++) - ax[j] = double(j); - checkpoint f_check("f_check", f_algo, ax, ay); - checkpoint g_check("g_check", g_algo, ay, az); - - // Record a version of z = g[f(x)] without checkpointing - Independent(ax); - f_algo(ax, ay); - g_algo(ay, az); - ADFun check_not(ax, az); - - // Record a version of z = g[f(x)] with checkpointing - Independent(ax); - f_check(ax, ay); - g_check(ay, az); - ADFun check_yes(ax, az); - - // checkpointing should use fewer operations - ok &= check_yes.size_var() < check_not.size_var(); - - // compare forward mode results for orders 0, 1, 2 - size_t q = 2; - CPPAD_TESTVECTOR(double) x_q(n*(q+1)), z_not(m*(q+1)), z_yes(m*(q+1)); - for(j = 0; j < n; j++) - { for(k = 0; k <= q; k++) - x_q[ j * (q+1) + k ] = 1.0 / (q + 1 - k); - } - z_not = check_not.Forward(q, x_q); - z_yes = check_yes.Forward(q, x_q); - for(i = 0; i < m; i++) - { for(k = 0; k <= q; k++) - { double zik_not = z_not[ i * (q+1) + k]; - double zik_yes = z_yes[ i * (q+1) + k]; - ok &= NearEqual(zik_not, zik_yes, eps, eps); - } - } - // compare reverse mode results - CPPAD_TESTVECTOR(double) w(m*(q+1)), dw_not(n*(q+1)), dw_yes(n*(q+1)); - dw_not = check_not.Reverse(q+1, w); - dw_yes = check_yes.Reverse(q+1, w); - for(j = 0; j < n; j++) - { for(k = 0; k <= q; k++) - { double dwjk_not = dw_not[ j * (q+1) + k]; - double dwjk_yes = dw_yes[ j * (q+1) + k]; - ok &= NearEqual(dwjk_not, dwjk_yes, eps, eps); - } - } + // different types of sparsity + option_enum pack_sparsity = CppAD::atomic_base::pack_sparsity_enum; + option_enum bool_sparsity = CppAD::atomic_base::bool_sparsity_enum; + option_enum set_sparsity = CppAD::atomic_base::set_sparsity_enum; + + // test some different cases + ok &= test_case(pack_sparsity, pack_sparsity); + ok &= test_case(pack_sparsity, bool_sparsity); + ok &= test_case(bool_sparsity, set_sparsity); + ok &= test_case(set_sparsity, set_sparsity); - // mix sparsity so test both cases - f_check.option( CppAD::atomic_base::bool_sparsity_enum ); - g_check.option( CppAD::atomic_base::set_sparsity_enum ); - - // compare forward mode Jacobian sparsity patterns - CppAD::vector< std::set > r(n), s_not(m), s_yes(m); - for(j = 0; j < n; j++) - r[j].insert(j); - s_not = check_not.ForSparseJac(n, r); - s_yes = check_yes.ForSparseJac(n, r); - for(i = 0; i < m; i++) - ok &= s_not[i] == s_yes[i]; - - // compare reverse mode Jacobian sparsity patterns - CppAD::vector< std::set > s(m), r_not(m), r_yes(m); - for(i = 0; i < m; i++) - s[i].insert(i); - r_not = check_not.RevSparseJac(m, s); - r_yes = check_yes.RevSparseJac(m, s); - for(i = 0; i < m; i++) - ok &= s_not[i] == s_yes[i]; - - - // compare reverse mode Hessian sparsity patterns - CppAD::vector< std::set > s_one(1), h_not(n), h_yes(n); - for(i = 0; i < m; i++) - s_one[0].insert(i); - h_not = check_not.RevSparseHes(n, s_one); - h_yes = check_yes.RevSparseHes(n, s_one); - for(i = 0; i < n; i++) - ok &= h_not[i] == h_yes[i]; - return ok; } // END C++ diff -Nru cppad-2015.00.00.9/example/atomic/CMakeLists.txt cppad-2016.00.00.1/example/atomic/CMakeLists.txt --- cppad-2015.00.00.9/example/atomic/CMakeLists.txt 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/CMakeLists.txt 2016-02-09 08:31:54.000000000 +0000 @@ -1,22 +1,22 @@ -# $Id: CMakeLists.txt 3505 2014-12-26 15:06:54Z bradbell $ +# $Id: CMakeLists.txt 3740 2015-10-07 03:47:28Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the example/atomic directory tests +# Build the example/atomic directory tests -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # -ADD_EXECUTABLE(example_atomic EXCLUDE_FROM_ALL +ADD_EXECUTABLE(example_atomic EXCLUDE_FROM_ALL atomic.cpp checkpoint.cpp get_started.cpp @@ -24,19 +24,15 @@ mat_mul.cpp norm_sq.cpp reciprocal.cpp + sparsity.cpp tangent.cpp - old_reciprocal.cpp - old_mat_mul.cpp - old_tan.cpp - old_usead_1.cpp - old_usead_2.cpp ) # Extra compiler flags add_cppad_cxx_flags( example_atomic ) # Add the check_example_atomic target -ADD_CUSTOM_TARGET(check_example_atomic - example_atomic - DEPENDS example_atomic +ADD_CUSTOM_TARGET(check_example_atomic + example_atomic + DEPENDS example_atomic ) diff -Nru cppad-2015.00.00.9/example/atomic/get_started.cpp cppad-2016.00.00.1/example/atomic/get_started.cpp --- cppad-2015.00.00.9/example/atomic/get_started.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/get_started.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: get_started.cpp 3160 2014-03-05 17:04:14Z bradbell $ +// $Id: get_started.cpp 3715 2015-08-30 12:20:43Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,9 +14,6 @@ $begin atomic_get_started.cpp$$ $section Getting Started with Atomic Operations: Example and Test$$ -$index get_started, atomic operation$$ -$index atomic, get_started $$ -$index operation, atomic get_started$$ $head Purpose$$ This example demonstrates the minimal amount of information @@ -36,7 +33,8 @@ $codep */ public: // constructor (could use const char* for name) - atomic_get_started(const std::string& name) : + atomic_get_started(const std::string& name) : + // this example does not use any sparsity patterns CppAD::atomic_base(name) { } private: @@ -108,11 +106,11 @@ // declare independent variables and start tape recording CppAD::Independent(ax); - // range space vector + // range space vector size_t m = 1; vector< AD > ay(m); - // call user function and store get_started(x) in au[0] + // call user function and store get_started(x) in au[0] vector< AD > au(m); afun(ax, au); // u = 1 / x @@ -125,7 +123,7 @@ /* $$ $subhead forward$$ $codep */ - // check function value + // check function value double check = x0; ok &= NearEqual( Value(ay[0]) , check, eps, eps); diff -Nru cppad-2015.00.00.9/example/atomic/hes_sparse.cpp cppad-2016.00.00.1/example/atomic/hes_sparse.cpp --- cppad-2015.00.00.9/example/atomic/hes_sparse.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/hes_sparse.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ // $Id$ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -13,10 +13,7 @@ $begin atomic_hes_sparse.cpp$$ $section Atomic Operation Hessian Sparsity: Example and Test$$ -$index hessian, atomic operation sparsity$$ -$index atomic, hessian sparsity $$ -$index operation, atomic hessian sparsity$$ -$index sparsity, atomic hessian$$ +$mindex sparsity$$ $head Purpose$$ This example demonstrates calculation of the Hessian sparsity pattern @@ -52,7 +49,7 @@ $codep */ public: // constructor (could use const char* for name) - atomic_hes_sparse(const std::string& name) : + atomic_hes_sparse(const std::string& name) : CppAD::atomic_base(name) { } private: @@ -103,7 +100,7 @@ size_t p , const vector< std::set >& r , vector< std::set >& s ) - { // This function needed if using f.ForSparseJac + { // This function needed if using f.ForSparseJac // with afun.option( CppAD::atomic_base::set_sparsity_enum ) size_t n = r.size(); size_t m = s.size(); @@ -114,7 +111,7 @@ s[0] = r[0]; my_union(s[1], r[0], r[1]); - return true; + return true; } /* $$ $head rev_sparse_hes$$ @@ -142,24 +139,24 @@ // There are no cross term second derivatives for this case, // so it is not necessary to vx. - // sparsity for T(x) = S(x) * f'(x) + // sparsity for T(x) = S(x) * f'(x) t[0] = s[0]; t[1] = s[0] || s[1]; - - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R + + // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) - + // back propagate the sparsity for U, // note both components of f'(x) may be non-zero; v[0] = u[0]; my_union(v[1], u[0], u[1]); // include forward Jacobian sparsity in Hessian sparsity - // f_0''(x) * R + // f_0''(x) * R if( s[0] ) my_union(v[0], v[0], r[0] ); - // f_1''(x) * R + // f_1''(x) * R if( s[1] ) { my_union(v[1], v[1], r[0] ); my_union(v[0], v[0], r[1] ); @@ -187,16 +184,16 @@ double x0_0 = 0.75, x0_1 = 2.00; vector< AD > au(n); au[0] = x0_0; - au[1] = x0_1; + au[1] = x0_1; // declare independent variables and start tape recording CppAD::Independent(au); - // range space vector + // range space vector size_t m = 2; vector< AD > ay(m); - // call user function + // call user function vector< AD > ax(n); ax[0] = au[0]; if( x_1_variable ) @@ -209,7 +206,7 @@ CppAD::ADFun f; f.Dependent (au, ay); // f(u) = y // - // check function value + // check function value double check_y0_0 = x0_0 * x0_0; double check_y0_1 = x0_0 * x0_1; ok &= NearEqual( Value(ay[0]) , check_y0_0, eps, eps); @@ -232,11 +229,11 @@ r[1].insert(1); jac_s = f.ForSparseJac(n, r); check_s[0].insert(0); - ok &= jac_s[0] == check_s[0]; + ok &= jac_s[0] == check_s[0]; check_s[1].insert(0); if( x_1_variable ) check_s[1].insert(1); - ok &= jac_s[1] == check_s[1]; + ok &= jac_s[1] == check_s[1]; // reverse sparse Hessian vector< std::set > h(2), check_h(2), hes_s(1); diff -Nru cppad-2015.00.00.9/example/atomic/makefile.am cppad-2016.00.00.1/example/atomic/makefile.am --- cppad-2015.00.00.9/example/atomic/makefile.am 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/makefile.am 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3505 2014-12-26 15:06:54Z bradbell $ +# $Id: makefile.am 3741 2015-10-07 14:51:10Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -16,12 +16,12 @@ # check_PROGRAMS = atomic # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ - $(EIGEN_INCLUDE) + $(EIGEN_INCLUDE) # atomic_SOURCES = \ atomic.cpp \ @@ -31,13 +31,8 @@ mat_mul.cpp \ norm_sq.cpp \ reciprocal.cpp \ - tangent.cpp \ - old_mat_mul.hpp \ - old_mat_mul.cpp \ - old_reciprocal.cpp \ - old_tan.cpp \ - old_usead_1.cpp \ - old_usead_2.cpp + sparsity.cpp \ + tangent.cpp test: check ./atomic diff -Nru cppad-2015.00.00.9/example/atomic/makefile.in cppad-2016.00.00.1/example/atomic/makefile.in --- cppad-2015.00.00.9/example/atomic/makefile.in 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/makefile.in 2016-02-09 08:31:54.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,20 +89,18 @@ host_triplet = @host@ check_PROGRAMS = atomic$(EXEEXT) subdir = example/atomic -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_atomic_OBJECTS = atomic.$(OBJEXT) checkpoint.$(OBJEXT) \ get_started.$(OBJEXT) hes_sparse.$(OBJEXT) mat_mul.$(OBJEXT) \ - norm_sq.$(OBJEXT) reciprocal.$(OBJEXT) tangent.$(OBJEXT) \ - old_mat_mul.$(OBJEXT) old_reciprocal.$(OBJEXT) \ - old_tan.$(OBJEXT) old_usead_1.$(OBJEXT) old_usead_2.$(OBJEXT) + norm_sq.$(OBJEXT) reciprocal.$(OBJEXT) sparsity.$(OBJEXT) \ + tangent.$(OBJEXT) atomic_OBJECTS = $(am_atomic_OBJECTS) atomic_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) @@ -124,18 +132,6 @@ am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = SOURCES = $(atomic_SOURCES) DIST_SOURCES = $(atomic_SOURCES) am__can_run_installinfo = \ @@ -162,6 +158,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -192,12 +189,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -278,26 +275,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -336,12 +336,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ - $(EIGEN_INCLUDE) + $(EIGEN_INCLUDE) # atomic_SOURCES = \ @@ -352,13 +352,8 @@ mat_mul.cpp \ norm_sq.cpp \ reciprocal.cpp \ - tangent.cpp \ - old_mat_mul.hpp \ - old_mat_mul.cpp \ - old_reciprocal.cpp \ - old_tan.cpp \ - old_usead_1.cpp \ - old_usead_2.cpp + sparsity.cpp \ + tangent.cpp all: all-am @@ -376,7 +371,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu example/atomic/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu example/atomic/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -414,12 +408,8 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_sparse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norm_sq.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_mat_mul.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_reciprocal.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_tan.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_usead_1.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_usead_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reciprocal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparsity.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tangent.Po@am__quote@ .cpp.o: @@ -639,6 +629,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check ./atomic diff -Nru cppad-2015.00.00.9/example/atomic/mat_mul.cpp cppad-2016.00.00.1/example/atomic/mat_mul.cpp --- cppad-2015.00.00.9/example/atomic/mat_mul.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/mat_mul.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: mat_mul.cpp 2905 2013-09-20 14:39:39Z bradbell $ +// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,7 @@ $$ $section User Atomic Matrix Multiply: Example and Test$$ -$index atomic, matrix multiply example$$ -$index matrix, atomic multiply example$$ -$index multiply, matrix atomic$$ +$mindex multiply$$ $children% cppad/example/matrix_mul.hpp @@ -107,11 +105,11 @@ ok &= y[3] == 5. * 7. + 6. * 8.; //---------------------------------------------------------------------- - // Test first order forward mode evaluation of g'(x) * [1, 2, 3, 4]^T + // Test first order forward mode evaluation of g'(x) * [1, 2, 3, 4]^T // g'(x) = [ x2, x3, x0, x1 ] // [ 7 , 8, 0, 0 ] // [ 0 , 0, 5, 6 ] - // [ 0 , 0, 0, 0 ] + // [ 0 , 0, 0, 0 ] CppAD::vector dx(n), dy(m); for(j = 0; j < n; j++) dx[j] = j + 1; @@ -122,7 +120,7 @@ ok &= dy[3] == 1. * 0. + 2. * 0. + 3. * 0. + 4. * 0.; //---------------------------------------------------------------------- - // Test second order forward mode + // Test second order forward mode // g_0^2 (x) = [ 0, 0, 1, 0 ], g_0^2 (x) * [1] = [3] // [ 0, 0, 0, 1 ] [2] [4] // [ 1, 0, 0, 0 ] [3] [1] @@ -133,7 +131,7 @@ ddy = g.Forward(2, ddx); // [1, 2, 3, 4] * g_0^2 (x) * [1, 2, 3, 4]^T = 1*3 + 2*4 + 3*1 + 4*2 - ok &= 2. * ddy[0] == 1. * 3. + 2. * 4. + 3. * 1. + 4. * 2.; + ok &= 2. * ddy[0] == 1. * 3. + 2. * 4. + 3. * 1. + 4. * 2.; // for i > 0, [1, 2, 3, 4] * g_i^2 (x) * [1, 2, 3, 4]^T = 0 ok &= ddy[1] == 0.; @@ -142,7 +140,7 @@ /* $$ $subhead reverse$$ $codep */ - // Test second order reverse mode + // Test second order reverse mode CppAD::vector w(m), dw(2 * n); for(i = 0; i < m; i++) w[i] = 0.; @@ -246,7 +244,7 @@ size_t check[] = {2, 3, 0, 1}; for(j = 0; j < n; j++) { // h[j] = { check[j] } - for(i = 0; i < n; i++) + for(i = 0; i < n; i++) { if( i == check[j] ) ok &= h[j].find(i) != h[j].end(); else ok &= h[j].find(i) == h[j].end(); @@ -258,14 +256,14 @@ h = g.RevSparseHes(n, t); for(j = 0; j < n; j++) { // h[j] = { } - for(i = 0; i < n; i++) + for(i = 0; i < n; i++) ok &= h[j].find(i) == h[j].end(); } //----------------------------------------------------------------- } // end for(size_t sparse_index ... //----------------------------------------------------------------- - + return ok; } /* $$ diff -Nru cppad-2015.00.00.9/example/atomic/norm_sq.cpp cppad-2016.00.00.1/example/atomic/norm_sq.cpp --- cppad-2015.00.00.9/example/atomic/norm_sq.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/norm_sq.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: norm_sq.cpp 3160 2014-03-05 17:04:14Z bradbell $ +// $Id: norm_sq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,13 +14,12 @@ $begin atomic_norm_sq.cpp$$ $spell sq + bool + enum $$ -$section Euclidean Norm Squared: Example and Test$$ -$index norm_sq, atomic operation$$ -$index atomic, norm_sq$$ -$index Euclidean, norm example$$ -$index operation, norm_sq$$ +$section Atomic Euclidean Norm Squared: Example and Test$$ +$mindex bool_sparsity_enum$$ $head Theory$$ This example demonstrates using $cref atomic_base$$ @@ -31,6 +30,9 @@ f(x) = x_0^2 + x_1^2 \] $$ +$head sparsity$$ +This example only uses bool sparsity patterns. + $nospell $head Start Class Definition$$ @@ -39,30 +41,15 @@ namespace { // isolate items below to this file using CppAD::vector; // abbreviate as vector // -// a utility to compute the union of two sets. -void my_union( - std::set& result , - const std::set& left , - const std::set& right ) -{ std::set temp; - std::set_union( - left.begin() , - left.end() , - right.begin() , - right.end() , - std::inserter(temp, temp.begin()) - ); - result.swap(temp); -} -// class atomic_norm_sq : public CppAD::atomic_base { /* $$ $head Constructor $$ $codep */ public: // constructor (could use const char* for name) - atomic_norm_sq(const std::string& name) : - CppAD::atomic_base(name) + atomic_norm_sq(const std::string& name) : + // this example only uses boolean sparsity patterns + CppAD::atomic_base(name, atomic_base::bool_sparsity_enum) { } private: /* $$ @@ -92,7 +79,7 @@ vy[0] = vx[0] | vx[1]; // Order zero forward mode must always be implemented. - // y^0 = f( x^0 ) + // y^0 = f( x^0 ) double x_00 = tx[ 0*(q+1) + 0]; // x_0^0 double x_10 = tx[ 1*(q+1) + 0]; // x_10 double f = x_00 * x_00 + x_10 * x_10; // f( x^0 ) @@ -130,12 +117,12 @@ const vector& py ) { size_t n = tx.size() / (q+1); - size_t m = ty.size() / (q+1); + size_t m = ty.size() / (q+1); assert( px.size() == n * (q+1) ); assert( py.size() == m * (q+1) ); assert( n == 2 ); assert( m == 1 ); - bool ok = q <= 1; + bool ok = q <= 1; double fp_0, fp_1; switch(q) @@ -163,39 +150,22 @@ size_t p , const vector& r , vector& s ) - { // This function needed if using f.ForSparseJac - // with afun.option( CppAD::atomic_base::bool_sparsity_enum ) + { // This function needed if using f.ForSparseJac size_t n = r.size() / p; size_t m = s.size() / p; assert( n == 2 ); assert( m == 1 ); - // sparsity for S(x) = f'(x) * R + // sparsity for S(x) = f'(x) * R // where f'(x) = 2 * [ x_0, x_1 ] for(size_t j = 0; j < p; j++) { s[j] = false; for(size_t i = 0; i < n; i++) - s[j] |= r[i * p + j]; + { // Visual Studio 2013 generates warning without bool below + s[j] |= bool( r[i * p + j] ); + } } - return true; - } - // forward Jacobian set sparsity routine called by CppAD - virtual bool for_sparse_jac( - size_t p , - const vector< std::set >& r , - vector< std::set >& s ) - { // This function needed if using f.ForSparseJac - // with afun.option( CppAD::atomic_base::set_sparsity_enum ) - size_t n = r.size(); - size_t m = s.size(); - assert( n == 2 ); - assert( m == 1 ); - - // sparsity for S(x) = f'(x) * R - // where f'(x) = 2 * [ x_0, x_1 ] - my_union(s[0], r[0], r[1]); - - return true; + return true; } /* $$ $head rev_sparse_jac$$ @@ -206,38 +176,18 @@ const vector& rt , vector& st ) { // This function needed if using RevSparseJac or optimize - // with afun.option( CppAD::atomic_base::bool_sparsity_enum ) size_t n = st.size() / p; size_t m = rt.size() / p; assert( n == 2 ); assert( m == 1 ); - // sparsity for S(x)^T = f'(x)^T * R^T + // sparsity for S(x)^T = f'(x)^T * R^T // where f'(x)^T = 2 * [ x_0, x_1]^T for(size_t j = 0; j < p; j++) for(size_t i = 0; i < n; i++) st[i * p + j] = rt[j]; - return true; - } - // reverse Jacobian set sparsity routine called by CppAD - virtual bool rev_sparse_jac( - size_t p , - const vector< std::set >& rt , - vector< std::set >& st ) - { // This function needed if using RevSparseJac or optimize - // with afun.option( CppAD::atomic_base::set_sparsity_enum ) - size_t n = st.size(); - size_t m = rt.size(); - assert( n == 2 ); - assert( m == 1 ); - - // sparsity for S(x)^T = f'(x)^T * R^T - // where f'(x)^T = 2 * [ x_0, x_1]^T - st[0] = rt[0]; - st[1] = rt[0]; - - return true; + return true; } /* $$ $head rev_sparse_hes$$ @@ -252,7 +202,6 @@ const vector& u , vector& v ) { // This function needed if using RevSparseHes - // with afun.option( CppAD::atomic_base::bool_sparsity_enum ) size_t m = s.size(); size_t n = t.size(); assert( r.size() == n * p ); @@ -264,14 +213,14 @@ // There are no cross term second derivatives for this case, // so it is not necessary to use vx. - // sparsity for T(x) = S(x) * f'(x) + // sparsity for T(x) = S(x) * f'(x) t[0] = s[0]; t[1] = s[0]; - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R + // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) - + // back propagate the sparsity for U size_t j; for(j = 0; j < p; j++) @@ -284,55 +233,9 @@ if( s[0] ) { for(j = 0; j < p; j++) for(size_t i = 0; i < n; i++) - v[ i * p + j] |= r[ i * p + j]; - } - - return true; - } - // reverse Hessian set sparsity routine called by CppAD - virtual bool rev_sparse_hes( - const vector& vx, - const vector& s , - vector& t , - size_t p , - const vector< std::set >& r , - const vector< std::set >& u , - vector< std::set >& v ) - { // This function needed if using RevSparseHes - // with afun.option( CppAD::atomic_base::set_sparsity_enum ) - size_t n = vx.size(); - size_t m = s.size(); - assert( t.size() == n ); - assert( r.size() == n ); - assert( u.size() == m ); - assert( v.size() == n ); - assert( n == 2 ); - assert( m == 1 ); - - // There are no cross term second derivatives for this case, - // so it is not necessary to vx. - - // sparsity for T(x) = S(x) * f'(x) - // where f'(x) = 2 * [ x_0, x_1 ] - t[0] = s[0]; - t[1] = s[0]; - - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R - // U(x) = g''(y) * f'(x) * R - // S(x) = g'(y) - - // Compute sparsity for f'(x)^T * U(x) - // where f'(x)^T = 2 * [ x_0, x_1 ]^T - v[0] = u[0]; - v[1] = u[0]; - - // include sparsity for g'(y) * f''(x) * R - // where f''(x) = [ 2 , 0 ] - // [ 0 , 2 ] - // note there are no cross terms - if( s[0] ) - { for(size_t i = 0; i < n; i++) - my_union(v[i], v[i], r[i] ); + { // Visual Studio 2013 generates warning without bool below + v[ i * p + j] |= bool( r[ i * p + j] ); + } } return true; @@ -373,20 +276,20 @@ // declare independent variables and start tape recording CppAD::Independent(ax); - // range space vector + // range space vector size_t m = 1; vector< AD > ay(m); - // call user function and store norm_sq(x) in au[0] + // call user function and store norm_sq(x) in au[0] afun(ax, ay); // y_0 = x_0 * x_0 + x_1 * x_1 // create f: x -> y and stop tape recording CppAD::ADFun f; - f.Dependent (ax, ay); + f.Dependent (ax, ay); /* $$ $subhead forward$$ $codep */ - // check function value + // check function value double check = x0 * x0 + x1 * x1; ok &= NearEqual( Value(ay[0]) , check, eps, eps); @@ -410,7 +313,7 @@ /* $$ $subhead reverse$$ $codep */ - // first order reverse mode + // first order reverse mode q = 1; vector w(m), dw(n * q); w[0] = 1.; @@ -428,15 +331,9 @@ r1[0] = true; r1[1] = false; // sparsity pattern identity r1[2] = false; r1[3] = true; // - afun.option( CppAD::atomic_base::bool_sparsity_enum ); s1 = f.ForSparseJac(p, r1); - ok &= s1[0] == true; // f[0] depends on x[0] - ok &= s1[1] == true; // f[0] depends on x[1] - // - afun.option( CppAD::atomic_base::set_sparsity_enum ); - s1 = f.ForSparseJac(p, r1); - ok &= s1[0] == true; // f[0] depends on x[0] - ok &= s1[1] == true; // f[0] depends on x[1] + ok &= s1[0] == true; // f[0] depends on x[0] + ok &= s1[1] == true; // f[0] depends on x[1] /* $$ $subhead rev_sparse_jac$$ $codep */ @@ -445,36 +342,22 @@ CppAD::vectorBool s2(q * m), r2(q * n); s2[0] = true; // compute sparsity pattern for f[0] // - afun.option( CppAD::atomic_base::bool_sparsity_enum ); - r2 = f.RevSparseJac(q, s2); - ok &= r2[0] == true; // f[0] depends on x[0] - ok &= r2[1] == true; // f[0] depends on x[1] - // - afun.option( CppAD::atomic_base::set_sparsity_enum ); r2 = f.RevSparseJac(q, s2); - ok &= r2[0] == true; // f[0] depends on x[0] - ok &= r2[1] == true; // f[0] depends on x[1] + ok &= r2[0] == true; // f[0] depends on x[0] + ok &= r2[1] == true; // f[0] depends on x[1] /* $$ $subhead rev_sparse_hes$$ $codep */ - // Hessian sparsity (using previous ForSparseJac call) + // Hessian sparsity (using previous ForSparseJac call) CppAD::vectorBool s3(m), h(p * n); s3[0] = true; // compute sparsity pattern for f[0] // - afun.option( CppAD::atomic_base::bool_sparsity_enum ); h = f.RevSparseHes(p, s3); ok &= h[0] == true; // partial of f[0] w.r.t. x[0],x[0] is non-zero ok &= h[1] == false; // partial of f[0] w.r.t. x[0],x[1] is zero ok &= h[2] == false; // partial of f[0] w.r.t. x[1],x[0] is zero ok &= h[3] == true; // partial of f[0] w.r.t. x[1],x[1] is non-zero // - afun.option( CppAD::atomic_base::set_sparsity_enum ); - h = f.RevSparseHes(p, s3); - ok &= h[0] == true; // partial of f[0] w.r.t. x[0],x[0] is non-zero - ok &= h[1] == false; // partial of f[0] w.r.t. x[0],x[1] is zero - ok &= h[2] == false; // partial of f[0] w.r.t. x[1],x[0] is zero - ok &= h[3] == true; // partial of f[0] w.r.t. x[1],x[1] is non-zero - return ok; } /* $$ diff -Nru cppad-2015.00.00.9/example/atomic/old_mat_mul.cpp cppad-2016.00.00.1/example/atomic/old_mat_mul.cpp --- cppad-2015.00.00.9/example/atomic/old_mat_mul.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/old_mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,273 +0,0 @@ -// $Id: old_mat_mul.cpp 2857 2013-05-28 02:36:51Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin old_mat_mul.cpp$$ -$spell - mul -$$ - -$section Matrix Multiply as a User Atomic Operation: Example and Test$$ - -$index old_atomic, example$$ -$index old_atomic, test$$ -$index matrix, atomic example$$ -$index old_mat_mul, example$$ -$index old_mat_mul, test$$ - -$head Deprecated$$ -This example has been deprecated; -see $cref atomic_mat_mul.cpp$$. - -$children% - example/atomic/old_mat_mul.hpp -%$$ -$head Include File$$ -This routine uses the include file $cref old_mat_mul.hpp$$. - -$code -$verbatim%example/atomic/old_mat_mul.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ -# include -# include "old_mat_mul.hpp" - -bool old_mat_mul(void) -{ bool ok = true; - using CppAD::AD; - - // matrix sizes for this test - size_t nr_result = 2; - size_t n_middle = 2; - size_t nc_result = 2; - - // declare the AD vectors ax and ay and X - size_t n = nr_result * n_middle + n_middle * nc_result; - size_t m = nr_result * nc_result; - CppAD::vector< AD > X(4), ax(n), ay(m); - size_t i, j; - for(j = 0; j < X.size(); j++) - X[j] = (j + 1); - - // X is the vector of independent variables - CppAD::Independent(X); - // left matrix - ax[0] = X[0]; // left[0,0] = x[0] = 1 - ax[1] = X[1]; // left[0,1] = x[1] = 2 - ax[2] = 5.; // left[1,0] = 5 - ax[3] = 6.; // left[1,1] = 6 - // right matrix - ax[4] = X[2]; // right[0,0] = x[2] = 3 - ax[5] = 7.; // right[0,1] = 7 - ax[6] = X[3]; // right[1,0] = x[3] = 4 - ax[7] = 8.; // right[1,1] = 8 - /* - [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] - [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] - */ - - // The call back routines need to know the dimensions of the matrices. - // Store information about the matrix multiply for this call to mat_mul. - call_info info; - info.nr_result = nr_result; - info.n_middle = n_middle; - info.nc_result = nc_result; - // info.vx gets set by forward during call to mat_mul below - assert( info.vx.size() == 0 ); - size_t id = info_.size(); - info_.push_back(info); - - // user defined AD version of matrix multiply - mat_mul(id, ax, ay); - //---------------------------------------------------------------------- - // check AD results - ok &= ay[0] == (1*3 + 2*4); ok &= Variable( ay[0] ); - ok &= ay[1] == (1*7 + 2*8); ok &= Variable( ay[1] ); - ok &= ay[2] == (5*3 + 6*4); ok &= Variable( ay[2] ); - ok &= ay[3] == (5*7 + 6*8); ok &= Parameter( ay[3] ); - //---------------------------------------------------------------------- - // use mat_mul to define a function g : X -> ay - CppAD::ADFun G; - G.Dependent(X, ay); - // g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2 + 6*x3 , 5*7 + 6*8 ]^T - //---------------------------------------------------------------------- - // Test zero order forward mode evaluation of g(x) - CppAD::vector x( X.size() ), y(m); - for(j = 0; j < X.size() ; j++) - x[j] = j + 2; - y = G.Forward(0, x); - ok &= y[0] == x[0] * x[2] + x[1] * x[3]; - ok &= y[1] == x[0] * 7. + x[1] * 8.; - ok &= y[2] == 5. * x[2] + 6. * x[3]; - ok &= y[3] == 5. * 7. + 6. * 8.; - - //---------------------------------------------------------------------- - // Test first order forward mode evaluation of g'(x) * [1, 2, 3, 4]^T - // g'(x) = [ x2, x3, x0, x1 ] - // [ 7 , 8, 0, 0 ] - // [ 0 , 0, 5, 6 ] - // [ 0 , 0, 0, 0 ] - CppAD::vector dx( X.size() ), dy(m); - for(j = 0; j < X.size() ; j++) - dx[j] = j + 1; - dy = G.Forward(1, dx); - ok &= dy[0] == 1. * x[2] + 2. * x[3] + 3. * x[0] + 4. * x[1]; - ok &= dy[1] == 1. * 7. + 2. * 8. + 3. * 0. + 4. * 0.; - ok &= dy[2] == 1. * 0. + 2. * 0. + 3. * 5. + 4. * 6.; - ok &= dy[3] == 1. * 0. + 2. * 0. + 3. * 0. + 4. * 0.; - - //---------------------------------------------------------------------- - // Test second order forward mode - // g_0^2 (x) = [ 0, 0, 1, 0 ], g_0^2 (x) * [1] = [3] - // [ 0, 0, 0, 1 ] [2] [4] - // [ 1, 0, 0, 0 ] [3] [1] - // [ 0, 1, 0, 0 ] [4] [2] - CppAD::vector ddx( X.size() ), ddy(m); - for(j = 0; j < X.size() ; j++) - ddx[j] = 0.; - ddy = G.Forward(2, ddx); - // [1, 2, 3, 4] * g_0^2 (x) * [1, 2, 3, 4]^T = 1*3 + 2*4 + 3*1 + 4*2 - ok &= 2. * ddy[0] == 1. * 3. + 2. * 4. + 3. * 1. + 4. * 2.; - // for i > 0, [1, 2, 3, 4] * g_i^2 (x) * [1, 2, 3, 4]^T = 0 - ok &= ddy[1] == 0.; - ok &= ddy[2] == 0.; - ok &= ddy[3] == 0.; - - //---------------------------------------------------------------------- - // Test second order reverse mode - CppAD::vector w(m), dw(2 * X.size() ); - for(i = 0; i < m; i++) - w[i] = 0.; - w[0] = 1.; - dw = G.Reverse(2, w); - // g_0'(x) = [ x2, x3, x0, x1 ] - ok &= dw[0*2 + 0] == x[2]; - ok &= dw[1*2 + 0] == x[3]; - ok &= dw[2*2 + 0] == x[0]; - ok &= dw[3*2 + 0] == x[1]; - // g_0'(x) * [1, 2, 3, 4] = 1 * x2 + 2 * x3 + 3 * x0 + 4 * x1 - // g_0^2 (x) * [1, 2, 3, 4] = [3, 4, 1, 2] - ok &= dw[0*2 + 1] == 3.; - ok &= dw[1*2 + 1] == 4.; - ok &= dw[2*2 + 1] == 1.; - ok &= dw[3*2 + 1] == 2.; - - //---------------------------------------------------------------------- - // Test forward and reverse Jacobian sparsity pattern - /* - [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] - [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] - so the sparsity pattern should be - s[0] = {0, 1, 2, 3} - s[1] = {0, 1} - s[2] = {2, 3} - s[3] = {} - */ - CppAD::vector< std::set > r( X.size() ), s(m); - for(j = 0; j < X.size() ; j++) - { assert( r[j].empty() ); - r[j].insert(j); - } - s = G.ForSparseJac( X.size() , r); - for(j = 0; j < X.size() ; j++) - { // s[0] = {0, 1, 2, 3} - ok &= s[0].find(j) != s[0].end(); - // s[1] = {0, 1} - if( j == 0 || j == 1 ) - ok &= s[1].find(j) != s[1].end(); - else ok &= s[1].find(j) == s[1].end(); - // s[2] = {2, 3} - if( j == 2 || j == 3 ) - ok &= s[2].find(j) != s[2].end(); - else ok &= s[2].find(j) == s[2].end(); - } - // s[3] == {} - ok &= s[3].empty(); - - //---------------------------------------------------------------------- - // Test reverse Jacobian sparsity pattern - /* - [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] - [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] - so the sparsity pattern should be - r[0] = {0, 1, 2, 3} - r[1] = {0, 1} - r[2] = {2, 3} - r[3] = {} - */ - for(i = 0; i < m; i++) - { s[i].clear(); - s[i].insert(i); - } - r = G.RevSparseJac(m, s); - for(j = 0; j < X.size() ; j++) - { // r[0] = {0, 1, 2, 3} - ok &= r[0].find(j) != r[0].end(); - // r[1] = {0, 1} - if( j == 0 || j == 1 ) - ok &= r[1].find(j) != r[1].end(); - else ok &= r[1].find(j) == r[1].end(); - // r[2] = {2, 3} - if( j == 2 || j == 3 ) - ok &= r[2].find(j) != r[2].end(); - else ok &= r[2].find(j) == r[2].end(); - } - // r[3] == {} - ok &= r[3].empty(); - - //---------------------------------------------------------------------- - /* Test reverse Hessian sparsity pattern - g_0^2 (x) = [ 0, 0, 1, 0 ] and for i > 0, g_i^2 = 0 - [ 0, 0, 0, 1 ] - [ 1, 0, 0, 0 ] - [ 0, 1, 0, 0 ] - so for the sparsity pattern for the first component of g is - h[0] = {2} - h[1] = {3} - h[2] = {0} - h[3] = {1} - */ - CppAD::vector< std::set > h( X.size() ), t(1); - t[0].clear(); - t[0].insert(0); - h = G.RevSparseHes(X.size() , t); - size_t check[] = {2, 3, 0, 1}; - for(j = 0; j < X.size() ; j++) - { // h[j] = { check[j] } - for(i = 0; i < n; i++) - { if( i == check[j] ) - ok &= h[j].find(i) != h[j].end(); - else ok &= h[j].find(i) == h[j].end(); - } - } - t[0].clear(); - for( j = 1; j < X.size(); j++) - t[0].insert(j); - h = G.RevSparseHes(X.size() , t); - for(j = 0; j < X.size() ; j++) - { // h[j] = { } - for(i = 0; i < X.size(); i++) - ok &= h[j].find(i) == h[j].end(); - } - - // -------------------------------------------------------------------- - // Free temporary work space. (If there are future calls to - // old_mat_mul they would create new temporary work space.) - CppAD::user_atomic::clear(); - info_.clear(); - - return ok; -} -// END C++ diff -Nru cppad-2015.00.00.9/example/atomic/old_mat_mul.hpp cppad-2016.00.00.1/example/atomic/old_mat_mul.hpp --- cppad-2015.00.00.9/example/atomic/old_mat_mul.hpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/old_mat_mul.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,445 +0,0 @@ -// $Id: old_mat_mul.hpp 3160 2014-03-05 17:04:14Z bradbell $ -# ifndef CPPAD_OLD_MAT_MUL_INCLUDED -# define CPPAD_OLD_MAT_MUL_INCLUDED - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin old_mat_mul.hpp$$ -$spell - old_mat_mul.hpp - cppad - CppAD - namespace - struct - nr - nc - bool - vx - const - im - mj - ij - px - py - std - tx - ty - resize - nz - var - jac - Jacobian - hes - vy -$$ - - -$section Define Matrix Multiply as a User Atomic Operation$$ - -$index old_mat_mul, define$$ -$index matrix, multiply$$ -$index multiply, matrix$$ -$index old_atomic, test$$ -$index test, old_atomic$$ -$index old_atomic, example$$ -$index example, old_atomic$$ - -$head Syntax$$ -This file is located in the $code example$$ directory. -It can be copied to the current working directory and included -with the syntax -$codei% - # include "old_mat_mul.hpp" -%$$ - -$head Example$$ -The file $cref old_mat_mul.cpp$$ contains an example use of -$code old_mat_mul.hpp$$. -It returns true if it succeeds and false otherwise. - -$head Begin Source$$ -$codep */ -# include // Include CppAD definitions -namespace { // Begin empty namespace - using CppAD::vector; // Let vector denote CppAD::vector -/* $$ - -$head Extra Call Information$$ -$codep */ - // Information we will attach to each mat_mul call - struct call_info { - size_t nr_result; - size_t n_middle; - size_t nc_result; - vector vx; - }; - vector info_; // vector of call information - - // number of orders for this operation (k + 1) - size_t n_order_ = 0; - // number of rows in the result matrix - size_t nr_result_ = 0; - // number of columns in left matrix and number of rows in right matrix - size_t n_middle_ = 0; - // number of columns in the result matrix - size_t nc_result_ = 0; - // which components of x are variables - vector* vx_ = CPPAD_NULL; - - // get the information corresponding to this call - void get_info(size_t id, size_t k, size_t n, size_t m) - { n_order_ = k + 1; - nr_result_ = info_[id].nr_result; - n_middle_ = info_[id].n_middle; - nc_result_ = info_[id].nc_result; - vx_ = &(info_[id].vx); - - assert(n == nr_result_ * n_middle_ + n_middle_ * nc_result_); - assert(m == nr_result_ * nc_result_); - } - -/* $$ -$head Matrix Indexing$$ -$codep */ - // Convert left matrix index pair and order to a single argument index - size_t left(size_t i, size_t j, size_t ell) - { assert( i < nr_result_ ); - assert( j < n_middle_ ); - return (i * n_middle_ + j) * n_order_ + ell; - } - // Convert right matrix index pair and order to a single argument index - size_t right(size_t i, size_t j, size_t ell) - { assert( i < n_middle_ ); - assert( j < nc_result_ ); - size_t offset = nr_result_ * n_middle_; - return (offset + i * nc_result_ + j) * n_order_ + ell; - } - // Convert result matrix index pair and order to a single result index - size_t result(size_t i, size_t j, size_t ell) - { assert( i < nr_result_ ); - assert( j < nc_result_ ); - return (i * nc_result_ + j) * n_order_ + ell; - } -/* $$ - -$head One Matrix Multiply$$ -Forward mode matrix multiply left times right and sum into result: -$codep */ - void multiply_and_sum( - size_t order_left , - size_t order_right, - const vector& tx , - vector& ty ) - { size_t i, j; - size_t order_result = order_left + order_right; - for(i = 0; i < nr_result_; i++) - { for(j = 0; j < nc_result_; j++) - { double sum = 0.; - size_t middle, im_left, mj_right, ij_result; - for(middle = 0; middle < n_middle_; middle++) - { im_left = left(i, middle, order_left); - mj_right = right(middle, j, order_right); - sum += tx[im_left] * tx[mj_right]; - } - ij_result = result(i, j, order_result); - ty[ ij_result ] += sum; - } - } - return; - } -/* $$ - -$head Reverse Partials One Order$$ -Compute reverse mode partials for one order and sum into px: -$codep */ - void reverse_multiply( - size_t order_left , - size_t order_right, - const vector& tx , - const vector& ty , - vector& px , - const vector& py ) - { size_t i, j; - size_t order_result = order_left + order_right; - for(i = 0; i < nr_result_; i++) - { for(j = 0; j < nc_result_; j++) - { size_t middle, im_left, mj_right, ij_result; - for(middle = 0; middle < n_middle_; middle++) - { ij_result = result(i, j, order_result); - im_left = left(i, middle, order_left); - mj_right = right(middle, j, order_right); - // sum += tx[im_left] * tx[mj_right]; - px[im_left] += tx[mj_right] * py[ij_result]; - px[mj_right] += tx[im_left] * py[ij_result]; - } - } - } - return; - } -/* $$ -$head Set Union$$ -$codep */ - void my_union( - std::set& result , - const std::set& left , - const std::set& right ) - { std::set temp; - std::set_union( - left.begin() , - left.end() , - right.begin() , - right.end() , - std::inserter(temp, temp.begin()) - ); - result.swap(temp); - } -/* $$ - -$head CppAD User Atomic Callback Functions$$ -$codep */ - // ---------------------------------------------------------------------- - // forward mode routine called by CppAD - bool mat_mul_forward( - size_t id , - size_t k , - size_t n , - size_t m , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { size_t i, j, ell; - get_info(id, k, n, m); - - // check if this is during the call to mat_mul(id, ax, ay) - if( vx.size() > 0 ) - { assert( k == 0 && vx.size() > 0 ); - - // store the vx information in info_ - assert( vx_->size() == 0 ); - info_[id].vx.resize(n); - for(j = 0; j < n; j++) - info_[id].vx[j] = vx[j]; - assert( vx_->size() == n ); - - // now compute vy - for(i = 0; i < nr_result_; i++) - { for(j = 0; j < nc_result_; j++) - { // compute vy[ result(i, j, 0) ] - bool var = false; - bool nz_left, nz_right; - size_t middle, im_left, mj_right, ij_result; - for(middle = 0; middle < n_middle_; middle++) - { im_left = left(i, middle, k); - mj_right = right(middle, j, k); - nz_left = vx[im_left] | (tx[im_left] != 0.); - nz_right = vx[mj_right] | (tx[mj_right]!= 0.); - // if not multiplying by the constant zero - if( nz_left & nz_right ) - var |= (vx[im_left] | vx[mj_right]); - } - ij_result = result(i, j, k); - vy[ij_result] = var; - } - } - } - - // initialize result as zero - for(i = 0; i < nr_result_; i++) - { for(j = 0; j < nc_result_; j++) - ty[ result(i, j, k) ] = 0.; - } - // sum the product of proper orders - for(ell = 0; ell <=k; ell++) - multiply_and_sum(ell, k-ell, tx, ty); - - // All orders are implemented and there are no possible error - // conditions, so always return true. - return true; - } - // ---------------------------------------------------------------------- - // reverse mode routine called by CppAD - bool mat_mul_reverse( - size_t id , - size_t k , - size_t n , - size_t m , - const vector& tx , - const vector& ty , - vector& px , - const vector& py - ) - { get_info(id, k, n, m); - - size_t ell = n * n_order_; - while(ell--) - px[ell] = 0.; - - size_t order = n_order_; - while(order--) - { // reverse sum the products for specified order - for(ell = 0; ell <=order; ell++) - reverse_multiply(ell, order-ell, tx, ty, px, py); - } - - // All orders are implemented and there are no possible error - // conditions, so always return true. - return true; - } - - // ---------------------------------------------------------------------- - // forward Jacobian sparsity routine called by CppAD - bool mat_mul_for_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - vector< std::set >& s ) - { size_t i, j, k, im_left, middle, mj_right, ij_result; - k = 0; - get_info(id, k, n, m); - - for(i = 0; i < nr_result_; i++) - { for(j = 0; j < nc_result_; j++) - { ij_result = result(i, j, k); - s[ij_result].clear(); - for(middle = 0; middle < n_middle_; middle++) - { im_left = left(i, middle, k); - mj_right = right(middle, j, k); - - // s[ij_result] = union( s[ij_result], r[im_left] ) - my_union(s[ij_result], s[ij_result], r[im_left]); - - // s[ij_result] = union( s[ij_result], r[mj_right] ) - my_union(s[ij_result], s[ij_result], r[mj_right]); - } - } - } - return true; - } - // ---------------------------------------------------------------------- - // reverse Jacobian sparsity routine called by CppAD - bool mat_mul_rev_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - vector< std::set >& r , - const vector< std::set >& s ) - { size_t i, j, k, im_left, middle, mj_right, ij_result; - k = 0; - get_info(id, k, n, m); - - for(j = 0; j < n; j++) - r[j].clear(); - - for(i = 0; i < nr_result_; i++) - { for(j = 0; j < nc_result_; j++) - { ij_result = result(i, j, k); - for(middle = 0; middle < n_middle_; middle++) - { im_left = left(i, middle, k); - mj_right = right(middle, j, k); - - // r[im_left] = union( r[im_left], s[ij_result] ) - my_union(r[im_left], r[im_left], s[ij_result]); - - // r[mj_right] = union( r[mj_right], s[ij_result] ) - my_union(r[mj_right], r[mj_right], s[ij_result]); - } - } - } - return true; - } - // ---------------------------------------------------------------------- - // reverse Hessian sparsity routine called by CppAD - bool mat_mul_rev_hes_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - const vector& s , - vector& t , - const vector< std::set >& u , - vector< std::set >& v ) - { size_t i, j, k, im_left, middle, mj_right, ij_result; - k = 0; - get_info(id, k, n, m); - - for(j = 0; j < n; j++) - { t[j] = false; - v[j].clear(); - } - - assert( vx_->size() == n ); - for(i = 0; i < nr_result_; i++) - { for(j = 0; j < nc_result_; j++) - { ij_result = result(i, j, k); - for(middle = 0; middle < n_middle_; middle++) - { im_left = left(i, middle, k); - mj_right = right(middle, j, k); - - // back propagate Jacobian sparsity - t[im_left] = (t[im_left] | s[ij_result]); - t[mj_right] = (t[mj_right] | s[ij_result]); - // Visual Studio C++ 2008 warns unsafe mix of int and - // bool if we use the following code directly above: - // t[im_left] |= s[ij_result]; - // t[mj_right] |= s[ij_result]; - - // back propagate Hessian sparsity - // v[im_left] = union( v[im_left], u[ij_result] ) - // v[mj_right] = union( v[mj_right], u[ij_result] ) - my_union(v[im_left], v[im_left], u[ij_result] ); - my_union(v[mj_right], v[mj_right], u[ij_result] ); - - // Check for case where the (i,j) result element - // is in reverse Jacobian and both left and right - // operands in multiplication are variables - if(s[ij_result] & (*vx_)[im_left] & (*vx_)[mj_right]) - { // v[im_left] = union( v[im_left], r[mj_right] ) - my_union(v[im_left], v[im_left], r[mj_right] ); - // v[mj_right] = union( v[mj_right], r[im_left] ) - my_union(v[mj_right], v[mj_right], r[im_left] ); - } - } - } - } - return true; - } -/* $$ - -$head Declare mat_mul Function$$ -Declare the $code AD$$ routine $codei%mat_mul(%id%, %ax%, %ay%)%$$ -and end empty namespace -(we could use any $cref/simple vector template class/SimpleVector/$$ -instead of $code CppAD::vector$$): -$codep */ - CPPAD_USER_ATOMIC( - mat_mul , - CppAD::vector , - double , - mat_mul_forward , - mat_mul_reverse , - mat_mul_for_jac_sparse , - mat_mul_rev_jac_sparse , - mat_mul_rev_hes_sparse - ) -} // End empty namespace -/* $$ -$end -*/ - -# endif diff -Nru cppad-2015.00.00.9/example/atomic/old_reciprocal.cpp cppad-2016.00.00.1/example/atomic/old_reciprocal.cpp --- cppad-2015.00.00.9/example/atomic/old_reciprocal.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/old_reciprocal.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,374 +0,0 @@ -// $Id: old_reciprocal.cpp 3160 2014-03-05 17:04:14Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin old_reciprocal.cpp$$ -$section Old Atomic Operation Reciprocal: Example and Test$$ -$index user, old atomic reciprocal$$ -$index atomic, old atomic reciprocal$$ -$index reciprocal, old atomic$$ - -$head Deprecated$$ -This example has been deprecated; -see $cref atomic_reciprocal.cpp$$ instead. - -$head Theory$$ -The example below defines the user atomic function -$latex f : \B{R}^n \rightarrow \B{R}^m$$ where -$latex n = 1$$, $latex m = 1$$, and $latex f(x) = 1 / x$$. - -$code -$verbatim%example/atomic/old_reciprocal.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ -# include - -namespace { // Begin empty namespace - using CppAD::vector; - // ---------------------------------------------------------------------- - // a utility to compute the union of two sets. - void my_union( - std::set& result , - const std::set& left , - const std::set& right ) - { std::set temp; - std::set_union( - left.begin() , - left.end() , - right.begin() , - right.end() , - std::inserter(temp, temp.begin()) - ); - result.swap(temp); - } - - // ---------------------------------------------------------------------- - // forward mode routine called by CppAD - bool reciprocal_forward( - size_t id , - size_t k , - size_t n , - size_t m , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - assert( k == 0 || vx.size() == 0 ); - bool ok = false; - double f, fp, fpp; - - // Must always define the case k = 0. - // Do not need case k if not using f.Forward(q, xp) for q >= k. - switch(k) - { case 0: - // this case must be implemented - if( vx.size() > 0 ) - vy[0] = vx[0]; - // y^0 = f( x^0 ) = 1 / x^0 - ty[0] = 1. / tx[0]; - ok = true; - break; - - case 1: - // needed if first order forward mode is used - assert( vx.size() == 0 ); - // y^1 = f'( x^0 ) x^1 - f = ty[0]; - fp = - f / tx[0]; - ty[1] = fp * tx[1]; - ok = true; - break; - - case 2: - // needed if second order forward mode is used - assert( vx.size() == 0 ); - // Y''(t) = X'(t)^\R{T} f''[X(t)] X'(t) + f'[X(t)] X''(t) - // 2 y^2 = x^1 * f''( x^0 ) x^1 + 2 f'( x^0 ) x^2 - f = ty[0]; - fp = - f / tx[0]; - fpp = - 2.0 * fp / tx[0]; - ty[2] = tx[1] * fpp * tx[1] / 2.0 + fp * tx[2]; - ok = true; - break; - } - return ok; - } - // ---------------------------------------------------------------------- - // reverse mode routine called by CppAD - bool reciprocal_reverse( - size_t id , - size_t k , - size_t n , - size_t m , - const vector& tx , - const vector& ty , - vector& px , - const vector& py - ) - { // Do not need case k if not using f.Reverse(k+1, w). - assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - bool ok = false; - - double f, fp, fpp, fppp; - switch(k) - { case 0: - // needed if first order reverse mode is used - // reverse: F^0 ( tx ) = y^0 = f( x^0 ) - f = ty[0]; - fp = - f / tx[0]; - px[0] = py[0] * fp;; - ok = true; - break; - - case 1: - // needed if second order reverse mode is used - // reverse: F^1 ( tx ) = y^1 = f'( x^0 ) x^1 - f = ty[0]; - fp = - f / tx[0]; - fpp = - 2.0 * fp / tx[0]; - px[1] = py[1] * fp; - px[0] = py[1] * fpp * tx[1]; - // reverse: F^0 ( tx ) = y^0 = f( x^0 ); - px[0] += py[0] * fp; - - ok = true; - break; - - case 2: - // needed if third order reverse mode is used - // reverse: F^2 ( tx ) = y^2 = - // = x^1 * f''( x^0 ) x^1 / 2 + f'( x^0 ) x^2 - f = ty[0]; - fp = - f / tx[0]; - fpp = - 2.0 * fp / tx[0]; - fppp = - 3.0 * fpp / tx[0]; - px[2] = py[2] * fp; - px[1] = py[2] * fpp * tx[1]; - px[0] = py[2] * tx[1] * fppp * tx[1] / 2.0 + fpp * tx[2]; - // reverse: F^1 ( tx ) = y^1 = f'( x^0 ) x^1 - px[1] += py[1] * fp; - px[0] += py[1] * fpp * tx[1]; - // reverse: F^0 ( tx ) = y^0 = f( x^0 ); - px[0] += py[0] * fp; - - ok = true; - break; - } - return ok; - } - // ---------------------------------------------------------------------- - // forward Jacobian sparsity routine called by CppAD - bool reciprocal_for_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - vector< std::set >& s ) - { // Can just return false if not using f.ForSparseJac - assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - - // sparsity for S(x) = f'(x) * R is same as sparsity for R - s[0] = r[0]; - - return true; - } - // ---------------------------------------------------------------------- - // reverse Jacobian sparsity routine called by CppAD - bool reciprocal_rev_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - vector< std::set >& r , - const vector< std::set >& s ) - { // Can just return false if not using RevSparseJac. - assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - - // sparsity for R(x) = S * f'(x) is same as sparsity for S - for(size_t q = 0; q < p; q++) - r[q] = s[q]; - - return true; - } - // ---------------------------------------------------------------------- - // reverse Hessian sparsity routine called by CppAD - bool reciprocal_rev_hes_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - const vector& s , - vector& t , - const vector< std::set >& u , - vector< std::set >& v ) - { // Can just return false if not use RevSparseHes. - assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - - // sparsity for T(x) = S(x) * f'(x) is same as sparsity for S - t[0] = s[0]; - - // V(x) = [ f'(x)^T * g''(y) * f'(x) + g'(y) * f''(x) ] * R - // U(x) = g''(y) * f'(x) * R - // S(x) = g'(y) - - // back propagate the sparsity for U because derivative of - // reciprocal may be non-zero - v[0] = u[0]; - - // convert forward Jacobian sparsity to Hessian sparsity - // because second derivative of reciprocal may be non-zero - if( s[0] ) - my_union(v[0], v[0], r[0] ); - - - return true; - } - // --------------------------------------------------------------------- - // Declare the AD routine reciprocal(id, ax, ay) - CPPAD_USER_ATOMIC( - reciprocal , - CppAD::vector , - double , - reciprocal_forward , - reciprocal_reverse , - reciprocal_for_jac_sparse , - reciprocal_rev_jac_sparse , - reciprocal_rev_hes_sparse - ) -} // End empty namespace - -bool old_reciprocal(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // -------------------------------------------------------------------- - // Create the function f(x) - // - // domain space vector - size_t n = 1; - double x0 = 0.5; - vector< AD > ax(n); - ax[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // range space vector - size_t m = 1; - vector< AD > ay(m); - - // call user function and store reciprocal(x) in au[0] - vector< AD > au(m); - size_t id = 0; // not used - reciprocal(id, ax, au); // u = 1 / x - - // call user function and store reciprocal(u) in ay[0] - reciprocal(id, au, ay); // y = 1 / u = x - - // create f: x -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (ax, ay); // f(x) = x - - // -------------------------------------------------------------------- - // Check forward mode results - // - // check function value - double check = x0; - ok &= NearEqual( Value(ay[0]) , check, eps, eps); - - // check zero order forward mode - size_t q; - vector x_q(n), y_q(m); - q = 0; - x_q[0] = x0; - y_q = f.Forward(q, x_q); - ok &= NearEqual(y_q[0] , check, eps, eps); - - // check first order forward mode - q = 1; - x_q[0] = 1; - y_q = f.Forward(q, x_q); - check = 1.; - ok &= NearEqual(y_q[0] , check, eps, eps); - - // check second order forward mode - q = 2; - x_q[0] = 0; - y_q = f.Forward(q, x_q); - check = 0.; - ok &= NearEqual(y_q[0] , check, eps, eps); - - // -------------------------------------------------------------------- - // Check reverse mode results - // - // third order reverse mode - q = 3; - vector w(m), dw(n * q); - w[0] = 1.; - dw = f.Reverse(q, w); - check = 1.; - ok &= NearEqual(dw[0] , check, eps, eps); - check = 0.; - ok &= NearEqual(dw[1] , check, eps, eps); - ok &= NearEqual(dw[2] , check, eps, eps); - - // -------------------------------------------------------------------- - // forward mode sparstiy pattern - size_t p = n; - CppAD::vectorBool r1(n * p), s1(m * p); - r1[0] = true; // compute sparsity pattern for x[0] - s1 = f.ForSparseJac(p, r1); - ok &= s1[0] == true; // f[0] depends on x[0] - - // -------------------------------------------------------------------- - // reverse mode sparstiy pattern - q = m; - CppAD::vectorBool s2(q * m), r2(q * n); - s2[0] = true; // compute sparsity pattern for f[0] - r2 = f.RevSparseJac(q, s2); - ok &= r2[0] == true; // f[0] depends on x[0] - - // -------------------------------------------------------------------- - // Hessian sparsity (using previous ForSparseJac call) - CppAD::vectorBool s3(m), h(p * n); - s3[0] = true; // compute sparsity pattern for f[0] - h = f.RevSparseHes(p, s3); - ok &= h[0] == true; // second partial of f[0] w.r.t. x[0] may be non-zero - - // ----------------------------------------------------------------- - // Free all temporary work space associated with old_atomic objects. - // (If there are future calls to user atomic functions, they will - // create new temporary work space.) - CppAD::user_atomic::clear(); - - return ok; -} -// END C++ diff -Nru cppad-2015.00.00.9/example/atomic/old_tan.cpp cppad-2016.00.00.1/example/atomic/old_tan.cpp --- cppad-2015.00.00.9/example/atomic/old_tan.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/old_tan.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,430 +0,0 @@ -// $Id: old_tan.cpp 3160 2014-03-05 17:04:14Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin old_tan.cpp$$ -$spell - Tanh -$$ - -$section Tan and Tanh as User Atomic Operations: Example and Test$$ - -$index tan, old_atomic$$ -$index user, atomic tan$$ -$index atomic, tan$$ -$index test, old_atomic$$ -$index old_atomic, example$$ -$index example, old_atomic$$ - -$head Deprecated$$ -This example has not deprecated; -see $cref atomic_tangent.cpp$$ instead. - -$head Theory$$ -The code below uses the $cref tan_forward$$ and $cref tan_reverse$$ -to implement the tangent ($icode%id% == 0%$$) and hyperbolic tangent -($icode%id% == 1%$$) functions as user atomic operations. - -$code -$verbatim%example/atomic/old_tan.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ -# include - -namespace { // Begin empty namespace - using CppAD::vector; - - // a utility to compute the union of two sets. - void my_union( - std::set& result , - const std::set& left , - const std::set& right ) - { std::set temp; - std::set_union( - left.begin() , - left.end() , - right.begin() , - right.end() , - std::inserter(temp, temp.begin()) - ); - result.swap(temp); - } - - // ---------------------------------------------------------------------- - // forward mode routine called by CppAD - bool old_tan_forward( - size_t id , - size_t order , - size_t n , - size_t m , - const vector& vx , - vector& vzy , - const vector& tx , - vector& tzy - ) - { - assert( id == 0 || id == 1 ); - assert( n == 1 ); - assert( m == 2 ); - assert( tx.size() >= (order+1) * n ); - assert( tzy.size() >= (order+1) * m ); - - size_t n_order = order + 1; - size_t j = order; - size_t k; - - // check if this is during the call to old_tan(id, ax, ay) - if( vx.size() > 0 ) - { assert( vx.size() >= n ); - assert( vzy.size() >= m ); - - // now setvzy - vzy[0] = vx[0]; - vzy[1] = vx[0]; - } - - if( j == 0 ) - { // z^{(0)} = tan( x^{(0)} ) or tanh( x^{(0)} ) - if( id == 0 ) - tzy[0] = tan( tx[0] ); - else tzy[0] = tanh( tx[0] ); - - // y^{(0)} = z^{(0)} * z^{(0)} - tzy[n_order + 0] = tzy[0] * tzy[0]; - } - else - { float j_inv = 1.f / float(j); - if( id == 1 ) - j_inv = - j_inv; - - // z^{(j)} = x^{(j)} +- sum_{k=1}^j k x^{(k)} y^{(j-k)} / j - tzy[j] = tx[j]; - for(k = 1; k <= j; k++) - tzy[j] += tx[k] * tzy[n_order + j-k] * k * j_inv; - - // y^{(j)} = sum_{k=0}^j z^{(k)} z^{(j-k)} - tzy[n_order + j] = 0.; - for(k = 0; k <= j; k++) - tzy[n_order + j] += tzy[k] * tzy[j-k]; - } - - // All orders are implemented and there are no possible errors - return true; - } - // ---------------------------------------------------------------------- - // reverse mode routine called by CppAD - bool old_tan_reverse( - size_t id , - size_t order , - size_t n , - size_t m , - const vector& tx , - const vector& tzy , - vector& px , - const vector& pzy - ) - { - assert( id == 0 || id == 1 ); - assert( n == 1 ); - assert( m == 2 ); - assert( tx.size() >= (order+1) * n ); - assert( tzy.size() >= (order+1) * m ); - assert( px.size() >= (order+1) * n ); - assert( pzy.size() >= (order+1) * m ); - - size_t n_order = order + 1; - size_t j, k; - - // copy because partials w.r.t. y and z need to change - vector qzy = pzy; - - // initialize accumultion of reverse mode partials - for(k = 0; k < n_order; k++) - px[k] = 0.; - - // eliminate positive orders - for(j = order; j > 0; j--) - { float j_inv = 1.f / float(j); - if( id == 1 ) - j_inv = - j_inv; - - // H_{x^{(k)}} += delta(j-k) +- H_{z^{(j)} y^{(j-k)} * k / j - px[j] += qzy[j]; - for(k = 1; k <= j; k++) - px[k] += qzy[j] * tzy[n_order + j-k] * k * j_inv; - - // H_{y^{j-k)} += +- H_{z^{(j)} x^{(k)} * k / j - for(k = 1; k <= j; k++) - qzy[n_order + j-k] += qzy[j] * tx[k] * k * j_inv; - - // H_{z^{(k)}} += H_{y^{(j-1)}} * z^{(j-k-1)} * 2. - for(k = 0; k < j; k++) - qzy[k] += qzy[n_order + j-1] * tzy[j-k-1] * 2.f; - } - - // eliminate order zero - if( id == 0 ) - px[0] += qzy[0] * (1.f + tzy[n_order + 0]); - else - px[0] += qzy[0] * (1.f - tzy[n_order + 0]); - - return true; - } - // ---------------------------------------------------------------------- - // forward Jacobian sparsity routine called by CppAD - bool old_tan_for_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - vector< std::set >& s ) - { - assert( n == 1 ); - assert( m == 2 ); - assert( id == 0 || id == 1 ); - assert( r.size() >= n ); - assert( s.size() >= m ); - - // sparsity for z and y are the same as for x - s[0] = r[0]; - s[1] = r[0]; - - return true; - } - // ---------------------------------------------------------------------- - // reverse Jacobian sparsity routine called by CppAD - bool old_tan_rev_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - vector< std::set >& r , - const vector< std::set >& s ) - { - assert( n == 1 ); - assert( m == 2 ); - assert( id == 0 || id == 1 ); - assert( r.size() >= n ); - assert( s.size() >= m ); - - // note that, if the users code only uses z, and not y, - // we could just set r[0] = s[0] - my_union(r[0], s[0], s[1]); - return true; - } - // ---------------------------------------------------------------------- - // reverse Hessian sparsity routine called by CppAD - bool old_tan_rev_hes_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - const vector& s , - vector& t , - const vector< std::set >& u , - vector< std::set >& v ) - { - assert( n == 1 ); - assert( m == 2 ); - assert( id == 0 || id == 1 ); - assert( r.size() >= n ); - assert( s.size() >= m ); - assert( t.size() >= n ); - assert( u.size() >= m ); - assert( v.size() >= n ); - - // back propagate Jacobian sparsity. If users code only uses z, - // we could just set t[0] = s[0]; - t[0] = s[0] | s[1]; - - // back propagate Hessian sparsity, ... - my_union(v[0], u[0], u[1]); - - // convert forward Jacobian sparsity to Hessian sparsity - // because tan and tanh are nonlinear - if( t[0] ) - my_union(v[0], v[0], r[0]); - - return true; - } - // --------------------------------------------------------------------- - // Declare the AD routine old_tan(id, ax, ay) - CPPAD_USER_ATOMIC( - old_tan , - CppAD::vector , - float , - old_tan_forward , - old_tan_reverse , - old_tan_for_jac_sparse , - old_tan_rev_jac_sparse , - old_tan_rev_hes_sparse - ) -} // End empty namespace - -bool old_tan(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - float eps = 10.f * CppAD::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - float x0 = 0.5; - CppAD::vector< AD > ax(n); - ax[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // range space vector - size_t m = 3; - CppAD::vector< AD > af(m); - - // temporary vector for old_tan computations - // (old_tan computes tan or tanh and its square) - CppAD::vector< AD > az(2); - - // call user tan function and store tan(x) in f[0] (ignore tan(x)^2) - size_t id = 0; - old_tan(id, ax, az); - af[0] = az[0]; - - // call user tanh function and store tanh(x) in f[1] (ignore tanh(x)^2) - id = 1; - old_tan(id, ax, az); - af[1] = az[0]; - - // put a constant in f[2] = tanh(1.) (for sparsity pattern testing) - CppAD::vector< AD > one(1); - one[0] = 1.; - old_tan(id, one, az); - af[2] = az[0]; - - // create f: x -> f and stop tape recording - CppAD::ADFun F; - F.Dependent(ax, af); - - // check function value - float tan = std::tan(x0); - ok &= NearEqual(af[0] , tan, eps, eps); - float tanh = std::tanh(x0); - ok &= NearEqual(af[1] , tanh, eps, eps); - - // check zero order forward - CppAD::vector x(n), f(m); - x[0] = x0; - f = F.Forward(0, x); - ok &= NearEqual(f[0] , tan, eps, eps); - ok &= NearEqual(f[1] , tanh, eps, eps); - - // compute first partial of f w.r.t. x[0] using forward mode - CppAD::vector dx(n), df(m); - dx[0] = 1.; - df = F.Forward(1, dx); - - // compute derivative of tan - tanh using reverse mode - CppAD::vector w(m), dw(n); - w[0] = 1.; - w[1] = 1.; - w[2] = 0.; - dw = F.Reverse(1, w); - - // tan'(x) = 1 + tan(x) * tan(x) - // tanh'(x) = 1 - tanh(x) * tanh(x) - float tanp = 1.f + tan * tan; - float tanhp = 1.f - tanh * tanh; - ok &= NearEqual(df[0], tanp, eps, eps); - ok &= NearEqual(df[1], tanhp, eps, eps); - ok &= NearEqual(dw[0], w[0]*tanp + w[1]*tanhp, eps, eps); - - // compute second partial of f w.r.t. x[0] using forward mode - CppAD::vector ddx(n), ddf(m); - ddx[0] = 0.; - ddf = F.Forward(2, ddx); - - // compute second derivative of tan - tanh using reverse mode - CppAD::vector ddw(2); - ddw = F.Reverse(2, w); - - // tan''(x) = 2 * tan(x) * tan'(x) - // tanh''(x) = - 2 * tanh(x) * tanh'(x) - // Note that second order Taylor coefficient for u half the - // corresponding second derivative. - float two = 2; - float tanpp = two * tan * tanp; - float tanhpp = - two * tanh * tanhp; - ok &= NearEqual(two * ddf[0], tanpp, eps, eps); - ok &= NearEqual(two * ddf[1], tanhpp, eps, eps); - ok &= NearEqual(ddw[0], w[0]*tanp + w[1]*tanhp , eps, eps); - ok &= NearEqual(ddw[1], w[0]*tanpp + w[1]*tanhpp, eps, eps); - - // Forward mode computation of sparsity pattern for F. - size_t p = n; - // user vectorBool because m and n are small - CppAD::vectorBool r1(p), s1(m * p); - r1[0] = true; // propagate sparsity for x[0] - s1 = F.ForSparseJac(p, r1); - ok &= (s1[0] == true); // f[0] depends on x[0] - ok &= (s1[1] == true); // f[1] depends on x[0] - ok &= (s1[2] == false); // f[2] does not depend on x[0] - - // Reverse mode computation of sparsity pattern for F. - size_t q = m; - CppAD::vectorBool s2(q * m), r2(q * n); - // Sparsity pattern for identity matrix - size_t i, j; - for(i = 0; i < q; i++) - { for(j = 0; j < m; j++) - s2[i * q + j] = (i == j); - } - r2 = F.RevSparseJac(q, s2); - ok &= (r2[0] == true); // f[0] depends on x[0] - ok &= (r2[1] == true); // f[1] depends on x[0] - ok &= (r2[2] == false); // f[2] does not depend on x[0] - - // Hessian sparsity for f[0] - CppAD::vectorBool s3(m), h(p * n); - s3[0] = true; - s3[1] = false; - s3[2] = false; - h = F.RevSparseHes(p, s3); - ok &= (h[0] == true); // Hessian is non-zero - - // Hessian sparsity for f[2] - s3[0] = false; - s3[2] = true; - h = F.RevSparseHes(p, s3); - ok &= (h[0] == false); // Hessian is zero - - // check tanh results for a large value of x - x[0] = std::numeric_limits::max() / two; - f = F.Forward(0, x); - tanh = 1.; - ok &= NearEqual(f[1], tanh, eps, eps); - df = F.Forward(1, dx); - tanhp = 0.; - ok &= NearEqual(df[1], tanhp, eps, eps); - - // -------------------------------------------------------------------- - // Free all temporary work space associated with old_atomic objects. - // (If there are future calls to user atomic functions, they will - // create new temporary work space.) - CppAD::user_atomic::clear(); - - return ok; -} -// END C++ diff -Nru cppad-2015.00.00.9/example/atomic/old_usead_1.cpp cppad-2016.00.00.1/example/atomic/old_usead_1.cpp --- cppad-2015.00.00.9/example/atomic/old_usead_1.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/old_usead_1.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,372 +0,0 @@ -// $Id: old_usead_1.cpp 3160 2014-03-05 17:04:14Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin old_usead_1.cpp$$ -$spell - checkpoint - var -$$ - -$section Using AD to Compute Atomic Function Derivatives$$ -$index AD, inside atomic$$ -$index user, atomic AD inside$$ -$index atomic, AD inside$$ -$index checkpoint$$ - -$head Deprecated$$ -This example has been deprecated because it is easier to use the -$cref checkpoint$$ class instead. - -$head Purpose$$ -Consider the case where an inner function is used repeatedly in the -definition of an outer function. -In this case, it may reduce the number of variables -$cref/size_var/seq_property/size_var/$$, -and hence the required memory. - -$head Simple Case$$ -This example is the same as $cref old_reciprocal.cpp$$, except that it -uses AD to compute the -derivatives needed by an atomic function. -This is a simple example of an inner function, and hence not really -useful for the purpose above; -see $cref old_usead_2.cpp$$ for a more complete example. - -$code -$verbatim%example/atomic/old_usead_1.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ -# include - -namespace { // Begin empty namespace - using CppAD::AD; - using CppAD::ADFun; - using CppAD::vector; - - // ---------------------------------------------------------------------- - // function that computes reciprocal - ADFun* r_ptr_; - void create_r(void) - { vector< AD > ax(1), ay(1); - ax[0] = 1; - CppAD::Independent(ax); - ay[0] = 1.0 / ax[0]; - r_ptr_ = new ADFun(ax, ay); - } - void destroy_r(void) - { delete r_ptr_; - r_ptr_ = CPPAD_NULL; - } - - // ---------------------------------------------------------------------- - // forward mode routine called by CppAD - bool reciprocal_forward( - size_t id , - size_t k , - size_t n , - size_t m , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - assert( k == 0 || vx.size() == 0 ); - bool ok = true; - vector x_q(1), y_q(1); - - // check for special case - if( vx.size() > 0 ) - vy[0] = vx[0]; - - // make sure r_ has proper lower order Taylor coefficients stored - // then compute ty[k] - for(size_t q = 0; q <= k; q++) - { x_q[0] = tx[q]; - y_q = r_ptr_->Forward(q, x_q); - if( q == k ) - ty[k] = y_q[0]; - assert( q == k || ty[q] == y_q[0] ); - } - return ok; - } - // ---------------------------------------------------------------------- - // reverse mode routine called by CppAD - bool reciprocal_reverse( - size_t id , - size_t k , - size_t n , - size_t m , - const vector& tx , - const vector& ty , - vector& px , - const vector& py - ) - { assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - bool ok = true; - vector x_q(1), w(k+1), dw(k+1); - - // make sure r_ has proper forward mode coefficients - size_t q; - for(q = 0; q <= k; q++) - { x_q[0] = tx[q]; -# ifdef NDEBUG - r_ptr_->Forward(q, x_q); -# else - vector y_q(1); - y_q = r_ptr_->Forward(q, x_q); - assert( ty[q] == y_q[0] ); -# endif - } - for(q = 0; q <=k; q++) - w[q] = py[q]; - dw = r_ptr_->Reverse(k+1, w); - for(q = 0; q <=k; q++) - px[q] = dw[q]; - - return ok; - } - // ---------------------------------------------------------------------- - // forward Jacobian sparsity routine called by CppAD - bool reciprocal_for_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - vector< std::set >& s ) - { assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - bool ok = true; - - vector< std::set > R(1), S(1); - R[0] = r[0]; - S = r_ptr_->ForSparseJac(p, R); - s[0] = S[0]; - - return ok; - } - // ---------------------------------------------------------------------- - // reverse Jacobian sparsity routine called by CppAD - bool reciprocal_rev_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - vector< std::set >& r , - const vector< std::set >& s ) - { - assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - bool ok = true; - - vector< std::set > R(p), S(p); - size_t q; - for(q = 0; q < p; q++) - S[q] = s[q]; - R = r_ptr_->RevSparseJac(p, S); - for(q = 0; q < p; q++) - r[q] = R[q]; - - return ok; - } - // ---------------------------------------------------------------------- - // reverse Hessian sparsity routine called by CppAD - bool reciprocal_rev_hes_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - const vector& s , - vector& t , - const vector< std::set >& u , - vector< std::set >& v ) - { // Can just return false if not use RevSparseHes. - assert( id == 0 ); - assert( n == 1 ); - assert( m == 1 ); - bool ok = true; - - // compute sparsity pattern for T(x) = S(x) * f'(x) - vector T(1), S(1); - S[0] = s[0]; - T = r_ptr_->RevSparseJac(1, S); - t[0] = T[0]; - - // compute sparsity pattern for A(x) = U(x)^T * f'(x) - vector Ut(p), A(p); - size_t q; - for(q = 0; q < p; q++) - Ut[q] = false; - std::set::iterator itr; - for(itr = u[0].begin(); itr != u[0].end(); itr++) - Ut[*itr] = true; - A = r_ptr_-> RevSparseJac(p, Ut); - - // compute sparsity pattern for H(x) = R^T * (S * F)''(x) - vector H(p), R(n); - for(q = 0; q < p; q++) - R[q] = false; - for(itr = r[0].begin(); itr != r[0].end(); itr++) - R[*itr] = true; - r_ptr_->ForSparseJac(p, R); - H = r_ptr_->RevSparseHes(p, S); - - // compute sparsity pattern for V(x) = A(x)^T + H(x)^T - v[0].clear(); - for(q = 0; q < p; q++) - if( A[q] | H[q] ) - v[0].insert(q); - - return ok; - } - // --------------------------------------------------------------------- - // Declare the AD routine reciprocal(id, ax, ay) - CPPAD_USER_ATOMIC( - reciprocal , - CppAD::vector , - double , - reciprocal_forward , - reciprocal_reverse , - reciprocal_for_jac_sparse , - reciprocal_rev_jac_sparse , - reciprocal_rev_hes_sparse - ) -} // End empty namespace - -bool old_usead_1(void) -{ bool ok = true; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // -------------------------------------------------------------------- - // Create the ADFun r_ - create_r(); - - // -------------------------------------------------------------------- - // Create the function f(x) - // - // domain space vector - size_t n = 1; - double x0 = 0.5; - vector< AD > ax(n); - ax[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // range space vector - size_t m = 1; - vector< AD > ay(m); - - // call user function and store reciprocal(x) in au[0] - vector< AD > au(m); - size_t id = 0; // not used - reciprocal(id, ax, au); // u = 1 / x - - // call user function and store reciprocal(u) in ay[0] - reciprocal(id, au, ay); // y = 1 / u = x - - // create f: x -> y and stop tape recording - ADFun f; - f.Dependent(ax, ay); // f(x) = x - - // -------------------------------------------------------------------- - // Check function value results - // - // check function value - double check = x0; - ok &= NearEqual( Value(ay[0]) , check, eps, eps); - - // check zero order forward mode - size_t q; - vector x_q(n), y_q(m); - q = 0; - x_q[0] = x0; - y_q = f.Forward(q, x_q); - ok &= NearEqual(y_q[0] , check, eps, eps); - - // check first order forward mode - q = 1; - x_q[0] = 1; - y_q = f.Forward(q, x_q); - check = 1.; - ok &= NearEqual(y_q[0] , check, eps, eps); - - // check second order forward mode - q = 2; - x_q[0] = 0; - y_q = f.Forward(q, x_q); - check = 0.; - ok &= NearEqual(y_q[0] , check, eps, eps); - - // -------------------------------------------------------------------- - // Check reverse mode results - // - // third order reverse mode - q = 3; - vector w(m), dw(n * q); - w[0] = 1.; - dw = f.Reverse(q, w); - check = 1.; - ok &= NearEqual(dw[0] , check, eps, eps); - check = 0.; - ok &= NearEqual(dw[1] , check, eps, eps); - ok &= NearEqual(dw[2] , check, eps, eps); - - // -------------------------------------------------------------------- - // forward mode sparstiy pattern - size_t p = n; - CppAD::vectorBool r1(n * p), s1(m * p); - r1[0] = true; // compute sparsity pattern for x[0] - s1 = f.ForSparseJac(p, r1); - ok &= s1[0] == true; // f[0] depends on x[0] - - // -------------------------------------------------------------------- - // reverse mode sparstiy pattern - q = m; - CppAD::vectorBool s2(q * m), r2(q * n); - s2[0] = true; // compute sparsity pattern for f[0] - r2 = f.RevSparseJac(q, s2); - ok &= r2[0] == true; // f[0] depends on x[0] - - // -------------------------------------------------------------------- - // Hessian sparsity (using previous ForSparseJac call) - CppAD::vectorBool s3(m), h(p * n); - s3[0] = true; // compute sparsity pattern for f[0] - h = f.RevSparseJac(p, s3); - ok &= h[0] == true; // second partial of f[0] w.r.t. x[0] may be non-zero - - // ----------------------------------------------------------------- - // Free all memory associated with the object r_ptr - destroy_r(); - - // ----------------------------------------------------------------- - // Free all temporary work space associated with old_atomic objects. - // (If there are future calls to user atomic functions, they will - // create new temporary work space.) - CppAD::user_atomic::clear(); - - return ok; -} -// END C++ diff -Nru cppad-2015.00.00.9/example/atomic/old_usead_2.cpp cppad-2016.00.00.1/example/atomic/old_usead_2.cpp --- cppad-2015.00.00.9/example/atomic/old_usead_2.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/old_usead_2.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,498 +0,0 @@ -// $Id: old_usead_2.cpp 3214 2014-03-18 20:50:38Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin old_usead_2.cpp$$ -$spell - checkpoint - var -$$ - -$section Using AD to Compute Atomic Function Derivatives$$ - -$index AD, inside atomic$$ -$index user, atomic AD inside$$ -$index atomic, AD inside$$ -$index checkpoint$$ - -$head Deprecated$$ -This example has been deprecated because it is easier to use the -$cref checkpoint$$ class instead. - -$head Purpose$$ -Consider the case where an inner function is used repeatedly in the -definition of an outer function. -In this case, it may reduce the number of variables -$cref/size_var/seq_property/size_var/$$, -and hence the required memory. - -$code -$verbatim%example/atomic/old_usead_2.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ -# include - -namespace { // Begin empty namespace - using CppAD::AD; - using CppAD::ADFun; - using CppAD::vector; - - // ---------------------------------------------------------------------- - // ODE for [t, t^2 / 2 ] in form required by Runge45 - class Fun { - public: - void Ode( - const AD &t, - const vector< AD > &z, - vector< AD > &f) - { assert( z.size() == 2 ); - assert( f.size() == 2 ); - f[0] = 1.0; - f[1] = z[0]; - } - }; - - // ---------------------------------------------------------------------- - // Create function that takes on Runge45 step for the ODE above - ADFun* r_ptr_; - void create_r(void) - { size_t n = 3, m = 2; - vector< AD > x(n), zi(m), y(m), e(m); - // The value of x does not matter because the operation sequence - // does not depend on x. - x[0] = 0.0; // initial value z_0 (t) at t = ti - x[1] = 0.0; // initial value z_1 (t) at t = ti - x[2] = 0.1; // final time for this integration - CppAD::Independent(x); - zi[0] = x[0]; // z_0 (t) at t = ti - zi[1] = x[1]; // z_1 (t) at t = ti - AD ti = 0.0; // t does not appear in ODE so does not matter - AD tf = x[2]; // final time - size_t M = 3; // number of Runge45 steps to take - Fun F; - y = CppAD::Runge45(F, M, ti, tf, zi, e); - r_ptr_ = new ADFun(x, y); - } - void destroy_r(void) - { delete r_ptr_; - r_ptr_ = CPPAD_NULL; - } - - // ---------------------------------------------------------------------- - // forward mode routine called by CppAD - bool solve_ode_forward( - size_t id , - size_t k , - size_t n , - size_t m , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { assert( id == 0 ); - assert( n == 3 ); - assert( m == 2 ); - assert( k == 0 || vx.size() == 0 ); - bool ok = true; - vector xp(n), yp(m); - size_t i, j; - - // check for special case - if( vx.size() > 0 ) - { //Compute r, a Jacobian sparsity pattern. - // Use reverse mode because m < n. - vector< std::set > s(m), r(m); - for(i = 0; i < m; i++) - s[i].insert(i); - r = r_ptr_->RevSparseJac(m, s); - std::set::const_iterator itr; - for(i = 0; i < m; i++) - { vy[i] = false; - for(itr = s[i].begin(); itr != s[i].end(); itr++) - { j = *itr; - assert( j < n ); - // y[i] depends on the value of x[j] - vy[i] |= vx[j]; - } - } - } - // make sure r_ has proper lower order Taylor coefficients stored - // then compute ty[k] - for(size_t q = 0; q <= k; q++) - { for(j = 0; j < n; j++) - xp[j] = tx[j * (k+1) + q]; - yp = r_ptr_->Forward(q, xp); - if( q == k ) - { for(i = 0; i < m; i++) - ty[i * (k+1) + q] = yp[i]; - } -# ifndef NDEBUG - else - { for(i = 0; i < m; i++) - assert( ty[i * (k+1) + q] == yp[i] ); - } -# endif - } - // no longer need the Taylor coefficients in r_ptr_ - // (have to reconstruct them every time) - r_ptr_->capacity_order(0); - return ok; - } - // ---------------------------------------------------------------------- - // reverse mode routine called by CppAD - bool solve_ode_reverse( - size_t id , - size_t k , - size_t n , - size_t m , - const vector& tx , - const vector& ty , - vector& px , - const vector& py - ) - { assert( id == 0 ); - assert( n == 3 ); - assert( m == 2 ); - bool ok = true; - vector xp(n), w( (k+1) * m ), dw( (k+1) * n ); - - // make sure r_ has proper forward mode coefficients - size_t i, j, q; - for(q = 0; q <= k; q++) - { for(j = 0; j < n; j++) - xp[j] = tx[j * (k+1) + q]; -# ifdef NDEBUG - r_ptr_->Forward(q, xp); -# else - vector yp(m); - yp = r_ptr_->Forward(q, xp); - for(i = 0; i < m; i++) - assert( ty[i * (k+1) + q] == yp[i] ); -# endif - } - for(i = 0; i < m; i++) - { for(q = 0; q <=k; q++) - w[ i * (k+1) + q] = py[ i * (k+1) + q]; - } - dw = r_ptr_->Reverse(k+1, w); - for(j = 0; j < n; j++) - { for(q = 0; q <=k; q++) - px[ j * (k+1) + q] = dw[ j * (k+1) + q]; - } - // no longer need the Taylor coefficients in r_ptr_ - // (have to reconstruct them every time) - r_ptr_->capacity_order(0); - - return ok; - } - // ---------------------------------------------------------------------- - // forward Jacobian sparsity routine called by CppAD - bool solve_ode_for_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - vector< std::set >& s ) - { assert( id == 0 ); - assert( n == 3 ); - assert( m == 2 ); - bool ok = true; - - vector< std::set > R(n), S(m); - for(size_t j = 0; j < n; j++) - R[j] = r[j]; - S = r_ptr_->ForSparseJac(p, R); - for(size_t i = 0; i < m; i++) - s[i] = S[i]; - - // no longer need the forward mode sparsity pattern - // (have to reconstruct them every time) - r_ptr_->size_forward_set(0); - - return ok; - } - // ---------------------------------------------------------------------- - // reverse Jacobian sparsity routine called by CppAD - bool solve_ode_rev_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - vector< std::set >& r , - const vector< std::set >& s ) - { - assert( id == 0 ); - assert( n == 3 ); - assert( m == 2 ); - bool ok = true; - - vector< std::set > R(p), S(p); - std::set::const_iterator itr; - size_t i; - // untranspose s - for(i = 0; i < m; i++) - { for(itr = s[i].begin(); itr != s[i].end(); itr++) - S[*itr].insert(i); - } - R = r_ptr_->RevSparseJac(p, S); - // transpose r - for(i = 0; i < m; i++) - r[i].clear(); - for(i = 0; i < p; i++) - { for(itr = R[i].begin(); itr != R[i].end(); itr++) - r[*itr].insert(i); - } - return ok; - } - // ---------------------------------------------------------------------- - // reverse Hessian sparsity routine called by CppAD - bool solve_ode_rev_hes_sparse( - size_t id , - size_t n , - size_t m , - size_t p , - const vector< std::set >& r , - const vector& s , - vector& t , - const vector< std::set >& u , - vector< std::set >& v ) - { // Can just return false if not use RevSparseHes. - assert( id == 0 ); - assert( n == 3 ); - assert( m == 2 ); - bool ok = true; - std::set::const_iterator itr; - - // compute sparsity pattern for T(x) = S(x) * f'(x) - vector< std::set > S(1); - size_t i, j; - S[0].clear(); - for(i = 0; i < m; i++) - if( s[i] ) - S[0].insert(i); - t = r_ptr_->RevSparseJac(1, s); - - // compute sparsity pattern for A(x)^T = U(x)^T * f'(x) - vector< std::set > Ut(p), At(p); - for(i = 0; i < m; i++) - { for(itr = u[i].begin(); itr != u[i].end(); itr++) - Ut[*itr].insert(i); - } - At = r_ptr_->RevSparseJac(p, Ut); - - // compute sparsity pattern for H(x)^T = R^T * (S * F)''(x) - vector< std::set > R(n), Ht(p); - for(j = 0; j < n; j++) - R[j] = r[j]; - r_ptr_->ForSparseJac(p, R); - Ht = r_ptr_->RevSparseHes(p, S); - - // compute sparsity pattern for V(x) = A(x) + H(x)^T - for(j = 0; j < n; j++) - v[j].clear(); - for(i = 0; i < p; i++) - { for(itr = At[i].begin(); itr != At[i].end(); itr++) - v[*itr].insert(i); - for(itr = Ht[i].begin(); itr != Ht[i].end(); itr++) - v[*itr].insert(i); - } - - // no longer need the forward mode sparsity pattern - // (have to reconstruct them every time) - r_ptr_->size_forward_set(0); - - return ok; - } - // --------------------------------------------------------------------- - // Declare the AD routine solve_ode(id, ax, ay) - CPPAD_USER_ATOMIC( - solve_ode , - CppAD::vector , - double , - solve_ode_forward , - solve_ode_reverse , - solve_ode_for_jac_sparse , - solve_ode_rev_jac_sparse , - solve_ode_rev_hes_sparse - ) -} // End empty namespace - -bool old_usead_2(void) -{ bool ok = true; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // -------------------------------------------------------------------- - // Create the ADFun r_ - create_r(); - - // -------------------------------------------------------------------- - // domain and range space vectors - size_t n = 3, m = 2; - vector< AD > au(n), ax(n), ay(m); - au[0] = 0.0; // value of z_0 (t) = t, at t = 0 - ax[1] = 0.0; // value of z_1 (t) = t^2/2, at t = 0 - au[2] = 1.0; // final t - CppAD::Independent(au); - size_t M = 2; // number of r steps to take - ax[0] = au[0]; // value of z_0 (t) = t, at t = 0 - ax[1] = au[1]; // value of z_1 (t) = t^2/2, at t = 0 - AD dt = au[2] / M; // size of each r step - ax[2] = dt; - for(size_t i_step = 0; i_step < M; i_step++) - { size_t id = 0; // not used - solve_ode(id, ax, ay); - ax[0] = ay[0]; - ax[1] = ay[1]; - } - - // create f: u -> y and stop tape recording - // y_0(t) = u_0 + t = u_0 + u_2 - // y_1(t) = u_1 + u_0 * t + t^2 / 2 = u_1 + u_0 * u_2 + u_2^2 / 2 - // where t = u_2 - ADFun f; - f.Dependent(au, ay); - - // -------------------------------------------------------------------- - // Check forward mode results - // - // zero order forward - vector up(n), yp(m); - size_t q = 0; - double u0 = 0.5; - double u1 = 0.25; - double u2 = 0.75; - double check; - up[0] = u0; - up[1] = u1; - up[2] = u2; - yp = f.Forward(q, up); - check = u0 + u2; - ok &= NearEqual( yp[0], check, eps, eps); - check = u1 + u0 * u2 + u2 * u2 / 2.0; - ok &= NearEqual( yp[1], check, eps, eps); - // - // forward mode first derivative w.r.t t - q = 1; - up[0] = 0.0; - up[1] = 0.0; - up[2] = 1.0; - yp = f.Forward(q, up); - check = 1.0; - ok &= NearEqual( yp[0], check, eps, eps); - check = u0 + u2; - ok &= NearEqual( yp[1], check, eps, eps); - // - // forward mode second order Taylor coefficient w.r.t t - q = 2; - up[0] = 0.0; - up[1] = 0.0; - up[2] = 0.0; - yp = f.Forward(q, up); - check = 0.0; - ok &= NearEqual( yp[0], check, eps, eps); - check = 1.0 / 2.0; - ok &= NearEqual( yp[1], check, eps, eps); - // -------------------------------------------------------------------- - // reverse mode derivatives of \partial_t y_1 (t) - vector w(m * q), dw(n * q); - w[0 * q + 0] = 0.0; - w[1 * q + 0] = 0.0; - w[0 * q + 1] = 0.0; - w[1 * q + 1] = 1.0; - dw = f.Reverse(q, w); - // derivative of y_1(u) = u_1 + u_0 * u_2 + u_2^2 / 2, w.r.t. u - // is equal deritative of \partial_u2 y_1(u) w.r.t \partial_u2 u - check = u2; - ok &= NearEqual( dw[0 * q + 1], check, eps, eps); - check = 1.0; - ok &= NearEqual( dw[1 * q + 1], check, eps, eps); - check = u0 + u2; - ok &= NearEqual( dw[2 * q + 1], check, eps, eps); - // derivative of \partial_t y_1 w.r.t u = u_0 + t, w.r.t u - check = 1.0; - ok &= NearEqual( dw[0 * q + 0], check, eps, eps); - check = 0.0; - ok &= NearEqual( dw[1 * q + 0], check, eps, eps); - check = 1.0; - ok &= NearEqual( dw[2 * q + 0], check, eps, eps); - // -------------------------------------------------------------------- - // forward mode sparsity pattern for the Jacobian - // f_u = [ 1, 0, 1 ] - // [ u_2, 1, u_2 ] - size_t i, j, p = n; - CppAD::vectorBool r(n * p), s(m * p); - // r = identity sparsity pattern - for(i = 0; i < n; i++) - for(j = 0; j < p; j++) - r[i*n +j] = (i == j); - s = f.ForSparseJac(p, r); - ok &= s[ 0 * p + 0] == true; - ok &= s[ 0 * p + 1] == false; - ok &= s[ 0 * p + 2] == true; - ok &= s[ 1 * p + 0] == true; - ok &= s[ 1 * p + 1] == true; - ok &= s[ 1 * p + 2] == true; - // -------------------------------------------------------------------- - // reverse mode sparsity pattern for the Jacobian - q = m; - s.resize(q * m); - r.resize(q * n); - // s = identity sparsity pattern - for(i = 0; i < q; i++) - for(j = 0; j < m; j++) - s[i*m +j] = (i == j); - r = f.RevSparseJac(q, s); - ok &= r[ 0 * n + 0] == true; - ok &= r[ 0 * n + 1] == false; - ok &= r[ 0 * n + 2] == true; - ok &= r[ 1 * n + 0] == true; - ok &= r[ 1 * n + 1] == true; - ok &= r[ 1 * n + 2] == true; - - // -------------------------------------------------------------------- - // Hessian sparsity for y_1 (u) = u_1 + u_0 * u_2 + u_2^2 / 2 - s.resize(m); - s[0] = false; - s[1] = true; - r.resize(n * n); - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - r[ i * n + j ] = (i == j); - CppAD::vectorBool h(n * n); - h = f.RevSparseHes(n, s); - ok &= h[0 * n + 0] == false; - ok &= h[0 * n + 1] == false; - ok &= h[0 * n + 2] == true; - ok &= h[1 * n + 0] == false; - ok &= h[1 * n + 1] == false; - ok &= h[1 * n + 2] == false; - ok &= h[2 * n + 0] == true; - ok &= h[2 * n + 1] == false; - ok &= h[2 * n + 2] == true; - - // -------------------------------------------------------------------- - destroy_r(); - - // Free all temporary work space associated with old_atomic objects. - // (If there are future calls to user atomic functions, they will - // create new temporary work space.) - CppAD::user_atomic::clear(); - - return ok; -} -// END C++ diff -Nru cppad-2015.00.00.9/example/atomic/reciprocal.cpp cppad-2016.00.00.1/example/atomic/reciprocal.cpp --- cppad-2015.00.00.9/example/atomic/reciprocal.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/reciprocal.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: reciprocal.cpp 3160 2014-03-05 17:04:14Z bradbell $ +// $Id: reciprocal.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,12 +12,12 @@ /* $begin atomic_reciprocal.cpp$$ +$spell + enum +$$ $section Reciprocal as an Atomic Operation: Example and Test$$ -$index reciprocal, atomic operation$$ -$index simple, atomic operation$$ -$index atomic, simple operation$$ -$index operation, simple atomic$$ +$mindex set_sparsity_enum$$ $head Theory$$ This example demonstrates using $cref atomic_base$$ @@ -25,6 +25,9 @@ $latex f : \B{R}^n \rightarrow \B{R}^m$$ where $latex n = 1$$, $latex m = 1$$, and $latex f(x) = 1 / x$$. +$head sparsity$$ +This example only uses set sparsity patterns. + $nospell $head Start Class Definition$$ @@ -55,8 +58,9 @@ $codep */ public: // constructor (could use const char* for name) - atomic_reciprocal(const std::string& name) : - CppAD::atomic_base(name) + atomic_reciprocal(const std::string& name) : + // this exmaple only uses set sparsity patterns + CppAD::atomic_base(name, atomic_base::set_sparsity_enum) { } private: /* $$ @@ -100,7 +104,7 @@ // y^1 = f'( x^0 ) x^1 double fp = - f / tx[0]; if( p <= 1 ) - ty[1] = fp * tx[1]; + ty[1] = fp * tx[1]; if( q <= 1 ) return ok; @@ -129,12 +133,12 @@ const vector& py ) { size_t n = tx.size() / (q + 1); - size_t m = ty.size() / (q + 1); + size_t m = ty.size() / (q + 1); assert( px.size() == n * (q + 1) ); assert( py.size() == m * (q + 1) ); assert( n == 1 ); assert( m == 1 ); - bool ok = q <= 2; + bool ok = q <= 2; double f, fp, fpp, fppp; switch(q) @@ -170,7 +174,7 @@ fppp = - 3.0 * fpp / tx[0]; px[2] = py[2] * fp; px[1] = py[2] * fpp * tx[1]; - px[0] = py[2] * tx[1] * fppp * tx[1] / 2.0 + fpp * tx[2]; + px[0] = py[2] * tx[1] * fppp * tx[1] / 2.0 + fpp * tx[2]; // reverse: F^1 ( tx ) = y^1 = f'( x^0 ) x^1 px[1] += py[1] * fp; px[0] += py[1] * fpp * tx[1]; @@ -187,31 +191,12 @@ /* $$ $head for_sparse_jac$$ $codep */ - // forward Jacobian bool sparsity routine called by CppAD - virtual bool for_sparse_jac( - size_t p , - const vector& r , - vector& s ) - { // This function needed if using f.ForSparseJac - // with afun.option( CppAD::atomic_base::bool_sparsity_enum ) - size_t n = r.size() / p; - size_t m = s.size() / p; - assert( n == 1 ); - assert( m == 1 ); - - // sparsity for S(x) = f'(x) * R is same as sparsity for R - for(size_t j = 0; j < p; j++) - s[j] = r[j]; - - return true; - } // forward Jacobian set sparsity routine called by CppAD virtual bool for_sparse_jac( size_t p , const vector< std::set >& r , vector< std::set >& s ) - { // This function needed if using f.ForSparseJac - // with afun.option( CppAD::atomic_base::set_sparsity_enum ) + { // This function needed if using f.ForSparseJac size_t n = r.size(); size_t m = s.size(); assert( n == 1 ); @@ -220,36 +205,17 @@ // sparsity for S(x) = f'(x) * R is same as sparsity for R s[0] = r[0]; - return true; + return true; } /* $$ $head rev_sparse_jac$$ $codep */ - // reverse Jacobian bool sparsity routine called by CppAD - virtual bool rev_sparse_jac( - size_t p , - const vector& rt , - vector& st ) - { // This function needed if using RevSparseJac or optimize - // with afun.option( CppAD::atomic_base::bool_sparsity_enum ) - size_t n = st.size() / p; - size_t m = rt.size() / p; - assert( n == 1 ); - assert( m == 1 ); - - // sparsity for S(x)^T = f'(x)^T * R^T is same as sparsity for R^T - for(size_t i = 0; i < p; i++) - st[i] = rt[i]; - - return true; - } // reverse Jacobian set sparsity routine called by CppAD virtual bool rev_sparse_jac( size_t p , const vector< std::set >& rt , vector< std::set >& st ) { // This function needed if using RevSparseJac or optimize - // with afun.option( CppAD::atomic_base::set_sparsity_enum ) size_t n = st.size(); size_t m = rt.size(); assert( n == 1 ); @@ -258,54 +224,11 @@ // sparsity for S(x)^T = f'(x)^T * R^T is same as sparsity for R^T st[0] = rt[0]; - return true; + return true; } /* $$ $head rev_sparse_hes$$ $codep */ - // reverse Hessian bool sparsity routine called by CppAD - virtual bool rev_sparse_hes( - const vector& vx, - const vector& s , - vector& t , - size_t p , - const vector& r , - const vector& u , - vector& v ) - { // This function needed if using RevSparseHes - // with afun.option( CppAD::atomic_base::bool_sparsity_enum ) - size_t m = s.size(); - size_t n = t.size(); - assert( r.size() == n * p ); - assert( u.size() == m * p ); - assert( v.size() == n * p ); - assert( n == 1 ); - assert( m == 1 ); - - // There are no cross term second derivatives for this case, - // so it is not necessary to vx. - - // sparsity for T(x) = S(x) * f'(x) is same as sparsity for S - t[0] = s[0]; - - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R - // U(x) = g''(y) * f'(x) * R - // S(x) = g'(y) - - // back propagate the sparsity for U, note f'(x) may be non-zero; - size_t j; - for(j = 0; j < p; j++) - v[j] = u[j]; - - // include forward Jacobian sparsity in Hessian sparsity - // (note sparsty for f''(x) * R same as for R) - if( s[0] ) - { for(j = 0; j < p; j++) - v[j] |= r[j]; - } - - return true; - } // reverse Hessian set sparsity routine called by CppAD virtual bool rev_sparse_hes( const vector& vx, @@ -316,7 +239,6 @@ const vector< std::set >& u , vector< std::set >& v ) { // This function needed if using RevSparseHes - // with afun.option( CppAD::atomic_base::set_sparsity_enum ) size_t n = vx.size(); size_t m = s.size(); assert( t.size() == n ); @@ -331,11 +253,11 @@ // sparsity for T(x) = S(x) * f'(x) is same as sparsity for S t[0] = s[0]; - - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R + + // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) - + // back propagate the sparsity for U, note f'(x) may be non-zero; v[0] = u[0]; @@ -380,11 +302,11 @@ // declare independent variables and start tape recording CppAD::Independent(ax); - // range space vector + // range space vector size_t m = 1; vector< AD > ay(m); - // call user function and store reciprocal(x) in au[0] + // call user function and store reciprocal(x) in au[0] vector< AD > au(m); afun(ax, au); // u = 1 / x @@ -397,7 +319,7 @@ /* $$ $subhead forward$$ $codep */ - // check function value + // check function value double check = x0; ok &= NearEqual( Value(ay[0]) , check, eps, eps); @@ -425,7 +347,7 @@ /* $$ $subhead reverse$$ $codep */ - // third order reverse mode + // third order reverse mode q = 3; vector w(m), dw(n * q); w[0] = 1.; @@ -443,13 +365,8 @@ CppAD::vectorBool r1(n * p), s1(m * p); r1[0] = true; // compute sparsity pattern for x[0] // - afun.option( CppAD::atomic_base::bool_sparsity_enum ); s1 = f.ForSparseJac(p, r1); - ok &= s1[0] == true; // f[0] depends on x[0] - // - afun.option( CppAD::atomic_base::set_sparsity_enum ); - s1 = f.ForSparseJac(p, r1); - ok &= s1[0] == true; // f[0] depends on x[0] + ok &= s1[0] == true; // f[0] depends on x[0] /* $$ $subhead rev_sparse_jac$$ $codep */ @@ -458,28 +375,18 @@ CppAD::vectorBool s2(q * m), r2(q * n); s2[0] = true; // compute sparsity pattern for f[0] // - afun.option( CppAD::atomic_base::bool_sparsity_enum ); - r2 = f.RevSparseJac(q, s2); - ok &= r2[0] == true; // f[0] depends on x[0] - // - afun.option( CppAD::atomic_base::set_sparsity_enum ); r2 = f.RevSparseJac(q, s2); - ok &= r2[0] == true; // f[0] depends on x[0] + ok &= r2[0] == true; // f[0] depends on x[0] /* $$ $subhead rev_sparse_hes$$ $codep */ - // Hessian sparsity (using previous ForSparseJac call) + // Hessian sparsity (using previous ForSparseJac call) CppAD::vectorBool s3(m), h(p * n); s3[0] = true; // compute sparsity pattern for f[0] // - afun.option( CppAD::atomic_base::bool_sparsity_enum ); h = f.RevSparseHes(p, s3); ok &= h[0] == true; // second partial of f[0] w.r.t. x[0] may be non-zero // - afun.option( CppAD::atomic_base::set_sparsity_enum ); - h = f.RevSparseHes(p, s3); - ok &= h[0] == true; // second partial of f[0] w.r.t. x[0] may be non-zero - return ok; } /* $$ diff -Nru cppad-2015.00.00.9/example/atomic/sparsity.cpp cppad-2016.00.00.1/example/atomic/sparsity.cpp --- cppad-2015.00.00.9/example/atomic/sparsity.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/sparsity.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,281 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin atomic_sparsity.cpp$$ +$spell + enum +$$ + +$section Atomic Sparsity Patterns: Example and Test$$ + +$head function$$ +For this example, the atomic function +$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +f( x_0, x_1 , x_2 ) = \left( \begin{array}{c} + x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ + +$head pack_sparsity_enum$$ +This example only uses pack sparsity patterns. + +$nospell + +$head Start Class Definition$$ +$codep */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +using CppAD::vectorBool; // abbreviate as vectorBool +// +class atomic_sparsity : public CppAD::atomic_base { +/* $$ +$head Constructor $$ +$codep */ + public: + // constructor + atomic_sparsity(const std::string& name) : + // this exampel only uses pack sparsity patterns + CppAD::atomic_base(name, pack_sparsity_enum ) + { } + private: +/* $$ +$head forward$$ +$codep */ + // forward + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); + assert( n == 3 ); + assert( m == 2 ); + + // only order zero + bool ok = q == 0; + if( ! ok ) + return ok; + + // check for defining variable information + if( vx.size() > 0 ) + { ok &= vx.size() == n; + vy[0] = vx[2]; + vy[1] = vx[0] || vx[1]; + } + + // Order zero forward mode. + // y[0] = x[2], y[1] = x[0] * x[1] + if( p <= 0 ) + { ty[0] = tx[2]; + ty[1] = tx[0] * tx[1]; + } + return ok; + } +/* $$ +$head for_sparse_jac$$ +$codep */ + // for_sparse_jac + virtual bool for_sparse_jac( + size_t p , + const vectorBool& r , + vectorBool& s ) + { // This function needed if using f.ForSparseJac + size_t n = r.size() / p; + size_t m = s.size() / p; + assert( n == 3 ); + assert( m == 2 ); + + // sparsity for S(x) = f'(x) * R = [ 0, 0, 1 ] * R + // [ x1, x0, 0 ] + for(size_t j = 0; j < p; j++) + { s[ 0 * p + j] = r[ 2 * p + j]; + s[ 1 * p + j] = r[ 0 * p + j] || r[ 1 * p + j]; + } + return true; + } +/* $$ +$head rev_sparse_jac$$ +$codep */ + virtual bool rev_sparse_jac( + size_t p , + const vectorBool& rt , + vectorBool& st ) + { // This function needed if using RevSparseJac or optimize + size_t n = st.size() / p; + size_t m = rt.size() / p; + assert( n == 3 ); + assert( m == 2 ); + + // [ 0, x1 ] + // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T + // [ 1, 0 ] + for(size_t j = 0; j < p; j++) + { st[ 0 * p + j ] = rt[ 1 * m + j ]; + st[ 1 * p + j ] = rt[ 1 * m + j ]; + st[ 2 * p + j ] = rt[ 0 * m + j ]; + } + return true; + } +/* $$ +$head rev_sparse_hes$$ +$codep */ + virtual bool rev_sparse_hes( + const vector& vx, + const vector& s , + vector& t , + size_t p , + const vectorBool& r , + const vectorBool& u , + vectorBool& v ) + { // This function needed if using RevSparseHes + size_t m = s.size(); + size_t n = t.size(); + assert( r.size() == n * p ); + assert( u.size() == m * p ); + assert( v.size() == n * p ); + assert( n == 3 ); + assert( m == 2 ); + + // sparsity for T(x) = S(x) * f'(x) = S(x) * [ 0, 0, 1 ] + // [ x1, x0, 0 ] + t[0] = s[1]; + t[1] = s[1]; + t[2] = s[0]; + + // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R + // U(x) = g''(y) * f'(x) * R + // S(x) = g'(y) + + // [ 0, x1 ] + // sparsity for f'(x)^T * U(x) = [ 0, x0 ] * U(x) + // [ 1, 0 ] + size_t j; + for(j = 0; j < p; j++) + { v[ 0 * p + j ] = u[ 1 * m + j ]; + v[ 1 * p + j ] = u[ 1 * m + j ]; + v[ 2 * p + j ] = u[ 0 * m + j ]; + } + + // include forward Jacobian sparsity in Hessian sparsity + // [ 0, 1, 0 ] + // sum_i S_i (x) g'(y) * f_i''(x) * R = S_1 (x) * [ 1, 0, 0 ] * R + // [ 0, 0, 0 ] + if( s[1] ) + { for(j = 0; j < p; j++) + { v[ 0 * p + j ] = bool(v[0 * p + j]) | bool(r[1 * p + j]); + v[ 1 * p + j ] = bool(v[1 * p + j]) | bool(r[0 * p + j]); + } + } + return true; + } +/* $$ +$head End Class Definition$$ +$codep */ +}; // End of atomic_sparsity class +} // End empty namespace + +/* $$ +$head Use Atomic Function$$ +$codep */ +bool sparsity(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); +/* $$ +$subhead Constructor$$ +$codep */ + // Create the atomic get_started object + atomic_sparsity afun("atomic_sparsity"); +/* $$ +$subhead Recording$$ +$codep */ + size_t n = 3; + size_t m = 2; + vector< AD > ax(n), ay(m); + for(size_t j = 0; j < n; j++) + ax[j] = double(j + 1); + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // call user function + afun(ax, ay); + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, ay); // f(x) = x + + // check function value + ok &= NearEqual(ay[0] , ax[2], eps, eps); + ok &= NearEqual(ay[1] , ax[0] * ax[1], eps, eps); + +/* $$ +$subhead forsparse_jac and rev_sparse_jac$$ +$codep */ + for(size_t dir = 0; dir < 2; dir++) + { size_t ell; + if( dir == 0 ) + ell = n; + else + ell = m; + + // identity martrix + vectorBool r(ell * ell); + for(size_t i = 0; i < ell; i++) + for(size_t j = 0; j < ell; j++) + r[i * ell + j] = (i == j); + + vectorBool s; + if( dir == 0 ) + s = f.ForSparseJac(n, r); + else + s = f.RevSparseJac(m, r); + + // check Jacobian result + ok &= s.size() == m * n; + ok &= s[0 * n + 0] == false; + ok &= s[0 * n + 1] == false; + ok &= s[0 * n + 2] == true; + ok &= s[1 * n + 0] == true; + ok &= s[1 * n + 1] == true; + ok &= s[1 * n + 2] == false; + } +/* $$ +$subhead rev_sparse_hes$$ +$codep */ + vectorBool s(m), h(n * n); + s[0] = true; + s[1] = true; + h = f.RevSparseHes(n, s); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + { bool check = false; + check |= (i == 0) && (j == 1); + check |= (j == 0) && (i == 1); + ok &= h[ i * n + j] == check; + } + } + // + return ok; +} +/* $$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2015.00.00.9/example/atomic/tangent.cpp cppad-2016.00.00.1/example/atomic/tangent.cpp --- cppad-2015.00.00.9/example/atomic/tangent.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/atomic/tangent.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: tangent.cpp 3160 2014-03-05 17:04:14Z bradbell $ +// $Id: tangent.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,24 +14,26 @@ $begin atomic_tangent.cpp$$ $spell Tanh + bool $$ $section Tan and Tanh as User Atomic Operations: Example and Test$$ -$index tangent, atomic operation$$ -$index atomic, tangent operation$$ -$index tan, atomic operation$$ +$mindex tangent operation$$ $head Theory$$ The code below uses the $cref tan_forward$$ and $cref tan_reverse$$ to implement the tangent and hyperbolic tangent functions as user atomic operations. +$head sparsity$$ +This atomic operation can use both set and bool sparsity patterns. + $nospell $head Start Class Definition$$ $codep */ # include -namespace { // Begin empty namespace +namespace { // Begin empty namespace using CppAD::vector; // // a utility to compute the union of two sets. @@ -58,7 +60,7 @@ const bool hyperbolic_; // is this hyperbolic tangent public: // constructor - atomic_tangent(const char* name, bool hyperbolic) + atomic_tangent(const char* name, bool hyperbolic) : CppAD::atomic_base(name), hyperbolic_(hyperbolic) { } @@ -98,7 +100,7 @@ // y^{(0)} = z^{(0)} * z^{(0)} tzy[q1 + 0] = tzy[0] * tzy[0]; - + p++; } for(j = p; j <= q; j++) @@ -107,7 +109,7 @@ j_inv = - j_inv; // z^{(j)} = x^{(j)} +- sum_{k=1}^j k x^{(k)} y^{(j-k)} / j - tzy[j] = tx[j]; + tzy[j] = tx[j]; for(k = 1; k <= j; k++) tzy[j] += tx[k] * tzy[q1 + j-k] * k * j_inv; @@ -133,7 +135,7 @@ ) { size_t q1 = q + 1; size_t n = tx.size() / q1; - size_t m = tzy.size() / q1; + size_t m = tzy.size() / q1; assert( px.size() == n * q1 ); assert( pzy.size() == m * q1 ); assert( n == 1 ); @@ -157,15 +159,15 @@ // H_{x^{(k)}} += delta(j-k) +- H_{z^{(j)} y^{(j-k)} * k / j px[j] += qzy[j]; for(k = 1; k <= j; k++) - px[k] += qzy[j] * tzy[q1 + j-k] * k * j_inv; + px[k] += qzy[j] * tzy[q1 + j-k] * k * j_inv; // H_{y^{j-k)} += +- H_{z^{(j)} x^{(k)} * k / j for(k = 1; k <= j; k++) - qzy[q1 + j-k] += qzy[j] * tx[k] * k * j_inv; + qzy[q1 + j-k] += qzy[j] * tx[k] * k * j_inv; - // H_{z^{(k)}} += H_{y^{(j-1)}} * z^{(j-k-1)} * 2. + // H_{z^{(k)}} += H_{y^{(j-1)}} * z^{(j-k-1)} * 2. for(k = 0; k < j; k++) - qzy[k] += qzy[q1 + j-1] * tzy[j-k-1] * 2.f; + qzy[k] += qzy[q1 + j-1] * tzy[j-k-1] * 2.f; } // eliminate order zero @@ -174,7 +176,7 @@ else px[0] += qzy[0] * (1.f + tzy[q1 + 0]); - return true; + return true; } /* $$ $head for_sparse_jac$$ @@ -230,7 +232,7 @@ for(size_t j = 0; j < p; j++) st[j] = rt[0 * p + j] | rt[1 * p + j]; - return true; + return true; } // reverse Jacobian sparsity routine called by CppAD virtual bool rev_sparse_jac( @@ -244,7 +246,7 @@ // sparsity for S(x)^T = f'(x)^T * R^T my_union(st[0], rt[0], rt[1]); - return true; + return true; } /* $$ $head rev_sparse_hes$$ @@ -270,14 +272,14 @@ // There are no cross term second derivatives for this case, // so it is not necessary to vx. - // sparsity for T(x) = S(x) * f'(x) + // sparsity for T(x) = S(x) * f'(x) t[0] = s[0] | s[1]; - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R + // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) - - // back propagate the sparsity for U, note both components + + // back propagate the sparsity for U, note both components // of f'(x) may be non-zero; size_t j; for(j = 0; j < p; j++) @@ -287,7 +289,9 @@ // (note sparsty for f''(x) * R same as for R) if( s[0] | s[1] ) { for(j = 0; j < p; j++) - v[j] |= r[j]; + { // Visual Studio 2013 generates warning without bool below + v[j] |= bool( r[j] ); + } } return true; @@ -312,14 +316,14 @@ // There are no cross term second derivatives for this case, // so it is not necessary to vx. - // sparsity for T(x) = S(x) * f'(x) + // sparsity for T(x) = S(x) * f'(x) t[0] = s[0] | s[1]; - // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R + // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) - - // back propagate the sparsity for U, note both components + + // back propagate the sparsity for U, note both components // of f'(x) may be non-zero; my_union(v[0], u[0], u[1]); @@ -362,7 +366,7 @@ // declare independent variables and start tape recording CppAD::Independent(ax); - // range space vector + // range space vector size_t m = 3; CppAD::vector< AD > af(m); @@ -382,15 +386,15 @@ CppAD::vector< AD > one(1); one[0] = 1.; my_tanh(one, az); - af[2] = az[0]; + af[2] = az[0]; // create f: x -> f and stop tape recording CppAD::ADFun F; - F.Dependent(ax, af); + F.Dependent(ax, af); /* $$ $subhead forward$$ $codep */ - // check function value + // check function value float tan = std::tan(x0); ok &= NearEqual(af[0] , tan, eps, eps); float tanh = std::tanh(x0); @@ -417,10 +421,10 @@ w[2] = 0.; dw = F.Reverse(1, w); - // tan'(x) = 1 + tan(x) * tan(x) - // tanh'(x) = 1 - tanh(x) * tanh(x) - float tanp = 1.f + tan * tan; - float tanhp = 1.f - tanh * tanh; + // tan'(x) = 1 + tan(x) * tan(x) + // tanh'(x) = 1 - tanh(x) * tanh(x) + float tanp = 1.f + tan * tan; + float tanhp = 1.f - tanh * tanh; ok &= NearEqual(df[0], tanp, eps, eps); ok &= NearEqual(df[1], tanhp, eps, eps); ok &= NearEqual(dw[0], w[0]*tanp + w[1]*tanhp, eps, eps); @@ -434,8 +438,8 @@ CppAD::vector ddw(2); ddw = F.Reverse(2, w); - // tan''(x) = 2 * tan(x) * tan'(x) - // tanh''(x) = - 2 * tanh(x) * tanh'(x) + // tan''(x) = 2 * tan(x) * tan'(x) + // tanh''(x) = - 2 * tanh(x) * tanh'(x) // Note that second order Taylor coefficient for u half the // corresponding second derivative. float two = 2; @@ -500,7 +504,7 @@ df = F.Forward(1, dx); tanhp = 0.; ok &= NearEqual(df[1], tanhp, eps, eps); - + return ok; } /* $$ diff -Nru cppad-2015.00.00.9/example/azmul.cpp cppad-2016.00.00.1/example/azmul.cpp --- cppad-2015.00.00.9/example/azmul.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/azmul.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,84 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin azmul.cpp$$ +$spell +$$ + +$section AD Absolute Zero Multiplication: Example and Test$$ + +$code +$verbatim%example/azmul.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# include +# include + +bool azmul(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + double inf = std::numeric_limits::infinity(); + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 2; + double x = 0.5; + double y = 2.0; + CPPAD_TESTVECTOR(AD) axy(n); + axy[0] = x; + axy[1] = y; + + // declare independent variables and start tape recording + CppAD::Independent(axy); + + // range space vector + size_t m = 5; + CPPAD_TESTVECTOR(AD) az(m); + az[0] = CppAD::azmul(axy[0], axy[1]); // azmul(variable, variable) + az[1] = CppAD::azmul(axy[0], inf); // azmul(variable, parameter=inf) + az[2] = CppAD::azmul(axy[0], 3.0); // azmul(variable, parameter=3.0) + az[3] = CppAD::azmul(0.0, axy[1]); // azmul(parameter=0.0, variable) + az[4] = CppAD::azmul(4.0, axy[1]); // azmul(parameter=4.0, variable) + + // create f: axy -> az and stop tape recording + CppAD::ADFun f(axy, az); + + // check value when x is not zero + ok &= NearEqual(az[0] , x * y, eps, eps); + ok &= az[1] == inf; + ok &= NearEqual(az[2] , x * 3.0, eps, eps); + ok &= az[3] == 0.0; + ok &= NearEqual(az[4] , 4.0 * y, eps, eps); + + + // check value x is zero and y is infinity + CPPAD_TESTVECTOR(double) xy(n), z(m); + xy[0] = 0.0; + xy[1] = inf; + z = f.Forward(0, xy); + ok &= z[0] == 0.0; + ok &= z[1] == 0.0; + ok &= z[2] == 0.0; + ok &= z[3] == 0.0; + ok &= z[4] == inf; + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/example/base_alloc.hpp cppad-2016.00.00.1/example/base_alloc.hpp --- cppad-2015.00.00.9/example/base_alloc.hpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/base_alloc.hpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,8 +1,8 @@ -/* $Id: base_alloc.hpp 3495 2014-12-24 01:16:15Z bradbell $ */ -# ifndef CPPAD_BASE_ALLOC_INCLUDED -# define CPPAD_BASE_ALLOC_INCLUDED +// $Id: base_alloc.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_BASE_ALLOC_HPP +# define CPPAD_BASE_ALLOC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -14,6 +14,11 @@ /* $begin base_alloc.hpp$$ $spell + azmul + expm1 + atanh + acosh + asinh Rel Lt Le Eq Ge Gt Cond @@ -45,9 +50,9 @@ $section Example AD Where Base Constructor Allocates Memory$$ $head Purpose$$ -Demonstrate use of $codei%AD<%Base%>%$$ +Demonstrate use of $codei%AD<%Base%>%$$ where memory is allocated for each element of the type $icode Base$$. -In addition, this is a complete example where all the +In addition, this is a complete example where all the $cref/required Base/base_require/$$ type operations are defined (as apposed to other examples where some of the operations for the Base type are already defined). @@ -57,12 +62,12 @@ and $cref thread_alloc$$. $codep */ # include -# include +# include /* $$ $head Computed Assignment Macro$$ -This macro is used for the -$code base_alloc$$ computed assignment operators; to be specific, +This macro is used for the +$code base_alloc$$ computed assignment operators; to be specific, used with $icode op $$ equal to $code +=$$, $code -=$$, @@ -75,8 +80,8 @@ /* $$ $head Binary Operator Macro$$ -This macro is used for the -$code base_alloc$$ binary operators (as member functions); to be specific, +This macro is used for the +$code base_alloc$$ binary operators (as member functions); to be specific, used with $icode op $$ equal to $code +$$, $code -$$, @@ -94,9 +99,9 @@ /* $$ $head Boolean Operator Macro$$ -This macro can be used for the -$code base_alloc$$ binary operators that have a -$code bool$$ result; to be specific, +This macro can be used for the +$code base_alloc$$ binary operators that have a +$code bool$$ result; to be specific, used with $icode op $$ equal to $code ==$$, $code !=$$, @@ -114,7 +119,7 @@ /* $$ $head Class Definition$$ -The following example class +The following example class defines the necessary $cref base_member$$ functions. It is made more complicated by storing a pointer to a $code double$$ instead of the $code double$$ value itself. @@ -126,18 +131,18 @@ base_alloc(void) { size_t cap; - void* v = CppAD::thread_alloc::get_memory(sizeof(double), cap); + void* v = CppAD::thread_alloc::get_memory(sizeof(double), cap); ptrdbl_ = static_cast(v); } base_alloc(double dbl) { size_t cap; - void *v = CppAD::thread_alloc::get_memory(sizeof(double), cap); + void *v = CppAD::thread_alloc::get_memory(sizeof(double), cap); ptrdbl_ = static_cast(v); *ptrdbl_ = dbl; } base_alloc(const base_alloc& x) { size_t cap; - void *v = CppAD::thread_alloc::get_memory(sizeof(double), cap); + void *v = CppAD::thread_alloc::get_memory(sizeof(double), cap); ptrdbl_ = static_cast(v); *ptrdbl_ = *x.ptrdbl_; } @@ -164,7 +169,7 @@ BASE_ALLOC_BINARY_OPERATOR(/) BASE_ALLOC_BOOL_OPERATOR(==) BASE_ALLOC_BOOL_OPERATOR(!=) - // The <= operator is not necessary for the base type requirements + // The <= operator is not necessary for the base type requirements // (needed so we can use NearEqual with base_alloc arguments). BASE_ALLOC_BOOL_OPERATOR(<=) }; @@ -175,11 +180,11 @@ Hence its $code CondExpOp$$ function is defined by $codep */ namespace CppAD { - inline base_alloc CondExpOp( + inline base_alloc CondExpOp( enum CompareOp cop , const base_alloc& left , - const base_alloc& right , - const base_alloc& exp_if_true , + const base_alloc& right , + const base_alloc& exp_if_true , const base_alloc& exp_if_false ) { // not used assert(false); @@ -244,6 +249,13 @@ } /* $$ +$head azmul$$ +$codep */ +namespace CppAD { + CPPAD_AZMUL( base_alloc ) +} +/* $$ + $head Ordered$$ The $code base_alloc$$ type supports ordered comparisons $codep */ @@ -271,10 +283,10 @@ inline base_alloc fun (const base_alloc& x) \ { return std::fun(*x.ptrdbl_); } /* $$ -The following invocations of the macro above define the +The following invocations of the macro above define the $cref/unary standard math/base_std_math/Unary Standard Math/$$ functions (except for $code abs$$): -$codep */ +$codep */ namespace CppAD { BASE_ALLOC_STD_MATH(acos) BASE_ALLOC_STD_MATH(asin) @@ -291,7 +303,7 @@ BASE_ALLOC_STD_MATH(tanh) } /* $$ -The absolute value function is special because its $code std$$ name is +The absolute value function is special because its $code std$$ name is $code fabs$$ $codep */ namespace CppAD { @@ -300,13 +312,21 @@ } /* $$ -$head erf$$ -The following defines the $code CppAD::erf$$ function that -is required th use $code AD$$: -$codep */ -# if CPPAD_COMPILER_HAS_ERF - inline base_alloc erf(const base_alloc& x) - { return std::erf(*x.ptrdbl_); } +$head erf, asinh, acosh, atanh, expm1, log1p$$ +The following defines the +$cref/erf, asinh, acosh, atanh, expm1, log1p + /base_std_math + /erf, asinh, acosh, atanh, expm1, log1p +/$$ functions +required by $code AD$$: +$codep */ +# if CPPAD_USE_CPLUSPLUS_2011 + BASE_ALLOC_STD_MATH(erf) + BASE_ALLOC_STD_MATH(asinh) + BASE_ALLOC_STD_MATH(acosh) + BASE_ALLOC_STD_MATH(atanh) + BASE_ALLOC_STD_MATH(expm1) + BASE_ALLOC_STD_MATH(log1p) # endif /* $$ @@ -324,7 +344,7 @@ } } /* $$ - + $head pow $$ The following defines a $code CppAD::pow$$ function that is required to use $code AD$$: @@ -335,26 +355,12 @@ } /* $$ -$head limits$$ +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code base_alloc$$: $codep */ namespace CppAD { - template <> - class numeric_limits { - public: - // machine epsilon - static base_alloc epsilon(void) - { return std::numeric_limits::epsilon(); } - // minimum positive normalized value - static base_alloc min(void) - { return std::numeric_limits::min(); } - // maximum finite value - static base_alloc max(void) - { return std::numeric_limits::max(); } - }; - // deprecated machine epsilon - template <> - inline base_alloc epsilon(void) - { return numeric_limits::epsilon(); } + CPPAD_NUMERIC_LIMITS(double, base_alloc) } /* $$ diff -Nru cppad-2015.00.00.9/example/base_require.cpp cppad-2016.00.00.1/example/base_require.cpp --- cppad-2015.00.00.9/example/base_require.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/base_require.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,6 +1,6 @@ -/* $Id: base_require.cpp 2799 2013-05-08 16:42:20Z bradbell $ */ +// $Id: base_require.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -16,11 +16,8 @@ $$ $section Using a User Defined AD Base Type: Example and Test$$ +$mindex type$$ -$index base, type example$$ -$index type, base example$$ -$index example, base type$$ -$index test, base type$$ $code $verbatim%example/base_require.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -57,7 +54,7 @@ // check function value f(x) = x^2 CPPAD_TESTVECTOR(base_alloc) x(n), y(m); - base_alloc eps = + base_alloc eps = base_alloc(100.) * CppAD::numeric_limits::epsilon(); x[0] = base_alloc(3.); y = f.Forward(0, x); diff -Nru cppad-2015.00.00.9/example/bender_quad.cpp cppad-2016.00.00.1/example/bender_quad.cpp --- cppad-2015.00.00.9/example/bender_quad.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/bender_quad.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: bender_quad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: bender_quad.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,44 +17,42 @@ $$ $section BenderQuad: Example and Test$$ +$mindex BenderQuad$$ -$index BenderQuad, example$$ -$index example, BenderQuad$$ -$index test, BenderQuad$$ -Define +Define $latex F : \B{R} \times \B{R} \rightarrow \B{R}$$ by $latex \[ -F(x, y) -= +F(x, y) += \frac{1}{2} \sum_{i=1}^N [ y * \sin ( x * t_i ) - z_i ]^2 -\] $$ +\] $$ where $latex z \in \B{R}^N$$ is a fixed vector. It follows that $latex \[ \begin{array}{rcl} -\partial_y F(x, y) -& = & +\partial_y F(x, y) +& = & \sum_{i=1}^N [ y * \sin ( x * t_i ) - z_i ] \sin( x * t_i ) \\ \partial_y \partial_y F(x, y) -& = & +& = & \sum_{i=1}^N \sin ( x t_i )^2 \end{array} \] $$ -Furthermore if we define $latex Y(x)$$ +Furthermore if we define $latex Y(x)$$ as the argmin of $latex F(x, y)$$ with respect to $latex y$$, $latex \[ \begin{array}{rcl} -Y(x) +Y(x) & = & -y - [ \partial_y \partial_y F(x, y) ]^{-1} \partial_y F[x, y] +y - [ \partial_y \partial_y F(x, y) ]^{-1} \partial_y F[x, y] \\ & = & -\left. - \sum_{i=1}^N z_i \sin ( x t_i ) - \right/ - \sum_{i=1}^N z_i \sin ( x * t_i )^2 +\left. + \sum_{i=1}^N z_i \sin ( x t_i ) + \right/ + \sum_{i=1}^N z_i \sin ( x * t_i )^2 \end{array} \] $$ @@ -114,11 +112,11 @@ } return fy; } - // Fun.dy(x, y, h) = - H_y (x,y)^{-1} * h + // Fun.dy(x, y, h) = - H_y (x,y)^{-1} * h // = - F_yy (x, y)^{-1} * h ADvector dy( - const BAvector &x , - const BAvector &y , + const BAvector &x , + const BAvector &y , const ADvector &H ) { size_t i; size_t N = size_t(z_.size()); @@ -143,7 +141,7 @@ size_t k; for(k = 0; k < size_t(t.size()); k++) { numerator += sin( x[0] * t[k] ) * z[k]; - denominator += sin( x[0] * t[k] ) * sin( x[0] * t[k] ); + denominator += sin( x[0] * t[k] ) * sin( x[0] * t[k] ); } AD y = numerator / denominator; @@ -184,7 +182,7 @@ z[i] = y[0] * sin( x[0] * t[i] ); // data without noise } - // construct the function object + // construct the function object Fun fun(t, z); // evaluate the G(x), G'(x) and G''(x) diff -Nru cppad-2015.00.00.9/example/bool_fun.cpp cppad-2016.00.00.1/example/bool_fun.cpp --- cppad-2015.00.00.9/example/bool_fun.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/bool_fun.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: bool_fun.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: bool_fun.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,8 @@ $$ $section AD Boolean Functions: Example and Test$$ +$mindex bool$$ -$index example, AD bool$$ -$index test, AD bool$$ $code $verbatim%example/bool_fun.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -35,7 +34,7 @@ # include -// define abbreviation for double precision complex +// define abbreviation for double precision complex typedef std::complex Complex; namespace { diff -Nru cppad-2015.00.00.9/example/bool_sparsity.cpp cppad-2016.00.00.1/example/bool_sparsity.cpp --- cppad-2015.00.00.9/example/bool_sparsity.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/bool_sparsity.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,195 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin bool_sparsity.cpp$$ +$spell + Bool +$$ + +$section Using vectorBool Sparsity To Conserve Memory: Example and Test$$ + +$head Purpose$$ +This example show how to conserve memory when computing sparsity patterns. + +$code +$verbatim%example/bool_sparsity.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include +namespace { + using CppAD::vector; + using std::cout; + using CppAD::vectorBool; + using CppAD::AD; + using CppAD::ADFun; + + // function f(x) that we are computing sparsity patterns for + template + vector fun(const vector& x) + { size_t n = x.size(); + vector ret(n + 1); + for(size_t j = 0; j < n; j++) + { size_t k = (j + 1) % n; + ret[j] = x[j] * x[j] * x[k]; + } + ret[n] = 0.0; + return ret; + } + // check sparsity pattern for f(x) + bool check_jac(const vectorBool& pattern, size_t n) + { bool ok = true; + for(size_t i = 0; i < n; i++) + { size_t k = (i + 1) % n; + for(size_t j = 0; j < n; j++) + { bool non_zero = (i == j) || (j == k); + ok &= pattern[ i * n + j] == non_zero; + } + } + for(size_t j = 0; j < n; j++) + ok &= pattern[ n * n + j] == false; + return ok; + } + // check sparsity pattern for the Hessian of sum_i f_i(x) + bool check_hes(const vectorBool& pattern, size_t n) + { bool ok = true; + for(size_t i = 0; i < n; i++) + { size_t k1 = (i + 1) % n; + size_t k2 = (n + i - 1) % n; + for(size_t j = 0; j < n; j++) + { bool non_zero = (i == j) || (j == k1) || (j == k2); + ok &= pattern[ i * n + j] == non_zero; + } + } + return ok; + } + // compute sparsity for Jacobian of f(x) using forward mode + bool for_sparse_jac(ADFun& f) + { bool ok = true; + size_t n = f.Domain(); + size_t m = f.Range(); + // + // number of columns of the sparsity patter to compute at a time + size_t n_col = vectorBool::bit_per_unit(); + vectorBool pattern(m * n), s(m * n_col), r(n * n_col); + // + size_t n_loop = (n - 1) / n_col + 1; + for(size_t i_loop = 0; i_loop < n_loop; i_loop++) + { size_t j_col = i_loop * n_col; + + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n_col; j++) + r[i * n_col + j] = (i == j_col + j); + } + s = f.ForSparseJac(n_col, r); + for(size_t i = 0; i < m; i++) + { for(size_t j = 0; j < n_col; j++) + if( j_col + j < n ) + pattern[ i * n + j_col + j ] = s[ i * n_col + j]; + } + } + ok &= check_jac(pattern, n); + // + return ok; + } + // compute sparsity for Jacobian of f(x) using reverse mode + bool rev_sparse_jac(ADFun& f) + { bool ok = true; + size_t n = f.Domain(); + size_t m = f.Range(); + // + // number of rows of the sparsity patter to compute at a time + size_t n_row = vectorBool::bit_per_unit(); + vectorBool pattern(m * n), s(n_row * n), r(n_row * m); + // + size_t n_loop = (m - 1) / n_row + 1; + for(size_t i_loop = 0; i_loop < n_loop; i_loop++) + { size_t i_row = i_loop * n_row; + + for(size_t i = 0; i < n_row; i++) + { for(size_t j = 0; j < m; j++) + r[i * m + j] = (i_row + i == j); + } + s = f.RevSparseJac(n_row, r); + for(size_t i = 0; i < n_row; i++) + { for(size_t j = 0; j < n; j++) + if( i_row + i < m ) + pattern[ (i_row + i) * n + j ] = s[ i * n + j]; + } + } + ok &= check_jac(pattern, n); + // + return ok; + } + // compute sparsity for Hessian of sum_i f_i (x) + bool rev_sparse_hes(ADFun& f) + { bool ok = true; + size_t n = f.Domain(); + size_t m = f.Range(); + // + // number of columns of the sparsity patter to compute at a time + size_t n_col = vectorBool::bit_per_unit(); + vectorBool pattern(n * n), r(n * n_col), h(n * n_col); + + // consider case where Hessian for sum of f_i(x) w.r.t i + vectorBool s(m); + for(size_t i = 0; i < m; i++) + s[i] = true; + // + size_t n_loop = (n - 1) / n_col + 1; + for(size_t i_loop = 0; i_loop < n_loop; i_loop++) + { size_t j_col = i_loop * n_col; + + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n_col; j++) + r[i * n_col + j] = (i == j_col + j); + } + // + f.ForSparseJac(n_col, r); + bool transpose = true; + h = f.RevSparseHes(n_col, s, transpose); + // + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n_col; j++) + if( j_col + j < n ) + pattern[ i * n + j_col + j ] = h[ i * n_col + j]; + } + } + ok &= check_hes(pattern, n); + // + return ok; + } +} +// driver for all of the cases above +bool bool_sparsity(void) +{ bool ok = true; + // + // record the funcion + size_t n = 100; + size_t m = n + 1; + vector< AD > x(n), y(m); + for(size_t j = 0; j < n; j++) + x[j] = AD(j+1); + CppAD::Independent(x); + y = fun(x); + ADFun f(x, y); + // + // run the three example / tests + ok &= for_sparse_jac(f); + ok &= rev_sparse_jac(f); + ok &= rev_sparse_hes(f); + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/example/capacity_order.cpp cppad-2016.00.00.1/example/capacity_order.cpp --- cppad-2015.00.00.9/example/capacity_order.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/capacity_order.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: capacity_order.cpp 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: capacity_order.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,8 @@ $$ $section Controlling Taylor Coefficient Memory Allocation: Example and Test$$ +$mindex capacity_order$$ -$index capacity_order, example$$ -$index example, capacity_order$$ $code $verbatim%example/capacity_order.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -29,33 +28,33 @@ */ // BEGIN C++ # include - + namespace { bool test(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; using CppAD::thread_alloc; - + // domain space vector size_t n(1), m(1); CPPAD_TESTVECTOR(AD) ax(n), ay(n); - + // declare independent variables and start tape recording ax[0] = 1.0; CppAD::Independent(ax); - - // Set y = x^3, use enough variables so more that the minimal amount + + // Set y = x^3, use enough variables so more that the minimal amount // of memory is allocated for Taylor coefficients ay[0] = 0.; for( size_t i = 0; i < 10; i++) ay[0] += ax[0] * ax[0] * ax[0]; ay[0] = ay[0] / 10.; - + // create f: x -> y and stop tape recording // (without running zero order forward mode). CppAD::ADFun f; - f.Dependent(ax, ay); + f.Dependent(ax, ay); // check that this is master thread size_t thread = thread_alloc::thread_num(); @@ -74,27 +73,27 @@ y = f.Forward(0, x); double eps = 10. * CppAD::numeric_limits::epsilon(); ok &= NearEqual(y[0], x[0] * x[0] * x[0], eps, eps); - + // forward computation of partials w.r.t. x CPPAD_TESTVECTOR(double) dx(n), dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 3. * x[0] * x[0], eps, eps); - + // Suppose we no longer need the first order Taylor coefficients. inuse = thread_alloc::inuse(thread); f.capacity_order(1); // just keep zero order coefficients ok &= thread_alloc::inuse(thread) < inuse; - + // Suppose we no longer need the zero order Taylor coefficients // (could have done this first and not used f.capacity_order(1)). inuse = thread_alloc::inuse(thread); f.capacity_order(0); ok &= thread_alloc::inuse(thread) < inuse; - + // turn off memory holding thread_alloc::hold_memory(false); - + return ok; } } @@ -113,8 +112,8 @@ // check that the amount of memroy inuse has not changed ok &= thread_alloc::inuse(thread) == inuse; - // Test above uses hold_memory, so return available memory - thread_alloc::free_available(thread); + // Test above uses hold_memory, so return available memory + thread_alloc::free_available(thread); return ok; } diff -Nru cppad-2015.00.00.9/example/change_const.cpp cppad-2016.00.00.1/example/change_const.cpp --- cppad-2015.00.00.9/example/change_const.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/change_const.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -/* $Id: change_const.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -# include - -/* -$begin change_const.cpp$$ -$spell - Jacobian -$$ - -$section Computing a Jacobian With Constants that Change$$ -$index multiple, AD level$$ -$index level, multiple AD$$ -$index constant, that change$$ -$index change, constant$$ - -$head Purpose$$ -In this example we use two levels of taping so that a derivative -can have constant parameters that can be changed. To be specific, -we consider the function $latex f : \B{R}^2 \rightarrow \B{R}^2$$ -$latex \[ -f(x) = p \left( \begin{array}{c} - \sin( x_0 ) \\ - \sin( x_1 ) -\end{array} \right) -\]$$ -were $latex p \in \B{R}$$ is a parameter. -The Jacobian of this function is -$latex \[ -g(x,p) = p \left( \begin{array}{cc} - \cos( x_0 ) & 0 \\ - 0 & \cos( x_1 ) -\end{array} \right) -\] $$ -In this example we use two levels of AD to avoid computing -the partial of $latex f(x)$$ with respect to $latex p$$, -but still allow for the evaluation of $latex g(x, p)$$ -at different values of $latex p$$. - -$end - -*/ - -bool change_const(void) -{ bool ok = true; // initialize test result - - typedef CppAD::AD A1_double; // for first level of taping - typedef CppAD::AD A2_double; // for second level of taping - - size_t nu = 3; // number components in u - size_t nx = 2; // number components in x - size_t ny = 2; // num components in f(x) - size_t nJ = ny * nx; // number components in Jacobian of f(x) - - // temporary indices - size_t j; - - // declare first level of independent variables - CPPAD_TESTVECTOR(A1_double) a1_u(nu); - for(j = 0; j < nu; j++) - a1_u[j] = 0.; - CppAD::Independent(a1_u); - - // parameter in computation of Jacobian - A1_double a1_p = a1_u[2]; - - // declare second level of independent variables - CPPAD_TESTVECTOR(A2_double) a2_x(nx); - for(j = 0; j < nx; j++) - a2_x[j] = 0.; - CppAD::Independent(a2_x); - - // compute dependent variables at second level - CPPAD_TESTVECTOR(A2_double) a2_y(ny); - a2_y[0] = sin( a2_x[0] ) * a1_p; - a2_y[1] = sin( a2_x[1] ) * a1_p; - - // declare function object that computes values at the first level - // (make sure we do not run zero order forward during constructor) - CppAD::ADFun a1_f; - a1_f.Dependent(a2_x, a2_y); - - // compute the Jacobian of a1_f at a1_u[0], a1_u[1] - CPPAD_TESTVECTOR(A1_double) a1_x(nx); - a1_x[0] = a1_u[0]; - a1_x[1] = a1_u[1]; - CPPAD_TESTVECTOR(A1_double) a1_J(nJ); - a1_J = a1_f.Jacobian( a1_x ); - - // declare function object that maps u = (x, p) to Jacobian of f - // (make sure we do not run zero order forward during constructor) - CppAD::ADFun g; - g.Dependent(a1_u, a1_J); - - // remove extra variables used during the reconding of a1_f, - // but not needed any more. - g.optimize(); - - // compute the Jacobian of f using zero order forward - // sweep with double values - CPPAD_TESTVECTOR(double) J(nJ), u(nu); - for(j = 0; j < nu; j++) - u[j] = double(j+1); - J = g.Forward(0, u); - - // accuracy for tests - double eps = 100. * CppAD::numeric_limits::epsilon(); - - // y[0] = sin( x[0] ) * p - // y[1] = sin( x[1] ) * p - CPPAD_TESTVECTOR(double) x(nx); - x[0] = u[0]; - x[1] = u[1]; - double p = u[2]; - - // J[0] = partial y[0] w.r.t x[0] = cos( x[0] ) * p - double check = cos( x[0] ) * p; - ok &= fabs( check - J[0] ) <= eps; - - // J[1] = partial y[0] w.r.t x[1] = 0.; - check = 0.; - ok &= fabs( check - J[1] ) <= eps; - - // J[2] = partial y[1] w.r.t. x[0] = 0. - check = 0.; - ok &= fabs( check - J[2] ) <= eps; - - // J[3] = partial y[1] w.r.t x[1] = cos( x[1] ) * p - check = cos( x[1] ) * p; - ok &= fabs( check - J[3] ) <= eps; - - return ok; -} -// END PROGRAM diff -Nru cppad-2015.00.00.9/example/change_param.cpp cppad-2016.00.00.1/example/change_param.cpp --- cppad-2015.00.00.9/example/change_param.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/change_param.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,142 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include + +/* +$begin change_param.cpp$$ +$spell + Jacobian +$$ + +$section Computing a Jacobian With Constants that Change$$ +$mindex multiple AD level$$ + +$head Purpose$$ +In this example we use two levels of taping so that a derivative +can have constant parameters that can be changed. To be specific, +we consider the function $latex f : \B{R}^2 \rightarrow \B{R}^2$$ +$latex \[ +f(x) = p \left( \begin{array}{c} + \sin( x_0 ) \\ + \sin( x_1 ) +\end{array} \right) +\]$$ +were $latex p \in \B{R}$$ is a parameter. +The Jacobian of this function is +$latex \[ +g(x,p) = p \left( \begin{array}{cc} + \cos( x_0 ) & 0 \\ + 0 & \cos( x_1 ) +\end{array} \right) +\] $$ +In this example we use two levels of AD to avoid computing +the partial of $latex f(x)$$ with respect to $latex p$$, +but still allow for the evaluation of $latex g(x, p)$$ +at different values of $latex p$$. + +$end + +*/ + +bool change_param(void) +{ bool ok = true; // initialize test result + + typedef CppAD::AD a1type; // for first level of taping + typedef CppAD::AD a2type; // for second level of taping + + size_t nu = 3; // number components in u + size_t nx = 2; // number components in x + size_t ny = 2; // num components in f(x) + size_t nJ = ny * nx; // number components in Jacobian of f(x) + + // temporary indices + size_t j; + + // declare first level of independent variables + // (Start taping now so can record dependency of a1f on a1p.) + CPPAD_TESTVECTOR(a1type) a1u(nu); + for(j = 0; j < nu; j++) + a1u[j] = 0.; + CppAD::Independent(a1u); + + // parameter in computation of Jacobian + a1type a1p = a1u[2]; + + // declare second level of independent variables + CPPAD_TESTVECTOR(a2type) a2x(nx); + for(j = 0; j < nx; j++) + a2x[j] = 0.; + CppAD::Independent(a2x); + + // compute dependent variables at second level + CPPAD_TESTVECTOR(a2type) a2y(ny); + a2y[0] = sin( a2x[0] ) * a1p; + a2y[1] = sin( a2x[1] ) * a1p; + + // declare function object that computes values at the first level + // (make sure we do not run zero order forward during constructor) + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + + // compute the Jacobian of a1f at a1u[0], a1u[1] + CPPAD_TESTVECTOR(a1type) a1x(nx); + a1x[0] = a1u[0]; + a1x[1] = a1u[1]; + CPPAD_TESTVECTOR(a1type) a1J(nJ); + a1J = a1f.Jacobian( a1x ); + + // declare function object that maps u = (x, p) to Jacobian of f + // (make sure we do not run zero order forward during constructor) + CppAD::ADFun g; + g.Dependent(a1u, a1J); + + // remove extra variables used during the reconding of a1f, + // but not needed any more. + g.optimize(); + + // compute the Jacobian of f using zero order forward + // sweep with double values + CPPAD_TESTVECTOR(double) J(nJ), u(nu); + for(j = 0; j < nu; j++) + u[j] = double(j+1); + J = g.Forward(0, u); + + // accuracy for tests + double eps = 100. * CppAD::numeric_limits::epsilon(); + + // y[0] = sin( x[0] ) * p + // y[1] = sin( x[1] ) * p + CPPAD_TESTVECTOR(double) x(nx); + x[0] = u[0]; + x[1] = u[1]; + double p = u[2]; + + // J[0] = partial y[0] w.r.t x[0] = cos( x[0] ) * p + double check = cos( x[0] ) * p; + ok &= fabs( check - J[0] ) <= eps; + + // J[1] = partial y[0] w.r.t x[1] = 0.; + check = 0.; + ok &= fabs( check - J[1] ) <= eps; + + // J[2] = partial y[1] w.r.t. x[0] = 0. + check = 0.; + ok &= fabs( check - J[2] ) <= eps; + + // J[3] = partial y[1] w.r.t x[1] = cos( x[1] ) * p + check = cos( x[1] ) * p; + ok &= fabs( check - J[3] ) <= eps; + + return ok; +} +// END PROGRAM diff -Nru cppad-2015.00.00.9/example/check_for_nan.cpp cppad-2016.00.00.1/example/check_for_nan.cpp --- cppad-2015.00.00.9/example/check_for_nan.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/check_for_nan.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: check_for_nan.cpp 2892 2013-08-13 17:30:55Z bradbell $ */ +/* $Id: check_for_nan.cpp 3753 2015-11-24 16:39:04Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,9 +14,6 @@ $begin check_for_nan.cpp$$ $section ADFun Checking For Nan: Example and Test$$ -$index check_for_nan, example$$ -$index example, check_for_nan$$ -$index test, check_for_nan$$ $code $verbatim%example/check_for_nan.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -26,6 +23,7 @@ */ // BEGIN C++ # include +# include namespace { void myhandler( @@ -35,27 +33,31 @@ const char *exp , const char *msg ) { // error handler must not return, so throw an exception - throw std::string("myhandler"); + std::string message = msg; + throw message; } } bool check_for_nan(void) { bool ok = true; using CppAD::AD; + using std::string; + double eps = 10. * std::numeric_limits::epsilon(); // replace the default CppAD error handler CppAD::ErrorHandler info(myhandler); CPPAD_TESTVECTOR(AD) ax(2), ay(2); - ax[0] = 0.0; + ax[0] = 2.0; ax[1] = 1.0; CppAD::Independent(ax); - ay = ax; + ay[0] = sqrt( ax[0] ); + ay[1] = sqrt( ax[1] ); CppAD::ADFun f(ax, ay); CPPAD_TESTVECTOR(double) x(2), y(2); x[0] = 2.0; - x[1] = CppAD::nan(0.0); + x[1] = -1.0; // use try / catch because this causes an exception // (assuming that NDEBUG is not defined) @@ -63,19 +65,52 @@ try { y = f.Forward(0, x); - // should never reach here +# ifndef NDEBUG + // When compiled with NDEBUG defined, + // CppAD does not spend time checking for nan. ok = false; +# endif } catch(std::string msg) - { ok &= msg == "myhandler"; - } + { + // get and check size of the independent variable vector + string pattern = "vector_size = "; + size_t start = msg.find(pattern) + pattern.size(); + string number; + for(size_t i = start; msg[i] != '\n'; i++) + number += msg[i]; + size_t vector_size = std::atoi(number.c_str()); + ok &= vector_size == 2; + + // get and check first dependent varialbe index that is nan + pattern = "index = "; + start = msg.find(pattern) + pattern.size(); + number = ""; + for(size_t i = start; msg[i] != '\n'; i++) + number += msg[i]; + size_t index = std::atoi(number.c_str()); + ok &= index == 1; + + // get the name of the file + pattern = "file_name = "; + start = msg.find(pattern) + pattern.size(); + string file_name; + for(size_t i = start; msg[i] != '\n'; i++) + file_name += msg[i]; + + // get and check independent variable vector that resulted in the nan + CppAD::vector vec(vector_size); + CppAD::get_check_for_nan(vec, file_name); + for(size_t i = 0; i < vector_size; i++) + ok &= vec[i] == x[i]; + } // now do calculation without an exception f.check_for_nan(false); y = f.Forward(0, x); - ok &= y[0] == x[0]; - ok &= CppAD::isnan( y[1] ); - + ok &= CppAD::NearEqual(y[0], std::sqrt(x[0]), eps, eps); + ok &= CppAD::isnan( y[1] ); + return ok; } diff -Nru cppad-2015.00.00.9/example/check_numeric_type.cpp cppad-2016.00.00.1/example/check_numeric_type.cpp --- cppad-2015.00.00.9/example/check_numeric_type.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/check_numeric_type.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: check_numeric_type.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: check_numeric_type.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,9 +14,7 @@ $begin check_numeric_type.cpp$$ $section The CheckNumericType Function: Example and Test$$ -$index CheckNumericType$$ -$index example, check NumericType$$ -$index test, check NumericType$$ +$mindex check NumericType$$ $code $verbatim%example/check_numeric_type.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -26,12 +24,12 @@ */ // BEGIN C++ -# include -# include +# include +# include -// Chosing a value between 1 and 10 selects a numeric class properity to be -// omitted and result in an error message being generated +// Chosing a value between 1 and 10 selects a numeric class properity to be +// omitted and result in an error message being generated # define CppADMyTypeOmit 0 namespace { // Empty namespace @@ -41,10 +39,10 @@ private: double d; public: - // constructor from void + // constructor from void MyType(void) : d(0.) { } - // constructor from an int + // constructor from an int MyType(int d_) : d(d_) { } // copy constuctor @@ -61,7 +59,7 @@ MyType operator + (void) const { MyType x; x.d = d; - return x; + return x; } # endif # if CppADMyTypeOmit != 2 @@ -69,7 +67,7 @@ MyType operator - (void) const { MyType x; x.d = - d; - return x; + return x; } # endif # if CppADMyTypeOmit != 3 @@ -77,7 +75,7 @@ MyType operator + (const MyType &x) const { MyType y; y.d = d + x.d ; - return y; + return y; } # endif # if CppADMyTypeOmit != 4 @@ -85,7 +83,7 @@ MyType operator - (const MyType &x) const { MyType y; y.d = d - x.d ; - return y; + return y; } # endif # if CppADMyTypeOmit != 5 @@ -93,7 +91,7 @@ MyType operator * (const MyType &x) const { MyType y; y.d = d * x.d ; - return y; + return y; } # endif # if CppADMyTypeOmit != 6 @@ -101,7 +99,7 @@ MyType operator / (const MyType &x) const { MyType y; y.d = d / x.d ; - return y; + return y; } # endif # if CppADMyTypeOmit != 7 @@ -127,9 +125,9 @@ }; // ------------------------------------------------------------------- /* - Solve: A[0] * x[0] + A[1] * x[1] = b[0] - A[2] * x[0] + A[3] * x[1] = b[1] - */ + Solve: A[0] * x[0] + A[1] * x[1] = b[0] + A[2] * x[0] + A[3] * x[1] = b[1] + */ template void Solve(NumericType *A, NumericType *x, NumericType *b) { @@ -173,7 +171,7 @@ A[0] = MyType(1); A[1] = MyType(2); A[2] = MyType(3); A[3] = MyType(4); - MyType b[2]; + MyType b[2]; b[0] = MyType(1); b[1] = MyType(2); diff -Nru cppad-2015.00.00.9/example/check_simple_vector.cpp cppad-2016.00.00.1/example/check_simple_vector.cpp --- cppad-2015.00.00.9/example/check_simple_vector.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/check_simple_vector.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: check_simple_vector.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: check_simple_vector.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,9 +14,7 @@ $begin check_simple_vector.cpp$$ $section The CheckSimpleVector Function: Example and Test$$ -$index CheckSimpleVector$$ -$index example, check SimpleVector$$ -$index test, check SimpleVector$$ +$mindex check SimpleVector$$ $code $verbatim%example/check_simple_vector.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -26,13 +24,13 @@ */ // BEGIN C++ -# include -# include +# include +# include # include -// Chosing a value between 1 and 9 selects a simple vector properity to be -// omitted and result in an error message being generated +// Chosing a value between 1 and 9 selects a simple vector properity to be +// omitted and result in an error message being generated # define CppADMyVectorOmit 0 // ------------------------------------------------------------------------- @@ -52,10 +50,10 @@ // conversion to Scalar operator Scalar() const { return *element; } -}; - +}; + -// example simple vector class +// example simple vector class template class MyVector { private: @@ -77,7 +75,7 @@ inline MyVector(size_t n) : length(n) { if( length == 0 ) data = 0; - else data = new Scalar[length]; + else data = new Scalar[length]; } # endif # if CppADMyVectorOmit != 4 @@ -86,13 +84,13 @@ { size_t i; if( length == 0 ) data = 0; - else data = new Scalar[length]; + else data = new Scalar[length]; for(i = 0; i < length; i++) data[i] = x.data[i]; } # endif -# if CppADMyVectorOmit != 4 +# if CppADMyVectorOmit != 4 # if CppADMyVectorOmit != 7 // destructor (it is not safe to delete the pointer in cases 4 and 7) ~MyVector(void) @@ -138,24 +136,24 @@ // ------------------------------------------------------------------------- /* -Compute r = a * v, where a is a scalar with same type as the elements of -the Simple Vector v. This routine uses the CheckSimpleVector function to ensure that +Compute r = a * v, where a is a scalar with same type as the elements of +the Simple Vector v. This routine uses the CheckSimpleVector function to ensure that the types agree. -*/ +*/ namespace { // Empty namespace template Vector Sscal(const Scalar &a, const Vector &v) { - // invoke CheckSimpleVector function + // invoke CheckSimpleVector function CppAD::CheckSimpleVector(); - + size_t n = v.size(); Vector r(n); - + size_t i; for(i = 0; i < n; i++) r[i] = a * v[i]; - + return r; } } diff -Nru cppad-2015.00.00.9/example/CMakeLists.txt cppad-2016.00.00.1/example/CMakeLists.txt --- cppad-2015.00.00.9/example/CMakeLists.txt 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/CMakeLists.txt 2016-02-09 08:31:55.000000000 +0000 @@ -1,18 +1,18 @@ -# $Id: CMakeLists.txt 3526 2014-12-29 21:56:45Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the example directory tests +# Build the example directory tests # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) @@ -28,8 +28,10 @@ sources_libs_define(adolc "${sources}" adolc ADOLC_EXAMPLES) # colpack_prefix -SET(sources colpack.cpp ../cppad/local/cppad_colpack.cpp) -sources_libs_define(colpack "${sources}" ColPack COLPACK_EXAMPLES) +SET(colpack_sources + colpack_hes.cpp + colpack_jac.cpp +) # eigen_prefix IF ( eigen_prefix ) @@ -58,7 +60,7 @@ # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh.in + ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh ) @@ -72,6 +74,7 @@ abort_recording.cpp abs.cpp acos.cpp + acosh.cpp add.cpp add_eq.cpp ad_assign.cpp @@ -81,14 +84,18 @@ ad_input.cpp ad_output.cpp asin.cpp + asinh.cpp atan.cpp + atanh.cpp atan2.cpp + azmul.cpp base_alloc.hpp base_require.cpp bender_quad.cpp bool_fun.cpp + bool_sparsity.cpp capacity_order.cpp - change_const.cpp + change_param.cpp check_for_nan.cpp check_numeric_type.cpp check_simple_vector.cpp @@ -100,12 +107,14 @@ cos.cpp cosh.cpp cppad_vector.cpp + dependency.cpp div.cpp div_eq.cpp equal_op_seq.cpp erf.cpp error_handler.cpp exp.cpp + expm1.cpp for_one.cpp for_two.cpp forward.cpp @@ -128,8 +137,9 @@ jac_lu_det.cpp jac_minor_det.cpp jacobian.cpp - limits.cpp + num_limits.cpp log.cpp + log1p.cpp log10.cpp lu_factor.cpp lu_invert.cpp @@ -153,7 +163,6 @@ ode_gear_control.cpp ode_stiff.cpp ode_taylor.cpp - omp_alloc.cpp opt_val_hes.cpp optimize.cpp par_var.cpp @@ -181,29 +190,34 @@ sinh.cpp sparse_hessian.cpp sparse_jacobian.cpp + sparse_sub_hes.cpp + sparsity_sub.cpp sqrt.cpp stack_machine.cpp sub.cpp sub_eq.cpp + sub_sparse_hes.cpp tan.cpp tanh.cpp tape_index.cpp thread_alloc.cpp + to_string.cpp unary_minus.cpp unary_plus.cpp value.cpp var2par.cpp vec_ad.cpp - vector_bool.cpp + vector_bool.cpp ) # Compiler flags for cppad source -add_cppad_cxx_flags(example) +add_cppad_cxx_flags(example) # List of libraries to be linked into the specified target -TARGET_LINK_LIBRARIES(example - ${adolc_libs} - ${colpack_libs} +TARGET_LINK_LIBRARIES(example + ${cppad_lib} + ${adolc_libs} + ${colpack_libs} ${eigen_libs} ) diff -Nru cppad-2015.00.00.9/example/colpack.cpp cppad-2016.00.00.1/example/colpack.cpp --- cppad-2015.00.00.9/example/colpack.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/colpack.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -/* $Id: colpack.cpp 3116 2014-02-24 21:44:26Z bradbell $ */ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin colpack.cpp$$ -$spell - colpack -$$ - -$section Using ColPack: Example and Test$$ - -$index example, colpack$$ -$index test, colpack$$ -$index spare, colpack$$ - -$code -$verbatim%example/colpack.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ - -# include -bool colpack(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - typedef CPPAD_TESTVECTOR(AD) a_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CppAD::vector i_vector; - size_t i, j, k, ell; - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // domain space vector - size_t n = 4; - a_vector a_x(n); - for(j = 0; j < n; j++) - a_x[j] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(a_x); - - size_t m = 3; - a_vector a_y(m); - a_y[0] = a_x[0] + a_x[1]; - a_y[1] = a_x[2] + a_x[3]; - a_y[2] = a_x[0] + a_x[1] + a_x[2] + a_x[3] * a_x[3] / 2.; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(a_x, a_y); - - // new value for the independent variable vector - d_vector x(n); - for(j = 0; j < n; j++) - x[j] = double(j); - - /* - [ 1 1 0 0 ] - jac = [ 0 0 1 1 ] - [ 1 1 1 x_3] - */ - d_vector check(m * n); - check[0] = 1.; check[1] = 1.; check[2] = 0.; check[3] = 0.; - check[4] = 0.; check[5] = 0.; check[6] = 1.; check[7] = 1.; - check[8] = 1.; check[9] = 1.; check[10] = 1.; check[11] = x[3]; - - // Normally one would use f.ForSparseJac or f.RevSparseJac to compute - // sparsity pattern, but for this example we extract it from check. - std::vector< std::set > p(m); - - // using row and column indices to compute non-zero in rows 1 and 2 - i_vector row, col; - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - { ell = i * n + j; - if( check[ell] != 0. ) - { row.push_back(i); - col.push_back(j); - p[i].insert(j); - } - } - } - size_t K = row.size(); - d_vector jac(K); - - // empty work structure - CppAD::sparse_jacobian_work work; - ok &= work.color_method == "cppad"; - - // choose to use ColPack - work.color_method = "colpack"; - - // forward mode - size_t n_sweep = f.SparseJacobianForward(x, p, row, col, jac, work); - for(k = 0; k < K; k++) - { ell = row[k] * n + col[k]; - ok &= NearEqual(check[ell], jac[k], eps, eps); - } - ok &= n_sweep == 4; - - // reverse mode - work.clear(); - work.color_method = "colpack"; - n_sweep = f.SparseJacobianReverse(x, p, row, col, jac, work); - for(k = 0; k < K; k++) - { ell = row[k] * n + col[k]; - ok &= NearEqual(check[ell], jac[k], eps, eps); - } - ok &= n_sweep == 2; - - return ok; -} -// END C++ diff -Nru cppad-2015.00.00.9/example/colpack_hes.cpp cppad-2016.00.00.1/example/colpack_hes.cpp --- cppad-2015.00.00.9/example/colpack_hes.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/colpack_hes.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,152 @@ +// $Id: colpack_hes.cpp 3757 2015-11-30 12:03:07Z bradbell $ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin colpack_hes.cpp$$ +$spell + colpack_hes + jacobian +$$ + +$section Using ColPack: Example and Test$$ +$mindex colpack hessian sparse$$ + + +$code +$verbatim%example/colpack_hes.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# include +bool colpack_hes(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CppAD::vector i_vector; + size_t i, j, k, ell; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // domain space vector + size_t n = 5; + a_vector a_x(n); + for(j = 0; j < n; j++) + a_x[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(a_x); + + // colpack example case where hessian is a spear head + // i.e, H(i, j) non zero implies i = 0, j = 0, or i = j + AD sum = 0.0; + // partial_0 partial_j = x[j] + // partial_j partial_j = x[0] + for(j = 1; j < n; j++) + sum += a_x[0] * a_x[j] * a_x[j] / 2.0; + // + // partial_i partial_i = 2 * x[i] + for(i = 0; i < n; i++) + sum += a_x[i] * a_x[i] * a_x[i] / 3.0; + + // declare dependent variables + size_t m = 1; + a_vector a_y(m); + a_y[0] = sum; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(a_x, a_y); + + // new value for the independent variable vector + d_vector x(n); + for(j = 0; j < n; j++) + x[j] = double(j + 1); + + /* + [ 2 2 3 4 5 ] + hes = [ 2 5 0 0 0 ] + [ 3 0 7 0 0 ] + [ 4 0 0 9 0 ] + [ 5 0 0 0 11 ] + */ + d_vector check(n * n); + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { size_t index = i * n + j; + check[index] = 0.0; + if( i == 0 && 1 <= j ) + check[index] += x[j]; + if( 1 <= i && j == 0 ) + check[index] += x[i]; + if( i == j ) + { check[index] += 2.0 * x[i]; + if( i != 0 ) + check[index] += x[0]; + } + } + } + // Normally one would use f.RevSparseHes to compute + // sparsity pattern, but for this example we extract it from check. + std::vector< std::set > p(n); + i_vector row, col; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { ell = i * n + j; + if( check[ell] != 0. ) + { // insert this non-zero entry in sparsity pattern + p[i].insert(j); + + // the Hessian is symmetric, so only upper lower triangle + if( j <= i ) + { row.push_back(i); + col.push_back(j); + } + } + } + } + size_t K = row.size(); + d_vector hes(K); + + // contrast and check results using both cppad and colpack + CppAD::sparse_hessian_work work; + for(size_t i_method = 0; i_method < 3; i_method++) + { // empty work structure + ok &= work.color_method == "cppad.symmetric"; + if( i_method == 2 ) + work.color_method = "colpack.star"; + + // compute Hessian + d_vector w(m); + w[0] = 1.0; + size_t n_sweep = f.SparseHessian(x, w, p, row, col, hes, work); + + // check result + for(k = 0; k < K; k++) + { ell = row[k] * n + col[k]; + ok &= NearEqual(check[ell], hes[k], eps, eps); + } + if( work.color_method != "cppad.general" ) + ok &= n_sweep == 2; + else + ok &= n_sweep == 5; + // + // check that clear resets color_method to cppad.symmetric + work.clear(); + ok &= work.color_method == "cppad.symmetric"; + } + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/example/colpack_jac.cpp cppad-2016.00.00.1/example/colpack_jac.cpp --- cppad-2015.00.00.9/example/colpack_jac.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/colpack_jac.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,122 @@ +// $Id: colpack_jac.cpp 3757 2015-11-30 12:03:07Z bradbell $ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin colpack_jac.cpp$$ +$spell + colpack_jac + jacobian +$$ + +$section Using ColPack: Example and Test$$ +$mindex colpack jacobian sparse$$ + + +$code +$verbatim%example/colpack_jac.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# include +bool colpack_jac(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CppAD::vector i_vector; + size_t i, j, k, ell; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // domain space vector + size_t n = 4; + a_vector a_x(n); + for(j = 0; j < n; j++) + a_x[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(a_x); + + size_t m = 3; + a_vector a_y(m); + a_y[0] = a_x[0] + a_x[1]; + a_y[1] = a_x[2] + a_x[3]; + a_y[2] = a_x[0] + a_x[1] + a_x[2] + a_x[3] * a_x[3] / 2.; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(a_x, a_y); + + // new value for the independent variable vector + d_vector x(n); + for(j = 0; j < n; j++) + x[j] = double(j); + + /* + [ 1 1 0 0 ] + jac = [ 0 0 1 1 ] + [ 1 1 1 x_3] + */ + d_vector check(m * n); + check[0] = 1.; check[1] = 1.; check[2] = 0.; check[3] = 0.; + check[4] = 0.; check[5] = 0.; check[6] = 1.; check[7] = 1.; + check[8] = 1.; check[9] = 1.; check[10] = 1.; check[11] = x[3]; + + // Normally one would use f.ForSparseJac or f.RevSparseJac to compute + // sparsity pattern, but for this example we extract it from check. + std::vector< std::set > p(m); + + // using row and column indices to compute non-zero in rows 1 and 2 + i_vector row, col; + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + { ell = i * n + j; + if( check[ell] != 0. ) + { row.push_back(i); + col.push_back(j); + p[i].insert(j); + } + } + } + size_t K = row.size(); + d_vector jac(K); + + // empty work structure + CppAD::sparse_jacobian_work work; + ok &= work.color_method == "cppad"; + + // choose to use ColPack + work.color_method = "colpack"; + + // forward mode + size_t n_sweep = f.SparseJacobianForward(x, p, row, col, jac, work); + for(k = 0; k < K; k++) + { ell = row[k] * n + col[k]; + ok &= NearEqual(check[ell], jac[k], eps, eps); + } + ok &= n_sweep == 4; + + // reverse mode + work.clear(); + work.color_method = "colpack"; + n_sweep = f.SparseJacobianReverse(x, p, row, col, jac, work); + for(k = 0; k < K; k++) + { ell = row[k] * n + col[k]; + ok &= NearEqual(check[ell], jac[k], eps, eps); + } + ok &= n_sweep == 2; + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/example/compare_change.cpp cppad-2016.00.00.1/example/compare_change.cpp --- cppad-2015.00.00.9/example/compare_change.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/compare_change.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: compare_change.cpp 2570 2012-11-14 18:25:24Z bradbell $ */ +// $Id: compare_change.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,13 +17,8 @@ $$ $section CompareChange and Re-Tape: Example and Test$$ +$mindex compare change re-tape$$ -$index compare, change$$ -$index example, CompareChange$$ -$index test, CompareChange$$ -$index re-tape, example$$ -$index example, re-tape$$ -$index test, re-tape$$ $code $verbatim%example/compare_change.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -39,74 +34,144 @@ template Type Minimum(const Type &x, const Type &y) { // Use a comparision to compute the min(x, y) - // (note that CondExp would never require retaping). - if( x < y ) + // (note that CondExp would never require retaping). + if( x < y ) return x; return y; } + struct error_info { + bool known; + int line; + std::string file; + std::string exp; + std::string msg; + }; + void error_handler( + bool known , + int line , + const char *file , + const char *exp , + const char *msg ) + { // error handler must not return, so throw an exception + error_info info; + info.known = known; + info.line = line; + info.file = file; + info.exp = exp; + info.msg = msg; + throw info; + } + } -bool CompareChange(void) +bool compare_change(void) { bool ok = true; -// f.CompareChange not defined when NDEBUG is true -# ifndef NDEBUG - using CppAD::AD; - using CppAD::ADFun; - using CppAD::Independent; // domain space vector size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 3.; - X[1] = 4.; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 3.; + ax[1] = 4.; // declare independent variables and start tape recording - CppAD::Independent(X); + CppAD::Independent(ax); // range space vector size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = Minimum(X[0], X[1]); + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = Minimum(ax[0], ax[1]); // create f: x -> y and stop tape recording - ADFun f(X, Y); + CppAD::ADFun f(ax, ay); + + // set count to one (not necessry because is its default value) + f.compare_change_count(1); - // evaluate zero mode Forward where conditional has the same result - // note that f.CompareChange is not defined when NDEBUG is true - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(double) y(m); - x[0] = 3.5; - x[1] = 4.; + // evaluate zero mode Forward where comparison has the same result + // as during taping; i.e., x[0] < x[1]. + CPPAD_TESTVECTOR(double) x(n), y(m); + x[0] = 2.; + x[1] = 3.; y = f.Forward(0, x); ok &= (y[0] == x[0]); ok &= (y[0] == Minimum(x[0], x[1])); - ok &= (f.CompareChange() == 0); + ok &= (f.compare_change_number() == 0); + ok &= (f.compare_change_op_index() == 0); - // evaluate zero mode Forward where conditional has different result - x[0] = 4.; - x[1] = 3.; + // evaluate zero mode Forward where comparison has different result + // as during taping; i.e., x[0] >= x[1]. + x[0] = 3.; + x[1] = 2.; y = f.Forward(0, x); ok &= (y[0] == x[0]); ok &= (y[0] != Minimum(x[0], x[1])); - ok &= (f.CompareChange() == 1); + ok &= (f.compare_change_number() == 1); + ok &= (f.compare_change_op_index() > 0 ); + size_t op_index = f.compare_change_op_index(); + + // Local block during which default CppAD error handler is replaced. + // If you do not replace the default CppAD error handler, + // and you run in the debugger, you will be able to inspect the + // call stack and see that 'if( x < y )' is where the comparison is. + bool missed_error = true; + { CppAD::ErrorHandler local_error_handler(error_handler); + + std::string check_msg = + "Operator index equals abort_op_index in Independent"; + try { + // determine the operation index where the change occurred + CppAD::Independent(ax, op_index); + ay[0] = Minimum(ax[0], ax[1]); +# ifdef NDEBUG + // CppAD does not spend time checking operator index when + // NDEBUG is defined + missed_error = false; + AD::abort_recording(); +# endif + } + catch( error_info info ) + { missed_error = false; + ok &= info.known; + ok &= info.msg == check_msg; + // Must abort the recording so we can start a new one + // (and to avoid a memory leak). + AD::abort_recording(); + } + } + ok &= ! missed_error; - // re-tape to obtain the new AD operation sequence - X[0] = 4.; - X[1] = 3.; - Independent(X); - Y[0] = Minimum(X[0], X[1]); - // stop tape and store result in f - f.Dependent(Y); + // set count to zero to demonstrate case where comparisons are not checked + f.compare_change_count(0); + y = f.Forward(0, x); + ok &= (y[0] == x[0]); + ok &= (y[0] != Minimum(x[0], x[1])); + ok &= (f.compare_change_number() == 0); + ok &= (f.compare_change_op_index() == 0); + + // now demonstrate that compare_change_number works for an optimized + // tape (note that compare_change_op_index is always zero after optimize) + f.optimize(); + f.compare_change_count(1); + y = f.Forward(0, x); + ok &= (y[0] == x[0]); + ok &= (y[0] != Minimum(x[0], x[1])); + ok &= (f.compare_change_number() == 1); + ok &= (f.compare_change_op_index() == 0); - // evaluate the function at new argument values + // now retape to get the a tape that agrees with the algorithm + ax[0] = x[0]; + ax[1] = x[1]; + Independent(ax); + ay[0] = Minimum(ax[0], ax[1]); + f.Dependent(ax, ay); y = f.Forward(0, x); ok &= (y[0] == x[1]); ok &= (y[0] == Minimum(x[0], x[1])); - ok &= (f.CompareChange() == 0); + ok &= (f.compare_change_number() == 0); + ok &= (f.compare_change_op_index() == 0); -# endif return ok; } diff -Nru cppad-2015.00.00.9/example/compare.cpp cppad-2016.00.00.1/example/compare.cpp --- cppad-2015.00.00.9/example/compare.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/compare.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: compare.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: compare.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,17 +17,9 @@ $$ $section AD Binary Comparison Operators: Example and Test$$ +$mindex compare < <= > >= == !=$$ + -$index compare, AD example$$ -$index example, AD compare$$ -$index test, AD compare$$ - -$index <, example$$ -$index <=, example$$ -$index >, example$$ -$index >=, example$$ -$index ==, example$$ -$index !=, example$$ $code $verbatim%example/compare.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -48,8 +40,8 @@ double x0 = 0.5; double x1 = 1.5; CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - x[1] = x1; + x[0] = x0; + x[1] = x1; CppAD::Independent(x); // some binary comparision operations @@ -61,27 +53,27 @@ p *= x[0]; // values in x choose this case else p *= x[1]; if( x[0] > x[1] ) - p *= x[0]; + p *= x[0]; else p *= x[1]; // values in x choose this case if( x[0] >= x[1] ) - p *= x[0]; + p *= x[0]; else p *= x[1]; // values in x choose this case if( x[0] == x[1] ) - p *= x[0]; + p *= x[0]; else p *= x[1]; // values in x choose this case if( x[0] != x[1] ) p *= x[0]; // values in x choose this case - else p *= x[1]; + else p *= x[1]; - // dependent variable vector + // dependent variable vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = p; // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0*x0*x1*x1*x1*x0, 1e-10 , 1e-10); // forward computation of partials w.r.t. x[0] diff -Nru cppad-2015.00.00.9/example/complex_poly.cpp cppad-2016.00.00.1/example/complex_poly.cpp --- cppad-2015.00.00.9/example/complex_poly.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/complex_poly.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: complex_poly.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: complex_poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,11 +17,8 @@ $$ $section Complex Polynomial: Example and Test$$ +$mindex polynomial$$ -$index complex, polynomial$$ -$index polynomial, complex$$ -$index example, complex polynomial$$ -$index test, complex polynomial$$ $head Poly$$ Select this link to view specifications for $cref Poly$$: @@ -43,11 +40,11 @@ using CppAD::AD; using CppAD::Poly; - typedef std::complex Complex; + typedef std::complex Complex; // polynomial coefficients CPPAD_TESTVECTOR( Complex ) a (deg + 1); // coefficients for p(z) - CPPAD_TESTVECTOR(AD) A (deg + 1); + CPPAD_TESTVECTOR(AD) A (deg + 1); size_t i; for(i = 0; i <= deg; i++) A[i] = a[i] = Complex(i, i); @@ -55,7 +52,7 @@ // independent variable vector CPPAD_TESTVECTOR(AD) Z(1); Complex z = Complex(1., 2.); - Z[0] = z; + Z[0] = z; Independent(Z); // dependent variable vector and indices diff -Nru cppad-2015.00.00.9/example/cond_exp.cpp cppad-2016.00.00.1/example/cond_exp.cpp --- cppad-2015.00.00.9/example/cond_exp.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/cond_exp.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cond_exp.cpp 2892 2013-08-13 17:30:55Z bradbell $ */ +// $Id: cond_exp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,10 +19,8 @@ $$ $section Conditional Expressions: Example and Test$$ +$mindex CondExp$$ -$index CondExp$$ -$index example, CondExp$$ -$index test, CondExp$$ $head Description$$ Use $code CondExp$$ to compute @@ -55,50 +53,49 @@ using CppAD::isnan; using CppAD::AD; using CppAD::NearEqual; - using CppAD::log; + using CppAD::log; using CppAD::abs; double eps = 100. * CppAD::numeric_limits::epsilon(); - double fmax = std::numeric_limits::max(); // domain space vector size_t n = 5; - CPPAD_TESTVECTOR(AD) X(n); + CPPAD_TESTVECTOR(AD) ax(n); size_t j; for(j = 0; j < n; j++) - X[j] = 1.; + ax[j] = 1.; // declare independent variables and start tape recording - CppAD::Independent(X); + CppAD::Independent(ax); - AD Sum = 0.; - AD Zero = 0.; + AD asum = 0.; + AD azero = 0.; for(j = 0; j < n; j++) { // if x_j > 0, add x_j * log( x_j ) to the sum - Sum += CppAD::CondExpGt(X[j], Zero, X[j] * log(X[j]), Zero); + asum += CppAD::CondExpGt(ax[j], azero, ax[j] * log(ax[j]), azero); } - // range space vector + // range space vector size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = Sum; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = asum; - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); + // create f: x -> ay and stop tape recording + CppAD::ADFun f(ax, ay); // vectors for arguments to the function object f CPPAD_TESTVECTOR(double) x(n); // argument values - CPPAD_TESTVECTOR(double) y(m); // function values - CPPAD_TESTVECTOR(double) w(m); // function weights + CPPAD_TESTVECTOR(double) y(m); // function values + CPPAD_TESTVECTOR(double) w(m); // function weights CPPAD_TESTVECTOR(double) dw(n); // derivative of weighted function // a case where x[j] > 0 for all j double check = 0.; for(j = 0; j < n; j++) - { x[j] = double(j + 1); + { x[j] = double(j + 1); check += x[j] * log( x[j] ); } - // function value + // function value y = f.Forward(0, x); ok &= NearEqual(y[0], check, eps, eps); @@ -106,13 +103,13 @@ w[0] = 1.; dw = f.Reverse(1, w); for(j = 0; j < n; j++) - ok &= NearEqual(dw[j], log(x[j]) + 1., eps, eps); + ok &= NearEqual(dw[j], log(x[j]) + 1., eps, eps); // a case where x[3] is equal to zero check -= x[3] * log( x[3] ); x[3] = 0.; - // function value + // function value y = f.Forward(0, x); ok &= NearEqual(y[0], check, eps, eps); @@ -122,15 +119,14 @@ dw = f.Reverse(1, w); for(j = 0; j < n; j++) { if( x[j] > 0 ) - ok &= NearEqual(dw[j], log(x[j]) + 1., eps, eps); + ok &= NearEqual(dw[j], log(x[j]) + 1., eps, eps); else - { // In this case computing dw[j] is computed using - // log(x[j]) + x[j] / x[j] - // which has limit minus infinity but computes as nan. - ok &= ( isnan( dw[j] ) || dw[j] <= -fmax ); + { // Note that in case where dw has type AD and is a variable + // this dw[j] can be nan (zero times nan is not zero). + ok &= NearEqual(dw[j], 0.0, eps, eps); } } - + return ok; } // END C++ diff -Nru cppad-2015.00.00.9/example/conj_grad.cpp cppad-2016.00.00.1/example/conj_grad.cpp --- cppad-2015.00.00.9/example/conj_grad.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/conj_grad.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: conj_grad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: conj_grad.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,30 +19,26 @@ $section Differentiate Conjugate Gradient Algorithm: Example and Test$$ -$index gradient, conjugate$$ -$index conjugate, gradient$$ -$index example, conjugate gradient$$ -$index test, conjugate gradient$$ $head Purpose$$ The conjugate gradient algorithm is sparse linear solver and -a good example where checkpointing can be applied (for each iteration). -This example is a preliminary version of a new library routine +a good example where checkpointing can be applied (for each iteration). +This example is a preliminary version of a new library routine for the conjugate gradient algorithm. $head Algorithm$$ Given a positive definite matrix $latex A \in \B{R}^{n \times n}$$, a vector $latex b \in \B{R}^n$$, and tolerance $latex \varepsilon$$, -the conjugate gradient algorithm finds an $latex x \in \B{R}^n$$ +the conjugate gradient algorithm finds an $latex x \in \B{R}^n$$ such that $latex \| A x - b \|^2 / n \leq \varepsilon^2$$ (or it terminates at a specified maximum number of iterations). $list number$$ -Input: +Input: $pre $$ -The matrix $latex A \in \B{R}^{n \times n}$$, +The matrix $latex A \in \B{R}^{n \times n}$$, the vector $latex b \in \B{R}^n$$, a tolerance $latex \varepsilon \geq 0$$, a maximum number of iterations $latex m$$, @@ -63,7 +59,7 @@ $pre $$ if $latex k = m$$ or $latex \sqrt{ s_k / n } < \varepsilon $$, -return $latex k$$ as the number of iterations and $latex x^k$$ +return $latex k$$ as the number of iterations and $latex x^k$$ as the approximate solution. $lnext @@ -87,7 +83,7 @@ $latex d^{k+1} = - g^k + ( s_{k+1} / s_k ) d^k$$. $lnext -Iterate: +Iterate: $pre $$ $latex k = k + 1$$, @@ -108,7 +104,7 @@ namespace { // Begin empty namespace using CppAD::AD; - // A simple matrix multiply c = a * b , where a has n columns + // A simple matrix multiply c = a * b , where a has n columns // and b has n rows. This should be changed to a function so that // it can efficiently handle the case were A is large and sparse. template // a simple vector class @@ -179,7 +175,7 @@ // mu = s / d^T * A * d mu = s_previous / dAd[0]; - // g = g + mu * A * d + // g = g + mu * A * d for(i = 0; i < n; i++) { x[i] = x[i] + mu * d[i]; g[i] = g[i] + mu * Ad[i]; @@ -211,7 +207,7 @@ size_t i, j; - // size of the vectors + // size of the vectors size_t n = 40; vector D(n * n), Dt(n * n), A(n * n), x(n), b(n), c(n); vector< AD > a_A(n * n), a_x(n), a_b(n); @@ -283,7 +279,7 @@ db[j] = 0.; db[0] = 1.; - // check db = A * dx + // check db = A * dx delta = 5. * delta; dx = f.Forward(1, db); mat_mul(n, A, dx, c); diff -Nru cppad-2015.00.00.9/example/cos.cpp cppad-2016.00.00.1/example/cos.cpp --- cppad-2015.00.00.9/example/cos.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/cos.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cos.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: cos.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section The AD cos Function: Example and Test$$ -$index cos, AD example$$ -$index example, AD cos$$ -$index test, AD cos$$ $code $verbatim%example/cos.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -48,15 +45,15 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::cos(x[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value double check = std::cos(x0); ok &= NearEqual(y[0] , check, 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/cosh.cpp cppad-2016.00.00.1/example/cosh.cpp --- cppad-2015.00.00.9/example/cosh.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/cosh.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cosh.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: cosh.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,6 @@ $section The AD cosh Function: Example and Test$$ -$index cosh, AD example$$ -$index example, AD cosh$$ -$index test, AD cosh$$ $code $verbatim%example/cosh.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -47,15 +44,15 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::cosh(x[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value double check = std::cosh(x0); ok &= NearEqual(y[0] , check, 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/cppad_vector.cpp cppad-2016.00.00.1/example/cppad_vector.cpp --- cppad-2015.00.00.9/example/cppad_vector.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/cppad_vector.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cppad_vector.cpp 3127 2014-02-28 15:28:12Z bradbell $ */ +// $Id: cppad_vector.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,11 +17,8 @@ $$ $section CppAD::vector Template Class: Example and Test$$ +$mindex vector CppAD$$ -$index vector, CppAD$$ -$index CppAD::vector, example$$ -$index example, CppAD::vector$$ -$index test, CppAD::vector$$ $code $verbatim%example/cppad_vector.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -31,53 +28,56 @@ */ // BEGIN C++ -# include -# include +# include +# include # include // sstream and string are used to test output operation # include bool CppAD_vector(void) { bool ok = true; - using CppAD::vector; // so can use vector instead of CppAD::vector + using CppAD::vector; // so can use vector instead of CppAD::vector typedef double Type; // change double to test other types // check Simple Vector specifications CppAD::CheckSimpleVector< Type, vector >(); - vector x; // default constructor + vector x; // default constructor ok &= (x.size() == 0); x.resize(2); // resize and set element assignment ok &= (x.size() == 2); - x[0] = Type(0); - x[1] = Type(1); + x[0] = Type(1); + x[1] = Type(2); vector y(2); // sizing constructor ok &= (y.size() == 2); const vector z(x); // copy constructor and const element access ok &= (z.size() == 2); - ok &= ( (z[0] == Type(0)) && (z[1] == Type(1)) ); + ok &= ( (z[0] == Type(1)) && (z[1] == Type(2)) ); x[0] = Type(2); // modify, assignment changes x ok &= (x[0] == Type(2)); x = y = z; // vector assignment - ok &= ( (x[0] == Type(0)) && (x[1] == Type(1)) ); - ok &= ( (y[0] == Type(0)) && (y[1] == Type(1)) ); - ok &= ( (z[0] == Type(0)) && (z[1] == Type(1)) ); + ok &= ( (x[0] == Type(1)) && (x[1] == Type(2)) ); + ok &= ( (y[0] == Type(1)) && (y[1] == Type(2)) ); + ok &= ( (z[0] == Type(1)) && (z[1] == Type(2)) ); // test of output - std::string correct= "{ 0, 1 }"; + std::string correct= "{ 1, 2 }"; std::string str; std::ostringstream buf; buf << z; str = buf.str(); ok &= (str == correct); - // test resize(0), capacity, and clear + // test resize(1), resize(0), capacity, and clear size_t i = x.capacity(); - ok &= i > 0; + ok &= i >= 2; + x.resize(1); + ok &= x[0] == Type(1); + ok &= i == x.capacity(); x.resize(0); ok &= i == x.capacity(); x.clear(); @@ -86,11 +86,11 @@ // test of push_back scalar and capacity size_t N = 100; for(i = 0; i < N; i++) - { size_t old_capacity = x.capacity(); + { size_t old_capacity = x.capacity(); x.push_back( Type(i) ); ok &= (i+1) == x.size(); ok &= i < x.capacity(); - ok &= (i == old_capacity) || old_capacity == x.capacity(); + ok &= (i == old_capacity) || old_capacity == x.capacity(); } for(i = 0; i < N; i++) ok &= ( x[i] == Type(i) ); @@ -103,7 +103,7 @@ ok &= x[i] == Type(N - i); } - // test of push_vector + // test of push_vector x.push_vector(x); ok &= (x.size() == 2 * N); for(i = 0; i < N; i++) diff -Nru cppad-2015.00.00.9/example/dependency.cpp cppad-2016.00.00.1/example/dependency.cpp --- cppad-2015.00.00.9/example/dependency.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/dependency.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,145 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin dependency.cpp$$ +$spell + CppAD + Jac +$$ + +$section Computing Dependency: Example and Test$$ + +$head Discussion$$ +The partial of an dependent variable with respect to an independent variable +might always be zero even though the dependent variable depends on the +value of the dependent variable. Consider the following case +$latex \[ +f(x) = {\rm sign} (x) = +\left\{ \begin{array}{rl} + +1 & {\rm if} \; x > 0 \\ + 0 & {\rm if} \; x = 0 \\ + -1 & {\rm if} \; x < 0 +\end{array} \right. +\] $$ +In this case the value of $latex f(x)$$ depends on the value of $latex x$$ +but CppAD always returns zero for the derivative of the $cref sign$$ function. + +$head Dependency Pattern$$ +If the $th i$$ dependent variables depends on the +value of the $th j$$ independent variable, +the corresponding entry in the dependency pattern is non-zero (true). +Otherwise it is zero (false). +CppAD uses $cref/sparsity patterns/glossary/Sparsity Pattern/$$ +to represent dependency matrices. +The $icode dependency$$ argument to +$cref/ForSparseJac/ForSparseJac/dependency/$$ and +$cref/RevSparseJac/RevSparseJac/dependency/$$ is a flag that signals +that the dependency pattern (instead of the sparsity pattern) is computed. + +$code +$verbatim%example/dependency.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include +namespace { + double heavyside(const double& x) + { if( x <= 0.0 ) + return 0.0; + return 1.0; + } + CPPAD_DISCRETE_FUNCTION(double, heavyside) +} + +bool dependency(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + + // VecAD object for use later + CppAD::VecAD vec_ad(2); + vec_ad[0] = 0.0; + vec_ad[1] = 1.0; + + // domain space vector + size_t n = 5; + CPPAD_TESTVECTOR(AD) ax(n); + for(size_t j = 0; j < n; j++) + ax[j] = AD(j + 1); + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // some AD constants + AD azero(0.0), aone(1.0); + + // range space vector + size_t m = n; + size_t m1 = n - 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[m1-0] = sign( ax[0] ); + ay[m1-1] = CondExpLe( ax[1], azero, azero, aone); + ay[m1-2] = CondExpLe( azero, ax[2], azero, aone); + ay[m1-3] = heavyside( ax[3] ); + ay[m1-4] = vec_ad[ ax[4] - AD(4.0) ]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // ----------------------------------------------------------- + // ForSparseJac and bool dependency + bool transpose = false; + bool dependency; + // could replace CppAD::vectorBooll by CPPAD_TEST_VECTOR + CppAD::vectorBool eye_bool(n * n), depend_bool(m * n); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + eye_bool[i * n + j] = (i == j); + } + dependency = true; + depend_bool = f.ForSparseJac(n, eye_bool, transpose, dependency); + for(size_t i = 0; i < m; i++) + { for(size_t j = 0; j < n; j++) + ok &= depend_bool[i * n + j] == (i == (m1-j)); + } + dependency = false; + depend_bool = f.ForSparseJac(n, eye_bool, transpose, dependency); + for(size_t i = 0; i < m; i++) + { for(size_t j = 0; j < n; j++) + ok &= depend_bool[i * n + j] == false; + } + + // ----------------------------------------------------------- + // RevSparseJac and set dependency + CppAD::vector< std::set > eye_set(m), depend_set(m); + for(size_t i = 0; i < m; i++) + { ok &= eye_set[i].empty(); + eye_set[i].insert(i); + } + dependency = true; + depend_set = f.RevSparseJac(n, eye_set, transpose, dependency); + for(size_t i = 0; i < m; i++) + { std::set check; + check.insert(m1 - i); + ok &= depend_set[i] == check; + } + dependency = false; + depend_set = f.RevSparseJac(n, eye_set, transpose, dependency); + for(size_t i = 0; i < m; i++) + ok &= depend_set[i].empty(); + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/example/div.cpp cppad-2016.00.00.1/example/div.cpp --- cppad-2015.00.00.9/example/div.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/div.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: div.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: div.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,12 +14,8 @@ $begin div.cpp$$ $section AD Binary Division: Example and Test$$ +$mindex / divide quotient$$ -$index /, AD example$$ -$index divide, AD example$$ -$index quotient, AD example$$ -$index example, AD divide$$ -$index test, AD divide$$ $code $verbatim%example/div.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -48,18 +44,18 @@ // some binary division operations AD a = x[0] / 1.; // AD / double AD b = a / 2; // AD / int - AD c = 3. / b; // double / AD - AD d = 4 / c; // int / AD + AD c = 3. / b; // double / AD + AD d = 4 / c; // int / AD - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = (x[0] * x[0]) / d; // AD / AD // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0], x0*x0*3.*2.*1./(4.*x0), 1e-10 , 1e-10); // forward computation of partials w.r.t. x[0] diff -Nru cppad-2015.00.00.9/example/div_eq.cpp cppad-2016.00.00.1/example/div_eq.cpp --- cppad-2015.00.00.9/example/div_eq.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/div_eq.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: div_eq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: div_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,17 +14,9 @@ $begin div_eq.cpp$$ $section AD Computed Assignment Division: Example and Test$$ +$mindex /= divide assign plus add$$ + -$index /=, AD example$$ -$index computed, AD assignment divide example$$ -$index assignment, AD computed divide example$$ -$index example, AD computed assignment divide$$ -$index test, AD computed assignment divide$$ - -$index computed, /= example$$ -$index assign, /= example$$ -$index plus, /= example$$ -$index add, /= example$$ $code $verbatim%example/div_eq.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -44,12 +36,12 @@ size_t n = 1; double x0 = .5; CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 2; CPPAD_TESTVECTOR(AD) y(m); y[0] = x[0] * x[0]; // initial value @@ -58,9 +50,9 @@ y[1] = y[0] /= x[0]; // use the result of a computed assignment // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0*x0/(2.*4.*x0), 1e-10 , 1e-10); ok &= NearEqual(y[1] , y[0], 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/eigen_array.cpp cppad-2016.00.00.1/example/eigen_array.cpp --- cppad-2015.00.00.9/example/eigen_array.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/eigen_array.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: eigen_array.cpp 2870 2013-07-28 17:00:59Z bradbell $ */ +// $Id: eigen_array.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,11 +17,8 @@ $$ $section Using Eigen Arrays: Example and Test$$ +$mindex array$$ -$index array, eigen example$$ -$index eigen, array example$$ -$index example, eigen array$$ -$index test, eigen array$$ $code $verbatim%example/eigen_array.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -56,10 +53,10 @@ CppAD::Independent(a_x); // evaluate a component wise function - a_y = a_x.array() + sin(a_x.array()); - + a_y = a_x.array() + sin(a_x.array()); + // create f: x -> y and stop tape recording - CppAD::ADFun f(a_x, a_y); + CppAD::ADFun f(a_x, a_y); // compute the derivative of y w.r.t x using CppAD CPPAD_TESTVECTOR(double) x(n); diff -Nru cppad-2015.00.00.9/example/eigen_det.cpp cppad-2016.00.00.1/example/eigen_det.cpp --- cppad-2015.00.00.9/example/eigen_det.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/eigen_det.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: eigen_det.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: eigen_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,11 +17,8 @@ $$ $section Using Eigen To Compute Determinant: Example and Test$$ +$mindex determinant$$ -$index determinant, eigen example$$ -$index eigen, determinant example$$ -$index example, eigen determinant$$ -$index test, eigen determinant$$ $code $verbatim%example/eigen_det.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -57,7 +54,7 @@ // set and declare independent variables and start tape recording for(i = 0; i < size; i++) { for(j = 0; j < size; j++) - { // lower triangular matrix + { // lower triangular matrix a_x[i * size + j] = x[i * size + j] = 0.0; if( j <= i ) a_x[i * size + j] = x[i * size + j] = double(1 + i + j); @@ -80,11 +77,11 @@ a_y[0] = log( a_X.determinant() ); // create f: x -> y and stop tape recording - CppAD::ADFun f(a_x, a_y); + CppAD::ADFun f(a_x, a_y); - // check function value + // check function value double eps = 100. * CppAD::numeric_limits::epsilon(); - CppAD::det_by_minor det(size); + CppAD::det_by_minor det(size); ok &= NearEqual(Value(a_y[0]) , log(det(x)), eps, eps); // compute the derivative of y w.r.t x using CppAD diff -Nru cppad-2015.00.00.9/example/equal_op_seq.cpp cppad-2016.00.00.1/example/equal_op_seq.cpp --- cppad-2015.00.00.9/example/equal_op_seq.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/equal_op_seq.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: equal_op_seq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: equal_op_seq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,8 @@ $$ $section EqualOpSeq: Example and Test$$ +$mindex EqualOpSeq$$ -$index EqualOpSeq, example$$ -$index example, EqualOpSeq$$ -$index test, EqualOpSeq$$ $code $verbatim%example/equal_op_seq.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -40,7 +38,7 @@ size_t n = 1; double x0 = 1.; CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); @@ -50,9 +48,9 @@ // both a and b are variables ok &= (a == b); // 1 + 1 == 2 * 1 - ok &= ! EqualOpSeq(a, b); // 1 + x[0] != 2 * x[0] + ok &= ! EqualOpSeq(a, b); // 1 + x[0] != 2 * x[0] - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = a; @@ -61,7 +59,7 @@ EqualOpSeq(y[0], a); // 2 * x[0] == 2 * x[0] // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); // both a and b are parameters (after the creation of f above) ok &= EqualOpSeq(a, b); // 1 + 1 == 2 * 1 diff -Nru cppad-2015.00.00.9/example/erf.cpp cppad-2016.00.00.1/example/erf.cpp --- cppad-2015.00.00.9/example/erf.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/erf.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: erf.cpp 3499 2014-12-24 15:31:55Z bradbell $ */ +// $Id: erf.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $section The AD erf Function: Example and Test$$ -$index erf, example$$ -$index example, erf$$ -$index test, erf$$ $code $verbatim%example/erf.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -51,18 +48,18 @@ // declare independent variables and start tape recording CppAD::Independent(ax); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = CppAD::erf(ax[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); - // check relative erorr + // check relative erorr double erf_x0 = 0.52050; ok &= NearEqual(ay[0] , erf_x0, 0., 4e-4); -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(ay[0] , erf_x0, 0., 1e-5); # endif @@ -77,7 +74,7 @@ dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], check, 0., 1e-3); -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(dy[0], check, 0., eps); # endif @@ -87,7 +84,7 @@ w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], check, 0., 1e-1); -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(dw[0], check, 0., eps); # endif diff -Nru cppad-2015.00.00.9/example/error_handler.cpp cppad-2016.00.00.1/example/error_handler.cpp --- cppad-2015.00.00.9/example/error_handler.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/error_handler.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: error_handler.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: error_handler.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,7 @@ $$ $section Replacing The CppAD Error Handler: Example and Test$$ -$index error, handler$$ -$index handler, error$$ -$index example, error handler$$ -$index test, error handler$$ +$mindex handler$$ $code $verbatim%example/error_handler.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -30,7 +27,7 @@ */ // BEGIN C++ -# include +# include # include namespace { @@ -61,7 +58,7 @@ try { // set the static variable Line to next source code line lineMinusFive = __LINE__; - + // can call myhandler anywhere that ErrorHandler is defined ErrorHandler::Call( true , // reason for the error is known @@ -69,7 +66,7 @@ __FILE__ , // current source code file name "1 > 0" , // an intentional error condition "Testing ErrorHandler" // reason for error - ); + ); } catch ( int line ) { // check value of the line number that was passed to handler diff -Nru cppad-2015.00.00.9/example/example.cpp cppad-2016.00.00.1/example/example.cpp --- cppad-2015.00.00.9/example/example.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/example.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: example.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: example.cpp 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,8 +17,6 @@ $$ $section CppAD Examples and Tests$$ -$index example, CppAD$$ -$index test, CppAD$$ $head Running Tests$$ To build this program and run its correctness tests see $cref cmake_check$$. @@ -41,40 +39,47 @@ # include // memory utility -# include +# include // prototype external compiled tests (this line expected by bin/new_test.sh) extern bool abort_recording(void); extern bool ad_assign(void); extern bool ad_ctor(void); extern bool abs(void); -extern bool Acos(void); +extern bool acos(void); +extern bool acosh(void); extern bool Add(void); extern bool AddEq(void); extern bool ad_fun(void); extern bool ad_in_c(void); extern bool ad_input(void); extern bool ad_output(void); -extern bool Asin(void); -extern bool Atan(void); -extern bool Atan2(void); +extern bool asin(void); +extern bool asinh(void); +extern bool atan(void); +extern bool atanh(void); +extern bool atan2(void); +extern bool azmul(void); extern bool base_require(void); extern bool BenderQuad(void); extern bool BoolFun(void); +extern bool bool_sparsity(void); extern bool capacity_order(void); -extern bool change_const(void); +extern bool change_param(void); extern bool check_for_nan(void); extern bool CheckNumericType(void); extern bool CheckSimpleVector(void); -extern bool colpack(void); +extern bool colpack_hes(void); +extern bool colpack_jac(void); extern bool Compare(void); -extern bool CompareChange(void); +extern bool compare_change(void); extern bool complex_poly(void); extern bool CondExp(void); extern bool conj_grad(void); extern bool Cos(void); extern bool Cosh(void); extern bool CppAD_vector(void); +extern bool dependency(void); extern bool Div(void); extern bool DivEq(void); extern bool eigen_array(void); @@ -82,7 +87,8 @@ extern bool EqualOpSeq(void); extern bool Erf(void); extern bool ErrorHandler(void); -extern bool Exp(void); +extern bool exp(void); +extern bool expm1(void); extern bool ForOne(void); extern bool ForTwo(void); extern bool ForSparseJac(void); @@ -105,9 +111,9 @@ extern bool JacLuDet(void); extern bool JacMinorDet(void); extern bool Jacobian(void); -extern bool limits(void); -extern bool Log(void); -extern bool Log10(void); +extern bool log(void); +extern bool log10(void); +extern bool log1p(void); extern bool LuFactor(void); extern bool LuInvert(void); extern bool LuRatio(void); @@ -124,18 +130,18 @@ extern bool NearEqualExt(void); extern bool number_skip(void); extern bool NumericType(void); +extern bool num_limits(void); extern bool OdeErrControl(void); extern bool OdeErrMaxabs(void); extern bool OdeGear(void); extern bool OdeGearControl(void); extern bool OdeStiff(void); extern bool ode_taylor(void); -extern bool omp_alloc(void); extern bool opt_val_hes(void); extern bool optimize(void); extern bool ParVar(void); extern bool Poly(void); -extern bool Pow(void); +extern bool pow(void); extern bool pow_int(void); extern bool print_for(void); extern bool reverse_any(void); @@ -158,14 +164,18 @@ extern bool Sinh(void); extern bool sparse_hessian(void); extern bool sparse_jacobian(void); +extern bool sparse_sub_hes(void); +extern bool sparsity_sub(void); extern bool Sqrt(void); extern bool StackMachine(void); extern bool Sub(void); extern bool SubEq(void); +extern bool sub_sparse_hes(void); extern bool Tan(void); extern bool Tanh(void); extern bool TapeIndex(void); extern bool thread_alloc(void); +extern bool to_string(void); extern bool UnaryMinus(void); extern bool UnaryPlus(void); extern bool Value(void); @@ -179,7 +189,7 @@ static size_t Run_error_count = 0; bool Run(bool TestOk(void), std::string name) { bool ok = true; - std::streamsize width = 20; + std::streamsize width = 20; std::cout.width( width ); std::cout.setf( std::ios_base::left ); std::cout << name; @@ -209,42 +219,49 @@ ok &= Run( ad_assign, "ad_assign" ); ok &= Run( ad_ctor, "ad_ctor" ); ok &= Run( abs, "abs" ); - ok &= Run( Acos, "Acos" ); + ok &= Run( acos, "acos" ); + ok &= Run( acosh, "acosh" ); ok &= Run( Add, "Add" ); ok &= Run( AddEq, "AddEq" ); ok &= Run( ad_fun, "ad_fun" ); ok &= Run( ad_in_c, "ad_in_c" ); ok &= Run( ad_input, "ad_input" ); ok &= Run( ad_output, "ad_output" ); - ok &= Run( Asin, "Asin" ); - ok &= Run( Atan, "Atan" ); - ok &= Run( Atan2, "Atan2" ); + ok &= Run( asin, "asin" ); + ok &= Run( asinh, "asinh" ); + ok &= Run( atan, "atan" ); + ok &= Run( atanh, "atanh" ); + ok &= Run( atan2, "atan2" ); + ok &= Run( azmul, "azmul" ); ok &= Run( BenderQuad, "BenderQuad" ); ok &= Run( BoolFun, "BoolFun" ); + ok &= Run( bool_sparsity, "bool_sparsity" ); ok &= Run( capacity_order, "capacity_order" ); - ok &= Run( change_const, "change_const" ); + ok &= Run( change_param, "change_param" ); ok &= Run( check_for_nan, "check_for_nan" ); ok &= Run( CheckNumericType, "CheckNumericType" ); ok &= Run( CheckSimpleVector, "CheckSimpleVector"); ok &= Run( Compare, "Compare" ); - ok &= Run( CompareChange, "CompareChange" ); + ok &= Run( compare_change, "compare_change" ); ok &= Run( complex_poly, "complex_poly" ); ok &= Run( CondExp, "CondExp" ); ok &= Run( conj_grad, "conj_grad" ); ok &= Run( Cos, "Cos" ); ok &= Run( Cosh, "Cosh" ); ok &= Run( CppAD_vector, "CppAD_vector" ); + ok &= Run( dependency, "dependency" ); ok &= Run( Div, "Div" ); ok &= Run( DivEq, "DivEq" ); ok &= Run( EqualOpSeq, "EqualOpSeq" ); ok &= Run( Erf, "Erf" ); ok &= Run( ErrorHandler, "ErrorHandler" ); - ok &= Run( Exp, "Exp" ); + ok &= Run( exp, "exp" ); + ok &= Run( expm1, "expm1" ); ok &= Run( ForOne, "ForOne" ); ok &= Run( ForTwo, "ForTwo" ); - ok &= Run( Forward, "Forward" ); - ok &= Run( forward_dir, "forward_dir" ); - ok &= Run( forward_order, "forward_order" ); + ok &= Run( Forward, "Forward" ); + ok &= Run( forward_dir, "forward_dir" ); + ok &= Run( forward_order, "forward_order" ); ok &= Run( ForSparseJac, "ForSparseJac" ); ok &= Run( fun_assign, "fun_assign" ); ok &= Run( FunCheck, "FunCheck" ); @@ -262,9 +279,9 @@ ok &= Run( JacLuDet, "JacLuDet" ); ok &= Run( JacMinorDet, "JacMinorDet" ); ok &= Run( Jacobian, "Jacobian" ); - ok &= Run( limits, "limits" ); - ok &= Run( Log, "Log" ); - ok &= Run( Log10, "Log10" ); + ok &= Run( log, "log" ); + ok &= Run( log10, "log10" ); + ok &= Run( log1p, "log1p" ); ok &= Run( LuFactor, "LuFactor" ); ok &= Run( LuInvert, "LuInvert" ); ok &= Run( LuRatio, "LuRatio" ); @@ -279,18 +296,18 @@ ok &= Run( NearEqualExt, "NearEqualExt" ); ok &= Run( number_skip, "number_skip" ); ok &= Run( NumericType, "NumericType" ); + ok &= Run( num_limits, "num_limits" ); ok &= Run( OdeErrControl, "OdeErrControl" ); ok &= Run( OdeErrMaxabs, "OdeErrMaxabs" ); ok &= Run( OdeGear, "OdeGear" ); ok &= Run( OdeGearControl, "OdeGearControl" ); ok &= Run( OdeStiff, "OdeStiff" ); ok &= Run( ode_taylor, "ode_taylor" ); - ok &= Run( omp_alloc, "omp_alloc" ); ok &= Run( opt_val_hes, "opt_val_hes" ); ok &= Run( optimize, "optimize" ); ok &= Run( ParVar, "ParVar" ); - ok &= Run( Pow, "Poly" ); - ok &= Run( Pow, "Pow" ); + ok &= Run( Poly, "Poly" ); + ok &= Run( pow, "pow" ); ok &= Run( pow_int, "pow_int" ); ok &= Run( reverse_any, "reverse_any" ); ok &= Run( reverse_one, "reverse_one" ); @@ -312,14 +329,18 @@ ok &= Run( Sinh, "Sinh" ); ok &= Run( sparse_hessian, "sparse_hessian" ); ok &= Run( sparse_jacobian, "sparse_jacobian" ); + ok &= Run( sparse_sub_hes, "sparse_sub_hes" ); + ok &= Run( sparsity_sub, "sparsity_sub" ); ok &= Run( Sqrt, "Sqrt" ); ok &= Run( StackMachine, "StackMachine" ); ok &= Run( Sub, "Sub" ); ok &= Run( SubEq, "SubEq" ); + ok &= Run( sub_sparse_hes, "sub_sparse_hes" ); ok &= Run( Tan, "Tan" ); ok &= Run( Tanh, "Tanh" ); ok &= Run( TapeIndex, "TapeIndex" ); ok &= Run( thread_alloc, "thread_alloc" ); + ok &= Run( to_string, "to_string" ); ok &= Run( UnaryMinus, "UnaryMinus" ); ok &= Run( UnaryPlus, "UnaryPlus" ); ok &= Run( Value, "Value" ); @@ -331,7 +352,8 @@ ok &= Run( mul_level_adolc_ode, "mul_level_adolc_ode" ); # endif # ifdef CPPAD_COLPACK_EXAMPLES - ok &= Run( colpack, "colpack" ); + ok &= Run( colpack_hes, "colpack_hes" ); + ok &= Run( colpack_jac, "colpack_jac" ); # endif # ifdef CPPAD_EIGEN_EXAMPLES ok &= Run( eigen_array, "eigen_array" ); diff -Nru cppad-2015.00.00.9/example/exp.cpp cppad-2016.00.00.1/example/exp.cpp --- cppad-2015.00.00.9/example/exp.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/exp.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: exp.cpp 3683 2015-05-10 02:24:16Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,10 +18,6 @@ $section The AD exp Function: Example and Test$$ -$index exp, AD example$$ -$index example, AD exp$$ -$index test, AD exp$$ - $code $verbatim%example/exp.cpp%0%// BEGIN C++%// END C++%1%$$ $$ @@ -33,54 +29,54 @@ # include # include -bool Exp(void) +bool exp(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = x0; // declare independent variables and start tape recording - CppAD::Independent(x); + CppAD::Independent(ax); - // range space vector + // range space vector size_t m = 1; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = CppAD::exp(x[0]); + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = CppAD::exp(ax[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(ax, ay); - // check value + // check value double check = std::exp(x0); - ok &= NearEqual(y[0] , check, 1e-10 , 1e-10); + ok &= NearEqual(ay[0], check, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); - check = std::exp(x0); - ok &= NearEqual(dy[0], check, 1e-10, 1e-10); + ok &= NearEqual(dy[0], check, eps, eps); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], check, 1e-10, 1e-10); + ok &= NearEqual(dw[0], check, eps, eps); // use a VecAD::reference object with exp CppAD::VecAD v(1); AD zero(0); v[zero] = x0; AD result = CppAD::exp(v[zero]); - ok &= NearEqual(result, check, 1e-10, 1e-10); + ok &= NearEqual(result, check, eps, eps); return ok; } diff -Nru cppad-2015.00.00.9/example/expm1.cpp cppad-2016.00.00.1/example/expm1.cpp --- cppad-2015.00.00.9/example/expm1.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/expm1.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,84 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin expm1.cpp$$ +$spell + exp +$$ + +$section The AD exp Function: Example and Test$$ + +$code +$verbatim%example/expm1.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# include +# include + +bool expm1(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = CppAD::expm1(ax[0]); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // expx0 value + double expx0 = std::exp(x0); + ok &= NearEqual(ay[0], expx0-1.0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], expx0, eps, eps); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], expx0, eps, eps); + + // use a VecAD::reference object with exp + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::expm1(v[zero]); + ok &= NearEqual(result, expx0-1.0, eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/example/for_one.cpp cppad-2016.00.00.1/example/for_one.cpp --- cppad-2015.00.00.9/example/for_one.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/for_one.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: for_one.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: for_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,9 +16,6 @@ Cpp $$ -$index partial, example$$ -$index example, partial$$ -$index test, partial$$ $section First Order Partial Driver: Example and Test$$ @@ -32,7 +29,7 @@ # include namespace { // ------------------------------------------------------- // define the template function ForOneCases in empty namespace -template +template bool ForOneCases() { bool ok = true; using CppAD::AD; @@ -80,7 +77,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool ForOne(void) diff -Nru cppad-2015.00.00.9/example/for_sparse_jac.cpp cppad-2016.00.00.1/example/for_sparse_jac.cpp --- cppad-2015.00.00.9/example/for_sparse_jac.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/for_sparse_jac.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: for_sparse_jac.cpp 2859 2013-05-28 06:03:21Z bradbell $ */ +// $Id: for_sparse_jac.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,11 +20,8 @@ $$ $section Forward Mode Jacobian Sparsity: Example and Test$$ +$mindex ForSparseJac sparsity$$ -$index ForSparseJac$$ -$index example, sparsity forward$$ -$index test, sparsity forward$$ -$index sparsity, forward example$$ $code $verbatim%example/for_sparse_jac.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -38,16 +35,16 @@ # include namespace { // ------------------------------------------------------------- -// define the template function BoolCases +// define the template function BoolCases template // vector class, elements of type bool bool BoolCases(void) { bool ok = true; using CppAD::AD; // domain space vector - size_t n = 2; + size_t n = 2; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; // declare independent variables and start recording @@ -110,16 +107,16 @@ return ok; } -// define the template function SetCases +// define the template function SetCases template // vector class, elements of type std::set bool SetCases(void) { bool ok = true; using CppAD::AD; // domain space vector - size_t n = 2; + size_t n = 2; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; // declare independent variables and start recording @@ -152,17 +149,17 @@ bool found; // Y[0] does depend on X[0] - found = s[0].find(0) != s[0].end(); ok &= ( found == true ); + found = s[0].find(0) != s[0].end(); ok &= ( found == true ); // Y[0] does not depend on X[1] - found = s[0].find(1) != s[0].end(); ok &= ( found == false ); + found = s[0].find(1) != s[0].end(); ok &= ( found == false ); // Y[1] does depend on X[0] - found = s[1].find(0) != s[1].end(); ok &= ( found == true ); + found = s[1].find(0) != s[1].end(); ok &= ( found == true ); // Y[1] does depend on X[1] - found = s[1].find(1) != s[1].end(); ok &= ( found == true ); + found = s[1].find(1) != s[1].end(); ok &= ( found == true ); // Y[2] does not depend on X[0] - found = s[2].find(0) != s[2].end(); ok &= ( found == false ); + found = s[2].find(0) != s[2].end(); ok &= ( found == false ); // Y[2] does depend on X[1] - found = s[2].find(1) != s[2].end(); ok &= ( found == true ); + found = s[2].find(1) != s[2].end(); ok &= ( found == true ); // check that values are stored ok &= (f.size_forward_set() > 0); @@ -175,17 +172,17 @@ st = f.ForSparseJac(n, r, transpose); // Y[0] does depend on X[0] - found = st[0].find(0) != st[0].end(); ok &= ( found == true ); + found = st[0].find(0) != st[0].end(); ok &= ( found == true ); // Y[0] does not depend on X[1] - found = st[1].find(0) != st[1].end(); ok &= ( found == false ); + found = st[1].find(0) != st[1].end(); ok &= ( found == false ); // Y[1] does depend on X[0] - found = st[0].find(1) != st[0].end(); ok &= ( found == true ); + found = st[0].find(1) != st[0].end(); ok &= ( found == true ); // Y[1] does depend on X[1] - found = st[1].find(1) != st[1].end(); ok &= ( found == true ); + found = st[1].find(1) != st[1].end(); ok &= ( found == true ); // Y[2] does not depend on X[0] - found = st[0].find(2) != st[0].end(); ok &= ( found == false ); + found = st[0].find(2) != st[0].end(); ok &= ( found == false ); // Y[2] does depend on X[1] - found = st[1].find(2) != st[1].end(); ok &= ( found == true ); + found = st[1].find(2) != st[1].end(); ok &= ( found == true ); // check that values are stored ok &= (f.size_forward_set() > 0); @@ -202,18 +199,18 @@ // all of which are Simple Vectors with elements of type bool. ok &= BoolCases< CppAD::vectorBool >(); ok &= BoolCases< CppAD::vector >(); - ok &= BoolCases< std::vector >(); - ok &= BoolCases< std::valarray >(); + ok &= BoolCases< std::vector >(); + ok &= BoolCases< std::valarray >(); - // Run with Vector equal to two different cases both of which are + // Run with Vector equal to two different cases both of which are // Simple Vectors with elements of type std::set typedef std::set set; ok &= SetCases< CppAD::vector >(); - // ok &= SetCases< std::vector >(); + // ok &= SetCases< std::vector >(); // Do not use valarray because its element access in the const case // returns a copy instead of a reference - // ok &= SetCases< std::valarray >(); + // ok &= SetCases< std::valarray >(); return ok; } diff -Nru cppad-2015.00.00.9/example/for_two.cpp cppad-2016.00.00.1/example/for_two.cpp --- cppad-2015.00.00.9/example/for_two.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/for_two.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: for_two.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: for_two.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,11 +17,8 @@ $$ $section Subset of Second Order Partials: Example and Test$$ +$mindex partial$$ -$index second, partial$$ -$index partial, second$$ -$index example, second partial$$ -$index test, second partial$$ $code $verbatim%example/for_two.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -34,7 +31,7 @@ namespace { // ----------------------------------------------------- // define the template function in empty namespace // bool ForTwoCases(void) -template +template bool ForTwoCases() { bool ok = true; using CppAD::AD; @@ -70,7 +67,7 @@ x[0] = 2.; x[1] = 1.; - // set j and k to compute specific second partials of y + // set j and k to compute specific second partials of y size_t p = 2; VectorSize_t j(p); VectorSize_t k(p); @@ -80,11 +77,11 @@ // compute the second partials VectorBase ddy(m * p); ddy = f.ForTwo(x, j, k); - /* + /* partial of y w.r.t x[0] is [ 2 * x[0] * exp(x[1]) ] [ 2 * x[0] * sin(x[1]) ] - [ 2 * x[0] * cos(x[1]) ] + [ 2 * x[0] * cos(x[1]) ] */ // second partial of y w.r.t x[0] and x[1] ok &= NearEqual( 2.*exp(x[1]), ddy[0*p+0], 1e-10, 1e-10 ); @@ -98,7 +95,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool ForTwo(void) diff -Nru cppad-2015.00.00.9/example/forward.cpp cppad-2016.00.00.1/example/forward.cpp --- cppad-2015.00.00.9/example/forward.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/forward.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward.cpp 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: forward.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,6 @@ $$ $section Forward Mode: Example and Test$$ -$index Forward$$ -$index example, Forward$$ -$index test, Forward$$ $code $verbatim%example/forward.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -32,7 +29,7 @@ # include namespace { // -------------------------------------------------------- // define the template function ForwardCases in empty namespace -template +template bool ForwardCases(void) { bool ok = true; using CppAD::AD; @@ -42,7 +39,7 @@ // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; + ax[0] = 0.; ax[1] = 1.; // declare independent variables and starting recording @@ -91,7 +88,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool Forward(void) diff -Nru cppad-2015.00.00.9/example/forward_dir.cpp cppad-2016.00.00.1/example/forward_dir.cpp --- cppad-2015.00.00.9/example/forward_dir.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/forward_dir.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_dir.cpp 3301 2014-05-24 05:20:21Z bradbell $ */ +// $Id: forward_dir.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,7 @@ $$ $section Forward Mode: Example and Test of Multiple Directions$$ -$index forward, multiple orders$$ -$index multiple, forward orders$$ -$index order, multiple forward$$ +$mindex orders order$$ $code $verbatim%example/forward_dir.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -40,7 +38,7 @@ // domain space vector size_t n = 3; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; + ax[0] = 0.; ax[1] = 1.; ax[2] = 2.; @@ -63,8 +61,8 @@ for(j = 0; j < n; j++) x0[j] = double(j+1); y0 = f.Forward(0, x0); - ok &= y0.size() == m; - double y_0 = 1.*2.*3.; + ok &= size_t( y0.size() ) == m; + double y_0 = 1.*2.*3.; ok &= NearEqual(y0[0], y_0, eps, eps); // first order Taylor coefficients @@ -75,8 +73,8 @@ x1[ r * j + ell ] = double(j + 1 + ell); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -84,15 +82,15 @@ x2[ r * j + ell ] = 0.0; } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] - // = (1 + 1t)(2 + 2t)(3 + 3t) + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] + // = (1 + 1t)(2 + 2t)(3 + 3t) double y_1_0 = 1.*2.*3. + 2.*1.*3. + 3.*1.*2.; double y_2_0 = 1.*2.*3. + 2.*1.*3. + 3.*1.*2.; - // - // Y_1 (t) = F[X_1(t)] - // = (1 + 2t)(2 + 3t)(3 + 4t) + // + // Y_1 (t) = F[X_1(t)] + // = (1 + 2t)(2 + 3t)(3 + 4t) double y_1_1 = 2.*2.*3. + 3.*1.*3. + 4.*1.*2.; double y_2_1 = 1.*3.*4. + 2.*2.*4. + 3.*2.*3.; // @@ -101,10 +99,10 @@ ok &= NearEqual(y2[0] , y_2_0, eps, eps); ok &= NearEqual(y2[1] , y_2_1, eps, eps); // - // check number of orders + // check number of orders ok &= f.size_order() == 3; // - // check number of directions + // check number of directions ok &= f.size_direction() == 2; // return ok; diff -Nru cppad-2015.00.00.9/example/forward_order.cpp cppad-2016.00.00.1/example/forward_order.cpp --- cppad-2015.00.00.9/example/forward_order.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/forward_order.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_order.cpp 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: forward_order.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,6 @@ $$ $section Forward Mode: Example and Test of Multiple Orders$$ -$index forward, multiple orders$$ -$index multiple, forward orders$$ -$index order, multiple forward$$ $code $verbatim%example/forward_order.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -39,7 +36,7 @@ // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; + ax[0] = 0.; ax[1] = 1.; // declare independent variables and starting recording @@ -63,10 +60,10 @@ xq[q1*0 + 1] = 1.; xq[q1*1 + 1] = 0.; // x^1 (order one) xq[q1*0 + 2] = 0.; xq[q1*1 + 2] = 0.; // x^2 (order two) // X(t) = x^0 + x^1 * t + x^2 * t^2 - // = [ 3 + t, 4 ] + // = [ 3 + t, 4 ] yq = f.Forward(q, xq); - ok &= yq.size() == m*q1; - // Y(t) = F[X(t)] + ok &= size_t( yq.size() ) == m*q1; + // Y(t) = F[X(t)] // = (3 + t) * (3 + t) * 4 // = y^0 + y^1 * t + y^2 * t^2 + o(t^3) // diff -Nru cppad-2015.00.00.9/example/fun_assign.cpp cppad-2016.00.00.1/example/fun_assign.cpp --- cppad-2015.00.00.9/example/fun_assign.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/fun_assign.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: fun_assign.cpp 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: fun_assign.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,10 +14,8 @@ $begin fun_assign.cpp$$ $section ADFun Assignment: Example and Test$$ +$mindex assignment$$ -$index ADFun, assignment example$$ -$index example, ADFun assignment$$ -$index assignment, ADFun example$$ $code $verbatim%example/fun_assign.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -50,7 +48,7 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 2; CPPAD_TESTVECTOR(AD) y(m); y[0] = x[0] + x[0] * x[1]; @@ -65,7 +63,7 @@ r[j].insert(j); // Store forward mode sparsity pattern in f - f.ForSparseJac(n, r); + f.ForSparseJac(n, r); // make a copy in g g = f; @@ -82,8 +80,8 @@ dx[i] = 0.; dx[1] = 1; dy = g.Forward(1, dx); - ok &= NearEqual(dy[0], x[0], eps, eps); // partial y[0] w.r.t x[1] - ok &= NearEqual(dy[1], x[2], eps, eps); // partial y[1] w.r.t x[1] + ok &= NearEqual(dy[0], x[0], eps, eps); // partial y[0] w.r.t x[1] + ok &= NearEqual(dy[1], x[2], eps, eps); // partial y[1] w.r.t x[1] // Use forward Jacobian sparsity pattern from f to calculate // Hessian sparsity pattern using g. @@ -91,18 +89,18 @@ s[0].insert(0); // Compute sparsity pattern for Hessian of y[0] h = f.RevSparseHes(n, s); - // check sparsity pattern for Hessian of y[0] = x[0] + x[0] * x[1] - ok &= ( h[0].find(0) == h[0].end() ); // zero w.r.t x[0], x[0] - ok &= ( h[0].find(1) != h[0].end() ); // non-zero w.r.t x[0], x[1] - ok &= ( h[0].find(2) == h[0].end() ); // zero w.r.t x[0], x[2] - - ok &= ( h[1].find(0) != h[1].end() ); // non-zero w.r.t x[1], x[0] - ok &= ( h[1].find(1) == h[1].end() ); // zero w.r.t x[1], x[1] - ok &= ( h[1].find(2) == h[1].end() ); // zero w.r.t x[1], x[2] - - ok &= ( h[2].find(0) == h[2].end() ); // zero w.r.t x[2], x[0] - ok &= ( h[2].find(1) == h[2].end() ); // zero w.r.t x[2], x[1] - ok &= ( h[2].find(2) == h[2].end() ); // zero w.r.t x[2], x[2] + // check sparsity pattern for Hessian of y[0] = x[0] + x[0] * x[1] + ok &= ( h[0].find(0) == h[0].end() ); // zero w.r.t x[0], x[0] + ok &= ( h[0].find(1) != h[0].end() ); // non-zero w.r.t x[0], x[1] + ok &= ( h[0].find(2) == h[0].end() ); // zero w.r.t x[0], x[2] + + ok &= ( h[1].find(0) != h[1].end() ); // non-zero w.r.t x[1], x[0] + ok &= ( h[1].find(1) == h[1].end() ); // zero w.r.t x[1], x[1] + ok &= ( h[1].find(2) == h[1].end() ); // zero w.r.t x[1], x[2] + + ok &= ( h[2].find(0) == h[2].end() ); // zero w.r.t x[2], x[0] + ok &= ( h[2].find(1) == h[2].end() ); // zero w.r.t x[2], x[1] + ok &= ( h[2].find(2) == h[2].end() ); // zero w.r.t x[2], x[2] return ok; } diff -Nru cppad-2015.00.00.9/example/fun_check.cpp cppad-2016.00.00.1/example/fun_check.cpp --- cppad-2015.00.00.9/example/fun_check.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/fun_check.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: fun_check.cpp 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: fun_check.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,18 +18,10 @@ $$ $section ADFun Check and Re-Tape: Example and Test$$ +$mindex FunCheck Dependent$$ + + -$index FunCheck, example$$ -$index example, FunCheck$$ -$index test, FunCheck$$ - -$index ADFun, example$$ -$index example, ADFun$$ -$index test, ADFun$$ - -$index Dependent, example$$ -$index example, Dependent$$ -$index test, Dependent$$ $code $verbatim%example/fun_check.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -56,12 +48,12 @@ size_t i; for(i = 0; i < n; i++) { // This operaiton sequence depends on x - if( x[i] >= 0 ) + if( x[i] >= 0 ) y[i] = exp(x[i]); else y[i] = exp(-x[i]); } return y; - } + } }; // template function FunCheckCases in empty namespace template @@ -98,13 +90,13 @@ // create function object to use with double Fun g(n); - // function values should agree when the independent variable + // function values should agree when the independent variable // values are the same as during recording Vector x(n); size_t j; for(j = 0; j < n; j++) x[j] = Value(X[j]); - double r = 1e-10; + double r = 1e-10; double a = 1e-10; ok &= FunCheck(f, g, x, a, r); @@ -129,7 +121,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool FunCheck(void) @@ -141,7 +133,7 @@ typedef std::valarray Vector3; typedef std::valarray< CppAD::AD > ADVector3; // Run with Vector and ADVector equal to three different cases - // all of which are Simple Vectors with elements of type + // all of which are Simple Vectors with elements of type // double and AD respectively. ok &= FunCheckCases< Vector1, ADVector2 >(); ok &= FunCheckCases< Vector2, ADVector3 >(); diff -Nru cppad-2015.00.00.9/example/hes_lagrangian.cpp cppad-2016.00.00.1/example/hes_lagrangian.cpp --- cppad-2015.00.00.9/example/hes_lagrangian.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/hes_lagrangian.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: hes_lagrangian.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: hes_lagrangian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,12 +19,8 @@ $comment ! NOTE the title states that this example is used two places !$$ $section Hessian of Lagrangian and ADFun Default Constructor: Example and Test$$ +$mindex HesLagrangian constructor$$ -$index HesLagrangian$$ -$index example, Hessian of Lagrangian$$ -$index test, Hessian of Lagrangian$$ -$index example, ADFun default constructor$$ -$index test, ADFun default constructor$$ $code $verbatim%example/hes_lagrangian.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -49,7 +45,7 @@ AD y0 = xyz[3]; AD y1 = xyz[4]; AD z = xyz[5]; - + // compute objective function AD f = x0 * x0; // compute constraint functions @@ -57,9 +53,9 @@ AD g1 = log( x0 * x2 ); // compute the Lagragian AD L = y0 * g0 + y1 * g1 + z * f; - + return L; - + } CppAD::vector< CppAD::AD > fg( const CppAD::vector< CppAD::AD > &x ) @@ -75,7 +71,7 @@ return fg; } bool CheckHessian( - CppAD::vector H , + CppAD::vector H , double x0, double x1, double x2, double y0, double y1, double z ) { using CppAD::NearEqual; bool ok = true; @@ -85,12 +81,12 @@ L = z*x0*x0 + y0*(1 + 2*x1 + 3*x2) + y1*log(x0*x2) L_0 = 2 * z * x0 + y1 / x0 - L_1 = y0 * 2 - L_2 = y0 * 3 + y1 / x2 + L_1 = y0 * 2 + L_2 = y0 * 3 + y1 / x2 */ // L_00 = 2 * z - y1 / ( x0 * x0 ) double check = 2. * z - y1 / (x0 * x0); - ok &= NearEqual(H[0 * n + 0], check, 1e-10, 1e-10); + ok &= NearEqual(H[0 * n + 0], check, 1e-10, 1e-10); // L_01 = L_10 = 0 ok &= NearEqual(H[0 * n + 1], 0., 1e-10, 1e-10); ok &= NearEqual(H[1 * n + 0], 0., 1e-10, 1e-10); @@ -142,8 +138,8 @@ CppAD::ADFun K; K.Dependent(L); - // Operation sequence corresponding to K does depends on - // value of y0, y1, and z. Must redo calculations above when + // Operation sequence corresponding to K does depends on + // value of y0, y1, and z. Must redo calculations above when // y0, y1, or z changes. // declare independent variable vector and Hessian @@ -158,7 +154,7 @@ H = K.Hessian(x, 0); // check this Hessian calculation - return CheckHessian(H, x0, x1, x2, y0, y1, z); + return CheckHessian(H, x0, x1, x2, y0, y1, z); } bool Usefg() { using CppAD::AD; @@ -186,10 +182,10 @@ CppAD::ADFun K; K.Dependent(FG); - // Operation sequence corresponding to K does not depend on - // value of x0, x1, x2, y0, y1, or z. + // Operation sequence corresponding to K does not depend on + // value of x0, x1, x2, y0, y1, or z. - // forward and reverse mode arguments and results + // forward and reverse mode arguments and results vector x(n); vector H( n * n ); vector dx(n); @@ -224,7 +220,7 @@ } // check this Hessian calculation - return CheckHessian(H, x0, x1, x2, y0, y1, z); + return CheckHessian(H, x0, x1, x2, y0, y1, z); } } diff -Nru cppad-2015.00.00.9/example/hes_lu_det.cpp cppad-2016.00.00.1/example/hes_lu_det.cpp --- cppad-2015.00.00.9/example/hes_lu_det.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/hes_lu_det.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: hes_lu_det.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: hes_lu_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,6 @@ $$ $section Gradient of Determinant Using LU Factorization: Example and Test$$ -$mindex gradient LU$$ -$index example, gradient$$ -$index test, gradient$$ -$index example, LU$$ -$index test, LU$$ $code $verbatim%example/hes_lu_det.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -79,7 +74,7 @@ */ Complex zero(0., 0.); Complex one(1., 0.); - Complex Htrue[] = { + Complex Htrue[] = { zero, zero, zero, one, zero, zero, -one, zero, zero, -one, zero, zero, diff -Nru cppad-2015.00.00.9/example/hes_minor_det.cpp cppad-2016.00.00.1/example/hes_minor_det.cpp --- cppad-2015.00.00.9/example/hes_minor_det.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/hes_minor_det.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: hes_minor_det.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: hes_minor_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,11 +17,7 @@ $$ $section Gradient of Determinant Using Expansion by Minors: Example and Test$$ -$mindex gradient minors expansion$$ -$index example, gradient$$ -$index test, gradient$$ -$index example, minors expansion$$ -$index test, minors expansion$$ +$mindex minors$$ $code $verbatim%example/hes_minor_det.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -64,7 +60,7 @@ Independent(X); // comupute the determinant - D[0] = Det(X); + D[0] = Det(X); // create the function object ADFun f(X, D); @@ -84,7 +80,7 @@ */ Complex zero(0., 0.); Complex one(1., 0.); - Complex Htrue[] = { + Complex Htrue[] = { zero, zero, zero, one, zero, zero, -one, zero, zero, -one, zero, zero, diff -Nru cppad-2015.00.00.9/example/hessian.cpp cppad-2016.00.00.1/example/hessian.cpp --- cppad-2015.00.00.9/example/hessian.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/hessian.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: hessian.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,10 +18,8 @@ $$ $section Hessian: Example and Test$$ +$mindex Hessian$$ -$index Hessian$$ -$index example, Hessian$$ -$index test, Hessian$$ $code $verbatim%example/hessian.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -34,7 +32,7 @@ # include namespace { // --------------------------------------------------------- // define the template function HessianCases in empty namespace -template +template bool HessianCases() { bool ok = true; using CppAD::AD; @@ -70,7 +68,7 @@ x[0] = 2.; x[1] = 1.; - // second derivative of y[1] + // second derivative of y[1] Vector hes( n * n ); hes = f.Hessian(x, 1); /* @@ -88,7 +86,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool Hessian(void) diff -Nru cppad-2015.00.00.9/example/hes_times_dir.cpp cppad-2016.00.00.1/example/hes_times_dir.cpp --- cppad-2015.00.00.9/example/hes_times_dir.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/hes_times_dir.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: hes_times_dir.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: hes_times_dir.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,8 +16,7 @@ $$ $section Hessian Times Direction: Example and Test$$ -$index Hessian, times direction$$ -$index direction, times Hessian$$ +$mindex direction$$ $code $verbatim%example/hes_times_dir.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -40,7 +39,7 @@ while(i--) sum += x[i] * x[i]; return sum; - } + } } bool HesTimesDir(void) @@ -51,10 +50,10 @@ using CppAD::NearEqual; // domain space vector - size_t n = 5; + size_t n = 5; CPPAD_TESTVECTOR(AD) X(n); for(j = 0; j < n; j++) - X[j] = AD(j); + X[j] = AD(j); // declare independent variables and start recording CppAD::Independent(X); @@ -79,7 +78,7 @@ CPPAD_TESTVECTOR(double) ddw(2 * n); w[0] = 1.; ddw = f.Reverse(2, w); - + // F(x) = x[0]^2 + x[1]^2 + ... + x[n-1]^2 // F''(x) = 2 * Identity_Matrix // F''(x) * dx = 2 * dx diff -Nru cppad-2015.00.00.9/example/independent.cpp cppad-2016.00.00.1/example/independent.cpp --- cppad-2015.00.00.9/example/independent.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/independent.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: independent.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: independent.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,6 @@ $comment ! NOTE the title states that this example is used two places !$$ $section Independent and ADFun Constructor: Example and Test$$ -$index Independent, example$$ -$index example, Independent$$ -$index test, Independent$$ $code $verbatim%example/independent.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -44,7 +41,7 @@ X[0] = 0.; X[1] = 1.; - // declare independent variables and start recording + // declare independent variables and start recording // use the template parameter VectorAD for the vector type CppAD::Independent(X); @@ -59,9 +56,9 @@ // create f: X -> Y and stop tape recording // use the template parameter VectorAD for the vector type - CppAD::ADFun f(X, Y); + CppAD::ADFun f(X, Y); - // check value + // check value ok &= NearEqual(Y[0] , 1., 1e-10 , 1e-10); ok &= NearEqual(Y[1] , 0., 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/index_sort.cpp cppad-2016.00.00.1/example/index_sort.cpp --- cppad-2015.00.00.9/example/index_sort.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/index_sort.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: index_sort.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: index_sort.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,11 +14,8 @@ $begin index_sort.cpp$$ $section Index Sort: Example and Test$$ +$mindex index_sort$$ -$index index_sort, example$$ -$index sort, index example$$ -$index index, sort example$$ -$index test, index_sort$$ $code $verbatim%example/index_sort.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -27,8 +24,8 @@ $end */ // BEGIN C++ -# include -# include +# include +# include # include # include @@ -61,27 +58,27 @@ size_t first[] = { 4, 4, 3, 3, 2, 2, 1, 1}; size_t second[] = { 0, 1, 0, 1, 0, 1, 0, 1}; size_t size = sizeof(first) / sizeof(first[0]); - + VectorKey keys(size); for(i = 0; i < size; i++) keys[i] = Key(first[i], second[i]); - + VectorSize ind(size); CppAD::index_sort(keys, ind); - + // check that all the indices are different for(i = 0; i < size; i++) { for(j = 0; j < size; j++) ok &= (i == j) | (ind[i] != ind[j]); } - + // check for increasing order for(i = 0; i < size-1; i++) { if( first[ ind[i] ] == first[ ind[i+1] ] ) ok &= second[ ind[i] ] <= second[ ind[i+1] ]; else ok &= first[ ind[i] ] < first[ ind[i+1] ]; - } - + } + return ok; } } diff -Nru cppad-2015.00.00.9/example/integer.cpp cppad-2016.00.00.1/example/integer.cpp --- cppad-2015.00.00.9/example/integer.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/integer.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: integer.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: integer.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,10 +18,8 @@ $$ $section Convert From AD to Integer: Example and Test$$ +$mindex Integer$$ -$index Integer$$ -$index example, Integer$$ -$index test, Integer$$ $code $verbatim%example/integer.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -63,7 +61,7 @@ v[zero] = 2; ok &= (Integer(v[zero]) == 2); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = - x[1]; diff -Nru cppad-2015.00.00.9/example/interface2c.cpp cppad-2016.00.00.1/example/interface2c.cpp --- cppad-2015.00.00.9/example/interface2c.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/interface2c.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: interface2c.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: interface2c.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,14 +12,11 @@ /* $begin interface2c.cpp$$ $spell - + $$ $section Interfacing to C: Example and Test$$ -$index C, interface to$$ -$index interface, to C$$ -$index difference, central$$ -$index central difference$$ +$mindex C interface difference central$$ $code $verbatim%example/interface2c.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -38,31 +35,31 @@ where the floating point type is a template parameter */ template -Float sumGauss(const Float &x, const CppAD::vector &a) -{ +Float sumGauss(const Float &x, const CppAD::vector &a) +{ // number of components in a size_t na = a.size(); // number of Gaussians size_t n = na / 3; - // check the restricitons on na + // check the restricitons on na assert( na == n * 3 ); // declare temporaries used inside of loop Float ex, arg; // initialize sum - Float y = 0.; + Float y = 0.; // loop with respect to Gaussians size_t i; for(i = 0; i < n; i++) { - arg = (x - a[3*i+1]) / a[3*i+2]; - ex = exp(-arg * arg); - y += a[3*i] * ex; - } + arg = (x - a[3*i+1]) / a[3*i+2]; + ex = exp(-arg * arg); + y += a[3*i] * ex; + } return y; } /* @@ -71,8 +68,8 @@ and its derivative with respect to the parameter vector a. */ extern "C" -void sumGauss(float x, float a[], float *y, float dyda[], size_t na) -{ // Note that any simple vector could replace CppAD::vector; +void sumGauss(float x, float a[], float *y, float dyda[], size_t na) +{ // Note that any simple vector could replace CppAD::vector; // for example, std::vector, std::valarray // check the restrictions on na @@ -86,12 +83,12 @@ CppAD::vector acopy(na); // used for derivative calculations // vector for the dependent variables (there is only one) - CppAD::vector Y(1); + CppAD::vector Y(1); // copy the independent variables from C vector to CppAD vectors size_t i; for(i = 0; i < na; i++) - A[i] = acopy[i] = a[i]; + A[i] = acopy[i] = a[i]; // declare that A is the independent variable vector CppAD::Independent(A); @@ -99,14 +96,14 @@ // value of x as an ADfloat object ADfloat X = x; - // Evaluate template version of sumGauss with ADfloat as the template + // Evaluate template version of sumGauss with ADfloat as the template // parameter. Set the independent variable to the resulting value - Y[0] = sumGauss(X, A); + Y[0] = sumGauss(X, A); // create the AD function object F : A -> Y CppAD::ADFun F(A, Y); - // use Value to convert Y[0] to float and return y = F(a) + // use Value to convert Y[0] to float and return y = F(a) *y = CppAD::Value(Y[0]); // evaluate the derivative F'(a) @@ -131,7 +128,7 @@ bool Interface2C(void) { // This routine is intentionally coded as if it were a C routine // except for the fact that it uses the predefined type bool. - bool ok = true; + bool ok = true; // declare variables float x, a[6], y, dyda[6], tmp[6]; @@ -157,7 +154,7 @@ { // local variables float small, ai, yp, ym, dy_da; - // We assume that the type float has at least 7 digits of + // We assume that the type float has at least 7 digits of // precision, so we choose small to be about pow(10., -7./2.). small = (float) 3e-4; @@ -178,7 +175,7 @@ // restore this component of a a[i] = ai; - ok &= NearEqual(dyda[i], dy_da, small, small); + ok &= NearEqual(dyda[i], dy_da, small, small); } return ok; } diff -Nru cppad-2015.00.00.9/example/interp_onetape.cpp cppad-2016.00.00.1/example/interp_onetape.cpp --- cppad-2015.00.00.9/example/interp_onetape.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/interp_onetape.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: interp_onetape.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: interp_onetape.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section Interpolation With Out Retaping: Example and Test$$ +$mindex interpolate tape retape$$ -$index interpolate, example$$ -$index interpolate, test$$ -$index tape, interpolate$$ -$index retape, interpolate$$ $head See Also$$ $cref interp_retape.cpp$$ @@ -59,7 +56,7 @@ size_t Index(const double &x) { // determine the index j such that x is between - // ArgumentValue[j] and ArgumentValue[j+1] + // ArgumentValue[j] and ArgumentValue[j+1] static size_t j = 0; while ( x < ArgumentValue[j] && j > 0 ) j--; @@ -106,7 +103,7 @@ CppAD::Independent(X); // evaluate piecewise linear interpolant at X[0] - AD A = Argument(X[0]); + AD A = Argument(X[0]); AD F = Function(X[0]); AD S = Slope(X[0]); AD I = F + (X[0] - A) * S; @@ -121,29 +118,29 @@ // vectors for arguments to the function object f CPPAD_TESTVECTOR(double) x(n); // argument values - CPPAD_TESTVECTOR(double) y(m); // function values + CPPAD_TESTVECTOR(double) y(m); // function values CPPAD_TESTVECTOR(double) dx(n); // differentials in x space CPPAD_TESTVECTOR(double) dy(m); // differentials in y space - // to check function value we use the fact that X[0] is between + // to check function value we use the fact that X[0] is between // ArgumentValue[1] and ArgumentValue[2] x[0] = Value(X[0]); double delta = ArgumentValue[2] - ArgumentValue[1]; double check = FunctionValue[2] * (x[0] - ArgumentValue[1]) / delta - + FunctionValue[1] * (ArgumentValue[2] - x[0]) / delta; + + FunctionValue[1] * (ArgumentValue[2] - x[0]) / delta; ok &= NearEqual(Y[0], check, 1e-10, 1e-10); // evaluate f where x has different value x[0] = .7 * ArgumentValue[2] + .3 * ArgumentValue[3]; y = f.Forward(0, x); - // check function value + // check function value delta = ArgumentValue[3] - ArgumentValue[2]; check = FunctionValue[3] * (x[0] - ArgumentValue[2]) / delta - + FunctionValue[2] * (ArgumentValue[3] - x[0]) / delta; + + FunctionValue[2] * (ArgumentValue[3] - x[0]) / delta; ok &= NearEqual(y[0], check, 1e-10, 1e-10); - // evaluate partials w.r.t. x[0] + // evaluate partials w.r.t. x[0] dx[0] = 1.; dy = f.Forward(1, dx); diff -Nru cppad-2015.00.00.9/example/interp_retape.cpp cppad-2016.00.00.1/example/interp_retape.cpp --- cppad-2015.00.00.9/example/interp_retape.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/interp_retape.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: interp_retape.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: interp_retape.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section Interpolation With Retaping: Example and Test$$ +$mindex interpolate tape retape$$ -$index interpolate, example$$ -$index interpolate, test$$ -$index tape, interpolate$$ -$index retape, interpolate$$ $head See Also$$ $cref interp_onetape.cpp$$ @@ -60,7 +57,7 @@ size_t Index(const CppAD::AD &x) { // determine the index j such that x is between - // ArgumentValue[j] and ArgumentValue[j+1] + // ArgumentValue[j] and ArgumentValue[j+1] static size_t j = 0; while ( x < ArgumentValue[j] && j > 0 ) j--; @@ -107,7 +104,7 @@ CppAD::Independent(X); // evaluate piecewise linear interpolant at X[0] - AD A = Argument(X[0]); + AD A = Argument(X[0]); AD F = Function(X[0]); AD S = Slope(X[0]); AD I = F + (X[0] - A) * S; @@ -122,7 +119,7 @@ // vectors for arguments to the function object f CPPAD_TESTVECTOR(double) x(n); // argument values - CPPAD_TESTVECTOR(double) y(m); // function values + CPPAD_TESTVECTOR(double) y(m); // function values CPPAD_TESTVECTOR(double) dx(n); // differentials in x space CPPAD_TESTVECTOR(double) dy(m); // differentials in y space @@ -132,10 +129,10 @@ x[0] = Value(X[0]); delta = ArgumentValue[k+1] - ArgumentValue[k]; check = FunctionValue[k+1] * (x[0]-ArgumentValue[k]) / delta - + FunctionValue[k] * (ArgumentValue[k+1]-x[0]) / delta; + + FunctionValue[k] * (ArgumentValue[k+1]-x[0]) / delta; ok &= NearEqual(Y[0], check, 1e-10, 1e-10); - // evaluate partials w.r.t. x[0] + // evaluate partials w.r.t. x[0] dx[0] = 1.; dy = f.Forward(1, dx); diff -Nru cppad-2015.00.00.9/example/ipopt_solve/CMakeLists.txt cppad-2016.00.00.1/example/ipopt_solve/CMakeLists.txt --- cppad-2015.00.00.9/example/ipopt_solve/CMakeLists.txt 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ipopt_solve/CMakeLists.txt 2016-02-09 08:31:55.000000000 +0000 @@ -1,52 +1,51 @@ -# $Id: CMakeLists.txt 3116 2014-02-24 21:44:26Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the example/ipopt_solve directory tests +# Build the example/ipopt_solve directory tests -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # Local link directories to search, as determined by pkg-config for ipopt LINK_DIRECTORIES( ${ipopt_LIBRARY_DIRS} ) -# colpack_prefix -IF ( colpack_prefix ) - # Extra source files if we are including colpack - SET(colpack_sources ../../cppad/local/cppad_colpack.cpp) - # add colpack to list of libraries - SET(colpack_libs "ColPack") -ELSE ( colpack_prefix ) - SET(colpack_sources "") - SET(colpack_libs "") -ENDIF ( colpack_prefix ) +# Copy a file to another location and modify its contents. +# configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh.in + ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh +) # -ADD_EXECUTABLE(example_ipopt_solve EXCLUDE_FROM_ALL +ADD_EXECUTABLE(example_ipopt_solve EXCLUDE_FROM_ALL solve.cpp get_started.cpp ode_inverse.cpp retape.cpp - ${colpack_sources} ) # Extra compiler flags add_cppad_cxx_flags( example_ipopt_solve ) -# libraries to be linked into the specified target, +# libraries to be linked into the specified target, # as determined by pkg-config for ipopt -TARGET_LINK_LIBRARIES(example_ipopt_solve ${ipopt_LIBRARIES} ${colpack_libs}) +TARGET_LINK_LIBRARIES(example_ipopt_solve + ${cppad_lib} + ${ipopt_LIBRARIES} + ${colpack_libs} +) # Add the check_example_ipopt_solve target -ADD_CUSTOM_TARGET(check_example_ipopt_solve - example_ipopt_solve - DEPENDS example_ipopt_solve +ADD_CUSTOM_TARGET(check_example_ipopt_solve + example_ipopt_solve + DEPENDS example_ipopt_solve ) diff -Nru cppad-2015.00.00.9/example/ipopt_solve/get_started.cpp cppad-2016.00.00.1/example/ipopt_solve/get_started.cpp --- cppad-2015.00.00.9/example/ipopt_solve/get_started.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ipopt_solve/get_started.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: get_started.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: get_started.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,9 @@ IpoptDir CppAD $$ -$index example, nonlinear, programming$$ -$index programming, nonlinear example$$ -$index ipopt, AD example$$ $section Nonlinear Programming Using CppAD and Ipopt: Example and Test$$ +$mindex ipopt AD$$ $head Purpose$$ This example program demonstrates how to use $cref ipopt_solve$$ to @@ -35,7 +33,7 @@ \\ & x_1^2 + x_2^2 + x_3^2 + x_4^2 = 40 \\ - & 1 \leq x_1, x_2, x_3, x_4 \leq 5 + & 1 \leq x_1, x_2, x_3, x_4 \leq 5 \end{array} \] $$ @@ -63,7 +61,7 @@ { assert( fg.size() == 3 ); assert( x.size() == 4 ); - // Fortran style indexing + // Fortran style indexing AD x1 = x[0]; AD x2 = x[1]; AD x3 = x[2]; @@ -79,14 +77,14 @@ } }; } - + bool get_started(void) { bool ok = true; size_t i; typedef CPPAD_TESTVECTOR( double ) Dvector; // number of independent variables (domain dimension for f and g) - size_t nx = 4; + size_t nx = 4; // number of constraints (range dimension for g) size_t ng = 2; // initial value of the independent variables @@ -104,25 +102,25 @@ // lower and upper limits for g Dvector gl(ng), gu(ng); gl[0] = 25.0; gu[0] = 1.0e19; - gl[1] = 40.0; gu[1] = 40.0; + gl[1] = 40.0; gu[1] = 40.0; // object that computes objective and constraints FG_eval fg_eval; - // options + // options std::string options; // turn off any printing - options += "Integer print_level 0\n"; + options += "Integer print_level 0\n"; options += "String sb yes\n"; // maximum number of iterations options += "Integer max_iter 10\n"; // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) options += "Numeric tol 1e-6\n"; // derivative testing options += "String derivative_test second-order\n"; - // maximum amount of random pertubation; e.g., + // maximum amount of random pertubation; e.g., // when evaluation finite diff options += "Numeric point_perturbation_radius 0.\n"; @@ -134,8 +132,8 @@ options, xi, xl, xu, gl, gu, fg_eval, solution ); // - // Check some of the solution values - // + // Check some of the solution values + // ok &= solution.status == CppAD::ipopt::solve_result::success; // double check_x[] = { 1.000000, 4.743000, 3.82115, 1.379408 }; diff -Nru cppad-2015.00.00.9/example/ipopt_solve/makefile.am cppad-2016.00.00.1/example/ipopt_solve/makefile.am --- cppad-2015.00.00.9/example/ipopt_solve/makefile.am 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ipopt_solve/makefile.am 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2661 2012-12-28 16:23:17Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -16,7 +16,7 @@ # check_PROGRAMS = solve # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ diff -Nru cppad-2015.00.00.9/example/ipopt_solve/makefile.in cppad-2016.00.00.1/example/ipopt_solve/makefile.in --- cppad-2015.00.00.9/example/ipopt_solve/makefile.in 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ipopt_solve/makefile.in 2016-02-09 08:31:55.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = solve$(EXEEXT) subdir = example/ipopt_solve -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(srcdir)/test.sh.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test.sh CONFIG_CLEAN_VPATH_FILES = @@ -150,6 +159,8 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/test.sh.in \ + $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -180,12 +191,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -266,26 +277,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -324,7 +338,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ @@ -362,7 +376,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu example/ipopt_solve/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu example/ipopt_solve/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -618,6 +631,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check ./test.sh diff -Nru cppad-2015.00.00.9/example/ipopt_solve/ode_inverse.cpp cppad-2016.00.00.1/example/ipopt_solve/ode_inverse.cpp --- cppad-2015.00.00.9/example/ipopt_solve/ode_inverse.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ipopt_solve/ode_inverse.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_inverse.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: ode_inverse.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,9 +15,8 @@ $$ $section ODE Inverse Problem Definitions: Source Code$$ -$index ode, inverse example$$ -$index inverse, ode example$$ -$index example, ode inverse$$ +$mindex example$$ + $head Purpose$$ This example demonstrates how to invert for parameters @@ -27,19 +26,19 @@ We consider the following ordinary differential equation: $latex \[ \begin{array}{rcl} - \partial_t y_0 ( t , a ) & = & - a_1 * y_0 (t, a ) + \partial_t y_0 ( t , a ) & = & - a_1 * y_0 (t, a ) \\ \partial_t y_1 (t , a ) & = & + a_1 * y_0 (t, a ) - a_2 * y_1 (t, a ) \end{array} \] $$ with the initial conditions $latex \[ - y_0 (0 , a) = ( a_0 , 0 )^\R{T} + y_0 (0 , a) = ( a_0 , 0 )^\R{T} \] $$ -Our forward problem is stated as follows: +Our forward problem is stated as follows: Given $latex a \in \B{R}^3$$ -determine the value of $latex y ( t , a ) $$, -for $latex t \in R$$, that solves the initial value problem above. +determine the value of $latex y ( t , a ) $$, +for $latex t \in R$$, that solves the initial value problem above. $head Measurements$$ Suppose we are also given measurement times $latex s \in \B{R}^5$$ @@ -48,7 +47,7 @@ $latex \[ z_i = y_1 ( s_{i+1} , a) + e_i \] $$ -where $latex e_{i-1} \sim {\bf N} (0 , \sigma^2 )$$ +where $latex e_{i-1} \sim {\bf N} (0 , \sigma^2 )$$ is the measurement noise, and $latex \sigma > 0$$ is the standard deviation of the noise. @@ -59,29 +58,29 @@ \begin{array}{rcl} y_0 (t , a) & = & a_0 * \exp( - a_1 * t ) \\ - y_1 (t , a) & = & + y_1 (t , a) & = & a_0 * a_1 * \frac{\exp( - a_2 * t ) - \exp( -a_1 * t )}{ a_1 - a_2 } \end{array} \] $$ $subhead Simulation Parameter Values$$ $table -$latex \bar{a}_0 = 1$$ $pre $$ $cnext - initial value of $latex y_0 (t, a)$$ +$latex \bar{a}_0 = 1$$ $pre $$ $cnext + initial value of $latex y_0 (t, a)$$ $rnext -$latex \bar{a}_1 = 2$$ $pre $$ $cnext +$latex \bar{a}_1 = 2$$ $pre $$ $cnext transfer rate from compartment zero to compartment one $rnext -$latex \bar{a}_2 = 1$$ $pre $$ $cnext +$latex \bar{a}_2 = 1$$ $pre $$ $cnext transfer rate from compartment one to outside world $rnext -$latex \sigma = 0$$ $pre $$ $cnext +$latex \sigma = 0$$ $pre $$ $cnext standard deviation of measurement noise $rnext $latex e_i = 0$$ $pre $$ $cnext simulated measurement noise, $latex i = 1 , \ldots , Nz$$ $rnext -$latex s_i = i * .5$$ $pre $$ $cnext +$latex s_i = i * .5$$ $pre $$ $cnext time corresponding to the $th i$$ measurement, $latex i = 0 , \ldots , 3$$ $tend @@ -90,11 +89,11 @@ The simulated measurement values are given by the equation $latex \[ \begin{array}{rcl} -z_i +z_i & = & e_i + y_1 ( s_{i+1} , \bar{a} ) \\ -& = & -\bar{a}_0 * \bar{a}_1 * +& = & +\bar{a}_0 * \bar{a}_1 * \frac{\exp( - \bar{a}_2 * s_i ) - \exp( -\bar{a}_1 * s_i )} { \bar{a}_1 - \bar{a}_2 } \end{array} @@ -107,8 +106,8 @@ solves the following optimization problem $latex \[ \begin{array}{rcl} -{\rm minimize} \; - & \sum_{i=0}^3 ( z_i - y_1 ( s_{i+1} , a ) )^2 +{\rm minimize} \; + & \sum_{i=0}^3 ( z_i - y_1 ( s_{i+1} , a ) )^2 & \;{\rm w.r.t} \; a \in \B{R}^3 \end{array} \] $$ @@ -117,10 +116,10 @@ We are given a number of approximation points per measurement interval $latex np$$ and define the time grid $latex t \in \B{R}^{4 \cdot np + 1}$$ as follows: -$latex t_0 = s_0$$ and +$latex t_0 = s_0$$ and for $latex i = 0 , 1 , 2, 3$$, $latex j = 1 , \ldots , np$$ $latex \[ - t_{i \cdot np + j} = s_i + (s_{i+1} - s{i}) \frac{i}{np} + t_{i \cdot np + j} = s_i + (s_{i+1} - s{i}) \frac{i}{np} \] $$ We note that for $latex i = 1 , \ldots , 4$$, $latex t_{i \cdot np} = s_i$$. @@ -141,33 +140,33 @@ \] $$ $head Solution Method$$ -We use constraints to embed the +We use constraints to embed the forward problem in the inverse problem. To be specific, we solve the optimization problem $latex \[ \begin{array}{rcl} -{\rm minimize} +{\rm minimize} & \sum_{i=0}^3 ( z_i - y_1^{(i+1) \cdot np} )^2 -& \; {\rm w.r.t} \; a \in \B{R}^3 +& \; {\rm w.r.t} \; a \in \B{R}^3 \; y^0 \in \B{R}^2 , \ldots , y^{3 \cdot np -1} \in \B{R}^2 \\ {\rm subject \; to} 0 = y^0 - ( a_0 , 0 )^\R{T} \\ - & 0 = y^k - y^{k-1} - + & 0 = y^k - y^{k-1} - \frac{G( y^k , a ) + G( y^{k-1} , a ) }{2} (t_k - t_{k-1}) & \; {\rm for} \; k = 1 , \ldots , 4 \cdot np \end{array} \] $$ -The code below we using the notation +The code below we using the notation $latex x \in \B{3 + (4 \cdot np + 1) \cdot 2}$$ defined by $latex \[ - x = \left( - a_0, a_1, a_2 , - y_0^0, y_1^0, - \ldots , - y_0^{4 \cdot np}, y_1^{4 \cdots np} - \right) + x = \left( + a_0, a_1, a_2 , + y_0^0, y_1^0, + \ldots , + y_0^{4 \cdot np}, y_1^{4 \cdots np} + \right) \] $$ $head Source$$ @@ -189,7 +188,7 @@ // value of a during simulation a[0], a[1], a[2] double a_[] = {2.0, 1.0, 0.5}; // number of components in a - size_t na_ = sizeof(a_) / sizeof(a_[0]); + size_t na_ = sizeof(a_) / sizeof(a_[0]); // function used to simulate data double yone(double t) @@ -198,7 +197,7 @@ } // time points were we have data (no data at first point) - double s_[] = {0.0, 0.5, 1.0, 1.5, 2.0 }; + double s_[] = {0.0, 0.5, 1.0, 1.5, 2.0 }; // Simulated data for case with no noise (first point is not used) double z_[] = {yone(s_[1]), yone(s_[2]), yone(s_[3]), yone(s_[4])}; @@ -231,7 +230,7 @@ AD y_1 = x[na_ + 2 * k + 1]; AD dif = z_[i] - y_1; fg[0] += dif * dif; - } + } // constraint corresponding to initial value y(0, a) // Note that this constraint is invariant with size of dt @@ -241,7 +240,7 @@ // constraints corresponding to trapozoidal approximation for(i = 0; i < nz_; i++) { // spacing between grid point - double dt = (s_[i+1] - s_[i]) / static_cast(np_); + double dt = (s_[i+1] - s_[i]) / static_cast(np_); for(j = 1; j <= np_; j++) { k = i * np_ + j; // compute derivative at y^k @@ -265,7 +264,7 @@ fg[2 + 2*k ] /= dt; } } - } + } }; } bool ode_inverse(void) @@ -296,18 +295,18 @@ // object defining both f(x) and g(x) FG_eval fg_eval; - // options + // options std::string options; // Use sparse matrices for calculation of Jacobians and Hessians // with forward mode for Jacobian (seems to be faster for this case). options += "Sparse true forward\n"; // turn off any printing - options += "Integer print_level 0\n"; + options += "Integer print_level 0\n"; options += "String sb yes\n"; // maximum number of iterations options += "Integer max_iter 30\n"; // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) options += "Numeric tol 1e-6\n"; @@ -319,8 +318,8 @@ options, xi, xl, xu, gl, gu, fg_eval, solution ); // - // Check some of the solution values - // + // Check some of the solution values + // ok &= solution.status == CppAD::ipopt::solve_result::success; // double rel_tol = 1e-4; // relative tolerance diff -Nru cppad-2015.00.00.9/example/ipopt_solve/retape.cpp cppad-2016.00.00.1/example/ipopt_solve/retape.cpp --- cppad-2015.00.00.9/example/ipopt_solve/retape.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ipopt_solve/retape.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: retape.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: retape.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,10 +20,9 @@ IpoptDir CppAD $$ -$index retape, ipopt_solve$$ -$index ipopt_solve, retape$$ $section Nonlinear Programming Retaping: Example and Test$$ +$mindex retape ipopt_solve$$ $head Purpose$$ This example program demonstrates a case were the $code ipopt::solve$$ @@ -60,13 +59,13 @@ } }; } - + bool retape(void) { bool ok = true; typedef CPPAD_TESTVECTOR( double ) Dvector; // number of independent variables (domain dimension for f and g) - size_t nx = 1; + size_t nx = 1; // number of constraints (range dimension for g) size_t ng = 0; // initial value, lower and upper limits, for the independent variables @@ -80,22 +79,22 @@ // object that computes objective and constraints FG_eval fg_eval; - // options + // options std::string options; // retape operation sequence for each new x options += "Retape true\n"; // turn off any printing - options += "Integer print_level 0\n"; + options += "Integer print_level 0\n"; options += "String sb yes\n"; // maximum number of iterations options += "Integer max_iter 10\n"; // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) options += "Numeric tol 1e-9\n"; // derivative testing options += "String derivative_test second-order\n"; - // maximum amount of random pertubation; e.g., + // maximum amount of random pertubation; e.g., // when evaluation finite diff options += "Numeric point_perturbation_radius 0.\n"; @@ -107,8 +106,8 @@ options, xi, xl, xu, gl, gu, fg_eval, solution ); // - // Check some of the solution values - // + // Check some of the solution values + // ok &= solution.status == CppAD::ipopt::solve_result::success; double rel_tol = 1e-6; // relative tolerance double abs_tol = 1e-6; // absolute tolerance diff -Nru cppad-2015.00.00.9/example/ipopt_solve/solve.cpp cppad-2016.00.00.1/example/ipopt_solve/solve.cpp --- cppad-2015.00.00.9/example/ipopt_solve/solve.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ipopt_solve/solve.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: solve.cpp 2859 2013-05-28 06:03:21Z bradbell $ */ +/* $Id: solve.cpp 3746 2015-11-09 04:50:27Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -51,11 +51,13 @@ int main(void) { bool ok = true; + // This line is used by test_one.sh + // external compiled tests ok &= Run( get_started, "get_started" ); ok &= Run( ode_inverse, "ode_inverse" ); ok &= Run( retape, "retape" ); - + // check for errors using std::cout; using std::endl; diff -Nru cppad-2015.00.00.9/example/ipopt_solve/test_one.sh.in cppad-2016.00.00.1/example/ipopt_solve/test_one.sh.in --- cppad-2015.00.00.9/example/ipopt_solve/test_one.sh.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/ipopt_solve/test_one.sh.in 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,87 @@ +#! /bin/bash -e +# $Id$ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# +# CppAD is distributed under multiple licenses. This distribution is under +# the terms of the +# GNU General Public License Version 3. +# +# A copy of this license is included in the COPYING file of this distribution. +# Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +# ----------------------------------------------------------------------------- +# Run one of the tests +if [ "$1" = "" ] +then + echo "usage: test_one.sh file [extra]" + echo "file is the *.cpp file name with extension" + echo "and extra is extra options for g++ command" + exit 1 +fi +if [ ! -e "$1" ] +then + echo "Cannot find the file $1" + exit 1 +fi +# determine the function name +fun=`grep "^bool *[a-zA-Z0-9_]* *( *void *)" $1 | tail -1 | \ + sed -e "s/^bool *\([a-zA-Z0-9_]*\) *( *void *)/\1/"` +# +if [ -e test_one.exe ] +then + rm test_one.exe +fi +if [ -e test_one.cpp ] +then + rm test_one.cpp +fi +sed < solve.cpp > test_one.cpp \ +-e '/ok *\&= *Run( /d' \ +-e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" +# +cxxflags='@cppad_cxx_flags@' +if echo "$fun" | grep 'eigen' > /dev/null +then + cxxflags=`echo "$cxxflags" | sed -e 's|-Wshadow||'` +fi +cmd="g++ test_one.cpp $*" +if [ -e @colpack_prefix@/include ] +then + cmd="$cmd ../../cppad/local/cppad_colpack.cpp" +fi +cmd="$cmd + -o test_one.exe + $cxxflags + -g + -fopenmp + -lboost_thread + -lpthread + -I../.. +" +if [ -e @colpack_prefix@/include ] +then + cmd="$cmd -I@colpack_prefix@/include" +fi +if [ -e @ipopt_prefix@/include ] +then + cmd="$cmd -I@ipopt_prefix@/include" + ipopt_libs=`pkg-config --libs ipopt` + cmd="$cmd $ipopt_libs" +fi +for lib in lib lib64 +do + if [ -e @colpack_prefix@/$lib ] + then + cmd="$cmd -L@colpack_prefix@/$lib -lColPack" + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@colpack_prefix@/$lib" + fi +done +echo $cmd +$cmd +# +echo "./test_one.exe" +if ! ./test_one.exe +then + exit 1 +fi +exit 0 diff -Nru cppad-2015.00.00.9/example/jac_lu_det.cpp cppad-2016.00.00.1/example/jac_lu_det.cpp --- cppad-2015.00.00.9/example/jac_lu_det.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/jac_lu_det.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: jac_lu_det.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: jac_lu_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,6 @@ $$ $section Gradient of Determinant Using Lu Factorization: Example and Test$$ -$mindex gradient Lu$$ -$index example, gradient$$ -$index test, gradient$$ -$index example, Lu$$ -$index test, Lu$$ $code $verbatim%example/jac_lu_det.cpp%0%// BEGIN C++%// END C++%1%$$ diff -Nru cppad-2015.00.00.9/example/jac_minor_det.cpp cppad-2016.00.00.1/example/jac_minor_det.cpp --- cppad-2015.00.00.9/example/jac_minor_det.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/jac_minor_det.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: jac_minor_det.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: jac_minor_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,11 +17,7 @@ $$ $section Gradient of Determinant Using Expansion by Minors: Example and Test$$ -$mindex gradient minors expansion$$ -$index example, gradient$$ -$index test, gradient$$ -$index example, minors expansion$$ -$index test, minors expansion$$ +$mindex minors$$ $code $verbatim%example/jac_minor_det.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -65,7 +61,7 @@ Independent(X); // comupute the determinant - D[0] = Det(X); + D[0] = Det(X); // create the function object ADFun f(X, D); diff -Nru cppad-2015.00.00.9/example/jacobian.cpp cppad-2016.00.00.1/example/jacobian.cpp --- cppad-2015.00.00.9/example/jacobian.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/jacobian.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: jacobian.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,10 +18,8 @@ $$ $section Jacobian: Example and Test$$ +$mindex Jacobian$$ -$index Jacobian$$ -$index example, Jacobian$$ -$index test, Jacobian$$ $code $verbatim%example/jacobian.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -34,7 +32,7 @@ # include namespace { // --------------------------------------------------------- // define the template function JacobianCases in empty namespace -template +template bool JacobianCases() { bool ok = true; using CppAD::AD; @@ -89,7 +87,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool Jacobian(void) diff -Nru cppad-2015.00.00.9/example/limits.cpp cppad-2016.00.00.1/example/limits.cpp --- cppad-2015.00.00.9/example/limits.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/limits.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -/* $Id: limits.cpp 2722 2013-01-06 16:52:46Z bradbell $ */ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin limits.cpp$$ -$spell -$$ - -$section Numeric Limits: Example and Test$$ -$index limits$$ -$index example, limits$$ -$index test, limits$$ - -$code -$verbatim%example/limits.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ - -# ifdef _MSC_VER -// Supress Microsoft compiler warning about possible loss of precision, -// in the constructors (when converting to std::complex) -// Float one = 1 -// Float two = 2 -// 1 and 2 are small enough so no loss of precision when converting to float. -# pragma warning(disable:4244) -# endif - -# include -# include - -namespace { - typedef CppAD::AD Float; - // - // ----------------------------------------------------------------- - bool check_epsilon(void) - { bool ok = true; - Float eps = CppAD::numeric_limits::epsilon(); - Float eps2 = eps / 2.0; - Float check = 1.0 + eps; - ok &= 1.0 != check; - check = 1.0 + eps2; - ok &= 1.0 == check; - return ok; - } - // ----------------------------------------------------------------- - bool check_min(void) - { bool ok = true; - Float min = CppAD::numeric_limits::min(); - Float eps = CppAD::numeric_limits::epsilon(); - // - Float match = (min / 100. ) * 100.; - ok &= abs(match/min - 1.0) > 3.0 * eps; - // - match = (min * 100.) / (100. * (1.0 - eps)); - ok &= abs(match / min - 1.0) < 3.0 * eps; - return ok; - } - // ----------------------------------------------------------------- - bool check_max(void) - { bool ok = true; - Float max = CppAD::numeric_limits::max(); - Float eps = CppAD::numeric_limits::epsilon(); - // - Float match = (max * 100.) / 100.; - ok &= abs(match / max - 1.0) > 3.0 * eps; - // - match = (max / 100. ) * (100. * (1.0 - eps)); - ok &= abs(match/max - 1.0) < 3.0 * eps; - return ok; - } -} - -bool limits(void) -{ bool ok = true; - - ok &= check_epsilon(); - ok &= check_max(); - ok &= check_min(); - - return ok; -} -// END C++ diff -Nru cppad-2015.00.00.9/example/log10.cpp cppad-2016.00.00.1/example/log10.cpp --- cppad-2015.00.00.9/example/log10.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/log10.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: log10.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: log10.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section The AD log10 Function: Example and Test$$ -$index log10, AD example$$ -$index example, AD log10$$ -$index test, AD log10$$ $code $verbatim%example/log10.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -32,7 +29,7 @@ # include -bool Log10(void) +bool log10(void) { bool ok = true; using CppAD::AD; @@ -49,17 +46,17 @@ // ten raised to the x0 power AD ten = 10.; - AD pow_10_x0 = CppAD::pow(ten, x[0]); + AD pow_10_x0 = CppAD::pow(ten, x[0]); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::log10(pow_10_x0); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0, 1e-10 , 1e-10); // forward computation of first partial w.r.t. x[0] diff -Nru cppad-2015.00.00.9/example/log1p.cpp cppad-2016.00.00.1/example/log1p.cpp --- cppad-2015.00.00.9/example/log1p.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/log1p.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,88 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin log1p.cpp$$ +$spell + expm1 + log1p +$$ + +$section The AD log1p Function: Example and Test$$ + +$code +$verbatim%example/log1p.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# include + +bool log1p(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // a temporary value + AD expm1_of_x0 = CppAD::expm1(x[0]); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = CppAD::log1p(expm1_of_x0); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 1., eps, eps); + + // use a VecAD::reference object with log1p + CppAD::VecAD v(1); + AD zero(0); + v[zero] = expm1_of_x0; + AD result = CppAD::log1p(v[zero]); + ok &= NearEqual(result, x0, eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/example/log.cpp cppad-2016.00.00.1/example/log.cpp --- cppad-2015.00.00.9/example/log.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/log.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: log.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: log.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $section The AD log Function: Example and Test$$ -$index log, AD example$$ -$index example, AD log$$ -$index test, AD log$$ $code $verbatim%example/log.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -33,7 +30,7 @@ # include -bool Log(void) +bool log(void) { bool ok = true; using CppAD::AD; @@ -51,15 +48,15 @@ // a temporary value AD exp_of_x0 = CppAD::exp(x[0]); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::log(exp_of_x0); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0, 1e-10 , 1e-10); // forward computation of first partial w.r.t. x[0] diff -Nru cppad-2015.00.00.9/example/lu_factor.cpp cppad-2016.00.00.1/example/lu_factor.cpp --- cppad-2015.00.00.9/example/lu_factor.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/lu_factor.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: lu_factor.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: lu_factor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,8 @@ $$ $section LuFactor: Example and Test$$ +$mindex LuFactor$$ -$index example, LuFactor$$ -$index test, LuFactor$$ $code $verbatim%example/lu_factor.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -32,9 +31,9 @@ // BEGIN C++ # include // for rand function -# include // for CppAD::LuFactor -# include // for CppAD::NearEqual -# include // for CppAD::vector +# include // for CppAD::LuFactor +# include // for CppAD::NearEqual +# include // for CppAD::vector bool LuFactor(void) { bool ok = true; @@ -44,7 +43,7 @@ using std::srand; # endif - size_t n = 5; // number rows in A + size_t n = 5; // number rows in A double rand_max = double(RAND_MAX); // maximum rand value double sum; // element of L * U double pij; // element of permuted A @@ -77,7 +76,7 @@ } } } - + // Extract L from LU for(i = 0; i < n; i++) { // elements along and below the diagonal @@ -87,7 +86,7 @@ for(j = i+1; j < n; j++) L[i * n + j] = 0.; } - + // Extract U from LU for(i = 0; i < n; i++) { // elements below the diagonal @@ -100,7 +99,7 @@ U[i * n + j] = LU[ ip[i] * n + jp[j] ]; } - // Compute L * U + // Compute L * U for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { // compute element (i,j) entry in L * U diff -Nru cppad-2015.00.00.9/example/lu_invert.cpp cppad-2016.00.00.1/example/lu_invert.cpp --- cppad-2015.00.00.9/example/lu_invert.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/lu_invert.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: lu_invert.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: lu_invert.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,8 @@ $$ $section LuInvert: Example and Test$$ +$mindex LuInvert$$ -$index example, LuInvert$$ -$index test, LuInvert$$ $code $verbatim%example/lu_invert.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -33,9 +32,9 @@ // BEGIN C++ # include // for rand function -# include // for CppAD::LuInvert -# include // for CppAD::NearEqual -# include // for CppAD::vector +# include // for CppAD::LuInvert +# include // for CppAD::NearEqual +# include // for CppAD::vector bool LuInvert(void) { bool ok = true; @@ -45,18 +44,18 @@ using std::srand; # endif - size_t n = 7; // number rows in A + size_t n = 7; // number rows in A size_t m = 3; // number columns in B double rand_max = double(RAND_MAX); // maximum rand value double sum; // element of L * U size_t i, j, k; // temporary indices // dimension matrices - CppAD::vector + CppAD::vector A(n*n), X(n*m), B(n*m), LU(n*n), L(n*n), U(n*n); // seed the random number generator - srand(123); + srand(123); // pivot vectors CppAD::vector ip(n); @@ -78,7 +77,7 @@ // chose U, a random upper triangular matrix with ones on diagonal for(i = 0; i < n; i++) { for(j = 0; j < i; j++) - U [i * n + j] = 0.; + U [i * n + j] = 0.; U[ i * n + i ] = 1.; for(j = i+1; j < n; j++) U [i * n + j] = rand() / rand_max; @@ -95,7 +94,7 @@ for(j = i+1; j < n; j++) LU [ ip[i] * n + jp[j] ] = U[i * n + j]; } - // set A to a permuted version of L * U + // set A to a permuted version of L * U for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { // compute (i,j) entry in permuted matrix diff -Nru cppad-2015.00.00.9/example/lu_ratio.cpp cppad-2016.00.00.1/example/lu_ratio.cpp --- cppad-2015.00.00.9/example/lu_ratio.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/lu_ratio.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: lu_ratio.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: lu_ratio.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,8 @@ $$ $section LuRatio: Example and Test$$ +$mindex LuRatio$$ -$index example, LuRatio$$ -$index test, LuRatio$$ $code $verbatim%example/lu_ratio.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -39,9 +38,9 @@ CppAD::ADFun *NewFactor( size_t n , - const CPPAD_TESTVECTOR(double) &x , + const CPPAD_TESTVECTOR(double) &x , bool &ok , - CPPAD_TESTVECTOR(size_t) &ip , + CPPAD_TESTVECTOR(size_t) &ip , CPPAD_TESTVECTOR(size_t) &jp ) { using CppAD::AD; using CppAD::ADFun; @@ -82,7 +81,7 @@ } } } - return FunPtr; + return FunPtr; } bool CheckLuFactor( size_t n , @@ -90,7 +89,7 @@ const CPPAD_TESTVECTOR(double) &y , const CPPAD_TESTVECTOR(size_t) &ip , const CPPAD_TESTVECTOR(size_t) &jp ) -{ bool ok = true; +{ bool ok = true; double sum; // element of L * U double pij; // element of permuted x @@ -121,7 +120,7 @@ U[i * n + j] = y[ ip[i] * n + jp[j] ]; } - // Compute L * U + // Compute L * U for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { // compute element (i,j) entry in L * U @@ -142,7 +141,7 @@ bool LuRatio(void) { bool ok = true; - size_t n = 2; // number rows in A + size_t n = 2; // number rows in A double ratio; // values for independent and dependent variables @@ -175,7 +174,7 @@ // check to see if we need to refactor matrix ok &= (ratio > 10.); if( ratio > 10. ) - { delete FunPtr; // to avoid a memory leak + { delete FunPtr; // to avoid a memory leak FunPtr = NewFactor(n, x, ok, ip, jp); } diff -Nru cppad-2015.00.00.9/example/lu_solve.cpp cppad-2016.00.00.1/example/lu_solve.cpp --- cppad-2015.00.00.9/example/lu_solve.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/lu_solve.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: lu_solve.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: lu_solve.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,11 +20,6 @@ $section LuSolve With Complex Arguments: Example and Test$$ -$index complex, LuSolve$$ -$index example, LuSolve$$ -$index test, LuSolve$$ -$index example, complex$$ -$index test, complex$$ $code $verbatim%example/lu_solve.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -35,9 +30,9 @@ // BEGIN C++ -# include // for CppAD::LuSolve -# include // for CppAD::NearEqual -# include // for CppAD::vector +# include // for CppAD::LuSolve +# include // for CppAD::NearEqual +# include // for CppAD::vector # include // for std::complex typedef std::complex Complex; // define the Complex type @@ -65,8 +60,8 @@ for(j = 0; j < n; j++) for(k = 0; k < m; k++) S[ j * m + k ] = Complex(j, j + k); - - // set B = A * S + + // set B = A * S size_t ik; Complex sum; for(k = 0; k < m; k++) diff -Nru cppad-2015.00.00.9/example/lu_vec_ad.cpp cppad-2016.00.00.1/example/lu_vec_ad.cpp --- cppad-2015.00.00.9/example/lu_vec_ad.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/lu_vec_ad.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: lu_vec_ad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: lu_vec_ad.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,14 +22,9 @@ Cpp $$ -$index LuVecAD$$ -$index Lu, linear equation$$ -$index determinant, Lu$$ -$index solve, linear equation$$ -$index equation, solve linear$$ -$index linear, solve equation$$ $section Lu Factor and Solve with Recorded Pivoting$$ +$mindex LuVecAD linear equation determinant$$ $pre $$ @@ -66,7 +61,7 @@ $$ It is often the case that $code LuSolve$$ is faster than $code LuVecAD$$ when $code LuSolve$$ -uses a simple vector class with +uses a simple vector class with $cref/elements of type double/SimpleVector/Elements of Specified Type/$$, but the corresponding $cref ADFun$$ objects have a fixed set of pivoting operations. @@ -84,13 +79,13 @@ (The length of $latex A$$ must be equal to $latex n * m $$.) $head n$$ -is the number of rows in +is the number of rows in $icode Matrix$$, $icode Rhs$$, and $icode Result$$. $head m$$ -is the number of columns in +is the number of columns in $icode Rhs$$ and $icode Result$$. It is ok for $icode m$$ to be zero which is reasonable when @@ -99,7 +94,7 @@ $head Matrix$$ On input, this is an -$latex n \times n$$ matrix containing the variable coefficients for +$latex n \times n$$ matrix containing the variable coefficients for the equation we wish to solve. On output, the elements of $icode Matrix$$ have been overwritten and are not specified. @@ -122,7 +117,7 @@ $head logdet$$ On input, the value of $icode logdet$$ does not matter. -On output, it has been set to the +On output, it has been set to the log of the determinant of $icode Matrix$$ (but not quite). To be more specific, if $icode signdet$$ is the value returned by $code LuVecAD$$, @@ -196,8 +191,8 @@ // singular matrix Type singular = 0.; - // some constants - Type M(m); + // some constants + Type M(m); Type N(n); Type One(1); Type Zero(0); @@ -220,7 +215,7 @@ for(p = 0; p < N; p += 1.) { - // determine row and column corresponding to element of + // determine row and column corresponding to element of // maximum absolute value in remaining part of Matrix imax = N; jmax = N; @@ -245,7 +240,7 @@ } assert( (imax < N) & (jmax < N) ); - + // switch rows so max absolute element is in row p index = ip[p]; ip[p] = ip[imax]; @@ -261,7 +256,7 @@ // if imax != p, switch sign of determinant signdet = CondExpEq(jmax, p, signdet, -signdet); - + // pivot using the max absolute element itmp = ip[p] * N; index = itmp + jp[p]; @@ -276,7 +271,7 @@ signdet = CondExpGe(pivot, Zero, signdet, - signdet); /* - Reduce by the elementary transformations that maps + Reduce by the elementary transformations that maps Matrix( ip[p], jp[p] ) to one and Matrix( ip[i], jp[p] ) to zero for i = p + 1., ... , n-1 */ @@ -309,12 +304,12 @@ for(j = p + 1.; j < N; j += 1.) { index = itmp + jp[j]; jndex = jtmp + jp[j]; - Matrix[ index ] = Matrix[ index ] + Matrix[ index ] = Matrix[ index ] - etmp * Matrix[ jndex ]; } itmp = ip[i] * M; - jtmp = ip[p] * M; + jtmp = ip[p] * M; for(k = 0; k < M; k += 1.) { index = itmp + k; @@ -343,7 +338,7 @@ { index = ip[i] * M + k; jndex = ip[i] * N + jp[p]; - Rhs[ index ] = Rhs[ index ] + Rhs[ index ] = Rhs[ index ] - etmp * Matrix[ jndex ]; } } diff -Nru cppad-2015.00.00.9/example/lu_vec_ad.hpp cppad-2016.00.00.1/example/lu_vec_ad.hpp --- cppad-2015.00.00.9/example/lu_vec_ad.hpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/lu_vec_ad.hpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: lu_vec_ad.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_LU_VEC_AD_INCLUDED -# define CPPAD_LU_VEC_AD_INCLUDED +// $Id: lu_vec_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_LU_VEC_AD_HPP +# define CPPAD_LU_VEC_AD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/example/lu_vec_ad_ok.cpp cppad-2016.00.00.1/example/lu_vec_ad_ok.cpp --- cppad-2015.00.00.9/example/lu_vec_ad_ok.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/lu_vec_ad_ok.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: lu_vec_ad_ok.cpp 2870 2013-07-28 17:00:59Z bradbell $ */ +// $Id: lu_vec_ad_ok.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,10 +19,8 @@ $$ $section Lu Factor and Solve With Recorded Pivoting: Example and Test$$ +$mindex record pivot$$ -$index Lu, record pivot$$ -$index example, Lu record pivot$$ -$index test, Lu record pivot$$ $code $verbatim%example/lu_vec_ad_ok.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -88,7 +86,7 @@ for(j = 0; j < n; j++) for(k = 0; k < m; k++) Rhs[ j * m + k ] = rhs[ j * m + k ]; - + // Declare independent variables Independent(A); @@ -130,16 +128,16 @@ ok &= NearEqual( rhs[i * m + k], sum, 1e-10, 1e-10 ); } } - - CPPAD_TESTVECTOR(double) y2(1 + n * m); - CPPAD_TESTVECTOR(double) A2(n * n); - for(i = 0; i < n * n; i++) - A[i] = A2[i] = a2[i]; - - - y2 = f.Forward(0, A2); - determinant = Det(A); - ok &= NearEqual(y2[ n * m], Value(determinant), 1e-10, 1e-10); + + CPPAD_TESTVECTOR(double) y2(1 + n * m); + CPPAD_TESTVECTOR(double) A2(n * n); + for(i = 0; i < n * n; i++) + A[i] = A2[i] = a2[i]; + + + y2 = f.Forward(0, A2); + determinant = Det(A); + ok &= NearEqual(y2[ n * m], Value(determinant), 1e-10, 1e-10); // Check solution of Rhs = A2 * Result for(k = 0; k < m; k++) diff -Nru cppad-2015.00.00.9/example/makefile.am cppad-2016.00.00.1/example/makefile.am --- cppad-2015.00.00.9/example/makefile.am 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/makefile.am 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3526 2014-12-29 21:56:45Z bradbell $ +# $Id: makefile.am 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -18,7 +18,7 @@ ADOLC_SRC_FILES = mul_level_adolc.cpp mul_level_adolc_ode.cpp ADOLC_EXTRA_FILES = ADOLC_LIB = -ladolc -lColPack -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64 -ADOLC_FLAGS = -DCPPAD_ADOLC_EXAMPLES -I$(ADOLC_DIR)/include +ADOLC_FLAGS = -DCPPAD_ADOLC_EXAMPLES -I$(ADOLC_DIR)/include else ADOLC_EXTRA_FILES = mul_level_adolc.cpp mul_level_adolc_ode.cpp ADOLC_SRC_FILES = @@ -37,11 +37,11 @@ libeigen_a_CXXFLAGS = \ -g $(CXX_FLAGS_EIGEN) \ -DCPPAD_EIGEN_EXAMPLES \ - -I$(EIGEN_DIR)/include + -I$(EIGEN_DIR)/include else EIGEN_EXTRA_FILES = eigen_det.cpp eigen_array.cpp EIGEN_LIB = -EIGEN_FLAGS = +EIGEN_FLAGS = endif else EIGEN_EXTRA_FILES = eigen_det.cpp eigen_array.cpp @@ -52,11 +52,12 @@ # auto-tools does not support use of colpack EXTRA_DIST = \ test_one.sh.in \ - colpack.cpp \ + colpack_hes.cpp \ + colpack_jac.cpp \ $(ADOLC_EXTRA_FILES) \ $(EIGEN_EXTRA_FILES) # -check_PROGRAMS = example +check_PROGRAMS = example # if CppAD_MS_COMPILER AM_CXXFLAGS = -EHsc -g $(ADOLC_FLAGS) $(EIGEN_FLAGS) $(CXX_FLAGS) @@ -81,6 +82,7 @@ abort_recording.cpp \ abs.cpp \ acos.cpp \ + acosh.cpp \ add.cpp \ add_eq.cpp \ ad_assign.cpp \ @@ -90,14 +92,18 @@ ad_input.cpp \ ad_output.cpp \ asin.cpp \ + asinh.cpp \ atan.cpp \ + atanh.cpp \ atan2.cpp \ + azmul.cpp \ base_alloc.hpp \ base_require.cpp \ bender_quad.cpp \ bool_fun.cpp \ + bool_sparsity.cpp \ capacity_order.cpp \ - change_const.cpp \ + change_param.cpp \ check_for_nan.cpp \ check_numeric_type.cpp \ check_simple_vector.cpp \ @@ -109,12 +115,14 @@ cos.cpp \ cosh.cpp \ cppad_vector.cpp \ + dependency.cpp \ div.cpp \ div_eq.cpp \ equal_op_seq.cpp \ erf.cpp \ error_handler.cpp \ exp.cpp \ + expm1.cpp \ for_one.cpp \ for_two.cpp \ forward.cpp \ @@ -137,8 +145,9 @@ jac_lu_det.cpp \ jac_minor_det.cpp \ jacobian.cpp \ - limits.cpp \ + num_limits.cpp \ log.cpp \ + log1p.cpp \ log10.cpp \ lu_factor.cpp \ lu_invert.cpp \ @@ -162,7 +171,6 @@ ode_gear_control.cpp\ ode_stiff.cpp \ ode_taylor.cpp \ - omp_alloc.cpp \ opt_val_hes.cpp \ optimize.cpp \ par_var.cpp \ @@ -190,20 +198,24 @@ sinh.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp \ + sparse_sub_hes.cpp \ + sparsity_sub.cpp \ sqrt.cpp \ stack_machine.cpp \ sub.cpp \ sub_eq.cpp \ + sub_sparse_hes.cpp \ tan.cpp \ tanh.cpp \ tape_index.cpp \ thread_alloc.cpp \ + to_string.cpp \ unary_minus.cpp \ unary_plus.cpp \ value.cpp \ var2par.cpp \ vec_ad.cpp \ - vector_bool.cpp + vector_bool.cpp test: check ./example diff -Nru cppad-2015.00.00.9/example/makefile.in cppad-2016.00.00.1/example/makefile.in --- cppad-2015.00.00.9/example/makefile.in 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/makefile.in 2016-02-09 08:31:54.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -80,12 +90,11 @@ host_triplet = @host@ check_PROGRAMS = example$(EXEEXT) subdir = example -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(srcdir)/test_one.sh.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test_one.sh CONFIG_CLEAN_VPATH_FILES = @@ -102,55 +111,61 @@ @CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@ libeigen_a-eigen_array.$(OBJEXT) libeigen_a_OBJECTS = $(am_libeigen_a_OBJECTS) am__example_SOURCES_DIST = mul_level_adolc.cpp mul_level_adolc_ode.cpp \ - example.cpp abort_recording.cpp abs.cpp acos.cpp add.cpp \ - add_eq.cpp ad_assign.cpp ad_ctor.cpp ad_fun.cpp ad_in_c.cpp \ - ad_input.cpp ad_output.cpp asin.cpp atan.cpp atan2.cpp \ - base_alloc.hpp base_require.cpp bender_quad.cpp bool_fun.cpp \ - capacity_order.cpp change_const.cpp check_for_nan.cpp \ - check_numeric_type.cpp check_simple_vector.cpp compare.cpp \ - compare_change.cpp complex_poly.cpp cond_exp.cpp conj_grad.cpp \ - cos.cpp cosh.cpp cppad_vector.cpp div.cpp div_eq.cpp \ - equal_op_seq.cpp erf.cpp error_handler.cpp exp.cpp for_one.cpp \ - for_two.cpp forward.cpp forward_dir.cpp forward_order.cpp \ - for_sparse_jac.cpp fun_assign.cpp fun_check.cpp \ - hes_lagrangian.cpp hes_lu_det.cpp hes_minor_det.cpp \ - hessian.cpp hes_times_dir.cpp independent.cpp index_sort.cpp \ - integer.cpp interface2c.cpp interp_onetape.cpp \ - interp_retape.cpp jac_lu_det.cpp jac_minor_det.cpp \ - jacobian.cpp limits.cpp log.cpp log10.cpp lu_factor.cpp \ - lu_invert.cpp lu_ratio.cpp lu_solve.cpp lu_vec_ad.cpp \ - lu_vec_ad.hpp lu_vec_ad_ok.cpp mul.cpp mul_eq.cpp \ - mul_level.cpp mul_level_ode.cpp nan.cpp near_equal.cpp \ - near_equal_ext.cpp number_skip.cpp numeric_type.cpp \ - ode_err_control.cpp ode_err_maxabs.cpp ode_gear.cpp \ - ode_gear_control.cpp ode_stiff.cpp ode_taylor.cpp \ - omp_alloc.cpp opt_val_hes.cpp optimize.cpp par_var.cpp \ - poly.cpp pow.cpp pow_int.cpp print_for.cpp reverse_any.cpp \ - reverse_one.cpp reverse_three.cpp reverse_two.cpp rev_one.cpp \ + example.cpp abort_recording.cpp abs.cpp acos.cpp acosh.cpp \ + add.cpp add_eq.cpp ad_assign.cpp ad_ctor.cpp ad_fun.cpp \ + ad_in_c.cpp ad_input.cpp ad_output.cpp asin.cpp asinh.cpp \ + atan.cpp atanh.cpp atan2.cpp azmul.cpp base_alloc.hpp \ + base_require.cpp bender_quad.cpp bool_fun.cpp \ + bool_sparsity.cpp capacity_order.cpp change_param.cpp \ + check_for_nan.cpp check_numeric_type.cpp \ + check_simple_vector.cpp compare.cpp compare_change.cpp \ + complex_poly.cpp cond_exp.cpp conj_grad.cpp cos.cpp cosh.cpp \ + cppad_vector.cpp dependency.cpp div.cpp div_eq.cpp \ + equal_op_seq.cpp erf.cpp error_handler.cpp exp.cpp expm1.cpp \ + for_one.cpp for_two.cpp forward.cpp forward_dir.cpp \ + forward_order.cpp for_sparse_jac.cpp fun_assign.cpp \ + fun_check.cpp hes_lagrangian.cpp hes_lu_det.cpp \ + hes_minor_det.cpp hessian.cpp hes_times_dir.cpp \ + independent.cpp index_sort.cpp integer.cpp interface2c.cpp \ + interp_onetape.cpp interp_retape.cpp jac_lu_det.cpp \ + jac_minor_det.cpp jacobian.cpp num_limits.cpp log.cpp \ + log1p.cpp log10.cpp lu_factor.cpp lu_invert.cpp lu_ratio.cpp \ + lu_solve.cpp lu_vec_ad.cpp lu_vec_ad.hpp lu_vec_ad_ok.cpp \ + mul.cpp mul_eq.cpp mul_level.cpp mul_level_ode.cpp nan.cpp \ + near_equal.cpp near_equal_ext.cpp number_skip.cpp \ + numeric_type.cpp ode_err_control.cpp ode_err_maxabs.cpp \ + ode_gear.cpp ode_gear_control.cpp ode_stiff.cpp ode_taylor.cpp \ + opt_val_hes.cpp optimize.cpp par_var.cpp poly.cpp pow.cpp \ + pow_int.cpp print_for.cpp reverse_any.cpp reverse_one.cpp \ + reverse_three.cpp reverse_two.cpp rev_one.cpp \ rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp \ romberg_mul.cpp romberg_one.cpp rosen_34.cpp runge45_1.cpp \ runge45_2.cpp seq_property.cpp simple_vector.cpp sign.cpp \ sin.cpp sinh.cpp sparse_hessian.cpp sparse_jacobian.cpp \ - sqrt.cpp stack_machine.cpp sub.cpp sub_eq.cpp tan.cpp tanh.cpp \ - tape_index.cpp thread_alloc.cpp unary_minus.cpp unary_plus.cpp \ - value.cpp var2par.cpp vec_ad.cpp vector_bool.cpp + sparse_sub_hes.cpp sparsity_sub.cpp sqrt.cpp stack_machine.cpp \ + sub.cpp sub_eq.cpp sub_sparse_hes.cpp tan.cpp tanh.cpp \ + tape_index.cpp thread_alloc.cpp to_string.cpp unary_minus.cpp \ + unary_plus.cpp value.cpp var2par.cpp vec_ad.cpp \ + vector_bool.cpp @CppAD_ADOLC_TRUE@am__objects_1 = mul_level_adolc.$(OBJEXT) \ @CppAD_ADOLC_TRUE@ mul_level_adolc_ode.$(OBJEXT) am_example_OBJECTS = $(am__objects_1) example.$(OBJEXT) \ abort_recording.$(OBJEXT) abs.$(OBJEXT) acos.$(OBJEXT) \ - add.$(OBJEXT) add_eq.$(OBJEXT) ad_assign.$(OBJEXT) \ - ad_ctor.$(OBJEXT) ad_fun.$(OBJEXT) ad_in_c.$(OBJEXT) \ - ad_input.$(OBJEXT) ad_output.$(OBJEXT) asin.$(OBJEXT) \ - atan.$(OBJEXT) atan2.$(OBJEXT) base_require.$(OBJEXT) \ + acosh.$(OBJEXT) add.$(OBJEXT) add_eq.$(OBJEXT) \ + ad_assign.$(OBJEXT) ad_ctor.$(OBJEXT) ad_fun.$(OBJEXT) \ + ad_in_c.$(OBJEXT) ad_input.$(OBJEXT) ad_output.$(OBJEXT) \ + asin.$(OBJEXT) asinh.$(OBJEXT) atan.$(OBJEXT) atanh.$(OBJEXT) \ + atan2.$(OBJEXT) azmul.$(OBJEXT) base_require.$(OBJEXT) \ bender_quad.$(OBJEXT) bool_fun.$(OBJEXT) \ - capacity_order.$(OBJEXT) change_const.$(OBJEXT) \ - check_for_nan.$(OBJEXT) check_numeric_type.$(OBJEXT) \ - check_simple_vector.$(OBJEXT) compare.$(OBJEXT) \ - compare_change.$(OBJEXT) complex_poly.$(OBJEXT) \ - cond_exp.$(OBJEXT) conj_grad.$(OBJEXT) cos.$(OBJEXT) \ - cosh.$(OBJEXT) cppad_vector.$(OBJEXT) div.$(OBJEXT) \ - div_eq.$(OBJEXT) equal_op_seq.$(OBJEXT) erf.$(OBJEXT) \ - error_handler.$(OBJEXT) exp.$(OBJEXT) for_one.$(OBJEXT) \ + bool_sparsity.$(OBJEXT) capacity_order.$(OBJEXT) \ + change_param.$(OBJEXT) check_for_nan.$(OBJEXT) \ + check_numeric_type.$(OBJEXT) check_simple_vector.$(OBJEXT) \ + compare.$(OBJEXT) compare_change.$(OBJEXT) \ + complex_poly.$(OBJEXT) cond_exp.$(OBJEXT) conj_grad.$(OBJEXT) \ + cos.$(OBJEXT) cosh.$(OBJEXT) cppad_vector.$(OBJEXT) \ + dependency.$(OBJEXT) div.$(OBJEXT) div_eq.$(OBJEXT) \ + equal_op_seq.$(OBJEXT) erf.$(OBJEXT) error_handler.$(OBJEXT) \ + exp.$(OBJEXT) expm1.$(OBJEXT) for_one.$(OBJEXT) \ for_two.$(OBJEXT) forward.$(OBJEXT) forward_dir.$(OBJEXT) \ forward_order.$(OBJEXT) for_sparse_jac.$(OBJEXT) \ fun_assign.$(OBJEXT) fun_check.$(OBJEXT) \ @@ -160,32 +175,33 @@ index_sort.$(OBJEXT) integer.$(OBJEXT) interface2c.$(OBJEXT) \ interp_onetape.$(OBJEXT) interp_retape.$(OBJEXT) \ jac_lu_det.$(OBJEXT) jac_minor_det.$(OBJEXT) \ - jacobian.$(OBJEXT) limits.$(OBJEXT) log.$(OBJEXT) \ - log10.$(OBJEXT) lu_factor.$(OBJEXT) lu_invert.$(OBJEXT) \ - lu_ratio.$(OBJEXT) lu_solve.$(OBJEXT) lu_vec_ad.$(OBJEXT) \ - lu_vec_ad_ok.$(OBJEXT) mul.$(OBJEXT) mul_eq.$(OBJEXT) \ - mul_level.$(OBJEXT) mul_level_ode.$(OBJEXT) nan.$(OBJEXT) \ - near_equal.$(OBJEXT) near_equal_ext.$(OBJEXT) \ + jacobian.$(OBJEXT) num_limits.$(OBJEXT) log.$(OBJEXT) \ + log1p.$(OBJEXT) log10.$(OBJEXT) lu_factor.$(OBJEXT) \ + lu_invert.$(OBJEXT) lu_ratio.$(OBJEXT) lu_solve.$(OBJEXT) \ + lu_vec_ad.$(OBJEXT) lu_vec_ad_ok.$(OBJEXT) mul.$(OBJEXT) \ + mul_eq.$(OBJEXT) mul_level.$(OBJEXT) mul_level_ode.$(OBJEXT) \ + nan.$(OBJEXT) near_equal.$(OBJEXT) near_equal_ext.$(OBJEXT) \ number_skip.$(OBJEXT) numeric_type.$(OBJEXT) \ ode_err_control.$(OBJEXT) ode_err_maxabs.$(OBJEXT) \ ode_gear.$(OBJEXT) ode_gear_control.$(OBJEXT) \ - ode_stiff.$(OBJEXT) ode_taylor.$(OBJEXT) omp_alloc.$(OBJEXT) \ - opt_val_hes.$(OBJEXT) optimize.$(OBJEXT) par_var.$(OBJEXT) \ - poly.$(OBJEXT) pow.$(OBJEXT) pow_int.$(OBJEXT) \ - print_for.$(OBJEXT) reverse_any.$(OBJEXT) \ - reverse_one.$(OBJEXT) reverse_three.$(OBJEXT) \ - reverse_two.$(OBJEXT) rev_one.$(OBJEXT) \ - rev_sparse_hes.$(OBJEXT) rev_sparse_jac.$(OBJEXT) \ - rev_two.$(OBJEXT) romberg_mul.$(OBJEXT) romberg_one.$(OBJEXT) \ - rosen_34.$(OBJEXT) runge45_1.$(OBJEXT) runge45_2.$(OBJEXT) \ - seq_property.$(OBJEXT) simple_vector.$(OBJEXT) sign.$(OBJEXT) \ - sin.$(OBJEXT) sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \ - sparse_jacobian.$(OBJEXT) sqrt.$(OBJEXT) \ - stack_machine.$(OBJEXT) sub.$(OBJEXT) sub_eq.$(OBJEXT) \ + ode_stiff.$(OBJEXT) ode_taylor.$(OBJEXT) opt_val_hes.$(OBJEXT) \ + optimize.$(OBJEXT) par_var.$(OBJEXT) poly.$(OBJEXT) \ + pow.$(OBJEXT) pow_int.$(OBJEXT) print_for.$(OBJEXT) \ + reverse_any.$(OBJEXT) reverse_one.$(OBJEXT) \ + reverse_three.$(OBJEXT) reverse_two.$(OBJEXT) \ + rev_one.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \ + rev_sparse_jac.$(OBJEXT) rev_two.$(OBJEXT) \ + romberg_mul.$(OBJEXT) romberg_one.$(OBJEXT) rosen_34.$(OBJEXT) \ + runge45_1.$(OBJEXT) runge45_2.$(OBJEXT) seq_property.$(OBJEXT) \ + simple_vector.$(OBJEXT) sign.$(OBJEXT) sin.$(OBJEXT) \ + sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \ + sparse_jacobian.$(OBJEXT) sparse_sub_hes.$(OBJEXT) \ + sparsity_sub.$(OBJEXT) sqrt.$(OBJEXT) stack_machine.$(OBJEXT) \ + sub.$(OBJEXT) sub_eq.$(OBJEXT) sub_sparse_hes.$(OBJEXT) \ tan.$(OBJEXT) tanh.$(OBJEXT) tape_index.$(OBJEXT) \ - thread_alloc.$(OBJEXT) unary_minus.$(OBJEXT) \ - unary_plus.$(OBJEXT) value.$(OBJEXT) var2par.$(OBJEXT) \ - vec_ad.$(OBJEXT) vector_bool.$(OBJEXT) + thread_alloc.$(OBJEXT) to_string.$(OBJEXT) \ + unary_minus.$(OBJEXT) unary_plus.$(OBJEXT) value.$(OBJEXT) \ + var2par.$(OBJEXT) vec_ad.$(OBJEXT) vector_bool.$(OBJEXT) example_OBJECTS = $(am_example_OBJECTS) example_LDADD = $(LDADD) am__DEPENDENCIES_1 = @@ -263,6 +279,8 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/test_one.sh.in \ + $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -293,12 +311,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -379,26 +397,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -444,7 +465,7 @@ @CppAD_ADOLC_FALSE@ADOLC_LIB = @CppAD_ADOLC_TRUE@ADOLC_LIB = -ladolc -lColPack -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64 @CppAD_ADOLC_FALSE@ADOLC_FLAGS = -@CppAD_ADOLC_TRUE@ADOLC_FLAGS = -DCPPAD_ADOLC_EXAMPLES -I$(ADOLC_DIR)/include +@CppAD_ADOLC_TRUE@ADOLC_FLAGS = -DCPPAD_ADOLC_EXAMPLES -I$(ADOLC_DIR)/include @CppAD_EIGEN_DIR_FALSE@@CppAD_HAVE_AR_TRUE@EIGEN_EXTRA_FILES = eigen_det.cpp eigen_array.cpp # ------------------------------------------------------------------------- # make a special library so can have it's own compile flags (see configure.ac) @@ -461,13 +482,14 @@ @CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@libeigen_a_CXXFLAGS = \ @CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@ -g $(CXX_FLAGS_EIGEN) \ @CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@ -DCPPAD_EIGEN_EXAMPLES \ -@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@ -I$(EIGEN_DIR)/include +@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@ -I$(EIGEN_DIR)/include # ------------------------------------------------------------------------- # auto-tools does not support use of colpack EXTRA_DIST = \ test_one.sh.in \ - colpack.cpp \ + colpack_hes.cpp \ + colpack_jac.cpp \ $(ADOLC_EXTRA_FILES) \ $(EIGEN_EXTRA_FILES) @@ -493,6 +515,7 @@ abort_recording.cpp \ abs.cpp \ acos.cpp \ + acosh.cpp \ add.cpp \ add_eq.cpp \ ad_assign.cpp \ @@ -502,14 +525,18 @@ ad_input.cpp \ ad_output.cpp \ asin.cpp \ + asinh.cpp \ atan.cpp \ + atanh.cpp \ atan2.cpp \ + azmul.cpp \ base_alloc.hpp \ base_require.cpp \ bender_quad.cpp \ bool_fun.cpp \ + bool_sparsity.cpp \ capacity_order.cpp \ - change_const.cpp \ + change_param.cpp \ check_for_nan.cpp \ check_numeric_type.cpp \ check_simple_vector.cpp \ @@ -521,12 +548,14 @@ cos.cpp \ cosh.cpp \ cppad_vector.cpp \ + dependency.cpp \ div.cpp \ div_eq.cpp \ equal_op_seq.cpp \ erf.cpp \ error_handler.cpp \ exp.cpp \ + expm1.cpp \ for_one.cpp \ for_two.cpp \ forward.cpp \ @@ -549,8 +578,9 @@ jac_lu_det.cpp \ jac_minor_det.cpp \ jacobian.cpp \ - limits.cpp \ + num_limits.cpp \ log.cpp \ + log1p.cpp \ log10.cpp \ lu_factor.cpp \ lu_invert.cpp \ @@ -574,7 +604,6 @@ ode_gear_control.cpp\ ode_stiff.cpp \ ode_taylor.cpp \ - omp_alloc.cpp \ opt_val_hes.cpp \ optimize.cpp \ par_var.cpp \ @@ -602,20 +631,24 @@ sinh.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp \ + sparse_sub_hes.cpp \ + sparsity_sub.cpp \ sqrt.cpp \ stack_machine.cpp \ sub.cpp \ sub_eq.cpp \ + sub_sparse_hes.cpp \ tan.cpp \ tanh.cpp \ tape_index.cpp \ thread_alloc.cpp \ + to_string.cpp \ unary_minus.cpp \ unary_plus.cpp \ value.cpp \ var2par.cpp \ vec_ad.cpp \ - vector_bool.cpp + vector_bool.cpp all: all-am @@ -633,7 +666,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu example/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu example/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -678,6 +710,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abort_recording.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acos.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acosh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_assign.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_ctor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_fun.Po@am__quote@ @@ -687,13 +720,17 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asinh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atanh.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/azmul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_require.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bender_quad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bool_fun.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bool_sparsity.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/capacity_order.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/change_const.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/change_param.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_for_nan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_numeric_type.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_simple_vector.Po@am__quote@ @@ -705,6 +742,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cos.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cosh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppad_vector.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dependency.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/div.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/div_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/equal_op_seq.Po@am__quote@ @@ -712,6 +750,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_handler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expm1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_jac.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_two.Po@am__quote@ @@ -736,9 +775,9 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jacobian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeigen_a-eigen_array.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeigen_a-eigen_det.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/limits.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log10.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log1p.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_factor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_invert.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_ratio.Po@am__quote@ @@ -754,6 +793,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/near_equal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/near_equal_ext.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/num_limits.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/number_skip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numeric_type.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_err_control.Po@am__quote@ @@ -762,7 +802,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_gear_control.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_stiff.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_taylor.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omp_alloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt_val_hes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimize.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/par_var.Po@am__quote@ @@ -790,14 +829,18 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sinh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jacobian.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_sub_hes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparsity_sub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqrt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack_machine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub_eq.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub_sparse_hes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tanh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tape_index.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread_alloc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/to_string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unary_minus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unary_plus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/value.Po@am__quote@ @@ -1052,6 +1095,8 @@ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am +.PRECIOUS: makefile + test: check ./example diff -Nru cppad-2015.00.00.9/example/mul.cpp cppad-2016.00.00.1/example/mul.cpp --- cppad-2015.00.00.9/example/mul.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/mul.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -13,12 +13,8 @@ $begin mul.cpp$$ $section AD Binary Multiplication: Example and Test$$ +$mindex * multiply times$$ -$index *, AD example$$ -$index multiply, AD example$$ -$index times, AD example$$ -$index example, AD multiply$$ -$index test, AD multiply$$ $code $verbatim%example/mul.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -46,18 +42,18 @@ // some binary multiplication operations AD a = x[0] * 1.; // AD * double AD b = a * 2; // AD * int - AD c = 3. * b; // double * AD - AD d = 4 * c; // int * AD + AD c = 3. * b; // double * AD + AD d = 4 * c; // int * AD - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = x[0] * d; // AD * AD // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0*(4.*3.*2.*1.)*x0, 1e-10 , 1e-10); // forward computation of partials w.r.t. x[0] @@ -65,14 +61,14 @@ CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], (4.*3.*2.*1.)*2.*x0, 1e-10 , 1e-10); + ok &= NearEqual(dy[0], (4.*3.*2.*1.)*2.*x0, 1e-10 , 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); + CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], (4.*3.*2.*1.)*2.*x0, 1e-10 , 1e-10); + ok &= NearEqual(dw[0], (4.*3.*2.*1.)*2.*x0, 1e-10 , 1e-10); // use a VecAD::reference object with multiplication CppAD::VecAD v(1); diff -Nru cppad-2015.00.00.9/example/mul_eq.cpp cppad-2016.00.00.1/example/mul_eq.cpp --- cppad-2015.00.00.9/example/mul_eq.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/mul_eq.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul_eq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: mul_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,17 +14,9 @@ $begin mul_eq.cpp$$ $section AD Computed Assignment Multiplication: Example and Test$$ +$mindex *= multiply assign plus add$$ + -$index *=, AD example$$ -$index computed, AD assignment multiply example$$ -$index assignment, AD computed multiply example$$ -$index example, AD computed assignment multiply$$ -$index test, AD computed assignment multiply$$ - -$index computed, *= example$$ -$index assign, *= example$$ -$index plus, *= example$$ -$index add, *= example$$ $code $verbatim%example/mul_eq.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -44,12 +36,12 @@ size_t n = 1; double x0 = .5; CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 2; CPPAD_TESTVECTOR(AD) y(m); y[0] = x[0]; // initial value @@ -58,9 +50,9 @@ y[1] = y[0] *= x[0]; // use the result of a computed assignment // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , x0*2.*4.*x0, 1e-10 , 1e-10); ok &= NearEqual(y[1] , y[0], 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/mul_level_adolc.cpp cppad-2016.00.00.1/example/mul_level_adolc.cpp --- cppad-2015.00.00.9/example/mul_level_adolc.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/mul_level_adolc.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,6 +1,6 @@ -/* $Id: mul_level_adolc.cpp 2683 2012-12-30 18:17:03Z bradbell $ */ +/* $Id: mul_level_adolc.cpp 3738 2015-10-05 13:16:50Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -19,13 +19,10 @@ $$ $section Using Adolc with Multiple Levels of Taping: Example and Test$$ -$index multiple, Adolc$$ -$index level, multiple Adolc$$ -$index Adolc, multiple level$$ $head Purpose$$ In this example, we use $code AD< adouble> >$$ (level two taping), -the compute values of the function $latex f : \B{R}^n \rightarrow \B{R}$$ where +the compute values of the function $latex f : \B{R}^n \rightarrow \B{R}$$ where $latex \[ f(x) = \frac{1}{2} \left( x_0^2 + \cdots + x_{n-1}^2 \right) \] $$ @@ -49,16 +46,17 @@ $code AD< AD >$$ and $code AD$$. $head Memory Management$$ -Adolc uses raw memory arrays that depend on the number of +Adolc uses raw memory arrays that depend on the number of dependent and independent variables. -The memory management utility $cref omp_alloc$$ +The memory management utility $cref thread_alloc$$ is used to manage this memory allocation. $head Configuration Requirement$$ This example will be compiled and tested provided that -the value $cref ipopt_prefix$$ is specified on the +the value $cref adolc_prefix$$ is specified on the $cref cmake$$ command line. +$head Source$$ $code $verbatim%example/mul_level_adolc.cpp%0%// BEGIN C++%// END C++%1%$$ $$ @@ -70,16 +68,16 @@ # include # include -// adouble definitions not in Adolc distribution and +// adouble definitions not in Adolc distribution and // required in order to use CppAD::AD # include # include -namespace { +namespace { // f(x) = |x|^2 / 2 = .5 * ( x[0]^2 + ... + x[n-1]^2 ) template - Type f(CPPAD_TESTVECTOR(Type) &x) + Type f(const CPPAD_TESTVECTOR(Type)& x) { Type sum; sum = 0.; @@ -88,57 +86,60 @@ sum += x[i] * x[i]; return .5 * sum; - } + } } -bool mul_level_adolc(void) +bool mul_level_adolc(void) { bool ok = true; // initialize test result - using CppAD::omp_alloc; // The CppAD memory allocator + using CppAD::thread_alloc; // The CppAD memory allocator - typedef adouble ADdouble; // for first level of taping - typedef CppAD::AD ADDdouble; // for second level of taping + typedef adouble a1type; // for first level of taping + typedef CppAD::AD a2type; // for second level of taping size_t n = 5; // number independent variables size_t j; - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(ADdouble) a_x(n); - CPPAD_TESTVECTOR(ADDdouble) aa_x(n); + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(a1type) a1x(n); + CPPAD_TESTVECTOR(a2type) a2x(n); // Values for the independent variables while taping the function f(x) for(j = 0; j < n; j++) - aa_x[j] = double(j); + a2x[j] = double(j); // Declare the independent variable for taping f(x) - CppAD::Independent(aa_x); + CppAD::Independent(a2x); // Use AD to tape the evaluation of f(x) - CPPAD_TESTVECTOR(ADDdouble) aa_f(1); - aa_f[0] = f(aa_x); + CPPAD_TESTVECTOR(a2type) a2y(1); + a2y[0] = f(a2x); - // Declare a_F as the corresponding ADFun function f(x) + // Declare a1f as the corresponding ADFun function f(x) // (make sure we do not run zero order forward during constructor) - CppAD::ADFun a_F; - a_F.Dependent(aa_x, aa_f); + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); // Value of the independent variables whitle taping f'(x) * v - int tag = 0; + int tag = 0; int keep = 1; trace_on(tag, keep); for(j = 0; j < n; j++) - a_x[j] <<= double(j); + a1x[j] <<= double(j); // set the argument value x for computing f'(x) * v - a_F.Forward(0, a_x); + a1f.Forward(0, a1x); // compute f'(x) * v - CPPAD_TESTVECTOR(ADdouble) a_v(n); - CPPAD_TESTVECTOR(ADdouble) a_df(1); + CPPAD_TESTVECTOR(a1type) a1v(n); + CPPAD_TESTVECTOR(a1type) a1df(1); for(j = 0; j < n; j++) - a_v[j] = double(n - j); - a_df = a_F.Forward(1, a_v); + a1v[j] = double(n - j); + a1df = a1f.Forward(1, a1v); // declare Adolc function corresponding to f'(x) * v - double df; - a_df[0] >>= df; + double df; + a1df[0] >>= df; trace_off(); // compute the d/dx of f'(x) * v = f''(x) * v @@ -146,21 +147,22 @@ // w = new double[capacity] where capacity >= m size_t capacity; - double* w = omp_alloc::create_array(m, capacity); - // w = new double[capacity] where capacity >= n - double* dw = omp_alloc::create_array(n, capacity); + double* w = thread_alloc::create_array(m, capacity); + + // dw = new double[capacity] where capacity >= n + double* dw = thread_alloc::create_array(n, capacity); w[0] = 1.; fos_reverse(tag, int(m), int(n), w, dw); for(j = 0; j < n; j++) - { double vj = a_v[j].value(); - ok &= CppAD::NearEqual(dw[j], vj, 1e-10, 1e-10); + { double vj = a1v[j].value(); + ok &= CppAD::NearEqual(dw[j], vj, eps, eps); } // make memory avaialble for other use by this thread - omp_alloc::delete_array(w); - omp_alloc::delete_array(dw); + thread_alloc::delete_array(w); + thread_alloc::delete_array(dw); return ok; } // END C++ diff -Nru cppad-2015.00.00.9/example/mul_level_adolc_ode.cpp cppad-2016.00.00.1/example/mul_level_adolc_ode.cpp --- cppad-2015.00.00.9/example/mul_level_adolc_ode.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/mul_level_adolc_ode.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul_level_adolc_ode.cpp 2683 2012-12-30 18:17:03Z bradbell $ */ +/* $Id: mul_level_adolc_ode.cpp 3738 2015-10-05 13:16:50Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,18 +23,15 @@ Vec $$ -$section Using Adolc with Taylor's Ode Solver: An Example and Test$$ -$index ODE, Taylor Adolc$$ -$index Taylor, ODE Adolc$$ -$index Adolc, ODE$$ +$section Taylor's Ode Solver: A Multi-Level Adolc Example and Test$$ $head Purpose$$ -This is a realistic example using -two levels of taping (see $cref mul_level$$). -The first level of taping uses Adolc's $code adouble$$ type +This is a realistic example using +two levels of AD; see $cref mul_level$$. +The first level uses Adolc's $code adouble$$ type to tape the solution of an ordinary differential equation. This solution is then differentiated with respect to a parameter vector. -The second level of taping uses CppAD's type $code AD$$ +The second level uses CppAD's type $code AD$$ to take derivatives during the solution of the differential equation. These derivatives are used in the application of Taylor's method to the solution of the ODE. @@ -47,19 +44,19 @@ For this example the ODE's are defined by the function $latex h : \B{R}^n \times \B{R}^n \rightarrow \B{R}^n$$ where $latex \[ - h[ x, y(t, x) ] = + h[ x, y(t, x) ] = \left( \begin{array}{c} x_0 \\ x_1 y_0 (t, x) \\ \vdots \\ x_{n-1} y_{n-2} (t, x) \end{array} \right) - = + = \left( \begin{array}{c} \partial_t y_0 (t , x) \\ \partial_t y_1 (t , x) \\ \vdots \\ - \partial_t y_{n-1} (t , x) + \partial_t y_{n-1} (t , x) \end{array} \right) \] $$ and the initial condition $latex y(0, x) = 0$$. @@ -67,17 +64,17 @@ and the function $latex g : \B{R}^n \rightarrow \B{R}^n$$ is used to define the ODE where $latex \[ - g(y) = + g(y) = \left( \begin{array}{c} x_0 \\ x_1 y_0 \\ \vdots \\ - x_{n-1} y_{n-2} + x_{n-1} y_{n-2} \end{array} \right) -\] $$ +\] $$ $head ODE Solution$$ -The solution for this example can be calculated by +The solution for this example can be calculated by starting with the first row and then using the solution for the first row to solve the second and so on. Doing this we obtain @@ -106,16 +103,16 @@ \] $$ $head Taylor's Method Using AD$$ -An $th m$$ order Taylor method for +An $th m$$ order Taylor method for approximating the solution of an -ordinary differential equations is +ordinary differential equations is $latex \[ - y(t + \Delta t , x) - \approx + y(t + \Delta t , x) + \approx \sum_{k=0}^p \partial_t^k y(t , x ) \frac{ \Delta t^k }{ k ! } = - y^{(0)} (t , x ) + - y^{(1)} (t , x ) \Delta t + \cdots + + y^{(0)} (t , x ) + + y^{(1)} (t , x ) \Delta t + \cdots + y^{(p)} (t , x ) \Delta t^p \] $$ where the Taylor coefficients $latex y^{(k)} (t, x)$$ are defined by @@ -126,17 +123,17 @@ $latex \[ z ( t , x ) = g[ y ( t , x ) ] = h [ x , y( t , x ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcl} - \partial_t y(t, x) & = & z (t , x) + \partial_t y(t, x) & = & z (t , x) \\ \partial_t^{k+1} y(t , x) & = & \partial_t^k z (t , x) \\ - y^{(k+1)} ( t , x) & = & z^{(k)} (t, x) / (k+1) + y^{(k+1)} ( t , x) & = & z^{(k)} (t, x) / (k+1) \end{array} \] $$ -where $latex z^{(k)} (t, x)$$ is the +where $latex z^{(k)} (t, x)$$ is the $th k$$ order Taylor coefficient for $latex z(t, x)$$. In the example below, the Taylor coefficients @@ -152,16 +149,20 @@ is $code adolc$$. $head Memory Management$$ -Adolc uses raw memory arrays that depend on the number of +Adolc uses raw memory arrays that depend on the number of dependent and independent variables. -The memory management utility $cref omp_alloc$$ -is used to manage this memory allocation. +The $cref thread_alloc$$ memory management utilities +$cref/create_array/ta_create_array/$$ and +$cref/delete_array/ta_delete_array/$$ +are used to manage this memory allocation. $head Configuration Requirement$$ This example will be compiled and tested provided that -the value $cref ipopt_prefix$$ is specified on the +the value $cref ipopt_prefix$$ is specified on the $cref cmake$$ command line. +$head Source$$ + $code $verbatim%example/mul_level_adolc_ode.cpp%0%// BEGIN C++%// END C++%1%$$ $$ @@ -181,103 +182,103 @@ // ========================================================================== namespace { // BEGIN empty namespace // define types for each level -typedef adouble ADdouble; -typedef CppAD::AD ADDdouble; +typedef adouble a1type; +typedef CppAD::AD a2type; // ------------------------------------------------------------------------- // class definition for C++ function object that defines ODE class Ode { private: // copy of a that is set by constructor and used by g(y) - CPPAD_TESTVECTOR( ADdouble ) x_; + CPPAD_TESTVECTOR(a1type) a1x_; public: // constructor - Ode( CPPAD_TESTVECTOR( ADdouble ) x) : x_(x) + Ode(const CPPAD_TESTVECTOR(a1type)& a1x) : a1x_(a1x) { } // the function g(y) is evaluated with two levels of taping - CPPAD_TESTVECTOR( ADDdouble ) operator() - ( const CPPAD_TESTVECTOR( ADDdouble ) &y) const - { size_t n = y.size(); - CPPAD_TESTVECTOR( ADDdouble ) g(n); + CPPAD_TESTVECTOR(a2type) operator() + ( const CPPAD_TESTVECTOR(a2type)& a2y) const + { size_t n = a2y.size(); + CPPAD_TESTVECTOR(a2type) a2g(n); size_t i; - g[0] = x_[0]; + a2g[0] = a1x_[0]; for(i = 1; i < n; i++) - g[i] = x_[i] * y[i-1]; + a2g[i] = a1x_[i] * a2y[i-1]; - return g; + return a2g; } }; // ------------------------------------------------------------------------- // Routine that uses Taylor's method to solve ordinary differential equaitons -// and allows for algorithmic differentiation of the solution. -CPPAD_TESTVECTOR( ADdouble ) taylor_ode_adolc( - Ode G , // function that defines the ODE - size_t order , // order of Taylor's method used - size_t nstep , // number of steps to take - ADdouble &dt , // Delta t for each step - CPPAD_TESTVECTOR( ADdouble ) &y_ini ) // y(t) at the initial time +// and allows for algorithmic differentiation of the solution. +CPPAD_TESTVECTOR(a1type) taylor_ode_adolc( + Ode G , // function that defines the ODE + size_t order , // order of Taylor's method used + size_t nstep , // number of steps to take + const a1type &a1dt , // Delta t for each step + const CPPAD_TESTVECTOR(a1type) &a1y_ini) // y(t) at the initial time { // some temporary indices size_t i, k, ell; // number of variables in the ODE - size_t n = y_ini.size(); + size_t n = a1y_ini.size(); // copies of x and g(y) with two levels of taping - CPPAD_TESTVECTOR( ADDdouble ) Y(n), Z(n); + CPPAD_TESTVECTOR(a2type) a2y(n), Z(n); // y, y^{(k)} , z^{(k)}, and y^{(k+1)} - CPPAD_TESTVECTOR( ADdouble ) y(n), y_k(n), z_k(n), y_kp(n); - + CPPAD_TESTVECTOR(a1type) a1y(n), a1y_k(n), a1z_k(n), a1y_kp(n); + // initialize x for(i = 0; i < n; i++) - y[i] = y_ini[i]; + a1y[i] = a1y_ini[i]; // loop with respect to each step of Taylors method for(ell = 0; ell < nstep; ell++) - { // prepare to compute derivatives of in ADdouble + { // prepare to compute derivatives using a1type for(i = 0; i < n; i++) - Y[i] = y[i]; - CppAD::Independent(Y); + a2y[i] = a1y[i]; + CppAD::Independent(a2y); - // evaluate ODE in ADDdouble - Z = G(Y); + // evaluate ODE using a2type + Z = G(a2y); // define differentiable version of g: X -> Y - // that computes its derivatives in ADdouble - CppAD::ADFun g(Y, Z); + // that computes its derivatives using a1type + CppAD::ADFun a1g(a2y, Z); // Use Taylor's method to take a step - y_k = y; // initialize y^{(k)} - ADdouble dt_kp = dt; // initialize dt^(k+1) + a1y_k = a1y; // initialize y^{(k)} + a1type dt_kp = a1dt; // initialize dt^(k+1) for(k = 0; k <= order; k++) { // evaluate k-th order Taylor coefficient of y - z_k = g.Forward(k, y_k); - + a1z_k = a1g.Forward(k, a1y_k); + for(i = 0; i < n; i++) { // convert to (k+1)-Taylor coefficient for x - y_kp[i] = z_k[i] / ADdouble(k + 1); + a1y_kp[i] = a1z_k[i] / a1type(k + 1); // add term for to this Taylor coefficient // to solution for y(t, x) - y[i] += y_kp[i] * dt_kp; + a1y[i] += a1y_kp[i] * dt_kp; } // next power of t - dt_kp *= dt; + dt_kp *= a1dt; // next Taylor coefficient - y_k = y_kp; + a1y_k = a1y_kp; } } - return y; + return a1y; } } // END empty namespace // ========================================================================== // Routine that tests algorithmic differentiation of solutions computed // by the routine taylor_ode. bool mul_level_adolc_ode(void) -{ // initialize the return value as true - bool ok = true; +{ bool ok = true; + double eps = 100. * std::numeric_limits::epsilon(); // number of components in differential equation size_t n = 4; @@ -285,78 +286,79 @@ // some temporary indices size_t i, j; - // set up for omp_alloc memory allocator - using CppAD::omp_alloc; // the allocator - size_t capacity; // capacity of an allocation - - // the vector x with lenght n (or greater) in double - double* x = omp_alloc::create_array(n, capacity); - // the vector x with lenght n in ADouble - CPPAD_TESTVECTOR(ADdouble) X(n); + // set up for thread_alloc memory allocator + using CppAD::thread_alloc; // the allocator + size_t capacity; // capacity of an allocation + + // the vector x with lenght n (or greater) in double + double* x = thread_alloc::create_array(n, capacity); + + // the vector x with lenght n in a1type + CPPAD_TESTVECTOR(a1type) a1x(n); for(i = 0; i < n; i++) - X[i] = x[i] = double(i + 1); + a1x[i] = x[i] = double(i + 1); // declare the parameters as the independent variable int tag = 0; // Adolc setup int keep = 1; trace_on(tag, keep); for(i = 0; i < n; i++) - X[i] <<= double(i + 1); // X is independent for adouble type + a1x[i] <<= double(i + 1); // a1x is independent for adouble type - // arguments to taylor_ode_adolc - Ode G(X); // function that defines the ODE + // arguments to taylor_ode_adolc + Ode G(a1x); // function that defines the ODE size_t order = n; // order of Taylor's method used size_t nstep = 2; // number of steps to take - ADdouble DT = 1.; // Delta t for each step + a1type a1dt = 1.; // Delta t for each step // value of y(t, x) at the initial time - CPPAD_TESTVECTOR( ADdouble ) Y_INI(n); + CPPAD_TESTVECTOR(a1type) a1y_ini(n); for(i = 0; i < n; i++) - Y_INI[i] = 0.; + a1y_ini[i] = 0.; // integrate the differential equation - CPPAD_TESTVECTOR( ADdouble ) Y_FINAL(n); - Y_FINAL = taylor_ode_adolc(G, order, nstep, DT, Y_INI); + CPPAD_TESTVECTOR(a1type) a1y_final(n); + a1y_final = taylor_ode_adolc(G, order, nstep, a1dt, a1y_ini); - // declare the differentiable fucntion f : A -> Y_FINAL + // declare the differentiable fucntion f : x -> y_final // (corresponding to the tape of adouble operations) - double* y_final = omp_alloc::create_array(n, capacity); + double* y_final = thread_alloc::create_array(n, capacity); for(i = 0; i < n; i++) - Y_FINAL[i] >>= y_final[i]; + a1y_final[i] >>= y_final[i]; trace_off(); // check function values double check = 1.; - double t = nstep * DT.value(); + double t = nstep * a1dt.value(); for(i = 0; i < n; i++) { check *= x[i] * t / double(i + 1); - ok &= CppAD::NearEqual(y_final[i], check, 1e-10, 1e-10); + ok &= CppAD::NearEqual(y_final[i], check, eps, eps); } // memory where Jacobian will be returned - double* jac_ = omp_alloc::create_array(n * n, capacity); - double** jac = omp_alloc::create_array(n, capacity); + double* jac_ = thread_alloc::create_array(n * n, capacity); + double** jac = thread_alloc::create_array(n, capacity); for(i = 0; i < n; i++) jac[i] = jac_ + i * n; // evaluate Jacobian of h at a size_t m = n; // # dependent variables - jacobian(tag, int(m), int(n), x, jac); - - // check Jacobian + jacobian(tag, int(m), int(n), x, jac); + + // check Jacobian for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { if( i < j ) check = 0.; else check = y_final[i] / x[j]; - ok &= CppAD::NearEqual(jac[i][j], check, 1e-10, 1e-10); + ok &= CppAD::NearEqual(jac[i][j], check, eps, eps); } } // make memroy avaiable for other use by this thread - omp_alloc::delete_array(x); - omp_alloc::delete_array(y_final); - omp_alloc::delete_array(jac_); - omp_alloc::delete_array(jac); + thread_alloc::delete_array(x); + thread_alloc::delete_array(y_final); + thread_alloc::delete_array(jac_); + thread_alloc::delete_array(jac); return ok; } diff -Nru cppad-2015.00.00.9/example/mul_level.cpp cppad-2016.00.00.1/example/mul_level.cpp --- cppad-2015.00.00.9/example/mul_level.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/mul_level.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul_level.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: mul_level.cpp 3735 2015-10-01 13:43:46Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,14 +19,11 @@ abs $$ -$section Multiple Tapes: Example and Test$$ -$index multiple, AD level$$ -$index level, multiple AD$$ -$index AD, multiple level$$ +$section Multiple Level of AD: Example and Test$$ $head Purpose$$ In this example, we use $code AD< AD >$$ (level two taping), -the compute values of the function $latex f : \B{R}^n \rightarrow \B{R}$$ where +the compute values of the function $latex f : \B{R}^n \rightarrow \B{R}$$ where $latex \[ f(x) = \frac{1}{2} \left( x_0^2 + \cdots + x_{n-1}^2 \right) \] $$ @@ -49,6 +46,8 @@ The example $cref mul_level_adolc.cpp$$ computes the same values using Adolc's type $code adouble$$ and CppAD's type $code AD$$. + +$head Source$$ $code $verbatim%example/mul_level.cpp%0%// BEGIN C++%// END C++%1%$$ $$ @@ -59,10 +58,10 @@ # include -namespace { +namespace { // f(x) = |x|^2 / 2 = .5 * ( x[0]^2 + ... + x[n-1]^2 ) template - Type f(CPPAD_TESTVECTOR(Type) &x) + Type f(const CPPAD_TESTVECTOR(Type)& x) { Type sum; sum = 0.; @@ -71,63 +70,68 @@ sum += x[i] * x[i]; return .5 * sum; - } + } } -bool mul_level(void) +bool mul_level(void) { bool ok = true; // initialize test result - typedef CppAD::AD A1_double; // for one level of taping - typedef CppAD::AD A2_double; // for two levels of taping - size_t n = 5; // dimension for example - size_t j; // a temporary index variable - - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(A1_double) a1_x(n), a1_v(n), a1_dy(1) ; - CPPAD_TESTVECTOR(A2_double) a2_x(n), a2_y(1); + typedef CppAD::AD a1type; // for one level of taping + typedef CppAD::AD a2type; // for two levels of taping + size_t n = 5; // dimension for example + size_t j; // a temporary index variable + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(a1type) a1x(n), a1v(n), a1dy(1) ; + CPPAD_TESTVECTOR(a2type) a2x(n), a2y(1); // Values for the independent variables while taping the function f(x) for(j = 0; j < n; j++) - a2_x[j] = a1_x[j] = x[j] = double(j); + a2x[j] = a1x[j] = x[j] = double(j); // Declare the independent variable for taping f(x) - CppAD::Independent(a2_x); + CppAD::Independent(a2x); // Use AD< AD > to tape the evaluation of f(x) - a2_y[0] = f(a2_x); + a2y[0] = f(a2x); - // Declare a1_F as the corresponding ADFun< AD > value a2_y + // Declare a1f as the corresponding ADFun< AD > // (make sure we do not run zero order forward during constructor) - CppAD::ADFun a1_F; - a1_F.Dependent(a2_x, a2_y); + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); // Values for the independent variables while taping f'(x) * v // Declare the independent variable for taping f'(x) * v - CppAD::Independent(a1_x); + // (Note we did not have to tape the creationg of a1f.) + CppAD::Independent(a1x); + // set the argument value x for computing f'(x) * v - a1_F.Forward(0, a1_x); + a1f.Forward(0, a1x); // compute f'(x) * v for(j = 0; j < n; j++) - a1_v[j] = double(n - j); - a1_dy = a1_F.Forward(1, a1_v); + a1v[j] = double(n - j); + a1dy = a1f.Forward(1, a1v); - // declare dF as ADFun function corresponding to f'(x) * v - CppAD::ADFun dF; - dF.Dependent(a1_x, a1_dy); + // declare g as ADFun function corresponding to f'(x) * v + CppAD::ADFun g; + g.Dependent(a1x, a1dy); // optimize out operations not necessary for function f'(x) * v - dF.optimize(); + g.optimize(); // Evaluate f'(x) * v - dF.Forward(0, x); + g.Forward(0, x); // compute the d/dx of f'(x) * v = f''(x) * v = v CPPAD_TESTVECTOR(double) w(1); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; - dw = dF.Reverse(1, w); + dw = g.Reverse(1, w); for(j = 0; j < n; j++) - ok &= CppAD::NearEqual(dw[j], a1_v[j], 1e-10, 1e-10); + ok &= CppAD::NearEqual(dw[j], a1v[j], eps, eps); return ok; } diff -Nru cppad-2015.00.00.9/example/mul_level_ode.cpp cppad-2016.00.00.1/example/mul_level_ode.cpp --- cppad-2015.00.00.9/example/mul_level_ode.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/mul_level_ode.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul_level_ode.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: mul_level_ode.cpp 3738 2015-10-05 13:16:50Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,19 +21,15 @@ adouble $$ -$section Taylor's Ode Solver: An Example and Test$$ -$index ODE, Taylor$$ -$index Taylor, ODE$$ -$index example, ODE$$ -$index test, ODE$$ +$section Taylor's Ode Solver: A Multi-Level AD Example and Test$$ $head Purpose$$ -This is a realistic example using -two levels of taping (see $cref mul_level$$). -The first level of taping uses $code AD$$ to tape the solution of an +This is a realistic example using +two levels of AD; see $cref mul_level$$. +The first level uses $code AD$$ to tape the solution of an ordinary differential equation. This solution is then differentiated with respect to a parameter vector. -The second level of taping uses $code AD< AD >$$ +The second level uses $code AD< AD >$$ to take derivatives during the solution of the differential equation. These derivatives are used in the application of Taylor's method to the solution of the ODE. @@ -46,19 +42,19 @@ For this example the ODE's are defined by the function $latex h : \B{R}^n \times \B{R}^n \rightarrow \B{R}^n$$ where $latex \[ - h[ x, y(t, x) ] = + h[ x, y(t, x) ] = \left( \begin{array}{c} x_0 \\ x_1 y_0 (t, x) \\ \vdots \\ x_{n-1} y_{n-2} (t, x) \end{array} \right) - = + = \left( \begin{array}{c} \partial_t y_0 (t , x) \\ \partial_t y_1 (t , x) \\ \vdots \\ - \partial_t y_{n-1} (t , x) + \partial_t y_{n-1} (t , x) \end{array} \right) \] $$ and the initial condition $latex y(0, x) = 0$$. @@ -66,17 +62,17 @@ and the function $latex g : \B{R}^n \rightarrow \B{R}^n$$ is used to define the ODE where $latex \[ - g(y) = + g(y) = \left( \begin{array}{c} x_0 \\ x_1 y_0 \\ \vdots \\ - x_{n-1} y_{n-2} + x_{n-1} y_{n-2} \end{array} \right) -\] $$ +\] $$ $head ODE Solution$$ -The solution for this example can be calculated by +The solution for this example can be calculated by starting with the first row and then using the solution for the first row to solve the second and so on. Doing this we obtain @@ -105,16 +101,16 @@ \] $$ $head Taylor's Method Using AD$$ -An $th m$$ order Taylor method for +An $th m$$ order Taylor method for approximating the solution of an -ordinary differential equations is +ordinary differential equations is $latex \[ - y(t + \Delta t , x) - \approx + y(t + \Delta t , x) + \approx \sum_{k=0}^p \partial_t^k y(t , x ) \frac{ \Delta t^k }{ k ! } = - y^{(0)} (t , x ) + - y^{(1)} (t , x ) \Delta t + \cdots + + y^{(0)} (t , x ) + + y^{(1)} (t , x ) \Delta t + \cdots + y^{(p)} (t , x ) \Delta t^p \] $$ where the Taylor coefficients $latex y^{(k)} (t, x)$$ are defined by @@ -125,17 +121,17 @@ $latex \[ z ( t , x ) = g[ y ( t , x ) ] = h [ x , y( t , x ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcl} - \partial_t y(t, x) & = & z (t , x) + \partial_t y(t, x) & = & z (t , x) \\ \partial_t^{k+1} y(t , x) & = & \partial_t^k z (t , x) \\ - y^{(k+1)} ( t , x) & = & z^{(k)} (t, x) / (k+1) + y^{(k+1)} ( t , x) & = & z^{(k)} (t, x) / (k+1) \end{array} \] $$ -where $latex z^{(k)} (t, x)$$ is the +where $latex z^{(k)} (t, x)$$ is the $th k$$ order Taylor coefficient for $latex z(t, x)$$. In the example below, the Taylor coefficients @@ -145,6 +141,7 @@ are used to calculate the Taylor coefficient $latex z^{(k)} ( t , x )$$ which in turn gives the value for $latex y^{(k+1)} y ( t , x)$$. +$head Source$$ $code $verbatim%example/mul_level_ode.cpp%0%// BEGIN C++%// END C++%1%$$ $$ @@ -159,103 +156,103 @@ // ========================================================================= // define types for each level namespace { // BEGIN empty namespace -typedef CppAD::AD ADdouble; -typedef CppAD::AD< ADdouble > ADDdouble; +typedef CppAD::AD a1type; +typedef CppAD::AD a2type; // ------------------------------------------------------------------------- // class definition for C++ function object that defines ODE class Ode { private: // copy of a that is set by constructor and used by g(y) - CPPAD_TESTVECTOR( ADdouble ) x_; + CPPAD_TESTVECTOR(a1type) a1x_; public: // constructor - Ode( CPPAD_TESTVECTOR( ADdouble ) x) : x_(x) + Ode(const CPPAD_TESTVECTOR(a1type)& a1x) : a1x_(a1x) { } // the function g(y) is evaluated with two levels of taping - CPPAD_TESTVECTOR( ADDdouble ) operator() - ( const CPPAD_TESTVECTOR( ADDdouble ) &y) const - { size_t n = y.size(); - CPPAD_TESTVECTOR( ADDdouble ) g(n); + CPPAD_TESTVECTOR(a2type) operator() + ( const CPPAD_TESTVECTOR(a2type)& a2y) const + { size_t n = a2y.size(); + CPPAD_TESTVECTOR(a2type) a2g(n); size_t i; - g[0] = x_[0]; + a2g[0] = a1x_[0]; for(i = 1; i < n; i++) - g[i] = x_[i] * y[i-1]; + a2g[i] = a1x_[i] * a2y[i-1]; - return g; + return a2g; } }; // ------------------------------------------------------------------------- // Routine that uses Taylor's method to solve ordinary differential equaitons -// and allows for algorithmic differentiation of the solution. -CPPAD_TESTVECTOR( ADdouble ) taylor_ode( - Ode G , // function that defines the ODE - size_t order , // order of Taylor's method used - size_t nstep , // number of steps to take - ADdouble &dt , // Delta t for each step - CPPAD_TESTVECTOR( ADdouble ) &y_ini ) // y(t) at the initial time +// and allows for algorithmic differentiation of the solution. +CPPAD_TESTVECTOR(a1type) taylor_ode( + Ode G , // function that defines the ODE + size_t order , // order of Taylor's method used + size_t nstep , // number of steps to take + const a1type& a1dt , // Delta t for each step + const CPPAD_TESTVECTOR(a1type)& a1y_ini) // y(t) at the initial time { // some temporary indices size_t i, k, ell; // number of variables in the ODE - size_t n = y_ini.size(); + size_t n = a1y_ini.size(); // copies of x and g(y) with two levels of taping - CPPAD_TESTVECTOR( ADDdouble ) Y(n), Z(n); + CPPAD_TESTVECTOR(a2type) a2y(n), a2z(n); // y, y^{(k)} , z^{(k)}, and y^{(k+1)} - CPPAD_TESTVECTOR( ADdouble ) y(n), y_k(n), z_k(n), y_kp(n); - + CPPAD_TESTVECTOR(a1type) a1y(n), a1y_k(n), a1z_k(n), a1y_kp(n); + // initialize x for(i = 0; i < n; i++) - y[i] = y_ini[i]; + a1y[i] = a1y_ini[i]; // loop with respect to each step of Taylors method for(ell = 0; ell < nstep; ell++) - { // prepare to compute derivatives of in ADdouble + { // prepare to compute derivatives using a1type for(i = 0; i < n; i++) - Y[i] = y[i]; - CppAD::Independent(Y); + a2y[i] = a1y[i]; + CppAD::Independent(a2y); - // evaluate ODE in ADDdouble - Z = G(Y); + // evaluate ODE in a2type + a2z = G(a2y); - // define differentiable version of g: X -> Y - // that computes its derivatives in ADdouble - CppAD::ADFun g(Y, Z); + // define differentiable version of a1g: y -> z + // that computes its derivatives using a1type objects + CppAD::ADFun a1g(a2y, a2z); // Use Taylor's method to take a step - y_k = y; // initialize y^{(k)} - ADdouble dt_kp = dt; // initialize dt^(k+1) + a1y_k = a1y; // initialize y^{(k)} + a1type a1dt_kp = a1dt; // initialize dt^(k+1) for(k = 0; k <= order; k++) { // evaluate k-th order Taylor coefficient of y - z_k = g.Forward(k, y_k); - + a1z_k = a1g.Forward(k, a1y_k); + for(i = 0; i < n; i++) { // convert to (k+1)-Taylor coefficient for x - y_kp[i] = z_k[i] / ADdouble(k + 1); + a1y_kp[i] = a1z_k[i] / a1type(k + 1); // add term for to this Taylor coefficient // to solution for y(t, x) - y[i] += y_kp[i] * dt_kp; + a1y[i] += a1y_kp[i] * a1dt_kp; } // next power of t - dt_kp *= dt; + a1dt_kp *= a1dt; // next Taylor coefficient - y_k = y_kp; + a1y_k = a1y_kp; } } - return y; + return a1y; } } // END empty namespace // ========================================================================== // Routine that tests alogirhtmic differentiation of solutions computed // by the routine taylor_ode. bool mul_level_ode(void) -{ // initialize the return value as true - bool ok = true; +{ bool ok = true; + double eps = 100. * std::numeric_limits::epsilon(); // number of components in differential equation size_t n = 4; @@ -263,39 +260,39 @@ // some temporary indices size_t i, j; - // parameter vector in both double and ADdouble - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(ADdouble) X(n); + // parameter vector in both double and a1type + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(a1type) a1x(n); for(i = 0; i < n; i++) - X[i] = x[i] = double(i + 1); + a1x[i] = x[i] = double(i + 1); // declare the parameters as the independent variable - CppAD::Independent(X); + CppAD::Independent(a1x); - // arguments to taylor_ode - Ode G(X); // function that defines the ODE + // arguments to taylor_ode + Ode G(a1x); // function that defines the ODE size_t order = n; // order of Taylor's method used size_t nstep = 2; // number of steps to take - ADdouble DT = 1.; // Delta t for each step + a1type a1dt = double(1.); // Delta t for each step // value of y(t, x) at the initial time - CPPAD_TESTVECTOR( ADdouble ) Y_INI(n); + CPPAD_TESTVECTOR(a1type) a1y_ini(n); for(i = 0; i < n; i++) - Y_INI[i] = 0.; + a1y_ini[i] = 0.; // integrate the differential equation - CPPAD_TESTVECTOR( ADdouble ) Y_FINAL(n); - Y_FINAL = taylor_ode(G, order, nstep, DT, Y_INI); + CPPAD_TESTVECTOR(a1type) a1y_final(n); + a1y_final = taylor_ode(G, order, nstep, a1dt, a1y_ini); - // define differentiable fucntion object f : A -> Y_FINAL + // define differentiable fucntion object f : x -> y_final // that computes its derivatives in double - CppAD::ADFun f(X, Y_FINAL); + CppAD::ADFun f(a1x, a1y_final); // check function values double check = 1.; - double t = nstep * Value(DT); + double t = nstep * Value(a1dt); for(i = 0; i < n; i++) { check *= x[i] * t / double(i + 1); - ok &= CppAD::NearEqual(Value(Y_FINAL[i]), check, 1e-10, 1e-10); + ok &= CppAD::NearEqual(Value(a1y_final[i]), check, eps, eps); } // evaluate the Jacobian of h at a @@ -304,14 +301,14 @@ // a warning for the equivalent form // CPPAD_TESTVECTOR(double) jac = f.Jacobian(x); - // check Jacobian + // check Jacobian for(i = 0; i < n; i++) { for(j = 0; j < n; j++) - { double jac_ij = jac[i * n + j]; + { double jac_ij = jac[i * n + j]; if( i < j ) check = 0.; - else check = Value( Y_FINAL[i] ) / x[j]; - ok &= CppAD::NearEqual(jac_ij, check, 1e-10, 1e-10); + else check = Value( a1y_final[i] ) / x[j]; + ok &= CppAD::NearEqual(jac_ij, check, eps, eps); } } return ok; diff -Nru cppad-2015.00.00.9/example/nan.cpp cppad-2016.00.00.1/example/nan.cpp --- cppad-2015.00.00.9/example/nan.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/nan.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: nan.cpp 2765 2013-03-03 15:48:35Z bradbell $ */ +// $Id: nan.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,9 +15,6 @@ $section nan: Example and Test$$ -$index nan, example$$ -$index example, nan$$ -$index test, nan$$ $code $verbatim%example/nan.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -26,28 +23,17 @@ $end */ -// these definitions will be erased when nan.hpp is included -# ifdef nan -# else -# define nan(z) Error_if_this_symbol_gets_used -# endif -# ifdef isnan -# else -# define isnan(z) Error_if_this_symbol_gets_used -# endif - - - // BEGIN C++ -# include +# include # include +# include bool nan(void) { bool ok = true; // get a nan double double_zero = 0.; - double double_nan = CppAD::nan(double_zero); + double double_nan = std::numeric_limits::quiet_NaN(); // create a simple vector with no nans std::vector v(2); diff -Nru cppad-2015.00.00.9/example/near_equal.cpp cppad-2016.00.00.1/example/near_equal.cpp --- cppad-2015.00.00.9/example/near_equal.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/near_equal.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: near_equal.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: near_equal.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,12 +19,9 @@ $$ $section NearEqual Function: Example and Test$$ -$index NearEqual, example$$ -$index example, NearEqual$$ -$index test, NearEqual$$ $head File Name$$ -This file is called $code near_equal.cpp$$ instead of +This file is called $code near_equal.cpp$$ instead of $code NearEqual.cpp$$ to avoid a name conflict with $code ../lib/NearEqual.cpp$$ in the corresponding Microsoft project file. @@ -37,7 +34,7 @@ */ // BEGIN C++ -# include +# include # include @@ -46,12 +43,12 @@ typedef std::complex Complex; using CppAD::NearEqual; - // double + // double double x = 1.00000; double y = 1.00001; double a = .00003; double r = .00003; - double zero = 0.; + double zero = 0.; double inf = 1. / zero; double nan = 0. / zero; @@ -64,7 +61,7 @@ ok &= ! NearEqual(-inf, -inf, r, a); ok &= ! NearEqual(nan, nan, r, a); - // complex + // complex Complex X(x, x / 2.); Complex Y(y, y / 2.); Complex Inf(inf, zero); diff -Nru cppad-2015.00.00.9/example/near_equal_ext.cpp cppad-2016.00.00.1/example/near_equal_ext.cpp --- cppad-2015.00.00.9/example/near_equal_ext.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/near_equal_ext.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: near_equal_ext.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: near_equal_ext.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,7 @@ $$ $section Compare AD with Base Objects: Example and Test$$ -$index NearEqualExt, example$$ -$index example, NearEqualExt$$ -$index test, NearEqualExt$$ +$mindex NearEqualExt$$ $code $verbatim%example/near_equal_ext.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -39,14 +37,14 @@ using CppAD::AD; using CppAD::NearEqual; - // double + // double double x = 1.00000; double y = 1.00001; double a = .00005; double r = .00005; - double zero = 0.; + double zero = 0.; - // AD + // AD AD ax(x); AD ay(y); @@ -54,11 +52,11 @@ ok &= NearEqual(ax, y, r, zero); ok &= NearEqual(x, ay, r, a); - // std::complex + // std::complex AD cx(x); AD cy(y); - // AD< std::complex > + // AD< std::complex > AD acx(x); AD acy(y); diff -Nru cppad-2015.00.00.9/example/number_skip.cpp cppad-2016.00.00.1/example/number_skip.cpp --- cppad-2015.00.00.9/example/number_skip.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/number_skip.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: number_skip.cpp 2991 2013-10-22 16:25:15Z bradbell $ */ +// $Id: number_skip.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,12 +17,8 @@ $$ $section Number of Variables That Can be Skipped: Example and Test$$ +$mindex number_skip optimize conditional expression condition$$ -$index number_skip, example$$ -$index example, number_skip$$ -$index optimize, conditional expression$$ -$index condition, expression optimize$$ -$index expression, conditional optimize$$ $code $verbatim%example/number_skip.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -36,38 +32,38 @@ { bool ok = true; using CppAD::AD; - // independent variable vector + // independent variable vector CppAD::vector< AD > ax(2); - ax[0] = 0.; + ax[0] = 0.; ax[1] = 1.; Independent(ax); - + // Use a conditional expression CppAD::vector< AD > ay(1); // variable that gets optimized out AD az = ax[0] * ax[0]; - + // conditional expression ay[0] = CondExpLt(ax[0], ax[1], ax[0] + ax[1], ax[0] - ax[1]); - + // create function object F : x -> ay CppAD::ADFun f; f.Dependent(ax, ay); - // use zero order to evaluate F[ (3, 4) ] + // use zero order to evaluate F[ (3, 4) ] CppAD::vector x( f.Domain() ); CppAD::vector y( f.Range() ); x[0] = 3.; x[1] = 4.; y = f.Forward(0, x); - ok &= (y[0] == x[0] + x[1]); + ok &= (y[0] == x[0] + x[1]); // before call to optimize ok &= f.number_skip() == 0; size_t n_var = f.size_var(); - + // now optimize the operation sequence f.optimize(); @@ -75,12 +71,12 @@ x[0] = 4.; x[1] = 3.; y = f.Forward(0, x); - ok &= (y[0] == x[0] - x[1]); + ok &= (y[0] == x[0] - x[1]); // after optimize, check amount of optimization ok &= f.size_var() == n_var - 1; ok &= f.number_skip() == 1; - + return ok; } diff -Nru cppad-2015.00.00.9/example/numeric_type.cpp cppad-2016.00.00.1/example/numeric_type.cpp --- cppad-2015.00.00.9/example/numeric_type.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/numeric_type.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: numeric_type.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: numeric_type.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,9 +14,7 @@ $begin numeric_type.cpp$$ $section The NumericType: Example and Test$$ -$index NumericType, example$$ -$index example, NumericType$$ -$index test, NumericType$$ +$mindex NumericType$$ $code $verbatim%example/numeric_type.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -35,14 +33,14 @@ private: double d; public: - // constructor from void + // constructor from void MyType(void) : d(0.) { } - // constructor from an int + // constructor from an int MyType(int d_) : d(d_) { } // copy constructor - MyType(const MyType &x) + MyType(const MyType &x) { d = x.d; } // assignment operator void operator = (const MyType &x) @@ -54,37 +52,37 @@ MyType operator + (void) const { MyType x; x.d = d; - return x; + return x; } // unary plus MyType operator - (void) const { MyType x; x.d = - d; - return x; + return x; } // binary addition MyType operator + (const MyType &x) const { MyType y; y.d = d + x.d ; - return y; + return y; } // binary subtraction MyType operator - (const MyType &x) const { MyType y; y.d = d - x.d ; - return y; + return y; } // binary multiplication MyType operator * (const MyType &x) const { MyType y; y.d = d * x.d ; - return y; + return y; } // binary division MyType operator / (const MyType &x) const { MyType y; y.d = d / x.d ; - return y; + return y; } // computed assignment addition void operator += (const MyType &x) diff -Nru cppad-2015.00.00.9/example/num_limits.cpp cppad-2016.00.00.1/example/num_limits.cpp --- cppad-2015.00.00.9/example/num_limits.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/num_limits.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,99 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin num_limits.cpp$$ +$spell +$$ + +$section Numeric Limits: Example and Test$$ + +$code +$verbatim%example/num_limits.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# ifdef _MSC_VER +// Supress Microsoft compiler warning about possible loss of precision, +// in the constructors (when converting to std::complex) +// Float one = 1 +// Float two = 2 +// 1 and 2 are small enough so no loss of precision when converting to float. +# pragma warning(disable:4244) +# endif + +# include +# include + +namespace { + typedef CppAD::AD Float; + // + // ----------------------------------------------------------------- + bool check_epsilon(void) + { bool ok = true; + Float eps = CppAD::numeric_limits::epsilon(); + Float eps2 = eps / 2.0; + Float check = 1.0 + eps; + ok &= 1.0 != check; + check = 1.0 + eps2; + ok &= 1.0 == check; + return ok; + } + // ----------------------------------------------------------------- + bool check_min(void) + { bool ok = true; + Float min = CppAD::numeric_limits::min(); + Float eps = CppAD::numeric_limits::epsilon(); + // + Float match = (min / 100.) * 100.; + ok &= abs(match / min - 1.0) > 3.0 * eps; + // + match = (min * 100.) / 100.; + ok &= abs(match / min - 1.0) < 3.0 * eps; + return ok; + } + // ----------------------------------------------------------------- + bool check_max(void) + { bool ok = true; + Float max = CppAD::numeric_limits::max(); + Float eps = CppAD::numeric_limits::epsilon(); + // + Float match = (max * 100.) / 100.; + ok &= abs(match / max - 1.0) > 3.0 * eps; + // + match = (max / 100.) * 100.; + ok &= abs(match / max - 1.0) < 3.0 * eps; + return ok; + } + // ----------------------------------------------------------------- + bool check_nan(void) + { bool ok = true; + Float nan = CppAD::numeric_limits::quiet_NaN(); + ok &= nan != nan; + return ok; + } +} + +bool num_limits(void) +{ bool ok = true; + + ok &= check_epsilon(); + ok &= check_min(); + ok &= check_max(); + ok &= check_nan(); + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/example/ode_err_control.cpp cppad-2016.00.00.1/example/ode_err_control.cpp --- cppad-2015.00.00.9/example/ode_err_control.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ode_err_control.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_err_control.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_err_control.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,11 +17,8 @@ $section OdeErrControl: Example and Test$$ -$index OdeErrControl, example$$ -$index example, OdeErrControl$$ -$index test, OdeErrControl$$ -Define +Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} @@ -45,7 +42,7 @@ ODE goes through a singularity between $latex X_0 (t) > 0$$ and $latex X_0 (t) < 0$$. If $latex X_0 (t) < 0$$, -we return $code nan$$ in order to inform +we return $code nan$$ in order to inform $code OdeErrControl$$ that its is taking to large a step. @@ -57,13 +54,13 @@ */ // BEGIN C++ +# include // for quiet_NaN # include // for size_t # include // for exp -# include // CppAD::OdeErrControl -# include // CppAD::NearEqual -# include // CppAD::vector -# include // CppAD::Runge45 -# include // for nan +# include // CppAD::OdeErrControl +# include // CppAD::NearEqual +# include // CppAD::vector +# include // CppAD::Runge45 namespace { // -------------------------------------------------------------- @@ -73,18 +70,18 @@ public: // constructor Fun(double alpha) : alpha_(alpha) - { } + { } // set f = x'(t) void Ode( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f) { f[0] = - alpha_ * x[0]; - f[1] = 1. / x[0]; + f[1] = 1. / x[0]; // case where ODE does not make sense if( x[0] < 0. ) - f[1] = CppAD::nan(0.); + f[1] = std::numeric_limits::quiet_NaN(); } }; @@ -98,8 +95,8 @@ Method(double alpha) : F(alpha) { } void step( - double ta, - double tb, + double ta, + double tb, CppAD::vector &xa , CppAD::vector &xb , CppAD::vector &eb ) @@ -138,7 +135,7 @@ CppAD::vector maxabs(2); size_t nstep; - + xf = OdeErrControl(method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); diff -Nru cppad-2015.00.00.9/example/ode_err_maxabs.cpp cppad-2016.00.00.1/example/ode_err_maxabs.cpp --- cppad-2015.00.00.9/example/ode_err_maxabs.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/ode_err_maxabs.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_err_maxabs.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_err_maxabs.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,14 +18,10 @@ $$ $section OdeErrControl: Example and Test Using Maxabs Argument$$ +$mindex OdeErrControl$$ -$index OdeErrControl, example$$ -$index OdeErrControl, maxabs$$ -$index example, OdeErrControl$$ -$index test, OdeErrControl$$ -$index maxabs, OdeErrControl$$ -Define +Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} @@ -37,7 +33,7 @@ $latex \[ \begin{array}{rcl} X_0^{(1)} (t) & = & - w_0 X_0 (t) \\ - X_1^{(1)} (t) & = & + w_0 X_0 (t) - w_1 X_1 (t) + X_1^{(1)} (t) & = & + w_0 X_0 (t) - w_1 X_1 (t) \end{array} \] $$ Note that $latex X_1 (0)$$ is zero an if $latex w_0 t$$ is large, @@ -54,10 +50,10 @@ # include // for size_t # include // for exp -# include // CppAD::OdeErrControl -# include // CppAD::NearEqual -# include // CppAD::vector -# include // CppAD::Runge45 +# include // CppAD::OdeErrControl +# include // CppAD::NearEqual +# include // CppAD::vector +# include // CppAD::Runge45 namespace { // -------------------------------------------------------------- @@ -67,15 +63,15 @@ public: // constructor Fun(const CppAD::vector &w_) : w(w_) - { } + { } // set f = x'(t) void Ode( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f) { f[0] = - w[0] * x[0]; - f[1] = + w[0] * x[0] - w[1] * x[1]; + f[1] = + w[0] * x[0] - w[1] * x[1]; } }; @@ -88,8 +84,8 @@ Method(const CppAD::vector &w_) : F(w_) { } void step( - double ta, - double tb, + double ta, + double tb, CppAD::vector &xa , CppAD::vector &xb , CppAD::vector &eb ) @@ -126,7 +122,7 @@ double smax = 1.; double scur = .5; double erel = 1e-4; - + bool accurate = false; while( ! accurate ) { xf = OdeErrControl(method, @@ -137,7 +133,7 @@ accurate &= ef[i] <= erel * maxabs[i]; if( ! accurate ) smin = smin / 2; - } + } double x0 = exp(-w[0]*tf); ok &= CppAD::NearEqual(x0, xf[0], erel, 0.); diff -Nru cppad-2015.00.00.9/example/ode_gear_control.cpp cppad-2016.00.00.1/example/ode_gear_control.cpp --- cppad-2015.00.00.9/example/ode_gear_control.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ode_gear_control.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_gear_control.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_gear_control.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,12 +17,10 @@ $$ $section OdeGearControl: Example and Test$$ +$mindex OdeGearControl$$ -$index OdeGearControl, example$$ -$index example, OdeGearControl$$ -$index test, OdeGearControl$$ -Define +Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} @@ -34,7 +32,7 @@ $latex \[ \begin{array}{rcl} X_0^{(1)} (t) & = & - w_0 X_0 (t) \\ - X_1^{(1)} (t) & = & + w_0 X_0 (t) - w_1 X_1 (t) + X_1^{(1)} (t) & = & + w_0 X_0 (t) - w_1 X_1 (t) \end{array} \] $$ The example tests OdeGearControl using the relations above: @@ -48,7 +46,7 @@ // BEGIN C++ # include -# include // CppAD::OdeGearControl +# include // CppAD::OdeGearControl namespace { // -------------------------------------------------------------- @@ -58,25 +56,25 @@ public: // constructor Fun(const CPPAD_TESTVECTOR(double) &w_) : w(w_) - { } + { } // set f = x'(t) template void Ode( - const Scalar &t, - const CPPAD_TESTVECTOR(Scalar) &x, + const Scalar &t, + const CPPAD_TESTVECTOR(Scalar) &x, CPPAD_TESTVECTOR(Scalar) &f) { f[0] = - w[0] * x[0]; - f[1] = + w[0] * x[0] - w[1] * x[1]; + f[1] = + w[0] * x[0] - w[1] * x[1]; } void Ode_dep( - const double &t, - const CPPAD_TESTVECTOR(double) &x, + const double &t, + const CPPAD_TESTVECTOR(double) &x, CPPAD_TESTVECTOR(double) &f_x) { using namespace CppAD; - size_t n = x.size(); + size_t n = x.size(); CPPAD_TESTVECTOR(AD) T(1); CPPAD_TESTVECTOR(AD) X(n); CPPAD_TESTVECTOR(AD) F(n); @@ -142,7 +140,7 @@ double smax = 1.; double sini = 1e-10; double erel = 0.; - + xf = CppAD::OdeGearControl(F, M, ti, tf, xi, smin, smax, sini, eabs, erel, ef, maxabs, nstep); diff -Nru cppad-2015.00.00.9/example/ode_gear.cpp cppad-2016.00.00.1/example/ode_gear.cpp --- cppad-2015.00.00.9/example/ode_gear.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/ode_gear.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_gear.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_gear.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,16 +17,14 @@ $$ $section OdeGear: Example and Test$$ +$mindex OdeGear$$ -$index OdeGear, example$$ -$index example, OdeGear$$ -$index test, OdeGear$$ -Define +Define $latex x : \B{R} \rightarrow \B{R}^n$$ by $latex \[ x_i (t) = t^{i+1} -\] $$ +\] $$ for $latex i = 1 , \ldots , n-1$$. It follows that $latex \[ @@ -46,23 +44,23 @@ */ // BEGIN C++ -# include +# include # include // For automatic differentiation namespace { class Fun { public: // constructor - Fun(bool use_x_) : use_x(use_x_) + Fun(bool use_x_) : use_x(use_x_) { } // compute f(t, x) both for double and AD template void Ode( - const Scalar &t, - const CPPAD_TESTVECTOR(Scalar) &x, + const Scalar &t, + const CPPAD_TESTVECTOR(Scalar) &x, CPPAD_TESTVECTOR(Scalar) &f) - { size_t n = x.size(); + { size_t n = x.size(); Scalar ti(1); f[0] = Scalar(1); size_t i; @@ -77,12 +75,12 @@ } void Ode_dep( - const double &t, - const CPPAD_TESTVECTOR(double) &x, + const double &t, + const CPPAD_TESTVECTOR(double) &x, CPPAD_TESTVECTOR(double) &f_x) { using namespace CppAD; - size_t n = x.size(); + size_t n = x.size(); CPPAD_TESTVECTOR(AD) T(1); CPPAD_TESTVECTOR(AD) X(n); CPPAD_TESTVECTOR(AD) F(n); @@ -130,7 +128,7 @@ size_t n = m; // number of components in x(t) // vector of times - CPPAD_TESTVECTOR(double) T(m+1); + CPPAD_TESTVECTOR(double) T(m+1); double step = .1; T[0] = 0.; for(j = 1; j <= m; j++) @@ -138,7 +136,7 @@ step = 2. * step; } - // initial values for x( T[m-j] ) + // initial values for x( T[m-j] ) CPPAD_TESTVECTOR(double) X((m+1) * n); for(j = 0; j < m; j++) { double ti = T[j]; @@ -154,7 +152,7 @@ size_t use_x; for( use_x = 0; use_x < 2; use_x++) { // function object depends on value of use_x - Fun F(use_x > 0); + Fun F(use_x > 0); // compute OdeGear approximation for x( T[m] ) CppAD::OdeGear(F, m, n, T, X, e); diff -Nru cppad-2015.00.00.9/example/ode_stiff.cpp cppad-2016.00.00.1/example/ode_stiff.cpp --- cppad-2015.00.00.9/example/ode_stiff.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/ode_stiff.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_stiff.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_stiff.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,13 +17,10 @@ $$ $section A Stiff Ode: Example and Test$$ +$mindex ode$$ -$index stiff, ode$$ -$index ode, stiff$$ -$index example, stiff ode$$ -$index test, stiff ode$$ -Define +Define $latex x : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} @@ -32,13 +29,13 @@ x_0^\prime (t) & = & - a_0 x_0 (t) \\ x_1^\prime (t) & = & + a_0 x_0 (t) - a_1 x_1 (t) \end{array} -\] $$ -If $latex a_0 \gg a_1 > 0$$, this is a stiff Ode and +\] $$ +If $latex a_0 \gg a_1 > 0$$, this is a stiff Ode and the analytic solution is $latex \[ \begin{array}{rcl} x_0 (t) & = & \exp( - a_0 t ) \\ -x_1 (t) & = & a_0 [ \exp( - a_1 t ) - \exp( - a_0 t ) ] / ( a_0 - a_1 ) +x_1 (t) & = & a_0 [ \exp( - a_1 t ) - \exp( - a_0 t ) ] / ( a_0 - a_1 ) \end{array} \] $$ The example tests Rosen34 using the relations above: @@ -51,7 +48,7 @@ */ // BEGIN C++ -# include +# include // To print the comparision, change the 0 to 1 on the next line. # define CPPAD_ODE_STIFF_PRINT 0 @@ -65,28 +62,28 @@ // constructor Fun(const CPPAD_TESTVECTOR(double)& a_) : a(a_) { } - // compute f(t, x) + // compute f(t, x) void Ode( - const double &t, - const CPPAD_TESTVECTOR(double) &x, + const double &t, + const CPPAD_TESTVECTOR(double) &x, CPPAD_TESTVECTOR(double) &f) { f[0] = - a[0] * x[0]; - f[1] = + a[0] * x[0] - a[1] * x[1]; + f[1] = + a[0] * x[0] - a[1] * x[1]; } - // compute partial of f(t, x) w.r.t. t + // compute partial of f(t, x) w.r.t. t void Ode_ind( - const double &t, - const CPPAD_TESTVECTOR(double) &x, + const double &t, + const CPPAD_TESTVECTOR(double) &x, CPPAD_TESTVECTOR(double) &f_t) { f_t[0] = 0.; f_t[1] = 0.; } - // compute partial of f(t, x) w.r.t. x + // compute partial of f(t, x) w.r.t. x void Ode_dep( - const double &t, - const CPPAD_TESTVECTOR(double) &x, + const double &t, + const CPPAD_TESTVECTOR(double) &x, CPPAD_TESTVECTOR(double) &f_x) - { f_x[0] = -a[0]; + { f_x[0] = -a[0]; f_x[1] = 0.; f_x[2] = +a[0]; f_x[3] = -a[1]; @@ -101,8 +98,8 @@ RungeMethod(const CPPAD_TESTVECTOR(double) &a_) : F(a_) { } void step( - double ta , - double tb , + double ta , + double tb , CPPAD_TESTVECTOR(double) &xa , CPPAD_TESTVECTOR(double) &xb , CPPAD_TESTVECTOR(double) &eb ) @@ -119,8 +116,8 @@ RosenMethod(const CPPAD_TESTVECTOR(double) &a_) : F(a_) { } void step( - double ta , - double tb , + double ta , + double tb , CPPAD_TESTVECTOR(double) &xa , CPPAD_TESTVECTOR(double) &xb , CPPAD_TESTVECTOR(double) &eb ) @@ -156,7 +153,7 @@ size_t k; for(k = 0; k < 3; k++) - { + { size_t M = 5; double ti = 0.; double tf = 1.; @@ -167,11 +164,11 @@ double erel = 0.; if( k == 0 ) - { xf = CppAD::OdeErrControl(rosen, ti, tf, + { xf = CppAD::OdeErrControl(rosen, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); } else if( k == 1 ) - { xf = CppAD::OdeErrControl(runge, ti, tf, + { xf = CppAD::OdeErrControl(runge, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); } else if( k == 2 ) @@ -182,7 +179,7 @@ ok &= CppAD::NearEqual(x0, xf[0], 0., eabs[0]); ok &= CppAD::NearEqual(0., ef[0], 0., eabs[0]); - double x1 = a[0] * + double x1 = a[0] * (exp(-a[1]*tf) - exp(-a[0]*tf))/(a[0] - a[1]); ok &= CppAD::NearEqual(x1, xf[1], 0., eabs[1]); ok &= CppAD::NearEqual(0., ef[1], 0., eabs[0]); diff -Nru cppad-2015.00.00.9/example/ode_taylor.cpp cppad-2016.00.00.1/example/ode_taylor.cpp --- cppad-2015.00.00.9/example/ode_taylor.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/ode_taylor.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_taylor.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_taylor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,39 +22,36 @@ $$ $section Taylor's Ode Solver: An Example and Test$$ -$index ODE, Taylor$$ -$index Taylor, ODE$$ -$index example, ODE$$ -$index test, ODE$$ +$mindex Taylor$$ $head Purpose$$ This example solves an ordinary differential equation using Taylor's method; i.e., $latex \[ - Z(t + \Delta t) - \approx - Z^{(0)} (t) + - \frac{ Z^{(1)} (t) }{ 1 !} \Delta t + \cdots + + Z(t + \Delta t) + \approx + Z^{(0)} (t) + + \frac{ Z^{(1)} (t) }{ 1 !} \Delta t + \cdots + \frac{ Z^{(p)} (t) }{ p !} ( \Delta t )^p ) \] $$ $head ODE$$ The ODE is defined by the function $latex h : \B{R}^n \rightarrow \B{R}^n$$, -which for this example is given by +which for this example is given by $latex \[ - Z^{(1)} (t) = H[ Z(t) ] = + Z^{(1)} (t) = H[ Z(t) ] = \left( \begin{array}{c} 1 \\ Z_1 (t) \\ \vdots \\ - Z_{n-1} (t) + Z_{n-1} (t) \end{array} \right) \] $$ and the initial condition is $latex z(0) = 0$$. $head ODE Solution$$ -The solution for this example can be calculated by +The solution for this example can be calculated by starting with the first row and then using the solution for the first row to solve the second and so on. Doing this we obtain @@ -76,8 +73,8 @@ we note that $latex \[ \begin{array}{rcl} -Z^{(1)} (t) -& = & +Z^{(1)} (t) +& = & H( z^{(0)} + z^{(1)} t + \cdots + z^{(K)} t^K ) + O( t^{K+1} ) \\ & = & @@ -118,7 +115,7 @@ CPPAD_TESTVECTOR( AD ) y(n); y[0] = 1; for(size_t k = 1; k < n; k++) - y[k] = Z[k-1]; + y[k] = Z[k-1]; return y; } @@ -127,7 +124,7 @@ // ------------------------------------------------------------------------- // Example that uses Taylor's method to solve ordinary differential equaitons bool ode_taylor(void) -{ // initialize the return value as true +{ // initialize the return value as true bool ok = true; // some temporary indices @@ -144,7 +141,7 @@ // initialize the solution vector at time zero CPPAD_TESTVECTOR( double ) z(n); for(j = 0; j < n; j++) - z[j] = 0.0; + z[j] = 0.0; size_t order = n; // order of the Taylor method size_t n_step = 4; // number of time steps @@ -160,7 +157,7 @@ for(k = 0; k < order; k++) { // evaluate k-th order Taylor coefficient of H hk = H.Forward(k, zk); - + for(j = 0; j < n; j++) { // convert to (k+1)-Taylor coefficient for z zk[j] = hk[j] / double(k + 1); @@ -174,7 +171,7 @@ } } - // check solution of the ODE, + // check solution of the ODE, // Taylor's method should have no truncation error for this case double eps = 100. * std::numeric_limits::epsilon(); double check = 1.; diff -Nru cppad-2015.00.00.9/example/omp_alloc.cpp cppad-2016.00.00.1/example/omp_alloc.cpp --- cppad-2015.00.00.9/example/omp_alloc.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/omp_alloc.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,194 +0,0 @@ -/* $Id: omp_alloc.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin omp_alloc.cpp$$ -$spell - openmp -$$ - -$section OpenMP Memory Allocator: Example and Test$$ - -$index openmp, memory allocation$$ -$index multi-thread, memory allocation$$ -$index example, memory allocation$$ -$index test, memory allocation$$ - -$head Deprecated$$ -This example is only intended to help convert calls to $cref omp_alloc$$ -to calls to $cref thread_alloc$$. - -$code -$verbatim%example/omp_alloc.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ -# include -# include -# include - -namespace { // Begin empty namespace - -bool omp_alloc_bytes(void) -{ bool ok = true; - using CppAD::omp_alloc; - size_t thread; - - // check initial memory values - ok &= ! CppAD::memory_leak(); - - // amount of static memory used by thread zero - size_t static_inuse = omp_alloc::inuse(0); - - // determine the currently executing thread - // (should be zero because not in parallel mode) - thread = omp_alloc::get_thread_num(); - - // repeatedly allocate enough memory for at least two size_t values. - size_t min_size_t = 2; - size_t min_bytes = min_size_t * sizeof(size_t); - size_t n_outter = 10; - size_t n_inner = 5; - size_t cap_bytes, i, j, k; - for(i = 0; i < n_outter; i++) - { // Do not use CppAD::vector here because its use of omp_alloc - // complicates the inuse and avaialble results. - std::vector v_ptr(n_inner); - for( j = 0; j < n_inner; j++) - { // allocate enough memory for min_size_t size_t objects - v_ptr[j] = omp_alloc::get_memory(min_bytes, cap_bytes); - size_t* ptr = reinterpret_cast(v_ptr[j]); - // determine the number of size_t values we have obtained - size_t cap_size_t = cap_bytes / sizeof(size_t); - ok &= min_size_t <= cap_size_t; - // use placement new to call the size_t copy constructor - for(k = 0; k < cap_size_t; k++) - new(ptr + k) size_t(i + j + k); - // check that the constructor worked - for(k = 0; k < cap_size_t; k++) - ok &= ptr[k] == (i + j + k); - } - // check that n_inner * cap_bytes are inuse and none are available - ok &= omp_alloc::inuse(thread) == n_inner*cap_bytes + static_inuse; - ok &= omp_alloc::available(thread) == 0; - // return the memrory to omp_alloc - for(j = 0; j < n_inner; j++) - omp_alloc::return_memory(v_ptr[j]); - // check that now n_inner * cap_bytes are now available - // and none are in use - ok &= omp_alloc::inuse(thread) == static_inuse; - ok &= omp_alloc::available(thread) == n_inner * cap_bytes; - } - // return all the available memory to the system - omp_alloc::free_available(thread); - ok &= ! CppAD::memory_leak(); - - return ok; -} - -class my_char { -public: - char ch_ ; - my_char(void) : ch_(' ') - { } - my_char(const my_char& my_ch) : ch_(my_ch.ch_) - { } -}; - -bool omp_alloc_array(void) -{ bool ok = true; - using CppAD::omp_alloc; - size_t i; - - // check initial memory values - size_t thread = omp_alloc::get_thread_num(); - ok &= thread == 0; - ok &= ! CppAD::memory_leak(); - size_t static_inuse = omp_alloc::inuse(0); - - // initial allocation of an array - size_t size_min = 3; - size_t size_one; - my_char *array_one = - omp_alloc::create_array(size_min, size_one); - - // check the values and change them to null 'x' - for(i = 0; i < size_one; i++) - { ok &= array_one[i].ch_ == ' '; - array_one[i].ch_ = 'x'; - } - - // now create a longer array - size_t size_two; - my_char *array_two = - omp_alloc::create_array(2 * size_min, size_two); - - // check the values in array one - for(i = 0; i < size_one; i++) - ok &= array_one[i].ch_ == 'x'; - - // check the values in array two - for(i = 0; i < size_two; i++) - ok &= array_two[i].ch_ == ' '; - - // check the amount of inuse and available memory - // (an extra size_t value is used for each memory block). - size_t check = static_inuse + sizeof(my_char)*(size_one + size_two); - ok &= omp_alloc::inuse(thread) - check < sizeof(my_char); - ok &= omp_alloc::available(thread) == 0; - - // delete the arrays - omp_alloc::delete_array(array_one); - omp_alloc::delete_array(array_two); - ok &= omp_alloc::inuse(thread) == static_inuse; - check = sizeof(my_char)*(size_one + size_two); - ok &= omp_alloc::available(thread) - check < sizeof(my_char); - - // free the memory for use by this thread - omp_alloc::free_available(thread); - ok &= ! CppAD::memory_leak(); - - return ok; -} -} // End empty namespace - -bool omp_alloc(void) -{ bool ok = true; - using CppAD::omp_alloc; - - // check initial state of allocator - ok &= omp_alloc::get_max_num_threads() == 1; - - // set the maximum number of threads greater than one - // so that omp_alloc holds onto memory - CppAD::omp_alloc::set_max_num_threads(2); - ok &= omp_alloc::get_max_num_threads() == 2; - ok &= ! CppAD::memory_leak(); - - // now use memory allocator in state where it holds onto memory - ok &= omp_alloc_bytes(); - ok &= omp_alloc_array(); - - // check that the tests have not held onto memory - ok &= ! CppAD::memory_leak(); - - // set the maximum number of threads back to one - // so that omp_alloc no longer holds onto memory - CppAD::omp_alloc::set_max_num_threads(1); - - return ok; -} - - -// END C++ diff -Nru cppad-2015.00.00.9/example/optimize.cpp cppad-2016.00.00.1/example/optimize.cpp --- cppad-2015.00.00.9/example/optimize.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/optimize.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: optimize.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: optimize.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,12 +14,8 @@ $begin optimize.cpp$$ $section ADFun Operation Sequence Optimization: Example and Test$$ +$mindex optimize$$ -$index optimize, operation sequence$$ -$index operation, optimize sequence$$ -$index sequence, optimize operation$$ -$index test, optimize$$ -$index example, optimize$$ $code $verbatim%example/optimize.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -30,38 +26,49 @@ // BEGIN C++ # include namespace { - template - void fun(const Float& x, Float& y, size_t& n_var, size_t& n_opt) - { using CppAD::exp; - - // Create a variable that is optimized out because - // it is only used in the comparision operation. - Float a = 1. / x; + template void fun( + const VectorFloat& x, VectorFloat& y, size_t& n_var, size_t& n_opt ) + { typedef typename VectorFloat::value_type Float; + + // One for each independent variable and one phantom variable at + // the beginning of operation sequence. + n_var = 1 + x.size(); + + // One operator for each independent variable and one to mark + // beginning of operation sequence. + n_opt = 1 + x.size(); + + // Create a variable that is is only used in the comparision operation + // (was optimized out until 2015-01-12). + Float a = 1. / x[0]; n_var += 1; - n_opt += 0; + n_opt += 1; // Create a variable that is used by the result - Float b = x * 5.; + Float b = x[0] * 5.; n_var += 1; n_opt += 1; + // only one variable created for this comparison operation + // but the value depends on which branch is taken. Float c; - if( a < x ) - c = b / 3.; // only one variable created by this choice - else c = b / 2.; + if( a < x[0] ) + c = 2.0 * b; + else + c = 3.0 * b; n_var += 1; n_opt += 1; // Create a variable that is optimized out because it // will always have the same value as b - Float d = 5. * x; + Float d = 5. * x[0]; n_var += 1; n_opt += 0; // Create three variables that will be converted to one - // cumulative summation. Note that a is not connected to + // cumulative summation. Note that a is not connected to // the result y (in the operation sequence). - y = 1. + b + c + d; + y[0] = 1.0 + b + c + d; n_var += 3; n_opt += 1; } @@ -73,41 +80,52 @@ // domain space vector size_t n = 1; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = .5; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.5; // declare independent variables and start tape recording - CppAD::Independent(X); - size_t n_var = 1 + n; // one phantom variable at the beginning - size_t n_opt = 1 + n; // and one for each independent variable + CppAD::Independent(ax); - // range space vector + // range space vector size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - fun(X[0], Y[0], n_var, n_opt); - - // create f: X -> Y and stop tape recording - CppAD::ADFun F(X, Y); - ok &= (F.size_var() == n_var); - - // Check zero order forward mode on the original operation sequence - CPPAD_TESTVECTOR(double) x(n), y(m); - x[0] = Value(X[0]); - size_t i = 0; // temporary variable (we do not use value) - double check; - fun(x[0], check, i, i); - y = F.Forward(0, x); - ok &= (y[0] == check); + CPPAD_TESTVECTOR(AD) ay(m); + size_t n_var, n_opt; + fun(ax, ay, n_var, n_opt); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= (f.size_var() == n_var); // Optimize the operation sequence - F.optimize(); - ok &= (F.size_var() == n_opt); + f.optimize(); + ok &= (f.size_var() == n_opt); + + // Check result for a zero order calculation for a different x, + // where the result of the comparison is he same. + CPPAD_TESTVECTOR(double) x(n), y(m), check(m); + x[0] = 0.75; + y = f.Forward(0, x); + ok &= f.CompareChange() == 0; + fun(x, check, n_var, n_opt); + ok &= (y[0] == check[0]); + + // Check case where result of the comparision is differnent + x[0] = 2.0; + y = f.Forward(0, x); + ok &= f.CompareChange() == 1; + fun(x, check, n_var, n_opt); + ok &= (y[0] != check[0]); + + // re-tape at new x value, re-optimize, and re-evaluate forward + ax[0] = x[0]; + CppAD::Independent(ax); + fun(ax, ay, n_var, n_opt); + f.Dependent(ax, ay); + f.optimize(); + y = f.Forward(0, x); + ok &= f.CompareChange() == 0; + ok &= (y[0] == check[0]); - // Check result for a zero order calculation. - // This has already been checked if NDEBUG is not defined. - fun(x[0], check, i, i); - ok &= (y[0] == check); - y = F.Forward(0, x); return ok; } diff -Nru cppad-2015.00.00.9/example/opt_val_hes.cpp cppad-2016.00.00.1/example/opt_val_hes.cpp --- cppad-2015.00.00.9/example/opt_val_hes.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/opt_val_hes.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: opt_val_hes.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: opt_val_hes.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,8 @@ $$ $section opt_val_hes: Example and Test$$ +$mindex opt_val_hes$$ -$index opt_val_hes, example$$ -$index example, opt_val_hes$$ -$index test, opt_val_hes$$ Fix $latex z \in \B{R}^\ell$$ and define the functions $latex S_k : \B{R} \times \B{R} \rightarrow \B{R}^\ell$$ by and @@ -31,27 +29,27 @@ \\ F(x, y) & = & \sum_{k=0}^{\ell-1} S_k (x, y) \end{array} -\] $$ +\] $$ It follows that $latex \[ \begin{array}{rcl} -\partial_y F(x, y) -& = & +\partial_y F(x, y) +& = & \sum_{k=0}^{\ell-1} [ y * \sin ( x * t_k ) - z_k ] \sin( x * t_k ) \\ \partial_y \partial_y F(x, y) -& = & +& = & \sum_{k=0}^{\ell-1} \sin ( x t_k )^2 \end{array} \] $$ -Furthermore if we define $latex Y(x)$$ +Furthermore if we define $latex Y(x)$$ as solving the equation $latex \partial F[ x, Y(x) ] = 0 $$ we have $latex \[ \begin{array}{rcl} 0 & = & \sum_{k=0}^{\ell-1} [ Y(x) * \sin ( x * t_k ) - z_k ] \sin( x * t_k ) \\ -Y(x) \sum_{k=0}^{\ell-1} \sin ( x * t_k )^2 +Y(x) \sum_{k=0}^{\ell-1} \sin ( x * t_k )^2 - \sum_{k=0}^{\ell-1} \sin ( x * t_k ) z_k \\ Y(x) & = & \frac{ @@ -83,7 +81,7 @@ const BaseVector t_; // measurement times const BaseVector z_; // measurement values public: - typedef ADVector ad_vector; + typedef ADVector ad_vector; // constructor Fun(const BaseVector &t, const BaseVector &z) : t_(t) , z_(z) @@ -106,7 +104,7 @@ AD residual = y[0] * sin( x[0] * t_[k] ) - z_[k]; sy_k[0] = residual * sin( x[0] * t_[k] ); - + return sy_k; } }; @@ -118,7 +116,7 @@ size_t k; for(k = 0; k < size_t(t.size()); k++) { numerator += sin( x[0] * t[k] ) * z[k]; - denominator += sin( x[0] * t[k] ) * sin( x[0] * t[k] ); + denominator += sin( x[0] * t[k] ) * sin( x[0] * t[k] ); } AD y = numerator / denominator; @@ -159,10 +157,10 @@ z[k] = y[0] * sin( x[0] * t[k] ); // data without noise } - // construct the function object + // construct the function object Fun fun(t, z); - // evaluate the Jacobian and Hessian + // evaluate the Jacobian and Hessian BaseVector jac(n), hes(n * n); int signdet = CppAD::opt_val_hes(x, y, fun, jac, hes); diff -Nru cppad-2015.00.00.9/example/par_var.cpp cppad-2016.00.00.1/example/par_var.cpp --- cppad-2015.00.00.9/example/par_var.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/par_var.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: par_var.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: par_var.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,14 +15,8 @@ $section AD Parameter and Variable Functions: Example and Test$$ -$index Parameter, example$$ -$index Variable, example$$ -$index example, Parameter$$ -$index example, Variable$$ -$index test, Parameter$$ -$index test, Variable$$ $code $verbatim%example/par_var.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -48,7 +42,7 @@ x[0] = 0.; ok &= Parameter(x[0]); // x[0] is a paraemter here CppAD::Independent(x); - ok &= Variable(x[0]); // now x[0] is a variable + ok &= Variable(x[0]); // now x[0] is a variable // dependent variable vector size_t m = 2; @@ -56,7 +50,7 @@ y[0] = 2.; ok &= Parameter(y[0]); // y[0] does not depend on x[0] y[1] = abs(x[0]); - ok &= Variable(y[1]); // y[1] does depends on x[0] + ok &= Variable(y[1]); // y[1] does depends on x[0] // VecAD objects VecAD z(2); @@ -65,7 +59,7 @@ ok &= Parameter(z); // z does not depend on x[0] z[x[0]] = 2.; ok &= Variable(z); // z depends on x[0] - + // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); diff -Nru cppad-2015.00.00.9/example/poly.cpp cppad-2016.00.00.1/example/poly.cpp --- cppad-2015.00.00.9/example/poly.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/poly.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: poly.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,9 +15,6 @@ $section Polynomial Evaluation: Example and Test$$ -$index polynomial, example$$ -$index example, polynomial$$ -$index test, polynomial$$ $code $verbatim%example/poly.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -36,7 +33,7 @@ // degree of the polynomial size_t deg = 3; - // set the polynomial coefficients + // set the polynomial coefficients CPPAD_TESTVECTOR(double) a(deg + 1); size_t i; for(i = 0; i <= deg; i++) @@ -51,8 +48,8 @@ // evaluate derivative k = 1; p = CppAD::Poly(k, a, z); - ok &= (p == 1 + 2.*z + 3.*z*z); - + ok &= (p == 1 + 2.*z + 3.*z*z); + return ok; } diff -Nru cppad-2015.00.00.9/example/pow.cpp cppad-2016.00.00.1/example/pow.cpp --- cppad-2015.00.00.9/example/pow.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/pow.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: pow.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: pow.cpp 3735 2015-10-01 13:43:46Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,6 @@ $section The AD Power Function: Example and Test$$ -$index pow, AD example$$ -$index example, AD pow$$ -$index test, AD pow$$ - $code $verbatim%example/pow.cpp%0%// BEGIN C++%// END C++%1%$$ $$ @@ -32,38 +28,39 @@ # include # include -bool Pow(void) +bool pow(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 2; double x = 0.5; double y = 2.; - CPPAD_TESTVECTOR(AD) XY(n); - XY[0] = x; - XY[1] = y; + CPPAD_TESTVECTOR(AD) axy(n); + axy[0] = x; + axy[1] = y; // declare independent variables and start tape recording - CppAD::Independent(XY); + CppAD::Independent(axy); - // range space vector + // range space vector size_t m = 3; - CPPAD_TESTVECTOR(AD) Z(m); - Z[0] = CppAD::pow(XY[0], XY[1]); // pow(variable, variable) - Z[1] = CppAD::pow(XY[0], y); // pow(variable, parameter) - Z[2] = CppAD::pow(x, XY[1]); // pow(parameter, variable) + CPPAD_TESTVECTOR(AD) az(m); + az[0] = CppAD::pow(axy[0], axy[1]); // pow(variable, variable) + az[1] = CppAD::pow(axy[0], y); // pow(variable, parameter) + az[2] = CppAD::pow(x, axy[1]); // pow(parameter, variable) - // create f: XY -> Z and stop tape recording - CppAD::ADFun f(XY, Z); + // create f: axy -> az and stop tape recording + CppAD::ADFun f(axy, az); - // check value + // check value double check = std::pow(x, y); size_t i; for(i = 0; i < m; i++) - ok &= NearEqual(Z[i] , check, 1e-10 , 1e-10); + ok &= NearEqual(az[i] , check, eps, eps); // forward computation of first partial w.r.t. x CPPAD_TESTVECTOR(double) dxy(n); @@ -72,18 +69,18 @@ dxy[1] = 0.; dz = f.Forward(1, dxy); check = y * std::pow(x, y-1.); - ok &= NearEqual(dz[0], check, 1e-10, 1e-10); - ok &= NearEqual(dz[1], check, 1e-10, 1e-10); - ok &= NearEqual(dz[2], 0., 1e-10, 1e-10); + ok &= NearEqual(dz[0], check, eps, eps); + ok &= NearEqual(dz[1], check, eps, eps); + ok &= NearEqual(dz[2], 0., eps, eps); // forward computation of first partial w.r.t. y dxy[0] = 0.; dxy[1] = 1.; dz = f.Forward(1, dxy); check = std::log(x) * std::pow(x, y); - ok &= NearEqual(dz[0], check, 1e-10, 1e-10); - ok &= NearEqual(dz[1], 0., 1e-10, 1e-10); - ok &= NearEqual(dz[2], check, 1e-10, 1e-10); + ok &= NearEqual(dz[0], check, eps, eps); + ok &= NearEqual(dz[1], 0., eps, eps); + ok &= NearEqual(dz[2], check, eps, eps); // reverse computation of derivative of z[0] + z[1] + z[2] CPPAD_TESTVECTOR(double) w(m); @@ -93,18 +90,18 @@ w[2] = 1.; dw = f.Reverse(1, w); check = y * std::pow(x, y-1.); - ok &= NearEqual(dw[0], 2. * check, 1e-10, 1e-10); + ok &= NearEqual(dw[0], 2. * check, eps, eps); check = std::log(x) * std::pow(x, y); - ok &= NearEqual(dw[1], 2. * check, 1e-10, 1e-10); + ok &= NearEqual(dw[1], 2. * check, eps, eps); // use a VecAD::reference object with pow CppAD::VecAD v(2); AD zero(0); AD one(1); - v[zero] = XY[0]; - v[one] = XY[1]; + v[zero] = axy[0]; + v[one] = axy[1]; AD result = CppAD::pow(v[zero], v[one]); - ok &= NearEqual(result, Z[0], 1e-10, 1e-10); + ok &= NearEqual(result, az[0], eps, eps); return ok; } diff -Nru cppad-2015.00.00.9/example/pow_int.cpp cppad-2016.00.00.1/example/pow_int.cpp --- cppad-2015.00.00.9/example/pow_int.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/pow_int.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: pow_int.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: pow_int.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,10 +18,8 @@ $$ $section The Pow Integer Exponent: Example and Test$$ +$mindex int$$ -$index pow, int$$ -$index example, pow int$$ -$index test, pow int$$ $code $verbatim%example/pow_int.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -47,19 +45,19 @@ x[0] = x0; CppAD::Independent(x); - // dependent variable vector + // dependent variable vector size_t m = 7; CPPAD_TESTVECTOR(AD) y(m); int i; - for(i = 0; i < int(m); i++) + for(i = 0; i < int(m); i++) y[i] = CppAD::pow(x[0], i - 3); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value double check; - for(i = 0; i < int(m); i++) + for(i = 0; i < int(m); i++) { check = std::pow(x0, double(i - 3)); ok &= NearEqual(y[i] , check, 1e-10 , 1e-10); } @@ -69,7 +67,7 @@ CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); - for(i = 0; i < int(m); i++) + for(i = 0; i < int(m); i++) { check = double(i-3) * std::pow(x0, double(i - 4)); ok &= NearEqual(dy[i] , check, 1e-10 , 1e-10); } @@ -77,14 +75,14 @@ // reverse computation of derivative of y[i] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); - for(i = 0; i < int(m); i++) + for(i = 0; i < int(m); i++) w[i] = 0.; - for(i = 0; i < int(m); i++) - { w[i] = 1.; + for(i = 0; i < int(m); i++) + { w[i] = 1.; dw = f.Reverse(1, w); check = double(i-3) * std::pow(x0, double(i - 4)); ok &= NearEqual(dw[0] , check, 1e-10 , 1e-10); - w[i] = 0.; + w[i] = 0.; } return ok; diff -Nru cppad-2015.00.00.9/example/print_for.cpp cppad-2016.00.00.1/example/print_for.cpp --- cppad-2015.00.00.9/example/print_for.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/print_for.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: print_for.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: print_for.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,6 @@ $$ $section Print During Zero Order Forward Mode: Example and Test$$ -$index print, zero order forward$$ -$index zero, order forward print$$ -$index forward, zero order print$$ $code $verbatim%example/print_for.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -30,7 +27,7 @@ // BEGIN C++ # include -namespace { +namespace { using std::endl; using CppAD::AD; @@ -44,7 +41,7 @@ PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); return log(y); - } + } } bool print_for(void) @@ -63,18 +60,18 @@ AD log_var = check_log(var, stream_out); ok &= stream_out.str() == ""; - // dependent variable vector + // dependent variable vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = log_var; // define f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); - // zero order forward with x[0] = 2 + // zero order forward with x[0] = 2 CPPAD_TESTVECTOR(double) x(n); x[0] = 2.; - f.Forward(0, x, stream_out); + f.Forward(0, x, stream_out); std::string string_out = stream_out.str(); ok &= stream_out.str() == "check_log: y == 0 which is <= 0\n"; diff -Nru cppad-2015.00.00.9/example/reverse_any.cpp cppad-2016.00.00.1/example/reverse_any.cpp --- cppad-2015.00.00.9/example/reverse_any.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/reverse_any.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse_any.cpp 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: reverse_any.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,24 +18,21 @@ $section Reverse Mode General Case: Example and Test$$ -$index reverse, example$$ -$index example, reverse$$ -$index test, reverse$$ $head Purpose$$ -Break a large computation into pieces and only store values at the +Break a large computation into pieces and only store values at the interface of the pieces (this is much easier to do using $cref checkpoint$$). -In actual applications, there may be many functions, but +In actual applications, there may be many functions, but for this example there are only two. -The functions -$latex F : \B{R}^2 \rightarrow \B{R}^2$$ +The functions +$latex F : \B{R}^2 \rightarrow \B{R}^2$$ and -$latex G : \B{R}^2 \rightarrow \B{R}^2$$ +$latex G : \B{R}^2 \rightarrow \B{R}^2$$ defined by $latex \[ - F(x) = \left( \begin{array}{c} x_0 x_1 \\ x_1 - x_0 \end{array} \right) + F(x) = \left( \begin{array}{c} x_0 x_1 \\ x_1 - x_0 \end{array} \right) \; , \; - G(y) = \left( \begin{array}{c} y_0 - y_1 \\ y_1 y_0 \end{array} \right) + G(y) = \left( \begin{array}{c} y_0 - y_1 \\ y_1 y_0 \end{array} \right) \] $$ $head Processing Steps$$ @@ -44,21 +41,21 @@ is defined by $latex \[ \begin{array}{rcl} - H(x) - & = & G_0 [ F(x) ] + G_1 [ F(x) ] + H(x) + & = & G_0 [ F(x) ] + G_1 [ F(x) ] \\ - & = & x_0 x_1 - ( x_1 - x_0 ) + x_0 x_1 ( x_1 - x_0 ) + & = & x_0 x_1 - ( x_1 - x_0 ) + x_0 x_1 ( x_1 - x_0 ) \\ & = & x_0 x_1 ( 1 - x_0 + x_1 ) - x_1 + x_0 \end{array} -\] $$ -Given the zero and first order Taylor coefficients +\] $$ +Given the zero and first order Taylor coefficients $latex x^{(0)} $$ and $latex x^{(1)}$$, we use $latex X(t)$$, $latex Y(t)$$ and $latex Z(t)$$ for the corresponding functions; i.e., $latex \[ \begin{array}{rcl} - X(t) & = & x^{(0)} + x^{(1)} t + X(t) & = & x^{(0)} + x^{(1)} t \\ Y(t) & = & F[X(t)] = y^{(0)} + y^{(1)} t + O(t^2) \\ @@ -72,15 +69,15 @@ Here are the processing steps: $list number$$ -Use forward mode on $latex F(x)$$ to compute +Use forward mode on $latex F(x)$$ to compute $latex y^{(0)}$$ and $latex y^{(1)}$$. $lnext Free some, or all, of the memory corresponding to $latex F(x)$$. $lnext -Use forward mode on $latex G(y)$$ to compute -$latex z^{(0)}$$ and $latex z^{(1)}$$ +Use forward mode on $latex G(y)$$ to compute +$latex z^{(0)}$$ and $latex z^{(1)}$$ $lnext -Use reverse mode on $latex G(y)$$ to compute the derivative of +Use reverse mode on $latex G(y)$$ to compute the derivative of $latex h^{(1)}$$ with respect to $latex y^{(0)}$$ and $latex y^{(1)}$$. $lnext @@ -146,7 +143,7 @@ namespace { bool reverse_any_case(bool free_all) { bool ok = true; - double eps = 10. * CppAD::numeric_limits::epsilon(); + double eps = 10. * CppAD::numeric_limits::epsilon(); using CppAD::AD; using CppAD::NearEqual; @@ -177,7 +174,7 @@ y1 = f.Forward(1, x1); if( free_all ) f = empty; - else + else { // free all the Taylor coefficients stored in f f.capacity_order(0); } @@ -204,7 +201,7 @@ check += x0[0] * x1[1] * (1. - x0[0] + x0[1]); double h1 = z1[0] + z1[1]; ok &= NearEqual(h1, check, eps, eps); - + // compute the derivative with respect to y^0 and y^0 of h^1 size_t p = 2; CPPAD_TESTVECTOR(double) w(n*p), dw(n*p); @@ -216,7 +213,7 @@ // We are done using g, so we can free its memory. g = empty; - // We need to use f next. + // We need to use f next. if( free_all ) { // we must again record the operation sequence for F(x) CppAD::Independent(X); @@ -231,7 +228,7 @@ // compute the derivative with respect to x^0 and x^0 of // h^1 = z_0^1 + z_1^1 CPPAD_TESTVECTOR(double) dv(n*p); - dv = f.Reverse(p, dw); + dv = f.Reverse(p, dw); // check partial of h^1 w.r.t x^0_0 check = x0[1] * (- x1[0] + x1[1]); @@ -241,7 +238,7 @@ // check partial of h^1 w.r.t x^0_1 check = x0[0] * (- x1[0] + x1[1]); - check += x1[0] * (1. - x0[0] + x0[1]) + x1[0] * x0[1]; + check += x1[0] * (1. - x0[0] + x0[1]) + x1[0] * x0[1]; check += x0[0] * x1[1]; ok &= NearEqual(dv[1*p+0], check, eps, eps); diff -Nru cppad-2015.00.00.9/example/reverse_one.cpp cppad-2016.00.00.1/example/reverse_one.cpp --- cppad-2015.00.00.9/example/reverse_one.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/reverse_one.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse_one.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: reverse_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section First Order Reverse Mode: Example and Test$$ -$index reverse, first order$$ -$index example, first order reverse$$ -$index test, first order reverse$$ $code $verbatim%example/reverse_one.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -32,7 +29,7 @@ # include namespace { // ---------------------------------------------------------- // define the template function reverse_one_cases in empty namespace -template +template bool reverse_one_cases(void) { bool ok = true; using CppAD::AD; @@ -41,7 +38,7 @@ // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; // declare independent variables and start recording @@ -80,7 +77,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool reverse_one(void) diff -Nru cppad-2015.00.00.9/example/reverse_three.cpp cppad-2016.00.00.1/example/reverse_three.cpp --- cppad-2015.00.00.9/example/reverse_three.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/reverse_three.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse_three.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: reverse_three.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $section Third Order Reverse Mode: Example and Test$$ -$index reverse, third order$$ -$index example, reverse third order$$ -$index test, reverse third order$$ $head Taylor Coefficients$$ $latex \[ @@ -34,7 +31,7 @@ \end{array} \] $$ Thus, we need to be careful to properly account for the fact that -$latex X^{(2)} (0) = 2 x^{(2)}$$ +$latex X^{(2)} (0) = 2 x^{(2)}$$ (and similarly $latex Y^{(2)} (0) = 2 y^{(2)}$$). $code @@ -47,7 +44,7 @@ # include namespace { // ---------------------------------------------------------- // define the template function cases in empty namespace -template +template bool cases(void) { bool ok = true; double eps = 10. * CppAD::numeric_limits::epsilon(); @@ -57,7 +54,7 @@ // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; // declare independent variables and start recording @@ -71,18 +68,18 @@ // create f : X -> Y and stop recording CppAD::ADFun f(X, Y); - // define x^0 and compute y^0 using user zero order forward + // define x^0 and compute y^0 using user zero order forward Vector x0(n), y0(m); x0[0] = 2.; x0[1] = 3.; y0 = f.Forward(0, x0); - // y^0 = F(x^0) + // y^0 = F(x^0) double check; check = x0[0] * x0[1]; ok &= NearEqual(y0[0] , check, eps, eps); - // define x^1 and compute y^1 using first order forward mode + // define x^1 and compute y^1 using first order forward mode Vector x1(n), y1(m); x1[0] = 4.; x1[1] = 5.; @@ -129,16 +126,16 @@ ok &= NearEqual(dw[1*p+1], check, eps, eps); // check partial w.r.t x^2_0 of W(x) - check = 3. * x0[1]; + check = 3. * x0[1]; ok &= NearEqual(dw[0*p+2], check, eps, eps); // check partial w.r.t x^2_1 of W(x) - check = 3. * x0[0]; + check = 3. * x0[0]; ok &= NearEqual(dw[1*p+2], check, eps, eps); return ok; } -} // End empty namespace +} // End empty namespace # include # include bool reverse_three(void) diff -Nru cppad-2015.00.00.9/example/reverse_two.cpp cppad-2016.00.00.1/example/reverse_two.cpp --- cppad-2015.00.00.9/example/reverse_two.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/reverse_two.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse_two.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: reverse_two.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,8 @@ $$ $section Second Order Reverse ModeExample and Test$$ +$mindex example$$ -$index reverse, second order$$ -$index example, second order reverse$$ -$index test, second order reverse$$ $code $verbatim%example/reverse_two.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -32,7 +30,7 @@ # include namespace { // ---------------------------------------------------------- // define the template function reverse_two_cases in empty namespace -template +template bool reverse_two_cases(void) { bool ok = true; using CppAD::AD; @@ -41,7 +39,7 @@ // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; // declare independent variables and start recording @@ -84,13 +82,13 @@ // check derivative of f^{(1)} (x) * dx check = 2.*x[1]*dx[1] + 2.*x[0]*dx[1]; - ok &= NearEqual(dw[0*2+1] , check, 1e-10, 1e-10); + ok &= NearEqual(dw[0*2+1] , check, 1e-10, 1e-10); check = 2.*x[0]*dx[1]; - ok &= NearEqual(dw[1*2+1] , check, 1e-10, 1e-10); + ok &= NearEqual(dw[1*2+1] , check, 1e-10, 1e-10); return ok; } -} // End empty namespace +} // End empty namespace # include # include bool reverse_two(void) diff -Nru cppad-2015.00.00.9/example/rev_one.cpp cppad-2016.00.00.1/example/rev_one.cpp --- cppad-2015.00.00.9/example/rev_one.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/rev_one.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rev_one.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: rev_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section First Order Derivative Driver: Example and Test$$ -$index derivative, example$$ -$index example, derivative$$ -$index test, derivative$$ $code $verbatim%example/rev_one.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -65,25 +62,25 @@ x[0] = 2.; x[1] = 1.; - // compute and check derivative of y[0] + // compute and check derivative of y[0] Vector dw(n); dw = f.RevOne(x, 0); ok &= NearEqual(dw[0], exp(x[1]), 1e-10, 1e-10 ); // w.r.t x[0] ok &= NearEqual(dw[1], x[0]*exp(x[1]), 1e-10, 1e-10 ); // w.r.t x[1] - // compute and check derivative of y[1] + // compute and check derivative of y[1] dw = f.RevOne(x, 1); ok &= NearEqual(dw[0], sin(x[1]), 1e-10, 1e-10 ); ok &= NearEqual(dw[1], x[0]*cos(x[1]), 1e-10, 1e-10 ); - // compute and check derivative of y[2] + // compute and check derivative of y[2] dw = f.RevOne(x, 2); ok &= NearEqual(dw[0], cos(x[1]), 1e-10, 1e-10 ); ok &= NearEqual(dw[1], - x[0]*sin(x[1]), 1e-10, 1e-10 ); return ok; } -} // End empty namespace +} // End empty namespace # include # include bool RevOne(void) diff -Nru cppad-2015.00.00.9/example/rev_sparse_hes.cpp cppad-2016.00.00.1/example/rev_sparse_hes.cpp --- cppad-2015.00.00.9/example/rev_sparse_hes.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/rev_sparse_hes.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rev_sparse_hes.cpp 2859 2013-05-28 06:03:21Z bradbell $ */ +// $Id: rev_sparse_hes.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,11 +21,8 @@ $$ $section Reverse Mode Hessian Sparsity: Example and Test$$ +$mindex RevSparseHes sparsity$$ -$index RevSparseHes$$ -$index example, sparsity Hessian$$ -$index test, sparsity Hessian$$ -$index sparsity, Hessian$$ $code $verbatim%example/rev_sparse_hes.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -57,9 +54,9 @@ using CppAD::AD; // domain space vector - size_t n = 3; + size_t n = 3; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; X[2] = 2.; @@ -96,7 +93,7 @@ // check values for(i = 0; i < n; i++) - for(j = 0; j < n; j++) + for(j = 0; j < n; j++) ok &= (h[ i * n + j ] == check_f0[ i * n + j ] ); // compute sparsity pattern for H(x) = F_1^{(2)} (x) @@ -107,7 +104,7 @@ // check values for(i = 0; i < n; i++) - for(j = 0; j < n; j++) + for(j = 0; j < n; j++) ok &= (h[ i * n + j ] == check_f1[ i * n + j ] ); // call that transposed the result @@ -116,7 +113,7 @@ // This h is symmetric, because R is symmetric, not really testing here for(i = 0; i < n; i++) - for(j = 0; j < n; j++) + for(j = 0; j < n; j++) ok &= (h[ j * n + i ] == check_f1[ i * n + j ] ); return ok; @@ -128,9 +125,9 @@ using CppAD::AD; // domain space vector - size_t n = 3; + size_t n = 3; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; X[2] = 2.; @@ -212,18 +209,18 @@ // all of which are Simple Vectors with elements of type bool. ok &= BoolCases< CppAD::vector >(); ok &= BoolCases< CppAD::vectorBool >(); - ok &= BoolCases< std::vector >(); - ok &= BoolCases< std::valarray >(); + ok &= BoolCases< std::vector >(); + ok &= BoolCases< std::valarray >(); - // Run with Vector equal to two different cases both of which are + // Run with Vector equal to two different cases both of which are // Simple Vectors with elements of type std::set typedef std::set set; ok &= SetCases< CppAD::vector >(); - ok &= SetCases< std::vector >(); + ok &= SetCases< std::vector >(); // Do not use valarray because its element access in the const case // returns a copy instead of a reference - // ok &= SetCases< std::valarray >(); + // ok &= SetCases< std::valarray >(); return ok; } diff -Nru cppad-2015.00.00.9/example/rev_sparse_jac.cpp cppad-2016.00.00.1/example/rev_sparse_jac.cpp --- cppad-2015.00.00.9/example/rev_sparse_jac.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/rev_sparse_jac.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rev_sparse_jac.cpp 2859 2013-05-28 06:03:21Z bradbell $ */ +// $Id: rev_sparse_jac.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,11 +20,8 @@ $$ $section Reverse Mode Jacobian Sparsity: Example and Test$$ +$mindex RevSparseJac sparsity$$ -$index RevSparseJac$$ -$index example, sparsity reverse$$ -$index test, sparsity reverse$$ -$index sparsity, reverse example$$ $code $verbatim%example/rev_sparse_jac.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -36,16 +33,16 @@ # include namespace { // ------------------------------------------------------------- -// define the template function BoolCases +// define the template function BoolCases template // vector class, elements of type bool bool BoolCases(void) { bool ok = true; using CppAD::AD; // domain space vector - size_t n = 2; + size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; + ax[0] = 0.; ax[1] = 1.; // declare independent variables and start recording @@ -96,16 +93,16 @@ return ok; } -// define the template function SetCases +// define the template function SetCases template // vector class, elements of type std::set bool SetCases(void) { bool ok = true; using CppAD::AD; // domain space vector - size_t n = 2; + size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; + ax[0] = 0.; ax[1] = 1.; // declare independent variables and start recording @@ -137,17 +134,17 @@ bool found; // y[0] does depend on x[0] - found = s[0].find(0) != s[0].end(); ok &= (found == true); + found = s[0].find(0) != s[0].end(); ok &= (found == true); // y[0] does not depend on x[1] - found = s[0].find(1) != s[0].end(); ok &= (found == false); + found = s[0].find(1) != s[0].end(); ok &= (found == false); // y[1] does depend on x[0] - found = s[1].find(0) != s[1].end(); ok &= (found == true); + found = s[1].find(0) != s[1].end(); ok &= (found == true); // y[1] does depend on x[1] - found = s[1].find(1) != s[1].end(); ok &= (found == true); + found = s[1].find(1) != s[1].end(); ok &= (found == true); // y[2] does not depend on x[0] - found = s[2].find(0) != s[2].end(); ok &= (found == false); + found = s[2].find(0) != s[2].end(); ok &= (found == false); // y[2] does depend on x[1] - found = s[2].find(1) != s[2].end(); ok &= (found == true); + found = s[2].find(1) != s[2].end(); ok &= (found == true); // sparsity pattern for F'(x)^T bool transpose = true; @@ -155,17 +152,17 @@ st = f.RevSparseJac(m, r, transpose); // y[0] does depend on x[0] - found = st[0].find(0) != st[0].end(); ok &= (found == true); + found = st[0].find(0) != st[0].end(); ok &= (found == true); // y[0] does not depend on x[1] - found = st[1].find(0) != st[1].end(); ok &= (found == false); + found = st[1].find(0) != st[1].end(); ok &= (found == false); // y[1] does depend on x[0] - found = st[0].find(1) != st[0].end(); ok &= (found == true); + found = st[0].find(1) != st[0].end(); ok &= (found == true); // y[1] does depend on x[1] - found = st[1].find(1) != st[1].end(); ok &= (found == true); + found = st[1].find(1) != st[1].end(); ok &= (found == true); // y[2] does not depend on x[0] - found = st[0].find(2) != st[0].end(); ok &= (found == false); + found = st[0].find(2) != st[0].end(); ok &= (found == false); // y[2] does depend on x[1] - found = st[1].find(2) != st[1].end(); ok &= (found == true); + found = st[1].find(2) != st[1].end(); ok &= (found == true); return ok; } @@ -178,19 +175,19 @@ // all of which are Simple Vectors with elements of type bool. ok &= BoolCases< CppAD::vectorBool >(); ok &= BoolCases< CppAD::vector >(); - ok &= BoolCases< std::vector >(); - ok &= BoolCases< std::valarray >(); + ok &= BoolCases< std::vector >(); + ok &= BoolCases< std::valarray >(); - // Run with Vector equal to two different cases both of which are + // Run with Vector equal to two different cases both of which are // Simple Vectors with elements of type std::set typedef std::set set; ok &= SetCases< CppAD::vector >(); - ok &= SetCases< std::vector >(); + ok &= SetCases< std::vector >(); // Do not use valarray because its element access in the const case // returns a copy instead of a reference - // ok &= SetCases< std::valarray >(); + // ok &= SetCases< std::valarray >(); return ok; } diff -Nru cppad-2015.00.00.9/example/rev_two.cpp cppad-2016.00.00.1/example/rev_two.cpp --- cppad-2015.00.00.9/example/rev_two.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/rev_two.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rev_two.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: rev_two.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,10 +18,6 @@ $section Second Partials Reverse Driver: Example and Test$$ -$index second, partial$$ -$index partial, second$$ -$index example, second partial$$ -$index test, second partial$$ $code $verbatim%example/rev_two.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -34,7 +30,7 @@ namespace { // ----------------------------------------------------- // define the template function in empty namespace // bool RevTwoCases(void) -template +template bool RevTwoCases() { bool ok = true; using CppAD::AD; @@ -82,18 +78,18 @@ ddw = f.RevTwo(x, i, j); // partials of y[0] w.r.t x[0] is 2 * x[0] * exp(x[1]) - // check partials of y[0] w.r.t x[0] and x[k] for k = 0, 1 + // check partials of y[0] w.r.t x[0] and x[k] for k = 0, 1 ok &= NearEqual( 2.*exp(x[1]), ddw[0*p+0], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*exp(x[1]), ddw[1*p+0], 1e-10, 1e-10 ); // partials of y[1] w.r.t x[1] is x[0] * x[0] * cos(x[1]) - // check partials of F_1 w.r.t x[1] and x[k] for k = 0, 1 + // check partials of F_1 w.r.t x[1] and x[k] for k = 0, 1 ok &= NearEqual( 2.*x[0]*cos(x[1]), ddw[0*p+1], 1e-10, 1e-10 ); ok &= NearEqual( -x[0]*x[0]*sin(x[1]), ddw[1*p+1], 1e-10, 1e-10 ); return ok; } -} // End empty namespace +} // End empty namespace # include # include bool RevTwo(void) diff -Nru cppad-2015.00.00.9/example/romberg_mul.cpp cppad-2016.00.00.1/example/romberg_mul.cpp --- cppad-2015.00.00.9/example/romberg_mul.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/romberg_mul.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: romberg_mul.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: romberg_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section One Dimensional Romberg Integration: Example and Test$$ -$index Romberg, example$$ -$index example, Romberg$$ -$index test, Romberg$$ $code $verbatim%example/romberg_mul.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -30,9 +27,9 @@ */ // BEGIN C++ -# include -# include -# include +# include +# include +# include namespace { @@ -42,7 +39,7 @@ const CppAD::vector deg; public: // constructor - TestFun(const CppAD::vector deg_) + TestFun(const CppAD::vector deg_) : deg(deg_) { } @@ -71,9 +68,9 @@ TestFun F(deg); CppAD::RombergMul< - TestFun , - CppAD::vector, - CppAD::vector, + TestFun , + CppAD::vector, + CppAD::vector, 2 > RombergMulTest; // arugments to RombergMul @@ -90,21 +87,21 @@ double r, e; // int_a1^b1 dx1 int_a0^b0 F(x0,x1) dx0 - // = [ b0^(deg[0]+1) - a0^(deg[0]+1) ] / (deg[0]+1) - // * [ b1^(deg[1]+1) - a1^(deg[1]+1) ] / (deg[1]+1) + // = [ b0^(deg[0]+1) - a0^(deg[0]+1) ] / (deg[0]+1) + // * [ b1^(deg[1]+1) - a1^(deg[1]+1) ] / (deg[1]+1) double bpow = 1.; double apow = 1.; for(i = 0; i <= deg[0]; i++) { bpow *= b[0]; apow *= a[0]; - } + } double check = (bpow - apow) / (deg[0]+1); bpow = 1.; apow = 1.; for(i = 0; i <= deg[1]; i++) { bpow *= b[1]; apow *= a[1]; - } + } check *= (bpow - apow) / (deg[1]+1); double step = (b[1] - a[1]) / exp(log(2.)*(n[1]-1)); @@ -118,7 +115,7 @@ r = RombergMulTest(F, a, b, n, p, e); ok &= e < bnd; - ok &= CppAD::NearEqual(check, r, 0., e); + ok &= CppAD::NearEqual(check, r, 0., e); } diff -Nru cppad-2015.00.00.9/example/romberg_one.cpp cppad-2016.00.00.1/example/romberg_one.cpp --- cppad-2015.00.00.9/example/romberg_one.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/romberg_one.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: romberg_one.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: romberg_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section One Dimensional Romberg Integration: Example and Test$$ -$index Romberg, example$$ -$index example, Romberg$$ -$index test, Romberg$$ $code $verbatim%example/romberg_one.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -30,9 +27,9 @@ */ // BEGIN C++ -# include -# include -# include +# include +# include +# include namespace { class Fun { @@ -40,7 +37,7 @@ const size_t degree; public: // constructor - Fun(size_t degree_) : degree(degree_) + Fun(size_t degree_) : degree(degree_) { } // function F(x) = x^degree @@ -69,13 +66,13 @@ size_t p; double r, e; - // int_a^b F(x) dx = [ b^(degree+1) - a^(degree+1) ] / (degree+1) + // int_a^b F(x) dx = [ b^(degree+1) - a^(degree+1) ] / (degree+1) double bpow = 1.; double apow = 1.; for(i = 0; i <= degree; i++) { bpow *= b; apow *= a; - } + } double check = (bpow - apow) / (degree+1); // step size corresponding to r @@ -91,7 +88,7 @@ r = CppAD::RombergOne(F, a, b, n, p, e); ok &= e < (degree+1) * spow; - ok &= CppAD::NearEqual(check, r, 0., e); + ok &= CppAD::NearEqual(check, r, 0., e); } return ok; diff -Nru cppad-2015.00.00.9/example/rosen_34.cpp cppad-2016.00.00.1/example/rosen_34.cpp --- cppad-2015.00.00.9/example/rosen_34.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/rosen_34.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rosen_34.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: rosen_34.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,16 +17,14 @@ $$ $section Rosen34: Example and Test$$ +$mindex Rosen34$$ -$index Rosen34, example$$ -$index example, Rosen34$$ -$index test, Rosen34$$ -Define +Define $latex X : \B{R} \rightarrow \B{R}^n$$ by $latex \[ X_i (t) = t^{i+1} -\] $$ +\] $$ for $latex i = 1 , \ldots , n-1$$. It follows that $latex \[ @@ -52,16 +50,16 @@ class Fun { public: // constructor - Fun(bool use_x_) : use_x(use_x_) + Fun(bool use_x_) : use_x(use_x_) { } // compute f(t, x) both for double and AD template void Ode( - const Scalar &t, - const CPPAD_TESTVECTOR(Scalar) &x, + const Scalar &t, + const CPPAD_TESTVECTOR(Scalar) &x, CPPAD_TESTVECTOR(Scalar) &f) - { size_t n = x.size(); + { size_t n = x.size(); Scalar ti(1); f[0] = Scalar(1); size_t i; @@ -77,12 +75,12 @@ // compute partial of f(t, x) w.r.t. t using AD void Ode_ind( - const double &t, - const CPPAD_TESTVECTOR(double) &x, + const double &t, + const CPPAD_TESTVECTOR(double) &x, CPPAD_TESTVECTOR(double) &f_t) { using namespace CppAD; - size_t n = x.size(); + size_t n = x.size(); CPPAD_TESTVECTOR(AD) T(1); CPPAD_TESTVECTOR(AD) X(n); CPPAD_TESTVECTOR(AD) F(n); @@ -110,12 +108,12 @@ // compute partial of f(t, x) w.r.t. x using AD void Ode_dep( - const double &t, - const CPPAD_TESTVECTOR(double) &x, + const double &t, + const CPPAD_TESTVECTOR(double) &x, CPPAD_TESTVECTOR(double) &f_x) { using namespace CppAD; - size_t n = x.size(); + size_t n = x.size(); CPPAD_TESTVECTOR(AD) T(1); CPPAD_TESTVECTOR(AD) X(n); CPPAD_TESTVECTOR(AD) F(n); @@ -162,20 +160,20 @@ size_t n = 4; // number components in X(t) and order of method size_t M = 2; // number of Rosen34 steps in [ti, tf] double ti = 0.; // initial time - double tf = 2.; // final time + double tf = 2.; // final time // xi = X(0) - CPPAD_TESTVECTOR(double) xi(n); + CPPAD_TESTVECTOR(double) xi(n); for(i = 0; i 0); + Fun F(use_x > 0); // compute Rosen34 approximation for X(tf) - CPPAD_TESTVECTOR(double) xf(n), e(n); + CPPAD_TESTVECTOR(double) xf(n), e(n); xf = CppAD::Rosen34(F, M, ti, tf, xi, e); double check = tf; diff -Nru cppad-2015.00.00.9/example/runge45_1.cpp cppad-2016.00.00.1/example/runge45_1.cpp --- cppad-2015.00.00.9/example/runge45_1.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/runge45_1.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: runge45_1.cpp 2509 2012-10-25 17:34:50Z bradbell $ */ +// $Id: runge45_1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,16 +17,14 @@ $$ $section Runge45: Example and Test$$ +$mindex Runge45$$ -$index Runge45, example$$ -$index example, Runge45$$ -$index test, Runge45$$ -Define +Define $latex X : \B{R} \rightarrow \B{R}^n$$ by $latex \[ X_i (t) = t^{i+1} -\] $$ +\] $$ for $latex i = 1 , \ldots , n-1$$. It follows that $latex \[ @@ -47,27 +45,27 @@ // BEGIN C++ # include // for size_t -# include // for CppAD::NearEqual -# include // for CppAD::vector -# include // for CppAD::Runge45 +# include // for CppAD::NearEqual +# include // for CppAD::vector +# include // for CppAD::Runge45 // Runge45 requires fabs to be defined (not std::fabs) -// defines this for doubles, but runge_45.hpp does not. +// defines this for doubles, but runge_45.hpp does not. # include // for fabs without std in front namespace { class Fun { public: // constructor - Fun(bool use_x_) : use_x(use_x_) + Fun(bool use_x_) : use_x(use_x_) { } // set f = x'(t) void Ode( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f) - { size_t n = x.size(); + { size_t n = x.size(); double ti = 1.; f[0] = 1.; size_t i; @@ -91,20 +89,20 @@ size_t n = 5; // number components in X(t) and order of method size_t M = 2; // number of Runge45 steps in [ti, tf] double ti = 0.; // initial time - double tf = 2.; // final time + double tf = 2.; // final time // xi = X(0) - CppAD::vector xi(n); + CppAD::vector xi(n); for(i = 0; i 0); + Fun F(use_x > 0); // compute Runge45 approximation for X(tf) - CppAD::vector xf(n), e(n); + CppAD::vector xf(n), e(n); xf = CppAD::Runge45(F, M, ti, tf, xi, e); double check = tf; diff -Nru cppad-2015.00.00.9/example/runge45_2.cpp cppad-2016.00.00.1/example/runge45_2.cpp --- cppad-2015.00.00.9/example/runge45_2.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/runge45_2.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: runge45_2.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: runge45_2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,16 +17,14 @@ $$ $section Runge45: Example and Test$$ +$mindex Runge45$$ -$index Runge45, example$$ -$index example, Runge45$$ -$index test, Runge45$$ -Define +Define $latex X : \B{R} \times \B{R} \rightarrow \B{R}^n$$ by $latex \[ X_j (b, t) = b \left( \sum_{k=0}^j t^k / k ! \right) -\] $$ +\] $$ for $latex j = 0 , \ldots , n-1$$. It follows that $latex \[ @@ -40,7 +38,7 @@ \end{array} \] $$ For a fixed $latex t_f$$, -we can use $cref Runge45$$ to define +we can use $cref Runge45$$ to define $latex f : \B{R} \rightarrow \B{R}^n$$ as an approximation for $latex f(b) = X(b, t_f )$$. We can then compute $latex f^{(1)} (b)$$ which is an approximation for @@ -66,15 +64,15 @@ class Fun { public: // constructor - Fun(void) + Fun(void) { } // set return value to X'(t) void Ode( - const Scalar &t, - const CPPAD_TESTVECTOR(Scalar) &x, + const Scalar &t, + const CPPAD_TESTVECTOR(Scalar) &x, CPPAD_TESTVECTOR(Scalar) &f) - { size_t n = x.size(); + { size_t n = x.size(); f[0] = 0.; for(size_t k = 1; k < n; k++) f[k] = x[k-1]; @@ -92,7 +90,7 @@ size_t n = 5; // number components in X(t) and order of method size_t M = 2; // number of Runge45 steps in [ti, tf] Scalar ad_ti = 0.; // initial time - Scalar ad_tf = 2.; // final time + Scalar ad_tf = 2.; // final time // value of independent variable at which to record operations CPPAD_TESTVECTOR(Scalar) ad_b(1); @@ -100,17 +98,17 @@ // declare b to be the independent variable Independent(ad_b); - + // object to evaluate ODE - Fun ad_F; + Fun ad_F; // xi = X(0) - CPPAD_TESTVECTOR(Scalar) ad_xi(n); + CPPAD_TESTVECTOR(Scalar) ad_xi(n); for(j = 0; j < n; j++) ad_xi[j] = ad_b[0]; // compute Runge45 approximation for X(tf) - CPPAD_TESTVECTOR(Scalar) ad_xf(n), ad_e(n); + CPPAD_TESTVECTOR(Scalar) ad_xf(n), ad_e(n); ad_xf = CppAD::Runge45(ad_F, M, ad_ti, ad_tf, ad_xi, ad_e); // stop recording and use it to create f : b -> xf @@ -147,7 +145,7 @@ term *= tf; term /= double(j+1); } - + return ok; } diff -Nru cppad-2015.00.00.9/example/seq_property.cpp cppad-2016.00.00.1/example/seq_property.cpp --- cppad-2015.00.00.9/example/seq_property.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/seq_property.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: seq_property.cpp 2991 2013-10-22 16:25:15Z bradbell $ */ +// $Id: seq_property.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,33 +21,10 @@ $$ $section ADFun Sequence Properties: Example and Test$$ +$mindex Domain Range Parameter size_var size_par size_op_arg size_VecAD$$ + + -$index Domain, ADFun$$ -$index Range, ADFun$$ -$index Parameter, ADFun$$ -$index size_var, ADFun$$ -$index size_par, ADFun$$ -$index size_op, ADFun$$ -$index size_op_arg, ADFun$$ -$index size_VecAD, ADFun$$ - -$index example, Domain$$ -$index example, Range$$ -$index example, Parameter$$ -$index example, size_var$$ -$index example, size_par$$ -$index example, size_op$$ -$index example, size_op_arg$$ -$index example, size_VecAD$$ - -$index test, Domain$$ -$index test, Range$$ -$index test, Parameter$$ -$index test, size_var$$ -$index test, size_par$$ -$index test, size_op$$ -$index test, size_op_arg$$ -$index test, size_VecAD$$ $code $verbatim%example/seq_property.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -96,14 +73,14 @@ x[1] = 1.; // declare independent variables and start tape recording - CppAD::Independent(x); + CppAD::Independent(x); nvar += n; nop += n; // a computation that adds to the operation sequence AD I = 0; - v[I] = x[0]; - nvecad += 3; // one for vector, two for its elements + v[I] = x[0]; + nvecad += 3; // one for vector, two for its elements npar += 2; // need parameters 0 and 1 for initial v nop += 1; // operator for storing in a VecAD object narg += 3; // the three arguments are v, I, and x[0] @@ -113,7 +90,7 @@ AD w = x[1]; // use same variable as x[1] // a computation that adds to the operation sequence - w = w * (u + w); + w = w * (u + w); nop += 2; // requires two new operators, an add and a multiply nvar += 2; // each operator results in its own variable narg += 4; // each operator has two arguments @@ -123,7 +100,7 @@ CPPAD_TESTVECTOR(AD) y(m); // operations that do not add to the operation sequence - y[0] = 1.; // re-use the parameter 1 + y[0] = 1.; // re-use the parameter 1 y[1] = u; // use same variable as u // a computation that adds to the operation sequence @@ -134,7 +111,7 @@ narg += 2; // operator has two arguments // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); nop += 1; // special operator for y[0] becasue it is a parameter nvar += 1; // special variable for y[0] because it is a parameter narg += 1; // identifies which parameter corresponds to y[0] diff -Nru cppad-2015.00.00.9/example/sign.cpp cppad-2016.00.00.1/example/sign.cpp --- cppad-2015.00.00.9/example/sign.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/sign.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sign.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sign.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,6 @@ $section Sign Function: Example and Test$$ -$index sign, example$$ -$index example, sign$$ -$index test, sign$$ $code $verbatim%example/sign.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -52,7 +49,7 @@ // use f(x) to evaluate the sign function and its derivatives CPPAD_TESTVECTOR(double) x(n), y(m), dx(n), dy(m), w(m), dw(n); dx[0] = 1.; - w[0] = 1.; + w[0] = 1.; // x[0] = 2.; y = f.Forward(0, x); diff -Nru cppad-2015.00.00.9/example/simple_vector.cpp cppad-2016.00.00.1/example/simple_vector.cpp --- cppad-2015.00.00.9/example/simple_vector.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/simple_vector.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: simple_vector.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: simple_vector.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,6 @@ $section Simple Vector Template Class: Example and Test$$ -$index vector, simple$$ -$index simple, vector example$$ -$index example, simple vector$$ -$index test, simple vector$$ $code $verbatim%example/simple_vector.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -34,8 +30,8 @@ # include // std::vector # include // std::valarray -# include // CppAD::vector -# include // CppAD::CheckSimpleVector +# include // CppAD::vector +# include // CppAD::CheckSimpleVector namespace { template bool Ok(void) @@ -50,12 +46,12 @@ ok &= (y.size() == 2); // size for an vector with elements // non-const access to the elements of y - size_t i; + size_t i; for(i = 0; i < 2; i++) - y[i] = Scalar(i); + y[i] = Scalar(i); const Vector z(y); // copy constructor - x.resize(2); // resize + x.resize(2); // resize x = z; // vector assignment // use the const access to the elements of x @@ -76,8 +72,8 @@ ok &= Ok< std::valarray >(); ok &= Ok< CppAD::vector >(); # ifndef _MSC_VER - // Avoid Microsoft following compiler warning: 'size_t' : - // forcing value to bool 'true' or 'false' (performance warning) + // Avoid Microsoft following compiler warning: 'size_t' : + // forcing value to bool 'true' or 'false' (performance warning) ok &= Ok< std::vector >(); ok &= Ok< CppAD::vector >(); # endif diff -Nru cppad-2015.00.00.9/example/sin.cpp cppad-2016.00.00.1/example/sin.cpp --- cppad-2015.00.00.9/example/sin.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/sin.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sin.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sin.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section The AD sin Function: Example and Test$$ -$index sin, AD example$$ -$index example, AD sin$$ -$index test, AD sin$$ $code $verbatim%example/sin.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -48,15 +45,15 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::sin(x[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value double check = std::sin(x0); ok &= NearEqual(y[0] , check, 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/sinh.cpp cppad-2016.00.00.1/example/sinh.cpp --- cppad-2015.00.00.9/example/sinh.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/sinh.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sinh.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sinh.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section The AD sinh Function: Example and Test$$ -$index sinh, AD example$$ -$index example, AD sinh$$ -$index test, AD sinh$$ $code $verbatim%example/sinh.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -48,15 +45,15 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::sinh(x[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value double check = std::sinh(x0); ok &= NearEqual(y[0] , check, 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/sparse_hessian.cpp cppad-2016.00.00.1/example/sparse_hessian.cpp --- cppad-2015.00.00.9/example/sparse_hessian.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/sparse_hessian.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_hessian.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section Sparse Hessian: Example and Test$$ +$mindex Hessian spare$$ -$index Hessian, sparse$$ -$index example, sparse Hessian$$ -$index test, sparse Hessian$$ -$index spare, Hessian example$$ $code $verbatim%example/sparse_hessian.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -161,13 +158,14 @@ x[1] = 0.5; ell = 1 * n + 1; check[ell] = 6.0 * x[1]; - n_sweep = f.SparseHessian(x, w, p_set, row, col, hes, work); + s_vector not_used; + n_sweep = f.SparseHessian(x, w, not_used, row, col, hes, work); for(k = 0; k < K; k++) { ell = row[k] * n + col[k]; ok &= NearEqual(w[0] * check[ell], hes[k], eps, eps ); } ok &= n_sweep == 2; - + return ok; diff -Nru cppad-2015.00.00.9/example/sparse_jacobian.cpp cppad-2016.00.00.1/example/sparse_jacobian.cpp --- cppad-2015.00.00.9/example/sparse_jacobian.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/sparse_jacobian.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_jacobian.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section Sparse Jacobian: Example and Test$$ +$mindex Jacobian spare$$ -$index Jacobian, sparse$$ -$index example, sparse Jacobian$$ -$index test, sparse Jacobian$$ -$index spare, Jacobian example$$ $code $verbatim%example/sparse_jacobian.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -104,7 +101,7 @@ ok &= NearEqual(check[ell], jac[ell], eps, eps ); // using row and column indices to compute non-zero in rows 1 and 2 - // (skip row 0). + // (skip row 0). size_t K = 6; i_vector row(K), col(K); jac.resize(K); @@ -119,13 +116,13 @@ k++; } } - } + } ok &= k == K; // empty work structure CppAD::sparse_jacobian_work work; - // could use p_b + // could use p_b size_t n_sweep = f.SparseJacobianReverse(x, p_s, row, col, jac, work); for(k = 0; k < K; k++) { ell = row[k] * n + col[k]; @@ -135,7 +132,8 @@ // now recompute at a different x value (using work from previous call) check[11] = x[3] = 10.; - n_sweep = f.SparseJacobianReverse(x, p_s, row, col, jac, work); + std::vector< std::set > not_used; + n_sweep = f.SparseJacobianReverse(x, not_used, row, col, jac, work); for(k = 0; k < K; k++) { ell = row[k] * n + col[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); @@ -189,9 +187,9 @@ [ 0 1 x_2 ] */ d_vector check(m * n); - check[0] = 1.; check[1] = 0.; check[2] = 1.; + check[0] = 1.; check[1] = 0.; check[2] = 1.; check[3] = 1.; check[4] = 0.; check[5] = 1.; - check[6] = 0.; check[7] = 1.; check[8] = 1.; + check[6] = 0.; check[7] = 1.; check[8] = 1.; check[9] = 0.; check[10] = 1.; check[11] = x[2]; for(ell = 0; ell < size_t(check.size()); ell++) ok &= NearEqual(check[ell], jac[ell], eps, eps ); @@ -218,7 +216,7 @@ ok &= NearEqual(check[ell], jac[ell], eps, eps ); // using row and column indices to compute non-zero elements excluding - // row 0 and column 0. + // row 0 and column 0. size_t K = 5; i_vector row(K), col(K); jac.resize(K); @@ -233,13 +231,13 @@ k++; } } - } + } ok &= k == K; // empty work structure CppAD::sparse_jacobian_work work; - // could use p_s + // could use p_s size_t n_sweep = f.SparseJacobianForward(x, p_b, row, col, jac, work); for(k = 0; k < K; k++) { ell = row[k] * n + col[k]; @@ -258,7 +256,7 @@ return ok; } -} // End empty namespace +} // End empty namespace bool sparse_jacobian(void) { bool ok = true; diff -Nru cppad-2015.00.00.9/example/sparse_sub_hes.cpp cppad-2016.00.00.1/example/sparse_sub_hes.cpp --- cppad-2015.00.00.9/example/sparse_sub_hes.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/sparse_sub_hes.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,139 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin sparse_sub_hes.cpp$$ +$spell +$$ + +$section Sparse Hessian on Subset of Variables: Example and Test$$ + +$head Purpose$$ +This example uses a subset of the sparsity pattern, +to compute the Hessian for a subset of the variables, +without having to compute the sparsity pattern for the entire function. + +$head See Also$$ +$cref sub_sparse_hes.cpp$$ + +$code +$verbatim%example/sparse_sub_hes.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include +bool sparse_sub_hes(void) +{ bool ok = true; + using CppAD::AD; + typedef CppAD::vector< double > d_vector; + typedef CppAD::vector< AD > a_vector; + typedef CppAD::vector i_vector; + typedef CppAD::vector< std::set > s_vector; + + // domain space vector + size_t n = 12; // must be greater than or equal 3; see n_sweep below + a_vector a_x(n); + for(size_t j = 0; j < n; j++) + a_x[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(a_x); + + // range space vector + size_t m = 1; + a_vector a_y(m); + a_y[0] = 0.0; + for(size_t j = 1; j < n; j++) + a_y[0] += a_x[j-1] * a_x[j] * a_x[j]; + + // create f: x -> y and stop tape recording + // (without executing zero order forward calculation) + CppAD::ADFun f; + f.Dependent(a_x, a_y); + + // sparsity patteren for the sub-set of variables we are computing + // the hessian w.r.t. + size_t n_sub = 4; + s_vector r(n); + for(size_t j = 0; j < n_sub; j++) + { assert( r[j].empty() ); + r[j].insert(j); + } + + // store forward sparsity for J(x) = F^{(1)} (x) * R + f.ForSparseJac(n_sub, r); + + // compute sparsity pattern for H(x) = (S * F)^{(2)} ( x ) * R + s_vector s(1); + assert( s[0].empty() ); + s[0].insert(0); + bool transpose = true; + s_vector h = f.RevSparseHes(n_sub, s, transpose); + + // check sparsity pattern + for(size_t i = 0; i < n; i++) + { std::set check; + assert( check.empty() ); + if( i <= n_sub ) + { if( i == 0 ) + check.insert(1); + else + { check.insert(i-1); + if( i < n_sub ) + check.insert(i); + if( i + 1 < n_sub) + check.insert(i+1); + } + } + ok &= h[i] == check; + } + + // set the row and column indices that correspond to lower triangle + i_vector row, col; + for(size_t i = 0; i < n_sub; i++) + { std::set::iterator itr; + for(itr = h[i].begin(); itr != h[i].end(); itr++) + { if( *itr <= i ) + { row.push_back( i ); + col.push_back( *itr ); + } + } + } + + // weighting for the Hessian + d_vector w(1); + w[0] = 1.0; + + // compute Hessian + CppAD::sparse_hessian_work work; + d_vector x(n), hes( row.size() ); + for(size_t j = 0; j < n; j++) + x[j] = double(j+1); + f.SparseHessian(x, w, h, row, col, hes, work); + + // check the values in the sparse hessian + for(size_t ell = 0; ell < row.size(); ell++) + { size_t i = row[ell]; + size_t j = col[ell]; + if( i == j ) + ok &= hes[ell] == 2.0 * x[i-1]; + else + { ok &= j+1 == i; + ok &= hes[ell] == 2.0 * x[i]; + } + ell++; + } + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/example/sparsity_sub.cpp cppad-2016.00.00.1/example/sparsity_sub.cpp --- cppad-2015.00.00.9/example/sparsity_sub.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/sparsity_sub.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,104 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin sparsity_sub.cpp$$ +$spell + Jac + Jacobian + Hes +$$ + +$section Sparsity Patterns For a Subset of Variables: Example and Test$$ + +$head See Also$$ +$cref sparse_sub_hes.cpp$$, $cref sub_sparse_hes.cpp$$. + +$head ForSparseJac$$ +The routine $cref ForSparseJac$$ is used to compute the +sparsity for both the full Jacobian (see $icode s$$) +and a subset of the Jacobian (see $icode s2$$). + +$head RevSparseHes$$ +The routine $cref RevSparseHes$$ is used to compute both +sparsity for both the full Hessian (see $icode h$$) +and a subset of the Hessian (see $icode h2$$). + +$code +$verbatim%example/sparsity_sub.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include + +bool sparsity_sub(void) +{ // C++ source code + bool ok = true; + // + using std::cout; + using CppAD::vector; + using CppAD::AD; + using CppAD::vectorBool; + + size_t n = 4; + size_t m = n-1; + vector< AD > ax(n), ay(m); + for(size_t j = 0; j < n; j++) + ax[j] = double(j+1); + CppAD::Independent(ax); + for(size_t i = 0; i < m; i++) + ay[i] = (ax[i+1] - ax[i]) * (ax[i+1] - ax[i]); + CppAD::ADFun f(ax, ay); + + // Evaluate the full Jacobian sparsity pattern for f + vectorBool r(n * n), s(m * n); + for(size_t j = 0 ; j < n; j++) + { for(size_t i = 0; i < n; i++) + r[i * n + j] = (i == j); + } + s = f.ForSparseJac(n, r); + + // evaluate the sparsity for the Hessian of f_0 + ... + f_{m-1} + vectorBool t(m), h(n * n); + for(size_t i = 0; i < m; i++) + t[i] = true; + h = f.RevSparseHes(n, t); + + // evaluate the Jacobian sparsity pattern for first n/2 components of x + size_t n2 = n / 2; + vectorBool r2(n * n2), s2(m * n2); + for(size_t j = 0 ; j < n2; j++) + { for(size_t i = 0; i < n; i++) + r2[i * n2 + j] = (i == j); + } + s2 = f.ForSparseJac(n2, r2); + + // evaluate the sparsity for the subset of Hessian of + // f_0 + ... + f_{m-1} where first partial has only first n/2 components + vectorBool h2(n2 * n); + h2 = f.RevSparseHes(n2, t); + + // check sparsity pattern for Jacobian + for(size_t i = 0; i < m; i++) + { for(size_t j = 0; j < n2; j++) + ok &= s2[i * n2 + j] == s[i * n + j]; + } + + // check sparsity pattern for Hessian + for(size_t i = 0; i < n2; i++) + { for(size_t j = 0; j < n; j++) + ok &= h2[i * n + j] == h[i * n + j]; + } + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/example/sqrt.cpp cppad-2016.00.00.1/example/sqrt.cpp --- cppad-2015.00.00.9/example/sqrt.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/sqrt.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sqrt.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sqrt.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section The AD sqrt Function: Example and Test$$ -$index sqrt, AD example$$ -$index example, AD sqrt$$ -$index test, AD sqrt$$ $code $verbatim%example/sqrt.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -48,15 +45,15 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::sqrt(x[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value double check = std::sqrt(x0); ok &= NearEqual(y[0] , check, 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/stack_machine.cpp cppad-2016.00.00.1/example/stack_machine.cpp --- cppad-2015.00.00.9/example/stack_machine.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/stack_machine.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: stack_machine.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: stack_machine.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,10 +15,8 @@ $$ $section Example Differentiating a Stack Machine Interpreter$$ +$mindex test$$ -$index interpreter, example$$ -$index example, interpreter$$ -$index test, interpreter$$ $code $verbatim%example/stack_machine.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -37,7 +35,7 @@ # include -namespace { +namespace { // Begin empty namespace ------------------------------------------------ bool is_number( const std::string &s ) @@ -56,7 +54,7 @@ return variable; } -void StackMachine( +void StackMachine( std::stack< std::string > &token_stack , CppAD::vector< CppAD::AD > &variable ) { using std::string; @@ -81,7 +79,7 @@ { value_one = variable[ size_t(s[0]) - size_t('a') ]; value_stack.push( value_one ); } - else if( is_binary(s) ) + else if( is_binary(s) ) { assert( value_stack.size() >= 2 ); value_one = value_stack.top(); value_stack.pop(); @@ -111,7 +109,7 @@ } } else if( s[0] == '=' ) - { assert( value_stack.size() >= 1 ); + { assert( value_stack.size() >= 1 ); assert( token_stack.size() >= 1 ); // s = token_stack.top(); @@ -163,7 +161,7 @@ // declare independent variables and start tape recording CppAD::Independent(X); - + // x[0] corresponds to a in the stack machine vector< AD > variable(26); variable[0] = X[0]; @@ -177,8 +175,8 @@ Y[0] = variable[1]; // b = a + 1 Y[1] = variable[2]; // c = (a + 1) * 2 Y[2] = variable[3]; // d = (a + 1) * 2 - 3 - Y[3] = variable[4]; // e = ( (a + 1) * 2 - 3 ) / 4 - + Y[3] = variable[4]; // e = ( (a + 1) * 2 - 3 ) / 4 + // create f : X -> Y and stop tape recording CppAD::ADFun f(X, Y); diff -Nru cppad-2015.00.00.9/example/sub.cpp cppad-2016.00.00.1/example/sub.cpp --- cppad-2015.00.00.9/example/sub.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/sub.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sub.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sub.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,12 +14,8 @@ $begin sub.cpp$$ $section AD Binary Subtraction: Example and Test$$ +$mindex - subtract minus$$ -$index -, AD example$$ -$index subtract, AD example$$ -$index minus, AD example$$ -$index example, subtract$$ -$index test, subtract$$ $code $verbatim%example/sub.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -46,10 +42,10 @@ AD a = 2. * x[0] - 1.; // AD - double AD b = a - 2; // AD - int - AD c = 3. - b; // double - AD - AD d = 4 - c; // int - AD + AD c = 3. - b; // double - AD + AD d = 4 - c; // int - AD - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = x[0] - d; // AD - AD @@ -57,7 +53,7 @@ // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0], x0-4.+3.+2.-2.*x0+1., 1e-10 , 1e-10); // forward computation of partials w.r.t. x[0] diff -Nru cppad-2015.00.00.9/example/sub_eq.cpp cppad-2016.00.00.1/example/sub_eq.cpp --- cppad-2015.00.00.9/example/sub_eq.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/sub_eq.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sub_eq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sub_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,17 +14,9 @@ $begin sub_eq.cpp$$ $section AD Computed Assignment Subtraction: Example and Test$$ +$mindex -= subtract assign plus add$$ + -$index -=, AD example$$ -$index computed, AD assignment subtract example$$ -$index assignment, AD computed subtract example$$ -$index example, AD computed assignment subtract$$ -$index test, AD computed assignment subtract$$ - -$index computed, -= example$$ -$index assign, -= example$$ -$index plus, -= example$$ -$index add, -= example$$ $code $verbatim%example/sub_eq.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -44,12 +36,12 @@ size_t n = 1; double x0 = .5; CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 2; CPPAD_TESTVECTOR(AD) y(m); y[0] = 3. * x[0]; // initial value @@ -58,9 +50,9 @@ y[1] = y[0] -= x[0]; // use the result of a computed assignment // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , 3.*x0-(2.+4.+x0), 1e-10 , 1e-10); ok &= NearEqual(y[1] , y[0], 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/example/sub_sparse_hes.cpp cppad-2016.00.00.1/example/sub_sparse_hes.cpp --- cppad-2015.00.00.9/example/sub_sparse_hes.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/sub_sparse_hes.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -0,0 +1,161 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin sub_sparse_hes.cpp$$ + +$section Computing Sparse Hessian for a Subset of Variables$$ + +$head Purpose$$ +This example uses +$cref/multiple levels of AD/mul_level/$$ +to compute the Hessian for a subset of the variables +without having to compute the sparsity pattern for the entire function. + +$head See Also$$ +$cref sparse_sub_hes.cpp$$, $cref sparsity_sub.cpp$$, + +$head Function$$ +We consider the function +$latex f : \B{R}^{nu} \times \B{R}^{nv} \rightarrow \B{R}$$ defined by +$latex \[ +f (u, v) = +\left( \sum_{j=0}^{nu-1} u_j^3 \right) +\left( \sum_{j=0}^{nv-1} v_j \right) +\] $$ + +$head Subset$$ +Suppose that we are only interested computing the function +$latex \[ + H(u, v) = \partial_u \partial_u f (u, v) +\] $$ +where this Hessian is sparse. + +$head Example$$ +The following code shows one way to compute this subset of the +Hessian of $latex f$$. +$code +$verbatim%example/sub_sparse_hes.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include + +namespace { + using CppAD::vector; + template + Scalar f(const vector& u,const vector& v) + { size_t i; + Scalar sum_v = Scalar(0); + for(i = 0; i < v.size(); i++) + sum_v += v[i]; + Scalar sum_cube_u = Scalar(0); + for(i = 0; i < u.size(); i++) + sum_cube_u += u[i] * u[i] * u[i] / 6.0; + return sum_v * sum_cube_u; + } +} + +bool sub_sparse_hes(void) +{ bool ok = true; + using CppAD::AD; + typedef AD adouble; + typedef AD a2double; + typedef vector< std::set > pattern; + double eps = 10. * std::numeric_limits::epsilon(); + size_t i, j; + + // start recording with x = (u , v) + size_t nu = 10; + size_t nv = 5; + size_t n = nu + nv; + vector ax(n); + for(j = 0; j < n; j++) + ax[j] = adouble(j + 2); + CppAD::Independent(ax); + + // extract u as independent variables + vector a2u(nu); + for(j = 0; j < nu; j++) + a2u[j] = a2double(j + 2); + CppAD::Independent(a2u); + + // extract v as parameters + vector a2v(nv); + for(j = 0; j < nv; j++) + a2v[j] = ax[nu+j]; + + // record g(u) + vector a2y(1); + a2y[0] = f(a2u, a2v); + CppAD::ADFun g; + g.Dependent(a2u, a2y); + + // compue sparsity pattern for Hessian of g(u) + pattern r(nu), s(1); + for(j = 0; j < nu; j++) + r[j].insert(j); + g.ForSparseJac(nu, r); + s[0].insert(0); + pattern p = g.RevSparseHes(nu, s); + + // Row and column indices for non-zeros in lower triangle of Hessian + vector row, col; + for(i = 0; i < nu; i++) + { std::set::const_iterator itr; + for(itr = p[i].begin(); itr != p[i].end(); itr++) + { j = *itr; + if( j <= i ) + { row.push_back(i); + col.push_back(j); + } + } + } + size_t K = row.size(); + CppAD::sparse_hessian_work work; + vector au(nu), ahes(K), aw(1); + aw[0] = 1.0; + for(j = 0; j < nu; j++) + au[j] = ax[j]; + size_t n_sweep = g.SparseHessian(au, aw, p, row, col, ahes, work); + + // The Hessian w.r.t u is diagonal + ok &= n_sweep == 1; + + // record H(u, v) = Hessian of f w.r.t u + CppAD::ADFun H(ax, ahes); + + // remove unecessary operations + H.optimize(); + + // Now evaluate the Hessian at a particular value for u, v + vector u(nu), v(nv), x(n); + for(j = 0; j < n; j++) + x[j] = double(j + 2); + vector hes = H.Forward(0, x); + + // Now check the Hessian + double sum_v = 0.0; + for(j = 0; j < nv; j++) + sum_v += x[nu + j]; + for(size_t k = 0; k < K; k++) + { i = row[k]; + j = col[k]; + ok &= i == j; + double check = sum_v * x[i]; + ok &= CppAD::NearEqual(hes[k], check, eps, eps); + } + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/example/tan.cpp cppad-2016.00.00.1/example/tan.cpp --- cppad-2015.00.00.9/example/tan.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/tan.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: tan.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: tan.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $section The AD tan Function: Example and Test$$ -$index tan, example$$ -$index example, tan$$ -$index test, tan$$ $code $verbatim%example/tan.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -51,15 +48,15 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::tan(x[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value double check = std::tan(x0); ok &= NearEqual(y[0] , check, eps, eps); @@ -68,7 +65,7 @@ CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); - check = 1. + std::tan(x0) * std::tan(x0); + check = 1. + std::tan(x0) * std::tan(x0); ok &= NearEqual(dy[0], check, eps, eps); // reverse computation of derivative of y[0] diff -Nru cppad-2015.00.00.9/example/tanh.cpp cppad-2016.00.00.1/example/tanh.cpp --- cppad-2015.00.00.9/example/tanh.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/example/tanh.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: tanh.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: tanh.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ $section The AD tanh Function: Example and Test$$ -$index tanh, example$$ -$index example, tanh$$ -$index test, tanh$$ $code $verbatim%example/tanh.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -50,15 +47,15 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::tanh(x[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value double check = std::tanh(x0); ok &= NearEqual(y[0] , check, eps, eps); @@ -67,7 +64,7 @@ CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); - check = 1. - std::tanh(x0) * std::tanh(x0); + check = 1. - std::tanh(x0) * std::tanh(x0); ok &= NearEqual(dy[0], check, eps, eps); // reverse computation of derivative of y[0] diff -Nru cppad-2015.00.00.9/example/tape_index.cpp cppad-2016.00.00.1/example/tape_index.cpp --- cppad-2015.00.00.9/example/tape_index.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/tape_index.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: tape_index.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: tape_index.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,10 +14,8 @@ $begin tape_index.cpp$$ $section Taping Array Index Operation: Example and Test$$ +$mindex tape operation$$ -$index array, tape index operation$$ -$index index, tape array operation$$ -$index tape, array index operation$$ $code $verbatim%example/tape_index.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -74,8 +72,8 @@ // vectors for arguments to the function object f CPPAD_TESTVECTOR(double) x(n); // argument values - CPPAD_TESTVECTOR(double) y(m); // function values - CPPAD_TESTVECTOR(double) w(m); // function weights + CPPAD_TESTVECTOR(double) y(m); // function values + CPPAD_TESTVECTOR(double) w(m); // function weights CPPAD_TESTVECTOR(double) dw(n); // derivative of weighted function // check function value @@ -90,7 +88,7 @@ y = f.Forward(0, x); ok &= y[0] == x[1] * Array(x[0]); - // evaluate derivaitve of y[0] + // evaluate derivaitve of y[0] w[0] = 1.; dw = f.Reverse(1, w); ok &= dw[0] == 0.; // partial w.r.t array index diff -Nru cppad-2015.00.00.9/example/test_one.sh.in cppad-2016.00.00.1/example/test_one.sh.in --- cppad-2015.00.00.9/example/test_one.sh.in 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/test_one.sh.in 2016-02-09 08:31:55.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: test_one.sh.in 3322 2014-09-12 10:29:34Z bradbell $ +# $Id: test_one.sh.in 3754 2015-11-26 22:23:05Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -24,7 +24,7 @@ exit 1 fi # determine the function name -fun=`grep "^bool *[a-zA-Z0-9_]*( *void *)" $1 | tail -1 | \ +fun=`grep "^bool *[a-zA-Z0-9_]* *( *void *)" $1 | tail -1 | \ sed -e "s/^bool *\([a-zA-Z0-9_]*\) *( *void *)/\1/"` # if [ -e test_one.exe ] @@ -37,23 +37,26 @@ fi sed < example.cpp > test_one.cpp \ -e '/ok *\&= *Run( /d' \ --e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" +-e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" # +cxxflags='@cppad_cxx_flags@' if echo "$fun" | grep 'eigen' > /dev/null then - cxxflags='-g -Wall -ansi -pedantic-errors' -else - cxxflags='-g -Wall -ansi -pedantic-errors -Wshadow' + cxxflags=`echo "$cxxflags" | sed -e 's|-Wshadow||'` fi -cmd="g++ test_one.cpp $* +cmd="g++ test_one.cpp $*" +cmd="$cmd -o test_one.exe $cxxflags + -L @cppad_BINARY_DIR@/cppad_lib + -lcppad_lib -g -fopenmp -lboost_thread -lpthread - -std=c++11 -DCPPAD_ADOLC_EXAMPLES -DCPPAD_EIGEN_EXAMPLES - -I.. + -DCPPAD_ADOLC_EXAMPLES + -DCPPAD_EIGEN_EXAMPLES + -I.. " if [ -e @adolc_prefix@/include ] then @@ -80,6 +83,7 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@colpack_prefix@/$lib" fi done +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@cppad_BINARY_DIR@/cppad_lib" echo $cmd $cmd # diff -Nru cppad-2015.00.00.9/example/thread_alloc.cpp cppad-2016.00.00.1/example/thread_alloc.cpp --- cppad-2015.00.00.9/example/thread_alloc.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/thread_alloc.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: thread_alloc.cpp 3408 2014-11-27 15:17:20Z bradbell $ */ +// $Id: thread_alloc.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,13 +18,8 @@ $$ $section Fast Multi-Threading Memory Allocator: Example and Test$$ +$mindex openmp allocation pthread boost multi-thread$$ -$index openmp, memory allocation$$ -$index pthread, memory allocation$$ -$index boost, multi-thread memory allocation$$ -$index multi-thread, memory allocation$$ -$index example, memory allocation$$ -$index test, memory allocation$$ $code $verbatim%example/thread_alloc.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -33,22 +28,22 @@ $end */ // BEGIN C++ -# include -# include +# include +# include # include # include namespace { // Begin empty namespace - + bool raw_allocate(void) { bool ok = true; using CppAD::thread_alloc; size_t thread; - // check that no memory is initilaly inuse + // check that no memory is initilaly inuse ok &= thread_alloc::free_all(); // amount of static memory used by thread zero @@ -59,12 +54,13 @@ size_t min_bytes = min_size_t * sizeof(size_t); size_t n_outter = 10; size_t n_inner = 5; - size_t cap_bytes, i, j, k; - for(i = 0; i < n_outter; i++) + for(size_t i = 0; i < n_outter; i++) { // Do not use CppAD::vector here because its use of thread_alloc - // complicates the inuse and avaialble results. + // complicates the inuse and avaialble results. std::vector v_ptr(n_inner); - for( j = 0; j < n_inner; j++) + // cap_bytes will be set by get_memory + size_t cap_bytes = 0; // set here to avoid MSC warning + for(size_t j = 0; j < n_inner; j++) { // allocate enough memory for min_size_t size_t objects v_ptr[j] = thread_alloc::get_memory(min_bytes, cap_bytes); size_t* ptr = reinterpret_cast(v_ptr[j]); @@ -72,10 +68,10 @@ size_t cap_size_t = cap_bytes / sizeof(size_t); ok &= min_size_t <= cap_size_t; // use placement new to call the size_t copy constructor - for(k = 0; k < cap_size_t; k++) + for(size_t k = 0; k < cap_size_t; k++) new(ptr + k) size_t(i + j + k); // check that the constructor worked - for(k = 0; k < cap_size_t; k++) + for(size_t k = 0; k < cap_size_t; k++) ok &= ptr[k] == (i + j + k); } // check that n_inner * cap_bytes are inuse and none are available @@ -83,7 +79,7 @@ ok &= thread_alloc::inuse(thread) == n_inner*cap_bytes + static_inuse; ok &= thread_alloc::available(thread) == 0; // return the memrory to thread_alloc - for(j = 0; j < n_inner; j++) + for(size_t j = 0; j < n_inner; j++) thread_alloc::return_memory(v_ptr[j]); // check that now n_inner * cap_bytes are now available // and none are in use @@ -91,7 +87,7 @@ ok &= thread_alloc::available(thread) == n_inner * cap_bytes; } thread_alloc::free_available(thread); - + // check that the tests have not held onto memory ok &= ! CppAD::memory_leak(); @@ -110,7 +106,7 @@ bool type_allocate(void) { bool ok = true; using CppAD::thread_alloc; - size_t i; + size_t i; // check initial memory values size_t thread = thread_alloc::thread_num(); @@ -121,7 +117,7 @@ // initial allocation of an array size_t size_min = 3; size_t size_one; - my_char *array_one = + my_char *array_one = thread_alloc::create_array(size_min, size_one); // check the values and change them to null 'x' @@ -132,7 +128,7 @@ // now create a longer array size_t size_two; - my_char *array_two = + my_char *array_two = thread_alloc::create_array(2 * size_min, size_two); // check the values in array one @@ -149,7 +145,7 @@ ok &= thread_alloc::inuse(thread) - check < sizeof(my_char); ok &= thread_alloc::available(thread) == 0; - // delete the arrays + // delete the arrays thread_alloc::delete_array(array_one); thread_alloc::delete_array(array_two); ok &= thread_alloc::inuse(thread) == static_inuse; @@ -158,7 +154,7 @@ // free the memory for use by this thread thread_alloc::free_available(thread); - + // check that the tests have not held onto memory ok &= ! CppAD::memory_leak(); @@ -191,13 +187,13 @@ // check that it is aligned ok &= (v_size_t % n_byte) == 0; - // return memory to available pool + // return memory to available pool thread_alloc::return_memory(v_ptr); // check array allocation ---------------------------------------------- size_t size_min = 1; size_t size_out; - my_char *array_ptr = + my_char *array_ptr = thread_alloc::create_array(size_min, size_out); // convert to a size_t value @@ -224,7 +220,7 @@ // and we are in sequential execution mode ok &= thread_alloc::in_parallel() == false; - // Instruct thread_alloc to hold onto memory. This makes memory + // Instruct thread_alloc to hold onto memory. This makes memory // allocation faster (especially when there are multiple threads). thread_alloc::hold_memory(true); diff -Nru cppad-2015.00.00.9/example/to_string.cpp cppad-2016.00.00.1/example/to_string.cpp --- cppad-2015.00.00.9/example/to_string.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/example/to_string.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -0,0 +1,109 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin to_string.cpp$$ + +$section to_string: Example and Test$$ + +$code +$verbatim%example/to_string.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +// Examples with fundamental types +# include +namespace { + template + Integer string2int(const std::string& s) + { Integer result = 0; + size_t index = 0; + if( s[0] == '-' ) + ++index; + while( index < s.size() ) + result = 10 * result + Integer( s[index++] - '0'); + if( s[0] == '-' ) + return - result; + return result; + } + template + bool integer(void) + { bool ok = true; + // + Integer max = std::numeric_limits::max(); + std::string s = CppAD::to_string(max); + Integer check = string2int(s); + ok &= max == check; + // + Integer min = std::numeric_limits::min(); + s = CppAD::to_string(min); + check = string2int(s); + ok &= min == check; + // + return ok; + } + template + bool floating(void) + { bool ok = true; + Float eps = std::numeric_limits::epsilon(); + Float pi = 4.0 * std::atan(1.); + // + std::string s = CppAD::to_string( pi ); + Float check = std::atof( s.c_str() ); + ok &= std::fabs( check - pi ) <= 2.0 * eps; + // + return ok; + } +} + +// Examples with AD types +# include +namespace { + template + bool ad_floating(void) + { bool ok = true; + Base eps = std::numeric_limits::epsilon(); + Base pi = 4.0 * std::atan(1.); + // + std::string s = CppAD::to_string( CppAD::AD( pi ) ); + Base check = std::atof( s.c_str() ); + ok &= std::fabs( check - pi ) <= 2.0 * eps; + // + return ok; + } +} + +// Test driver +bool to_string(void) +{ bool ok = true; + + ok &= integer(); + ok &= integer(); + ok &= integer(); +# if CPPAD_USE_CPLUSPLUS_2011 + ok &= integer(); +# endif + // + ok &= floating(); + ok &= floating(); + ok &= floating(); + // + ok &= ad_floating(); + ok &= ad_floating(); + // + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/example/unary_minus.cpp cppad-2016.00.00.1/example/unary_minus.cpp --- cppad-2015.00.00.9/example/unary_minus.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/unary_minus.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: unary_minus.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: unary_minus.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $section AD Unary Minus Operator: Example and Test$$ -$index unary minus, example$$ -$index example, unary minus$$ -$index test, unary minus$$ $code $verbatim%example/unary_minus.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -46,7 +43,7 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = - x[0]; @@ -78,7 +75,7 @@ v[zero] = x[0]; AD result = - v[zero]; ok &= (result == y[0]); - + return ok; } // END C++ diff -Nru cppad-2015.00.00.9/example/unary_plus.cpp cppad-2016.00.00.1/example/unary_plus.cpp --- cppad-2015.00.00.9/example/unary_plus.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/unary_plus.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: unary_plus.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: unary_plus.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,9 +19,6 @@ $section AD Unary Plus Operator: Example and Test$$ -$index unary plus, example$$ -$index example, unary plus$$ -$index test, unary plus$$ $code $verbatim%example/unary_plus.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -46,7 +43,7 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = + x[0]; @@ -78,7 +75,7 @@ v[zero] = x[0]; AD result = + v[zero]; ok &= (result == y[0]); - + return ok; } // END C++ diff -Nru cppad-2015.00.00.9/example/value.cpp cppad-2016.00.00.1/example/value.cpp --- cppad-2015.00.00.9/example/value.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/value.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: value.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: value.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section Convert From AD to its Base Type: Example and Test$$ +$mindex Value record$$ -$index Value$$ -$index example, Value$$ -$index test, Value$$ -$index record, example$$ $code $verbatim%example/value.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -52,7 +49,7 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = - x[1]; diff -Nru cppad-2015.00.00.9/example/var2par.cpp cppad-2016.00.00.1/example/var2par.cpp --- cppad-2015.00.00.9/example/var2par.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/example/var2par.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: var2par.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: var2par.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,12 +18,8 @@ $$ $section Convert an AD Variable to a Parameter: Example and Test$$ +$mindex Var2Par Value during taping$$ -$index Var2Par$$ -$index example, Var2Par$$ -$index test, Var2Par$$ -$index Value, during taping$$ -$index taping, Value during$$ $code $verbatim%example/var2par.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -51,15 +47,15 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = - x[1] * Var2Par(x[0]); // same as y[0] = -x[1] * 3.; // cannot call Value(x[j]) or Value(y[0]) here (currently variables) ok &= ( Value( Var2Par(x[0]) ) == 3. ); - ok &= ( Value( Var2Par(x[1]) ) == 4. ); - ok &= ( Value( Var2Par(y[0]) ) == -12. ); + ok &= ( Value( Var2Par(x[1]) ) == 4. ); + ok &= ( Value( Var2Par(y[0]) ) == -12. ); // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); diff -Nru cppad-2015.00.00.9/example/vec_ad.cpp cppad-2016.00.00.1/example/vec_ad.cpp --- cppad-2015.00.00.9/example/vec_ad.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/vec_ad.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: vec_ad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: vec_ad.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,11 +19,8 @@ $$ $section AD Vectors that Record Index Operations: Example and Test$$ +$mindex VecAD vec_ad.cpp$$ -$index VecAD$$ -$index example, VecAD$$ -$index test, VecAD$$ -$index vec_ad.cpp$$ $code $verbatim%example/vec_ad.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -37,23 +34,23 @@ # include namespace { - // return the vector x that solves the following linear system + // return the vector x that solves the following linear system // a[0] * x[0] + a[1] * x[1] = b[0] // a[2] * x[0] + a[3] * x[1] = b[1] // in a way that will record pivot operations on the AD tape typedef CPPAD_TESTVECTOR(CppAD::AD) Vector; Vector Solve(const Vector &a , const Vector &b) { using namespace CppAD; - assert(a.size() == 4 && b.size() == 2); + assert(a.size() == 4 && b.size() == 2); // copy the vector b into the VecAD object B - VecAD B(2); + VecAD B(2); AD u; for(u = 0; u < 2; u += 1.) B[u] = b[ Integer(u) ]; // copy the matrix a into the VecAD object A - VecAD A(4); + VecAD A(4); for(u = 0; u < 4; u += 1.) A[u] = a [ Integer(u) ]; @@ -88,7 +85,7 @@ bool vec_ad(void) { bool ok = true; - + using CppAD::AD; using CppAD::NearEqual; @@ -97,8 +94,8 @@ CPPAD_TESTVECTOR(double) x(n); CPPAD_TESTVECTOR(AD) X(n); // 2 * identity matrix (rmax in Solve will be 0) - X[0] = x[0] = 2.; X[1] = x[1] = 0.; - X[2] = x[2] = 0.; X[3] = x[3] = 2.; + X[0] = x[0] = 2.; X[1] = x[1] = 0.; + X[2] = x[2] = 0.; X[3] = x[3] = 2.; // declare independent variables and start tape recording CppAD::Independent(X); @@ -115,18 +112,18 @@ Y = Solve(X, B); // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); + CppAD::ADFun f(X, Y); // By Cramer's rule: // y[0] = [ b[0] * x[3] - x[1] * b[1] ] / [ x[0] * x[3] - x[1] * x[2] ] // y[1] = [ x[0] * b[1] - b[0] * x[2] ] / [ x[0] * x[3] - x[1] * x[2] ] - + double den = x[0] * x[3] - x[1] * x[2]; double dsq = den * den; double num0 = b[0] * x[3] - x[1] * b[1]; double num1 = x[0] * b[1] - b[0] * x[2]; - // check value + // check value ok &= NearEqual(Y[0] , num0 / den, 1e-10 , 1e-10); ok &= NearEqual(Y[1] , num1 / den, 1e-10 , 1e-10); @@ -155,7 +152,7 @@ y = f.Forward(0, x); ok &= NearEqual(y[0] , num0 / den, 1e-10 , 1e-10); ok &= NearEqual(y[1] , num1 / den, 1e-10 , 1e-10); - + // forward computation of partials w.r.t. x[1] dx[0] = 0.; dx[1] = 1.; dx[2] = 0.; dx[3] = 0.; diff -Nru cppad-2015.00.00.9/example/vector_bool.cpp cppad-2016.00.00.1/example/vector_bool.cpp --- cppad-2015.00.00.9/example/vector_bool.cpp 2015-02-24 08:31:43.000000000 +0000 +++ cppad-2016.00.00.1/example/vector_bool.cpp 2016-02-09 08:31:55.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: vector_bool.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: vector_bool.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,12 +18,8 @@ $$ $section CppAD::vectorBool Class: Example and Test$$ +$mindex bool vectorBool CppAD$$ -$index bool, CppAD::vector$$ -$index vectorBool, CppAD$$ -$index CppAD::vectorBool, example$$ -$index example, CppAD::vectorBool$$ -$index test, CppAD::vectorBool$$ $code $verbatim%example/vector_bool.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -33,8 +29,8 @@ */ // BEGIN C++ -# include -# include +# include +# include # include // sstream and string are used to test output operation # include @@ -42,7 +38,7 @@ { bool ok = true; using CppAD::vectorBool; - vectorBool x; // default constructor + vectorBool x; // default constructor ok &= (x.size() == 0); x.resize(2); // resize and set element assignment to bool @@ -60,7 +56,13 @@ x[0] = true; // modify, assignment changes x ok &= (x[0] == true); - x = y = z; // vector assignment + // resize x to zero and check that vector assignment works for both + // size zero and mathching sizes + x.resize(0); + ok &= (x.size() == 0); + ok &= (y.size() == z.size()); + // + x = y = z; ok &= ( (x[0] == false) && (x[1] == true) ); ok &= ( (y[0] == false) && (y[1] == true) ); ok &= ( (z[0] == false) && (z[1] == true) ); diff -Nru cppad-2015.00.00.9/.gitignore cppad-2016.00.00.1/.gitignore --- cppad-2015.00.00.9/.gitignore 2014-12-24 01:16:15.000000000 +0000 +++ cppad-2016.00.00.1/.gitignore 2015-10-18 23:02:57.000000000 +0000 @@ -36,7 +36,7 @@ test_one.cpp */test_one.cpp */*/test_one.cpp -# all directions with and without extension +# all directories with and without extension doxyfile doxyfile.* */doxyfile diff -Nru cppad-2015.00.00.9/install-sh cppad-2016.00.00.1/install-sh --- cppad-2015.00.00.9/install-sh 2014-11-27 17:04:26.000000000 +0000 +++ cppad-2016.00.00.1/install-sh 2015-08-09 16:12:42.000000000 +0000 @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2011-11-20.07; # UTC +scriptversion=2013-12-25.23; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -41,19 +41,15 @@ # This script is compatible with the BSD install script, but was written # from scratch. +tab=' ' nl=' ' -IFS=" "" $nl" +IFS=" $tab$nl" -# set DOITPROG to echo to test this script +# Set DOITPROG to "echo" to test this script. -# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -68,17 +64,6 @@ rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - posix_mkdir= # Desired mode of installed file. @@ -97,7 +82,7 @@ dst_arg= copy_on_change=false -no_target_directory= +is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -137,46 +122,57 @@ -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; -s) stripcmd=$stripprog;; - -t) dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; - -T) no_target_directory=true;; + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -208,6 +204,15 @@ fi if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 @@ -223,16 +228,16 @@ *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -269,41 +274,15 @@ # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - + dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi @@ -314,74 +293,74 @@ if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else @@ -391,53 +370,51 @@ # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac - eval "$initialize_posix_glob" - oIFS=$IFS IFS=/ - $posix_glob set -f + set -f set fnord $dstdir shift - $posix_glob set +f + set +f IFS=$oIFS prefixes= for d do - test X"$d" = X && continue + test X"$d" = X && continue - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -472,15 +449,12 @@ # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - + set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then @@ -493,24 +467,24 @@ # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_2.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_2.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_2.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_2.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,8 +14,8 @@ # include "exp_2.hpp" // definition of exp_2 algorithm bool exp_2(void) { double x = .5; - double check = 1 + x + x * x / 2.; - bool ok = std::fabs( exp_2(x) - check ) <= 1e-10; + double check = 1 + x + x * x / 2.; + bool ok = std::fabs( exp_2(x) - check ) <= 1e-10; return ok; } // END C++ diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2_cppad.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_2_cppad.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_2_cppad.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2_cppad.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_2_cppad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_2_cppad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -39,7 +39,7 @@ Use CppAD forward and reverse modes to compute the partial derivative with respect to $latex x$$, at the point $latex x = .5$$, -of the function +of the function $codei% exp_2(%x%) %$$ @@ -49,8 +49,8 @@ $list number$$ Create and test a modified version of the routine below that computes the same order derivatives with respect to $latex x$$, -at the point $latex x = .1$$ -of the function +at the point $latex x = .1$$ +of the function $codei% exp_2(%x%) %$$ @@ -58,7 +58,7 @@ Create a routine called $codei% exp_3(%x%) -%$$ +%$$ that evaluates the function $latex \[ f(x) = 1 + x^2 / 2 + x^3 / 6 @@ -69,7 +69,7 @@ $lend $codep */ -# include // http://www.coin-or.org/CppAD/ +# include // http://www.coin-or.org/CppAD/ # include "exp_2.hpp" // second order exponential approximation bool exp_2_cppad(void) { bool ok = true; @@ -87,7 +87,7 @@ // evaluate our exponential approximation AD x = X[0]; - AD apx = exp_2(x); + AD apx = exp_2(x); // range space vector size_t m = 1; // dimension of the range space @@ -95,7 +95,7 @@ Y[0] = apx; // variable that represents only range space component // Create f: X -> Y corresponding to this operation sequence - // and stop recording. This also executes a zero order forward + // and stop recording. This also executes a zero order forward // sweep using values in X for x. CppAD::ADFun f(X, Y); @@ -118,11 +118,11 @@ // second order forward sweep that computes // second partial of exp_2(x) with respect to x - vector x2(n); // second order Taylor coefficients - vector y2(m); + vector x2(n); // second order Taylor coefficients + vector y2(m); x2[0] = 0.; // evaluate second partial .w.r.t. x y2 = f.Forward(2, x2); - check = 0.5 * 1.; // Taylor coef is 1/2 second derivative + check = 0.5 * 1.; // Taylor coef is 1/2 second derivative ok &= NearEqual(y2[0], check, 1e-10, 1e-10); // second order reverse sweep that computes diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2_for0.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_2_for0.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_2_for0.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2_for0.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_2_for0.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_2_for0.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,10 +20,8 @@ $$ $section exp_2: Verify Zero Order Forward Sweep$$ +$mindex exp_2$$ -$index zero, order exp_2$$ -$index order, zero exp_2$$ -$index exp_2, zero order$$ $codep */ diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2_for1.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_2_for1.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_2_for1.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2_for1.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_2_for1.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_2_for1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,10 +20,8 @@ $$ $section exp_2: Verify First Order Forward Sweep$$ +$mindex exp_2$$ -$index first, order exp_2$$ -$index order, first exp_2$$ -$index exp_2, first order$$ $codep */ # include // prototype for fabs diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2_for2.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_2_for2.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_2_for2.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2_for2.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_2_for2.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_2_for2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,10 +20,8 @@ $$ $section exp_2: Verify Second Order Forward Sweep$$ +$mindex exp_2$$ -$index second, order exp_2$$ -$index order, second exp_2$$ -$index exp_2, second order$$ $codep */ # include // prototype for fabs diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2.hpp cppad-2016.00.00.1/introduction/exp_apx/exp_2.hpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_2.hpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2.hpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,12 +1,12 @@ -/* $Id: exp_2.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_EXP_2_INCLUDED -# define CPPAD_EXP_2_INCLUDED +// $Id: exp_2.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_EXP_2_HPP +# define CPPAD_EXP_2_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,11 +25,8 @@ $$ $section Second Order Exponential Approximation$$ +$mindex exp_2 example algorithm$$ -$index exp_2$$ -$index example, algorithm$$ -$index algorithm, example$$ -$index exp, example$$ $head Syntax$$ $codei%# include "exp_2.hpp"%$$ @@ -39,23 +36,23 @@ $head Purpose$$ -This is a simple example algorithm that is used to demonstrate +This is a simple example algorithm that is used to demonstrate Algorithmic Differentiation (see $cref exp_eps$$ for a more complex example). $head Mathematical Form$$ The exponential function can be defined by $latex \[ - \exp (x) = 1 + x^1 / 1 ! + x^2 / 2 ! + \cdots + \exp (x) = 1 + x^1 / 1 ! + x^2 / 2 ! + \cdots \] $$ The second order approximation for the exponential function is $latex \[ -{\rm exp\_2} (x) = 1 + x + x^2 / 2 +{\rm exp\_2} (x) = 1 + x + x^2 / 2 \] $$ $head include$$ -The include command in the syntax is relative to +The include command in the syntax is relative to $codei% cppad-%yyyymmdd%/introduction/exp_apx %$$ @@ -69,7 +66,7 @@ const %Type% &%x% %$$ (see $icode Type$$ below). -It specifies the point at which to evaluate the +It specifies the point at which to evaluate the approximation for the second order exponential approximation. $head y$$ @@ -77,23 +74,23 @@ $codei% %Type% %y% %$$ -It is the value of the exponential function +It is the value of the exponential function approximation defined above. $head Type$$ If $icode u$$ and $icode v$$ are $icode Type$$ objects and $icode i$$ -is an $code int$$: +is an $code int$$: $table $bold Operation$$ $cnext $bold Result Type$$ $cnext $bold Description$$ $rnext -$icode%Type%(%i%)%$$ +$icode%Type%(%i%)%$$ $cnext $icode Type$$ - $cnext construct object with value equal to $icode i$$ + $cnext construct object with value equal to $icode i$$ $rnext -$icode%Type u %=% v%$$ +$icode%Type u %=% v%$$ $cnext $icode Type$$ - $cnext construct $icode u$$ with value equal to $icode v$$ + $cnext construct $icode u$$ with value equal to $icode v$$ $rnext $icode%u% * %v%$$ $cnext $icode Type$$ @@ -119,19 +116,19 @@ contains a C++ implementation of this function. $head Test$$ -The file $cref exp_2.cpp$$ +The file $cref exp_2.cpp$$ contains a test of this implementation. It returns true for success and false for failure. $head Exercises$$ $list number$$ -Suppose that we make the call +Suppose that we make the call $codep double x = .1; double y = exp_2(x); $$ -What is the value assigned to +What is the value assigned to $code v1$$, $code v2$$, ... ,$code v5$$ in $cref exp_2.hpp$$ ? $lnext Extend the routine $code exp_2.hpp$$ to @@ -157,11 +154,11 @@ */ // BEGIN C++ template -Type exp_2(const Type &x) +Type exp_2(const Type &x) { Type v1 = x; // v1 = x Type v2 = Type(1) + v1; // v2 = 1 + x Type v3 = v1 * v1; // v3 = x^2 - Type v4 = v3 / Type(2); // v4 = x^2 / 2 + Type v4 = v3 / Type(2); // v4 = x^2 / 2 Type v5 = v2 + v4; // v5 = 1 + x + x^2 / 2 return v5; // exp_2(x) = 1 + x + x^2 / 2 } diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2.omh cppad-2016.00.00.1/introduction/exp_apx/exp_2.omh --- cppad-2015.00.00.9/introduction/exp_apx/exp_2.omh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2.omh 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: exp_2.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: exp_2.omh 3757 2015-11-30 12:03:07Z bradbell $ ----------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,8 +15,7 @@ $$ $section exp_2: Implementation$$ -$index implementation, exp_2$$ -$index exp_2, implementation$$ +$mindex exp_2$$ $code $verbatim%introduction/exp_apx/exp_2.hpp%0%// BEGIN C++%// END C++%$$ @@ -30,8 +29,6 @@ $$ $section exp_2: Test$$ -$index test, exp_2$$ -$index exp_2, test$$ $code $verbatim%introduction/exp_apx/exp_2.cpp%0%// BEGIN C++%// END C++%$$ @@ -47,15 +44,9 @@ $$ $section exp_2: Operation Sequence and Zero Order Forward Mode$$ +$mindex example$$ + -$index exp_2, operation sequence$$ -$index example, operation sequence$$ -$index operation, sequence example$$ -$index sequence, example operation$$ - -$index zero, order forward$$ -$index order, zero forward$$ -$index forward, zero order$$ $head Mathematical Form$$ @@ -67,35 +58,32 @@ \] $$ An algorithmic differentiation package does not operate on the mathematical function $latex f(x)$$ -but rather on the particular algorithm used to compute the function +but rather on the particular algorithm used to compute the function (in this case $cref exp_2.hpp$$). $head Zero Order Expansion$$ -$index expansion, zero order$$ -$index zero, order expansion$$ -$index order, zero expansion$$ In general, a zero order forward sweep is given a vector $latex x^{(0)} \in \B{R}^n$$ and it returns the corresponding vector $latex y^{(0)} \in \B{R}^m$$ given by $latex \[ y^{(0)} = f( x^{(0)} ) \]$$ -The superscript $latex (0)$$ denotes zero order derivative; +The superscript $latex (0)$$ denotes zero order derivative; i.e., it is equal to the value of the corresponding variable. -For the example we are considering here, +For the example we are considering here, both $latex n$$ and $latex m$$ are equal to one. $head Operation Sequence$$ An atomic $icode Type$$ operation is an operation -that has a $icode Type$$ result and is not made up of +that has a $icode Type$$ result and is not made up of other more basic operations. A sequence of atomic $icode Type$$ operations is called a $icode Type$$ operation sequence. Given an C++ algorithm and its inputs, -there is a corresponding $icode Type$$ operation sequence for each type. -If $icode Type$$ is clear from the context, +there is a corresponding $icode Type$$ operation sequence for each type. +If $icode Type$$ is clear from the context, we drop it and just refer to the operation sequence. $pre @@ -107,23 +95,23 @@ $subhead Index$$ The Index column contains the index in the operation sequence -of the corresponding atomic operation and variable. -A Forward sweep starts with the first operation +of the corresponding atomic operation and variable. +A Forward sweep starts with the first operation and ends with the last. $subhead Code$$ -The Code column contains the C++ source code corresponding -to the corresponding atomic operation in the sequence. +The Code column contains the C++ source code corresponding +to the corresponding atomic operation in the sequence. $subhead Operation$$ -The Operation column contains the +The Operation column contains the mathematical function corresponding to each atomic operation in the sequence. $subhead Zero Order$$ The Zero Order column contains the zero order derivative for the corresponding variable in the operation sequence. Forward mode refers to the fact that -these coefficients are computed in the same order as the original algorithm; +these coefficients are computed in the same order as the original algorithm; i.e, in order of increasing index in the operation sequence. $subhead Sweep$$ @@ -174,26 +162,26 @@ %$$ $head Verification$$ -The file $cref exp_2_for0.cpp$$ contains a routine +The file $cref exp_2_for0.cpp$$ contains a routine that verifies the values computed above. It returns true for success and false for failure. $head Exercises$$ $list number$$ Suppose that $latex x^{(0)} = .2$$, -what is the result of a zero order forward sweep for -the operation sequence above; +what is the result of a zero order forward sweep for +the operation sequence above; i.e., what are the corresponding values for $latex \[ v_1^{(0)} , v_2^{(0)} , \cdots , v_5^{(0)} \]$$ $lnext -Create a modified version of +Create a modified version of $cref exp_2_for0.cpp$$ that verifies the values you obtained for the previous exercise. $lnext -Create and run a main program that reports the result of calling -the modified version +Create and run a main program that reports the result of calling +the modified version of $cref exp_2_for0.cpp$$ in the previous exercise. $lend @@ -207,17 +195,9 @@ $section exp_2: First Order Forward Mode$$ -$index exp_2, forward mode$$ -$index example, forward mode$$ -$index forward, mode example$$ -$index mode, example forward$$ -$index forward, first order$$ $head First Order Expansion$$ -$index first, order expansion$$ -$index order, first expansion$$ -$index expansion, first order$$ We define $latex x(t)$$ near $latex t = 0$$ by the first order expansion $latex \[ x(t) = x^{(0)} + x^{(1)} * t @@ -237,37 +217,37 @@ for all the other variables in the operation sequence. $head Mathematical Form$$ -Suppose that we use the algorithm $cref exp_2.hpp$$ to compute +Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ f(x) = 1 + x + x^2 / 2 \] $$ -The corresponding derivative function is +The corresponding derivative function is $latex \[ \partial_x f (x) = 1 + x \] $$ An algorithmic differentiation package does not operate on the mathematical form of the function, or its derivative, -but rather on the +but rather on the $cref/operation sequence/exp_2_for0/Operation Sequence/$$ for the for the algorithm that is used to evaluate the function. $head Operation Sequence$$ We consider the case where $cref exp_2.hpp$$ is executed with $latex x = .5$$. -The corresponding operation sequence and +The corresponding operation sequence and zero order forward mode values (see $cref/zero order sweep/exp_2_for0/Operation Sequence/Sweep/$$) are inputs and are used by a first order forward sweep. $subhead Index$$ The Index column contains the index in the operation sequence -of the corresponding atomic operation. -A Forward sweep starts with the first operation +of the corresponding atomic operation. +A Forward sweep starts with the first operation and ends with the last. $subhead Operation$$ -The Operation column contains the +The Operation column contains the mathematical function corresponding to each atomic operation in the sequence. $subhead Zero Order$$ @@ -289,7 +269,7 @@ \] $$ We use $latex x^{(1)} = 1$$ so that differentiation with respect to $latex t$$, -at $latex t = 0$$, is the same as partial differentiation +at $latex t = 0$$, is the same as partial differentiation with respect to $latex x$$ at $latex x = x^{(0)}$$. @@ -299,7 +279,7 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Operation$$ + $cnext $pre $$ $cnext $bold Operation$$ $cnext $pre $$ $cnext $bold Zero Order$$ $cnext $pre $$ $cnext $bold Derivative$$ $cnext $pre $$ $cnext $bold First Order$$ @@ -307,28 +287,28 @@ 1 $cnext $pre $$ $cnext $latex v_1 = x $$ $cnext $cnext 0.5 - $cnext $cnext + $cnext $cnext $latex v_1^{(1)} = x^{(1)} $$ $cnext $cnext $latex v_1^{(1)} = 1$$ $rnext 2 $cnext $pre $$ $cnext $latex v_2 = 1 + v_1$$ $cnext $cnext 1.5 - $cnext $cnext + $cnext $cnext $latex v_2^{(1)} = v_1^{(1)}$$ $cnext $cnext $latex v_2^{(1)} = 1$$ $rnext 3 $cnext $pre $$ $cnext $latex v_3 = v_1 * v_1$$ $cnext $cnext 0.25 - $cnext $cnext + $cnext $cnext $latex v_3^{(1)} = 2 * v_1^{(0)} * v_1^{(1)}$$ $cnext $cnext $latex v_3^{(1)} = 1$$ $rnext 4 $cnext $pre $$ $cnext $latex v_4 = v_3 / 2$$ $cnext $cnext 0.125 - $cnext $cnext + $cnext $cnext $latex v_4^{(1)} = v_3^{(1)} / 2$$ $cnext $cnext $latex v_4^{(1)} = 0.5$$ $rnext @@ -344,14 +324,14 @@ The derivative of the return value for this case is $latex \[ \begin{array}{rcl} - 1.5 + 1.5 & = & v_5^{(1)} = - \left[ \D{v_5}{t} \right]_{t=0} = + \left[ \D{v_5}{t} \right]_{t=0} = \left[ \D{}{t} f ( x^{(0)} + x^{(1)} t ) \right]_{t=0} \\ & = & - f^{(1)} ( x^{(0)} ) * x^{(1)} = + f^{(1)} ( x^{(0)} ) * x^{(1)} = f^{(1)} ( x^{(0)} ) \end{array} \] $$ @@ -361,24 +341,24 @@ introduction/exp_apx/exp_2_for1.cpp %$$ $head Verification$$ -The file $cref exp_2_for1.cpp$$ contains a routine +The file $cref exp_2_for1.cpp$$ contains a routine which verifies the values computed above. It returns true for success and false for failure. $head Exercises$$ $list number$$ -Which statement in the routine defined by $cref exp_2_for1.cpp$$ uses -the values that are calculated by the routine +Which statement in the routine defined by $cref exp_2_for1.cpp$$ uses +the values that are calculated by the routine defined by $cref exp_2_for0.cpp$$ ? $lnext Suppose that $latex x = .1$$, -what are the results of a zero and first order forward sweep for -the operation sequence above; +what are the results of a zero and first order forward sweep for +the operation sequence above; i.e., what are the corresponding values for $latex v_1^{(0)}, v_2^{(0)}, \cdots , v_5^{(0)}$$ and $latex v_1^{(1)}, v_2^{(1)}, \cdots , v_5^{(1)}$$ ? $lnext -Create a modified version of $cref exp_2_for1.cpp$$ that verifies +Create a modified version of $cref exp_2_for1.cpp$$ that verifies the derivative values from the previous exercise. Also create and run a main program that reports the result of calling the modified version of @@ -394,31 +374,24 @@ $section exp_2: First Order Reverse Mode$$ -$index exp_2, reverse mode$$ -$index example, reverse mode$$ -$index reverse, mode example$$ -$index mode, example reverse$$ - -$index first, order reverse$$ -$index order, first reverse$$ -$index reverse, first order$$ + $head Purpose$$ -First order reverse mode uses the +First order reverse mode uses the $cref/operation sequence/exp_2_for0/Operation Sequence/$$, and zero order forward sweep values, to compute the first order derivative -of one dependent variable with respect to all the independent variables. -The computations are done in reverse +of one dependent variable with respect to all the independent variables. +The computations are done in reverse of the order of the computations in the original algorithm. $head Mathematical Form$$ -Suppose that we use the algorithm $cref exp_2.hpp$$ to compute +Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ f(x) = 1 + x + x^2 / 2 \] $$ -The corresponding derivative function is +The corresponding derivative function is $latex \[ \partial_x f (x) = 1 + x \] $$ @@ -428,11 +401,11 @@ of the value returned by $cref exp_2.hpp$$ which is equal to the symbol $latex v_5$$ in the $cref/exp_2 operation sequence/exp_2_for0/Operation Sequence/$$. -We begin with the function $latex f_5 $$ where $latex v_5$$ +We begin with the function $latex f_5 $$ where $latex v_5$$ is both an argument and the value of the function; i.e., $latex \[ \begin{array}{rcl} -f_5 ( v_1 , v_2 , v_3 , v_4 , v_5 ) & = & v_5 +f_5 ( v_1 , v_2 , v_3 , v_4 , v_5 ) & = & v_5 \\ \D{f_5}{v_5} & = & 1 \end{array} @@ -445,58 +418,58 @@ $latex \[ v_5 = v_2 + v_4 \] $$ -We define the function +We define the function $latex f_4 ( v_1 , v_2 , v_3 , v_4 ) $$ as equal to $latex f_5 $$ -except that $latex v_5 $$ is eliminated using +except that $latex v_5 $$ is eliminated using this operation; i.e. $latex \[ -f_4 = +f_4 = f_5 [ v_1 , v_2 , v_3 , v_4 , v_5 ( v_2 , v_4 ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_4}{v_2} -& = & \D{f_5}{v_2} + - \D{f_5}{v_5} * \D{v_5}{v_2} +\D{f_4}{v_2} +& = & \D{f_5}{v_2} + + \D{f_5}{v_5} * \D{v_5}{v_2} & = 1 \\ -\D{f_4}{v_4} -& = & \D{f_5}{v_4} + - \D{f_5}{v_5} * \D{v_5}{v_4} +\D{f_4}{v_4} +& = & \D{f_5}{v_4} + + \D{f_5}{v_5} * \D{v_5}{v_4} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_4$$ are zero. $head Index 4: f_3$$ -The next operation has index 4, +The next operation has index 4, $latex \[ v_4 = v_3 / 2 \] $$ -We define the function +We define the function $latex f_3 ( v_1 , v_2 , v_3 ) $$ as equal to $latex f_4 $$ except that $latex v_4 $$ is eliminated using this operation; i.e., $latex \[ -f_3 = +f_3 = f_4 [ v_1 , v_2 , v_3 , v_4 ( v_3 ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} \D{f_3}{v_1} & = & \D{f_4}{v_1} & = 0 \\ -\D{f_3}{v_2} +\D{f_3}{v_2} & = & \D{f_4}{v_2} & = 1 \\ -\D{f_3}{v_3} -& = & \D{f_4}{v_3} + - \D{f_4}{v_4} * \D{v_4}{v_3} +\D{f_3}{v_3} +& = & \D{f_4}{v_3} + + \D{f_4}{v_4} * \D{v_4}{v_3} & = 0.5 \end{array} \] $$ @@ -506,25 +479,25 @@ $latex \[ v_3 = v_1 * v_1 \] $$ -We define the function +We define the function $latex f_2 ( v_1 , v_2 ) $$ as equal to $latex f_3 $$ except that $latex v_3 $$ is eliminated using this operation; i.e., $latex \[ -f_2 = +f_2 = f_3 [ v_1 , v_2 , v_3 ( v_1 ) ] \] $$ Note that the value of $latex v_1$$ is equal to $latex x$$ which is .5 for this evaluation. -It follows that +It follows that $latex \[ \begin{array}{rcll} \D{f_2}{v_1} & = & \D{f_3}{v_1} + - \D{f_3}{v_3} * \D{v_3}{v_1} + \D{f_3}{v_3} * \D{v_3}{v_1} & = 0.5 \\ -\D{f_2}{v_2} +\D{f_2}{v_2} & = & \D{f_3}{v_2} & = 1 \end{array} @@ -535,20 +508,20 @@ $latex \[ v_2 = 1 + v_1 \] $$ -We define the function +We define the function $latex f_1 ( v_1 ) $$ as equal to $latex f_2 $$ except that $latex v_2 $$ is eliminated using this operation; i.e., $latex \[ -f_1 = +f_1 = f_2 [ v_1 , v_2 ( v_1 ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} \D{f_1}{v_1} & = & \D{f_2}{v_1} + - \D{f_2}{v_2} * \D{v_2}{v_1} + \D{f_2}{v_2} * \D{v_2}{v_1} & = 1.5 \end{array} \] $$ @@ -560,7 +533,7 @@ introduction/exp_apx/exp_2_rev1.cpp %$$ $head Verification$$ -The file $cref exp_2_rev1.cpp$$ contains a routine +The file $cref exp_2_rev1.cpp$$ contains a routine which verifies the values computed above. It returns true for success and false for failure. It only tests the partial derivatives of @@ -571,20 +544,20 @@ $head Exercises$$ $list number$$ -Which statement in the routine defined by $cref exp_2_rev1.cpp$$ uses -the values that are calculated by the routine +Which statement in the routine defined by $cref exp_2_rev1.cpp$$ uses +the values that are calculated by the routine defined by $cref exp_2_for0.cpp$$ ? $lnext Consider the case where $latex x = .1$$ and we first preform a zero order forward sweep for the operation sequence used above. -What are the results of a +What are the results of a first order reverse sweep; i.e., what are the corresponding derivatives of $latex f_5 , f_4 , \ldots , f_1$$. $lnext -Create a modified version of -$cref exp_2_rev1.cpp$$ +Create a modified version of +$cref exp_2_rev1.cpp$$ that verifies the values you obtained for the previous exercise. Also create and run a main program that reports the result of calling the modified version of @@ -600,17 +573,9 @@ $section exp_2: Second Order Forward Mode$$ -$index exp_2, forward mode$$ -$index example, forward mode$$ -$index forward, mode example$$ -$index mode, example forward$$ -$index forward, second order$$ $head Second Order Expansion$$ -$index second, order expansion$$ -$index order, second expansion$$ -$index expansion, second order$$ We define $latex x(t)$$ near $latex t = 0$$ by the second order expansion $latex \[ x(t) = x^{(0)} + x^{(1)} * t + x^{(2)} * t^2 / 2 @@ -630,11 +595,11 @@ for all the variables in the operation sequence. $head Mathematical Form$$ -Suppose that we use the algorithm $cref exp_2.hpp$$ to compute +Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ f(x) = 1 + x + x^2 / 2 \] $$ -The corresponding second derivative function is +The corresponding second derivative function is $latex \[ \Dpow{2}{x} f (x) = 1 \] $$ @@ -649,8 +614,8 @@ $subhead Index$$ The Index column contains the index in the operation sequence -of the corresponding atomic operation. -A Forward sweep starts with the first operation +of the corresponding atomic operation. +A Forward sweep starts with the first operation and ends with the last. $subhead Zero$$ @@ -659,7 +624,7 @@ (see $cref/zero order sweep/exp_2_for0/Operation Sequence/Sweep/$$). $subhead Operation$$ -The Operation column contains the +The Operation column contains the first order sweep operation for this variable. $subhead First$$ @@ -682,8 +647,8 @@ \] $$ We use $latex x^{(0)} = 1$$, and $latex x^{(2)} = 0$$ so that second order differentiation -with respect to $latex t$$, at $latex t = 0$$, -is the same as the second partial differentiation +with respect to $latex t$$, at $latex t = 0$$, +is the same as the second partial differentiation with respect to $latex x$$ at $latex x = x^{(0)}$$. @@ -693,7 +658,7 @@ $table $bold Index$$ $cnext $pre $$ $cnext $bold Zero$$ - $cnext $pre $$ $cnext $bold Operation$$ + $cnext $pre $$ $cnext $bold Operation$$ $cnext $pre $$ $cnext $bold First$$ $cnext $pre $$ $cnext $bold Derivative$$ $cnext $pre $$ $cnext $bold Second$$ @@ -702,7 +667,7 @@ $cnext $cnext 0.5 $cnext $pre $$ $cnext $latex v_1^{(1)} = x^{(1)} $$ $cnext $cnext 1 - $cnext $cnext + $cnext $cnext $latex v_1^{(2)} = x^{(2)}$$ $cnext $cnext $latex v_1^{(2)} = 0$$ $rnext @@ -710,7 +675,7 @@ $cnext $cnext 1.5 $cnext $pre $$ $cnext $latex v_2^{(1)} = v_1^{(1)}$$ $cnext $cnext 1 - $cnext $cnext + $cnext $cnext $latex v_2^{(2)} = v_1^{(2)}$$ $cnext $cnext $latex v_2^{(2)} = 0$$ $rnext @@ -718,7 +683,7 @@ $cnext $cnext 0.25 $cnext $pre $$ $cnext $latex v_3^{(1)} = 2 * v_1^{(0)} * v_1^{(1)}$$ $cnext $cnext 1 - $cnext $cnext + $cnext $cnext $latex v_3^{(2)} = 2 * (v_1^{(1)} * v_1^{(1)} + v_1^{(0)} * v_1^{(2)} )$$ $cnext $cnext $latex v_3^{(2)} = 2$$ $rnext @@ -726,7 +691,7 @@ $cnext $cnext 0.125 $cnext $pre $$ $cnext $latex v_4^{(1)} = v_3^{(1)} / 2$$ $cnext $cnext .5 - $cnext $cnext + $cnext $cnext $latex v_4^{(2)} = v_3^{(2)} / 2$$ $cnext $cnext $latex v_4^{(2)} = 1$$ $rnext @@ -744,14 +709,14 @@ The second derivative of the return value for this case is $latex \[ \begin{array}{rcl} - 1 + 1 & = & v_5^{(2)} = \left[ \Dpow{2}{t} v_5 \right]_{t=0} = \left[ \Dpow{2}{t} f( x^{(0)} + x^{(1)} * t ) \right]_{t=0} \\ & = & - x^{(1)} * \Dpow{2}{x} f ( x^{(0)} ) * x^{(1)} = + x^{(1)} * \Dpow{2}{x} f ( x^{(0)} ) * x^{(1)} = \Dpow{2}{x} f ( x^{(0)} ) \end{array} \] $$ @@ -762,23 +727,23 @@ introduction/exp_apx/exp_2_for2.cpp %$$ $head Verification$$ -The file $cref exp_2_for2.cpp$$ contains a routine +The file $cref exp_2_for2.cpp$$ contains a routine which verifies the values computed above. It returns true for success and false for failure. $head Exercises$$ $list number$$ -Which statement in the routine defined by $cref exp_2_for2.cpp$$ uses -the values that are calculated by the routine +Which statement in the routine defined by $cref exp_2_for2.cpp$$ uses +the values that are calculated by the routine defined by $cref exp_2_for1.cpp$$ ? $lnext Suppose that $latex x = .1$$, -what are the results of a zero, first, and second order forward sweep for -the operation sequence above; +what are the results of a zero, first, and second order forward sweep for +the operation sequence above; i.e., what are the corresponding values for $latex v_i^{(k)}$$ for $latex i = 1, \ldots , 5$$ and $latex k = 0, 1, 2$$. $lnext -Create a modified version of $cref exp_2_for2.cpp$$ that verifies +Create a modified version of $cref exp_2_for2.cpp$$ that verifies the derivative values from the previous exercise. Also create and run a main program that reports the result of calling the modified version of @@ -794,31 +759,24 @@ $section exp_2: Second Order Reverse Mode$$ -$index exp_2, reverse mode$$ -$index example, reverse mode$$ -$index reverse, mode example$$ -$index mode, example reverse$$ - -$index second, order reverse$$ -$index order, second reverse$$ -$index reverse, second order$$ + $head Purpose$$ In general, a second order reverse sweep is given the $cref/first order expansion/exp_2_for1/First Order Expansion/$$ for all of the variables in an operation sequence. -Given a choice of a particular variable, -it computes the derivative, -of that variables first order expansion coefficient, +Given a choice of a particular variable, +it computes the derivative, +of that variables first order expansion coefficient, with respect to all of the independent variables. $head Mathematical Form$$ -Suppose that we use the algorithm $cref exp_2.hpp$$ to compute +Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ f(x) = 1 + x + x^2 / 2 \] $$ -The corresponding second derivative is +The corresponding second derivative is $latex \[ \Dpow{2}{x} f (x) = 1 \] $$ @@ -828,18 +786,18 @@ with respect to all the independent variable. For the case computed for the $cref/first order sweep/exp_2_for1/Operation Sequence/Sweep/$$, -$latex v_5^{(1)}$$ is the derivative +$latex v_5^{(1)}$$ is the derivative of the value returned by $cref exp_2.hpp$$. -This the value computed will be the second derivative of +This the value computed will be the second derivative of the value returned by $cref exp_2.hpp$$. -We begin with the function $latex f_5 $$ where $latex v_5^{(1)}$$ +We begin with the function $latex f_5 $$ where $latex v_5^{(1)}$$ is both an argument and the value of the function; i.e., $latex \[ \begin{array}{rcl} -f_5 \left( - v_1^{(0)}, v_1^{(1)} , \ldots , v_5^{(0)} , v_5^{(1)} -\right) -& = & v_5^{(1)} +f_5 \left( + v_1^{(0)}, v_1^{(1)} , \ldots , v_5^{(0)} , v_5^{(1)} +\right) +& = & v_5^{(1)} \\ \D{f_5}{v_5^{(1)}} & = & 1 \end{array} @@ -857,36 +815,36 @@ v_5^{(1)} & = & v_2^{(1)} + v_4^{(1)} \end{array} \] $$ -We define the function +We define the function $latex f_4 \left( v_1^{(0)} , \ldots , v_4^{(1)} \right) $$ as equal to $latex f_5 $$ -except that $latex v_5^{(0)} $$ and $latex v_5^{(1)}$$ are eliminated using +except that $latex v_5^{(0)} $$ and $latex v_5^{(1)}$$ are eliminated using this operation; i.e. $latex \[ -f_4 = -f_5 \left[ v_1^{(0)} , \ldots , v_4^{(1)} , - v_5^{(0)} \left( v_2^{(0)} , v_4^{(0)} \right) , - v_5^{(1)} \left( v_2^{(1)} , v_4^{(1)} \right) -\right] +f_4 = +f_5 \left[ v_1^{(0)} , \ldots , v_4^{(1)} , + v_5^{(0)} \left( v_2^{(0)} , v_4^{(0)} \right) , + v_5^{(1)} \left( v_2^{(1)} , v_4^{(1)} \right) +\right] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_4}{v_2^{(1)}} -& = & \D{f_5}{v_2^{(1)}} + - \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_2^{(1)}} +\D{f_4}{v_2^{(1)}} +& = & \D{f_5}{v_2^{(1)}} + + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_2^{(1)}} & = 1 \\ -\D{f_4}{v_4^{(1)}} -& = & \D{f_5}{v_4^{(1)}} + - \D{f_5}{v_5^{(1)}} * \D{v_5}{v_4^{(1)}} +\D{f_4}{v_4^{(1)}} +& = & \D{f_5}{v_4^{(1)}} + + \D{f_5}{v_5^{(1)}} * \D{v_5}{v_4^{(1)}} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_4$$ are zero. $head Index 4: f_3$$ -The next operation has index 4, +The next operation has index 4, $latex \[ \begin{array}{rcl} v_4^{(0)} & = & v_3^{(0)} / 2 @@ -894,28 +852,28 @@ v_4^{(1)} & = & v_3^{(1)} / 2 \end{array} \] $$ -We define the function +We define the function $latex f_3 \left( v_1^{(0)} , \ldots , v_3^{(1)} \right) $$ as equal to $latex f_4 $$ -except that $latex v_4^{(0)}$$ and $latex v_4^{(1)}$$ +except that $latex v_4^{(0)}$$ and $latex v_4^{(1)}$$ are eliminated using this operation; i.e., $latex \[ -f_3 = +f_3 = f_4 \left[ v_1^{(0)} , \ldots , v_3^{(1)} , v_4^{(0)} \left( v_3^{(0)} \right) , v_4^{(1)} \left( v_3^{(1)} \right) \right] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_3}{v_2^{(1)}} +\D{f_3}{v_2^{(1)}} & = & \D{f_4}{v_2^{(1)}} & = 1 \\ -\D{f_3}{v_3^{(1)}} -& = & \D{f_4}{v_3^{(1)}} + - \D{f_4}{v_4^{(1)}} * \D{v_4^{(1)}}{v_3^{(1)}} +\D{f_3}{v_3^{(1)}} +& = & \D{f_4}{v_3^{(1)}} + + \D{f_4}{v_4^{(1)}} * \D{v_4^{(1)}}{v_3^{(1)}} & = 0.5 \end{array} \] $$ @@ -930,43 +888,43 @@ v_3^{(1)} & = & 2 * v_1^{(0)} * v_1^{(1)} \end{array} \] $$ -We define the function +We define the function $latex f_2 \left( v_1^{(0)} , \ldots , v_2^{(1)} \right) $$ as equal to $latex f_3 $$ except that $latex v_3^{(0)} $$ and $latex v_3^{(1)}$$ are eliminated using this operation; i.e., $latex \[ -f_2 = +f_2 = f_3 \left[ v_1^{(0)} , \ldots , v_2^{(1)} , v_3^{(0)} ( v_1^{(0)} ) , - v_3^{(1)} ( v_1^{(0)} , v_1^{(1)} ) + v_3^{(1)} ( v_1^{(0)} , v_1^{(1)} ) \right] \] $$ -Note that, from the +Note that, from the $cref/first order forward sweep/exp_2_for1/Operation Sequence/Sweep/$$, the value of $latex v_1^{(0)}$$ is equal to $latex .5$$ -and $latex v_1^{(1)}$$ is equal 1. -It follows that +and $latex v_1^{(1)}$$ is equal 1. +It follows that $latex \[ \begin{array}{rcll} \D{f_2}{v_1^{(0)}} -& = & +& = & \D{f_3}{v_1^{(0)}} + \D{f_3}{v_3^{(0)}} * \D{v_3^{(0)}}{v_1^{(0)}} + - \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_1^{(0)}} + \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_1^{(0)}} & = 1 \\ \D{f_2}{v_1^{(1)}} -& = & +& = & \D{f_3}{v_1^{(1)}} + - \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_1^{(1)}} -& = 0.5 + \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_1^{(1)}} +& = 0.5 \\ -\D{f_2}{v_2^{(0)}} +\D{f_2}{v_2^{(0)}} & = & \D{f_3}{v_2^{(0)}} & = 0 \\ -\D{f_2}{v_2^{(1)}} +\D{f_2}{v_2^{(1)}} & = & \D{f_3}{v_2^{(1)}} & = 1 \end{array} @@ -981,48 +939,48 @@ v_2^{(1)} & = & v_1^{(1)} \end{array} \] $$ -We define the function +We define the function $latex f_1 ( v_1^{(0)} , v_1^{(1)} ) $$ as equal to $latex f_2 $$ except that $latex v_2^{(0)} $$ and $latex v_2^{(1)} $$ are eliminated using this operation; i.e., $latex \[ -f_1 = -f_2 \left[ v_1^{(0)} , v_1^{(1)} , +f_1 = +f_2 \left[ v_1^{(0)} , v_1^{(1)} , v_2^{(0)} ( v_1^{(0)} ) , v_2^{(1)} ( v_1^{(1)} ) \right] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} \D{f_1}{v_1^{(0)}} & = & \D{f_2}{v_1^{(0)}} + - \D{f_2}{v_2^{(0)}} * \D{v_2^{(0)}}{v_1^{(0)}} + \D{f_2}{v_2^{(0)}} * \D{v_2^{(0)}}{v_1^{(0)}} & = 1 \\ \D{f_1}{v_1^{(1)}} & = & \D{f_2}{v_1^{(1)}} + - \D{f_2}{v_2^{(1)}} * \D{v_2^{(1)}}{v_1^{(1)}} -& = 1.5 + \D{f_2}{v_2^{(1)}} * \D{v_2^{(1)}}{v_1^{(1)}} +& = 1.5 \end{array} \] $$ Note that $latex v_1$$ is equal to $latex x$$, -so the second derivative of +so the second derivative of the function defined by $cref exp_2.hpp$$ at $latex x = .5$$ is given by $latex \[ -\Dpow{2}{x} v_5^{(0)} +\Dpow{2}{x} v_5^{(0)} += +\D{ v_5^{(1)} }{x} = -\D{ v_5^{(1)} }{x} +\D{ v_5^{(1)} }{v_1^{(0)}} = -\D{ v_5^{(1)} }{v_1^{(0)}} -= \D{f_1}{v_1^{(0)}} = 1 \] $$ There is a theorem about Algorithmic Differentiation that explains why the other partial of $latex f_1$$ is equal to the -first derivative of +first derivative of the function defined by $cref exp_2.hpp$$ at $latex x = .5$$. @@ -1030,7 +988,7 @@ introduction/exp_apx/exp_2_rev2.cpp %$$ $head Verification$$ -The file $cref exp_2_rev2.cpp$$ contains a routine +The file $cref exp_2_rev2.cpp$$ contains a routine which verifies the values computed above. It returns true for success and false for failure. It only tests the partial derivatives of @@ -1041,8 +999,8 @@ $head Exercises$$ $list number$$ -Which statement in the routine defined by $cref exp_2_rev2.cpp$$ uses -the values that are calculated by the routine +Which statement in the routine defined by $cref exp_2_rev2.cpp$$ uses +the values that are calculated by the routine defined by $cref exp_2_for0.cpp$$ ? Which statements use values that are calculate by the routine defined in $cref exp_2_for1.cpp$$ ? @@ -1051,13 +1009,13 @@ and we first preform a zero order forward sweep, then a first order sweep, for the operation sequence used above. -What are the results of a +What are the results of a second order reverse sweep; i.e., what are the corresponding derivatives of $latex f_5 , f_4 , \ldots , f_1$$. $lnext -Create a modified version of -$cref exp_2_rev2.cpp$$ +Create a modified version of +$cref exp_2_rev2.cpp$$ that verifies the values you obtained for the previous exercise. Also create and run a main program that reports the result of calling the modified version of diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2_rev1.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_2_rev1.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_2_rev1.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2_rev1.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_2_rev1.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_2_rev1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,9 +21,8 @@ $$ $section exp_2: Verify First Order Reverse Sweep$$ +$mindex exp_2 mode$$ -$index reverse, exp_2$$ -$index exp_2, reverse mode$$ $codep */ diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_2_rev2.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_2_rev2.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_2_rev2.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_2_rev2.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_2_rev2.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_2_rev2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,9 +21,8 @@ $$ $section exp_2: Verify Second Order Reverse Sweep$$ +$mindex exp_2 mode$$ -$index reverse, exp_2$$ -$index exp_2, reverse mode$$ $codep */ diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_eps.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_eps.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_eps.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,7 +16,7 @@ { double x = .5; double epsilon = .2; double check = 1 + .5 + .125; // include 1 term less than epsilon - bool ok = std::fabs( exp_eps(x, epsilon) - check ) <= 1e-10; + bool ok = std::fabs( exp_eps(x, epsilon) - check ) <= 1e-10; return ok; } // END C++ diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps_cppad.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_eps_cppad.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps_cppad.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps_cppad.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_eps_cppad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_eps_cppad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -40,7 +40,7 @@ Use CppAD forward and reverse modes to compute the partial derivative with respect to $latex x$$, at the point $latex x = .5$$ and $latex \varepsilon = .2$$, -of the function +of the function $codei% exp_eps(%x%, %epsilon%) %$$ @@ -51,7 +51,7 @@ Create and test a modified version of the routine below that computes the same order derivatives with respect to $latex x$$, at the point $latex x = .1$$ and $latex \varepsilon = .2$$, -of the function +of the function $codei% exp_eps(%x%, %epsilon%) %$$ @@ -59,7 +59,7 @@ Create and test a modified version of the routine below that computes partial derivative with respect to $latex x$$, at the point $latex x = .1$$ and $latex \varepsilon = .2$$, -of the function corresponding to the operation sequence +of the function corresponding to the operation sequence for $latex x = .5$$ and $latex \varepsilon = .2$$. Hint: you could define a vector u with two components and use $codei% @@ -70,7 +70,7 @@ $icode f$$ was recorded. $lend $codep */ -# include // http://www.coin-or.org/CppAD/ +# include // http://www.coin-or.org/CppAD/ # include "exp_eps.hpp" // our example exponential function approximation bool exp_eps_cppad(void) { bool ok = true; @@ -90,7 +90,7 @@ // evaluate our exponential approximation AD x = U[0]; AD epsilon = U[1]; - AD apx = exp_eps(x, epsilon); + AD apx = exp_eps(x, epsilon); // range space vector size_t m = 1; // dimension of the range space @@ -98,7 +98,7 @@ Y[0] = apx; // variable that represents only range space component // Create f: U -> Y corresponding to this operation sequence - // and stop recording. This also executes a zero order forward + // and stop recording. This also executes a zero order forward // mode sweep using values in U for x and e. CppAD::ADFun f(U, Y); @@ -114,7 +114,7 @@ // first order reverse mode sweep that computes the derivative vector w(m); // weights for components of the range vector dw(n); // derivative of the weighted function - w[0] = 1.; // there is only one weight + w[0] = 1.; // there is only one weight dw = f.Reverse(1, w); // derivative of w[0] * exp_eps(x, epsilon) check = 1.5; // partial w.r.t. x ok &= NearEqual(dw[0], check, 1e-10, 1e-10); diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps_for0.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_eps_for0.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps_for0.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps_for0.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_eps_for0.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_eps_for0.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,10 +21,8 @@ $section exp_eps: Verify Zero Order Forward Sweep$$ +$mindex exp_eps$$ -$index zero, order exp_eps$$ -$index order, zero exp_eps$$ -$index exp_eps, zero order$$ $codep */ # include // for fabs function diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps_for1.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_eps_for1.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps_for1.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps_for1.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_eps_for1.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_eps_for1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,10 +21,8 @@ $$ $section exp_eps: Verify First Order Forward Sweep$$ +$mindex exp_2$$ -$index first, order exp_2$$ -$index order, first exp_2$$ -$index exp_2, first order$$ $codep */ # include // for fabs function diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps_for2.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_eps_for2.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps_for2.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps_for2.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_eps_for2.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_eps_for2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,10 +21,8 @@ $$ $section exp_eps: Verify Second Order Forward Sweep$$ +$mindex first exp_2$$ -$index first, order exp_2$$ -$index order, first exp_2$$ -$index exp_2, first order$$ $codep */ # include // for fabs function @@ -51,7 +49,7 @@ ok &= std::fabs( v2[4] - 0. ) <= 1e-10; v2[5] = v2[3] * v0[1] + 2. * v1[3] * v1[1] // v5 = v3 * v1 - + v0[3] * v2[1]; + + v0[3] * v2[1]; ok &= std::fabs( v2[5] - 2. ) <= 1e-10; v2[6] = v2[5] / 2.; // v6 = v5 / 2 diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps.hpp cppad-2016.00.00.1/introduction/exp_apx/exp_eps.hpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps.hpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps.hpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: exp_eps.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_EXP_EPS_INCLUDED -# define CPPAD_EXP_EPS_INCLUDED +// $Id: exp_eps.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_EXP_EPS_HPP +# define CPPAD_EXP_EPS_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,11 +24,8 @@ $$ $section An Epsilon Accurate Exponential Approximation$$ +$mindex exp_eps example algorithm$$ -$index exp_eps$$ -$index example, algorithm$$ -$index algorithm, example$$ -$index exp, example$$ $head Syntax$$ $codei%# include "exp_eps.hpp"%$$ @@ -38,20 +35,20 @@ $head Purpose$$ -This is a an example algorithm that is used to demonstrate -how Algorithmic Differentiation works with loops and +This is a an example algorithm that is used to demonstrate +how Algorithmic Differentiation works with loops and boolean decision variables -(see $cref exp_2$$ for a simpler example). +(see $cref exp_2$$ for a simpler example). $head Mathematical Function$$ The exponential function can be defined by $latex \[ - \exp (x) = 1 + x^1 / 1 ! + x^2 / 2 ! + \cdots + \exp (x) = 1 + x^1 / 1 ! + x^2 / 2 ! + \cdots \] $$ We define $latex k ( x, \varepsilon ) $$ as the smallest non-negative integer such that $latex \varepsilon \geq x^k / k !$$; i.e., $latex \[ -k( x, \varepsilon ) = +k( x, \varepsilon ) = \min \{ k \in {\rm Z}_+ \; | \; \varepsilon \geq x^k / k ! \} \] $$ The mathematical form for our approximation of the exponential function is @@ -59,8 +56,8 @@ \begin{array}{rcl} {\rm exp\_eps} (x , \varepsilon ) & = & \left\{ \begin{array}{ll} -\frac{1}{ {\rm exp\_eps} (-x , \varepsilon ) } - & {\rm if} \; x < 0 +\frac{1}{ {\rm exp\_eps} (-x , \varepsilon ) } + & {\rm if} \; x < 0 \\ 1 + x^1 / 1 ! + \cdots + x^{k( x, \varepsilon)} / k( x, \varepsilon ) ! & {\rm otherwise} @@ -71,7 +68,7 @@ $head include$$ -The include command in the syntax is relative to +The include command in the syntax is relative to $codei% cppad-%yyyymmdd%/introduction/exp_apx %$$ @@ -86,7 +83,7 @@ const %Type% &%x% %$$ (see $icode Type$$ below). -It specifies the point at which to evaluate the +It specifies the point at which to evaluate the approximation for the exponential function. $head epsilon$$ @@ -96,7 +93,7 @@ %$$ It specifies the accuracy with which to approximate the exponential function value; i.e., -it is the value of $latex \varepsilon$$ in the +it is the value of $latex \varepsilon$$ in the exponential function approximation defined above. $head y$$ @@ -104,23 +101,23 @@ $codei% %Type% %y% %$$ -It is the value of the exponential function +It is the value of the exponential function approximation defined above. $head Type$$ If $icode u$$ and $icode v$$ are $icode Type$$ objects and $icode i$$ -is an $code int$$: +is an $code int$$: $table $bold Operation$$ $cnext $bold Result Type$$ $cnext $bold Description$$ $rnext -$icode%Type%(%i%)%$$ +$icode%Type%(%i%)%$$ $cnext $icode Type$$ - $cnext object with value equal to $icode i$$ + $cnext object with value equal to $icode i$$ $rnext -$icode%Type u %=% v%$$ +$icode%Type u %=% v%$$ $cnext $icode Type$$ - $cnext construct $icode u$$ with value equal to $icode v$$ + $cnext construct $icode u$$ with value equal to $icode v$$ $rnext $icode%u% > %v%$$ $cnext $code bool$$ @@ -128,7 +125,7 @@ if $icode u$$ greater than $icode v$$, an false otherwise $rnext $icode%u% = %v%$$ - $cnext $icode Type$$ + $cnext $icode Type$$ $cnext new $icode u$$ (and result) is value of $icode v$$ $rnext $icode%u% * %v%$$ @@ -158,14 +155,14 @@ contains a C++ implementation of this function. $head Test$$ -The file $cref exp_eps.cpp$$ +The file $cref exp_eps.cpp$$ contains a test of this implementation. It returns true for success and false for failure. $head Exercises$$ $list number$$ Using the definition of $latex k( x, \varepsilon )$$ above, -what is the value of +what is the value of $latex k(.5, 1)$$, $latex k(.5, .1)$$, and $latex k(.5, .01)$$ ? $lnext Suppose that we make the following call to $code exp_eps$$: @@ -174,12 +171,12 @@ double epsilon = .01; double y = exp_eps(x, epsilon); $$ -What is the value assigned to +What is the value assigned to $code k$$, $code temp$$, $code term$$, and $code sum$$ the first time through the $code while$$ loop in $cref exp_eps.hpp$$ ? $lnext -Continuing the previous exercise, -what is the value assigned to +Continuing the previous exercise, +what is the value assigned to $code k$$, $code temp$$, $code term$$, and $code sum$$ the second time through the $code while$$ loop in $cref exp_eps.hpp$$ ? $lend @@ -196,7 +193,7 @@ if( Type(0) > x ) abs_x = - x; // initialize - int k = 0; // initial order + int k = 0; // initial order Type term = 1.; // term = |x|^k / k ! Type sum = term; // initial sum while(term > epsilon) @@ -206,7 +203,7 @@ sum = sum + term; // sum = 1 + ... + |x|^k / k ! } // In the case where x is negative, use exp(x) = 1 / exp(-|x|) - if( Type(0) > x ) + if( Type(0) > x ) sum = Type(1) / sum; return sum; } diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps.omh cppad-2016.00.00.1/introduction/exp_apx/exp_eps.omh --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps.omh 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps.omh 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: exp_eps.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: exp_eps.omh 3757 2015-11-30 12:03:07Z bradbell $ ---------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,8 +15,7 @@ $$ $section exp_eps: Implementation$$ -$index implementation, exp_eps$$ -$index exp_eps, implementation$$ +$mindex exp_eps$$ $code $verbatim%introduction/exp_apx/exp_eps.hpp%0%// BEGIN C++%// END C++%$$ @@ -30,8 +29,6 @@ $$ $section exp_eps: Test of exp_eps$$ -$index test, exp_eps$$ -$index exp_eps, test$$ $code $verbatim%introduction/exp_apx/exp_eps.cpp%0%// BEGIN C++%// END C++%$$ @@ -47,26 +44,20 @@ $$ $section exp_eps: Operation Sequence and Zero Order Forward Sweep$$ +$mindex example$$ + -$index exp_eps, operation sequence$$ -$index example, operation sequence$$ -$index operation, sequence example$$ -$index sequence, example operation$$ - -$index zero, order forward$$ -$index order, zero forward$$ -$index forward, zero order$$ $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 -and $icode epsilon$$ is equal to .2. -For this case, -the mathematical form for the operation sequence +and $icode epsilon$$ is equal to .2. +For this case, +the mathematical form for the operation sequence corresponding to the $code exp_eps$$ is $latex \[ - f( x , \varepsilon ) = 1 + x + x^2 / 2 + f( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ Note that, for these particular values of $icode x$$ and $icode epsilon$$, this is the same as the mathematical form for @@ -74,11 +65,11 @@ $head Operation Sequence$$ -We consider the +We consider the $cref/operation sequence/glossary/Operation/Sequence/$$ corresponding to the algorithm $cref exp_eps.hpp$$ with the argument $icode x$$ is equal to .5 -and $icode epsilon$$ is equal to .2. +and $icode epsilon$$ is equal to .2. $subhead Variable$$ We refer to values that depend on the input variables @@ -93,20 +84,20 @@ $subhead Index$$ The Index column contains the index in the operation sequence -of the corresponding atomic operation and variable. -A Forward sweep starts with the first operation +of the corresponding atomic operation and variable. +A Forward sweep starts with the first operation and ends with the last. $subhead Code$$ -The Code column contains the C++ source code corresponding -to the corresponding atomic operation in the sequence. +The Code column contains the C++ source code corresponding +to the corresponding atomic operation in the sequence. $subhead Operation$$ -The Operation column contains the +The Operation column contains the mathematical function corresponding to each atomic operation in the sequence. $subhead Zero Order$$ -The Zero Order column contains the +The Zero Order column contains the $cref/zero order derivative/exp_2_for0/Zero Order Expansion/$$ for the corresponding variable in the operation sequence. Forward mode refers to the fact that @@ -118,7 +109,7 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Code$$ + $cnext $pre $$ $cnext $bold Code$$ $cnext $pre $$ $cnext $bold Operation$$ $cnext $pre $$ $cnext $bold Zero Order$$ $rnext @@ -172,15 +163,15 @@ or if $icode epsilon$$ were a much smaller or much larger value, the results of the following comparisons could be different: $codep - if( Type(0) > x ) + if( Type(0) > x ) while(term > epsilon) $$ This in turn would result in a different operation sequence. -Thus the operation sequence above only corresponds to +Thus the operation sequence above only corresponds to $cref exp_eps.hpp$$ for values of $icode x$$ and $icode epsilon$$ within a certain range. Note that there is a neighborhood -of $latex x = 0.5$$ for which the comparisons would have the +of $latex x = 0.5$$ for which the comparisons would have the same result and hence the operation sequence would be the same. $children% @@ -188,24 +179,24 @@ %$$ $head Verification$$ -The file $cref exp_eps_for0.cpp$$ contains a routine +The file $cref exp_eps_for0.cpp$$ contains a routine that verifies the values computed above. It returns true for success and false for failure. $head Exercises$$ $list number$$ Suppose that $latex x^{(0)} = .1$$, -what is the result of a zero order forward sweep for -the operation sequence above; +what is the result of a zero order forward sweep for +the operation sequence above; i.e., what are the corresponding values for $latex v_1^{(0)} , v_2^{(0)} , \ldots , v_7^{(0)}$$. $lnext -Create a modified version of +Create a modified version of $cref exp_eps_for0.cpp$$ that verifies the values you obtained for the previous exercise. $lnext -Create and run a main program that reports the result of calling -the modified version +Create and run a main program that reports the result of calling +the modified version of $cref exp_eps_for0.cpp$$ in the previous exercise. $lend @@ -218,20 +209,14 @@ $section exp_eps: First Order Forward Sweep$$ -$index first, order forward$$ -$index order, first forward$$ -$index forward, first order$$ $head First Order Expansion$$ -$index first, order expansion$$ -$index order, first expansion$$ -$index expansion, first order$$ -We define $latex x(t)$$ and $latex \varepsilon(t) ]$$ near $latex t = 0$$ +We define $latex x(t)$$ and $latex \varepsilon(t) ]$$ near $latex t = 0$$ by the first order expansions $latex \[ \begin{array}{rcl} - x(t) & = & x^{(0)} + x^{(1)} * t + x(t) & = & x^{(0)} + x^{(1)} * t \\ \varepsilon(t) & = & \varepsilon^{(0)} + \varepsilon^{(1)} * t \end{array} @@ -246,11 +231,11 @@ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 -and $icode epsilon$$ is equal to .2. +and $icode epsilon$$ is equal to .2. For this case, the mathematical function for the operation sequence corresponding to $code exp_eps$$ is $latex \[ -f ( x , \varepsilon ) = 1 + x + x^2 / 2 +f ( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ The corresponding partial derivative with respect to $latex x$$, and the value of the derivative, are @@ -262,12 +247,12 @@ $subhead Index$$ The Index column contains the index in the operation sequence -of the corresponding atomic operation. -A Forward sweep starts with the first operation +of the corresponding atomic operation. +A Forward sweep starts with the first operation and ends with the last. $subhead Operation$$ -The Operation column contains the +The Operation column contains the mathematical function corresponding to each atomic operation in the sequence. $subhead Zero Order$$ @@ -289,8 +274,8 @@ \] $$ We use $latex x^{(1)} = 1$$ and $latex \varepsilon^{(1)} = 0$$, so that differentiation with respect to $latex t$$, -at $latex t = 0$$, -is the same partial differentiation with respect to $latex x$$ +at $latex t = 0$$, +is the same partial differentiation with respect to $latex x$$ at $latex x = x^{(0)}$$. @@ -299,7 +284,7 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Operation$$ + $cnext $pre $$ $cnext $bold Operation$$ $cnext $pre $$ $cnext $bold Zero Order$$ $cnext $pre $$ $cnext $bold Derivative$$ $cnext $pre $$ $cnext $bold First Order$$ @@ -307,49 +292,49 @@ 1 $cnext $pre $$ $cnext $latex v_1 = x $$ $cnext $cnext 0.5 - $cnext $cnext + $cnext $cnext $latex v_1^{(1)} = x^{(1)} $$ $cnext $cnext $latex v_1^{(1)} = 1$$ $rnext 2 $cnext $pre $$ $cnext $latex v_2 = 1 * v_1$$ $cnext $cnext 0.5 - $cnext $cnext + $cnext $cnext $latex v_2^{(1)} = 1 * v_1^{(1)}$$ $cnext $cnext $latex v_2^{(1)} = 1$$ $rnext 3 $cnext $pre $$ $cnext $latex v_3 = v_2 / 1$$ $cnext $cnext 0.5 - $cnext $cnext + $cnext $cnext $latex v_3^{(1)} = v_2^{(1)} / 1$$ $cnext $cnext $latex v_3^{(1)} = 1$$ $rnext 4 $cnext $pre $$ $cnext $latex v_4 = 1 + v_3$$ $cnext $cnext 1.5 - $cnext $cnext + $cnext $cnext $latex v_4^{(1)} = v_3^{(1)} $$ $cnext $cnext $latex v_4^{(1)} = 1$$ $rnext 5 $cnext $pre $$ $cnext $latex v_5 = v_3 * v_1$$ $cnext $cnext 0.25 - $cnext $cnext + $cnext $cnext $latex v_5^{(1)} = v_3^{(1)} * v_1^{(0)} + v_3^{(0)} * v_1^{(1)}$$ $cnext $cnext $latex v_5^{(1)} = 1$$ $rnext 6 $cnext $pre $$ $cnext $latex v_6 = v_5 / 2$$ $cnext $cnext 0.125 - $cnext $cnext + $cnext $cnext $latex v_6^{(1)} = v_5^{(1)} / 2$$ $cnext $cnext $latex v_6^{(1)} = 0.5$$ $rnext 7 $cnext $pre $$ $cnext $latex v_7 = v_4 + v_6$$ $cnext $cnext 1.625 - $cnext $cnext + $cnext $cnext $latex v_7^{(1)} = v_4^{(1)} + v_6^{(1)}$$ $cnext $cnext $latex v_7^{(1)} = 1.5$$ $tend @@ -359,18 +344,18 @@ The derivative of the return value for this case is $latex \[ \begin{array}{rcl} -1.5 -& = & +1.5 +& = & v_7^{(1)} = \left[ \D{v_7}{t} \right]_{t=0} = \left[ \D{}{t} f( x^{(0)} + x^{(1)} * t , \varepsilon^{(0)} ) \right]_{t=0} \\ & = & -\partial_x f ( x^{(0)} , \varepsilon^{(0)} ) * x^{(1)} = +\partial_x f ( x^{(0)} , \varepsilon^{(0)} ) * x^{(1)} = \partial_x f ( x^{(0)} , \varepsilon^{(0)} ) \end{array} \] $$ -(We have used the fact that +(We have used the fact that $latex x^{(1)} = 1$$ and $latex \varepsilon^{(1)} = 0$$.) $children% @@ -378,27 +363,27 @@ %$$ $head Verification$$ -The file $cref exp_eps_for1.cpp$$ contains a routine +The file $cref exp_eps_for1.cpp$$ contains a routine that verifies the values computed above. It returns true for success and false for failure. $head Exercises$$ $list number$$ Suppose that $latex x = .1$$, -what are the results of a zero and first order forward mode sweep for -the operation sequence above; +what are the results of a zero and first order forward mode sweep for +the operation sequence above; i.e., what are the corresponding values for $latex v_1^{(0)}, v_2^{(0)}, \cdots , v_7^{(0)}$$ and $latex v_1^{(1)}, v_2^{(1)}, \cdots , v_7^{(1)}$$ ? $lnext -Create a modified version of $cref exp_eps_for1.cpp$$ that verifies +Create a modified version of $cref exp_eps_for1.cpp$$ that verifies the derivative values from the previous exercise. Also create and run a main program that reports the result of calling the modified version of $cref exp_eps_for1.cpp$$. $lnext Suppose that $latex x = .1$$ and $latex \epsilon = .2$$, -what is the operation sequence corresponding to +what is the operation sequence corresponding to $codei% exp_eps(%x%, %epsilon%) %$$ @@ -412,34 +397,28 @@ $$ $section exp_eps: First Order Reverse Sweep$$ +$mindex mode$$ + -$index exp_eps, reverse mode$$ -$index example, reverse mode$$ -$index reverse, mode example$$ -$index mode, reverse example$$ - -$index first, order reverse$$ -$index order, first reverse$$ -$index reverse, first order$$ $head Purpose$$ -First order reverse mode uses the +First order reverse mode uses the $cref/operation sequence/exp_eps_for0/Operation Sequence/$$, and zero order forward sweep values, to compute the first order derivative -of one dependent variable with respect to all the independent variables. -The computations are done in reverse +of one dependent variable with respect to all the independent variables. +The computations are done in reverse of the order of the computations in the original algorithm. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 -and $icode epsilon$$ is equal to .2. +and $icode epsilon$$ is equal to .2. For this case, the mathematical function for the operation sequence corresponding to $code exp_eps$$ is $latex \[ -f ( x , \varepsilon ) = 1 + x + x^2 / 2 +f ( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ The corresponding partial derivatives, and the value of the derivatives, are @@ -455,7 +434,7 @@ Since $latex \varepsilon$$ is an independent variable, it could included as an argument to all of the $latex f_j$$ functions below. -The result would be that all the partials with respect to +The result would be that all the partials with respect to $latex \varepsilon$$ would be zero and hence we drop it to simplify the presentation. @@ -464,11 +443,11 @@ compute its derivative with respect to all the independent variables. For our example, we chose the value returned by $cref exp_eps.hpp$$ which is $latex v_7$$. -We begin with the function $latex f_7$$ where $latex v_7$$ +We begin with the function $latex f_7$$ where $latex v_7$$ is both an argument and the value of the function; i.e., $latex \[ \begin{array}{rcl} -f_7 ( v_1 , v_2 , v_3 , v_4 , v_5 , v_6 , v_7 ) & = & v_7 +f_7 ( v_1 , v_2 , v_3 , v_4 , v_5 , v_6 , v_7 ) & = & v_7 \\ \D{f_7}{v_7} & = & 1 \end{array} @@ -476,58 +455,58 @@ All the other partial derivatives of $latex f_7$$ are zero. $head Index 7: f_6$$ -The last operation has index 7, +The last operation has index 7, $latex \[ - v_7 = v_4 + v_6 + v_7 = v_4 + v_6 \] $$ -We define the function +We define the function $latex f_6 ( v_1 , v_2 , v_3 , v_4 , v_5 , v_6 ) $$ as equal to $latex f_7$$ -except that $latex v_7$$ is eliminated using +except that $latex v_7$$ is eliminated using this operation; i.e. $latex \[ -f_6 = +f_6 = f_7 [ v_1 , v_2 , v_3 , v_4 , v_5 , v_6 , v_7 ( v_4 , v_6 ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_6}{v_4} -& = & \D{f_7}{v_4} + - \D{f_7}{v_7} * \D{v_7}{v_4} +\D{f_6}{v_4} +& = & \D{f_7}{v_4} + + \D{f_7}{v_7} * \D{v_7}{v_4} & = 1 \\ -\D{f_6}{v_6} -& = & \D{f_7}{v_6} + - \D{f_7}{v_7} * \D{v_7}{v_6} +\D{f_6}{v_6} +& = & \D{f_7}{v_6} + + \D{f_7}{v_7} * \D{v_7}{v_6} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_6$$ are zero. $head Index 6: f_5$$ -The previous operation has index 6, +The previous operation has index 6, $latex \[ v_6 = v_5 / 2 \] $$ -We define the function +We define the function $latex f_5 ( v_1 , v_2 , v_3 , v_4 , v_5 ) $$ as equal to $latex f_6 $$ except that $latex v_6 $$ is eliminated using this operation; i.e., $latex \[ -f_5 = +f_5 = f_6 [ v_1 , v_2 , v_3 , v_4 , v_5 , v_6 ( v_5 ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_5}{v_4} -& = & \D{f_6}{v_4} +\D{f_5}{v_4} +& = & \D{f_6}{v_4} & = 1 \\ -\D{f_5}{v_5} -& = & \D{f_6}{v_5} + - \D{f_6}{v_6} * \D{v_6}{v_5} +\D{f_5}{v_5} +& = & \D{f_6}{v_5} + + \D{f_6}{v_6} * \D{v_6}{v_5} & = 0.5 \end{array} \] $$ @@ -538,33 +517,33 @@ $latex \[ v_5 = v_3 * v_1 \] $$ -We define the function +We define the function $latex f_4 ( v_1 , v_2 , v_3 , v_4 ) $$ as equal to $latex f_5 $$ except that $latex v_5 $$ is eliminated using this operation; i.e., $latex \[ -f_4 = +f_4 = f_5 [ v_1 , v_2 , v_3 , v_4 , v_5 ( v_3 , v_1 ) ] \] $$ Given the information from the forward sweep, we have $latex v_3 = 0.5 $$ and $latex v_1 = 0.5 $$. -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_4}{v_1} -& = & \D{f_5}{v_1} + - \D{f_5}{v_5} * \D{v_5}{v_1} +\D{f_4}{v_1} +& = & \D{f_5}{v_1} + + \D{f_5}{v_5} * \D{v_5}{v_1} & = 0.25 \\ \D{f_4}{v_2} & = & \D{f_5}{v_2} & = 0 \\ -\D{f_4}{v_3} -& = & \D{f_5}{v_3} + - \D{f_5}{v_5} * \D{v_5}{v_3} +\D{f_4}{v_3} +& = & \D{f_5}{v_3} + + \D{f_5}{v_5} * \D{v_5}{v_3} & = 0.25 \\ \D{f_4}{v_4} -& = & \D{f_5}{v_4} +& = & \D{f_5}{v_4} & = 1 \end{array} \] $$ @@ -574,26 +553,26 @@ $latex \[ v_4 = 1 + v_3 \] $$ -We define the function +We define the function $latex f_3 ( v_1 , v_2 , v_3 ) $$ as equal to $latex f_4 $$ except that $latex v_4 $$ is eliminated using this operation; i.e., $latex \[ -f_3 = +f_3 = f_4 [ v_1 , v_2 , v_3 , v_4 ( v_3 ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_3}{v_1} -& = & \D{f_4}{v_1} +\D{f_3}{v_1} +& = & \D{f_4}{v_1} & = 0.25 \\ \D{f_3}{v_2} & = & \D{f_4}{v_2} & = 0 \\ -\D{f_3}{v_3} -& = & \D{f_4}{v_3} + - \D{f_4}{v_4} * \D{v_4}{v_3} +\D{f_3}{v_3} +& = & \D{f_4}{v_3} + + \D{f_4}{v_4} * \D{v_4}{v_3} & = 1.25 \end{array} \] $$ @@ -604,19 +583,19 @@ $latex \[ v_3 = v_2 / 1 \] $$ -We define the function +We define the function $latex f_2 ( v_1 , v_2 ) $$ as equal to $latex f_3 $$ except that $latex v_3 $$ is eliminated using this operation; i.e., $latex \[ -f_2 = +f_2 = f_4 [ v_1 , v_2 , v_3 ( v_2 ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_2}{v_1} -& = & \D{f_3}{v_1} +\D{f_2}{v_1} +& = & \D{f_3}{v_1} & = 0.25 \\ \D{f_2}{v_2} & = & \D{f_3}{v_2} + @@ -630,15 +609,15 @@ $latex \[ v_2 = 1 * v_1 \] $$ -We define the function +We define the function $latex f_1 ( v_1 ) $$ as equal to $latex f_2 $$ except that $latex v_2 $$ is eliminated using this operation; i.e., $latex \[ -f_1 = +f_1 = f_2 [ v_1 , v_2 ( v_1 ) ] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} \D{f_1}{v_1} & = & \D{f_2}{v_1} + @@ -648,11 +627,11 @@ \] $$ Note that $latex v_1$$ is equal to $latex x$$, -so the derivative of $codei%exp_eps(%x%, %epsilon%)%$$ +so the derivative of $codei%exp_eps(%x%, %epsilon%)%$$ at $icode x$$ equal to .5 and $icode epsilon$$ equal .2 is 1.5 in the $icode x$$ direction and zero in the $icode epsilon$$ direction. -We also note that -$cref/forward/exp_eps_for1/$$ forward mode gave the +We also note that +$cref/forward/exp_eps_for1/$$ forward mode gave the same result for the partial in the $icode x$$ direction. @@ -661,7 +640,7 @@ %$$ $head Verification$$ -The file $cref exp_eps_rev1.cpp$$ contains a routine +The file $cref exp_eps_rev1.cpp$$ contains a routine that verifies the values computed above. It returns true for success and false for failure. It only tests the partial derivatives of @@ -675,14 +654,14 @@ Consider the case where $latex x = .1$$ and we first preform a zero order forward mode sweep for the operation sequence used above (in reverse order). -What are the results of a +What are the results of a first order reverse mode sweep; i.e., -what are the corresponding values for +what are the corresponding values for $latex \D{f_j}{v_k}$$ for all $latex j, k$$ such that $latex \D{f_j}{v_k} \neq 0$$. $lnext -Create a modified version of -$cref exp_eps_rev1.cpp$$ +Create a modified version of +$cref exp_eps_rev1.cpp$$ that verifies the values you obtained for the previous exercise. Also create and run a main program that reports the result of calling the modified version of @@ -698,19 +677,11 @@ $section exp_eps: Second Order Forward Mode$$ -$index exp_eps, forward mode$$ -$index example, forward mode$$ -$index forward, mode example$$ -$index mode, example forward$$ -$index forward, second order$$ $head Second Order Expansion$$ -$index second, order expansion$$ -$index order, second expansion$$ -$index expansion, second order$$ -We define $latex x(t)$$ and $latex \varepsilon(t) ]$$ near $latex t = 0$$ +We define $latex x(t)$$ and $latex \varepsilon(t) ]$$ near $latex t = 0$$ by the second order expansions $latex \[ \begin{array}{rcl} @@ -742,11 +713,11 @@ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 -and $icode epsilon$$ is equal to .2. +and $icode epsilon$$ is equal to .2. For this case, the mathematical function for the operation sequence corresponding to $code exp_eps$$ is $latex \[ -f ( x , \varepsilon ) = 1 + x + x^2 / 2 +f ( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ The corresponding second partial derivative with respect to $latex x$$, and the value of the derivative, are @@ -758,8 +729,8 @@ $subhead Index$$ The Index column contains the index in the operation sequence -of the corresponding atomic operation. -A Forward sweep starts with the first operation +of the corresponding atomic operation. +A Forward sweep starts with the first operation and ends with the last. $subhead Zero$$ @@ -768,7 +739,7 @@ (see $cref/zero order sweep/exp_2_for0/Operation Sequence/Sweep/$$). $subhead Operation$$ -The Operation column contains the +The Operation column contains the first order sweep operation for this variable. $subhead First$$ @@ -792,8 +763,8 @@ We use $latex x^{(1)} = 1$$, $latex x^{(2)} = 0$$, use $latex \varepsilon^{(1)} = 1$$, and $latex \varepsilon^{(2)} = 0$$ so that second order differentiation -with respect to $latex t$$, at $latex t = 0$$, -is the same as the second partial differentiation +with respect to $latex t$$, at $latex t = 0$$, +is the same as the second partial differentiation with respect to $latex x$$ at $latex x = x^{(0)}$$. @@ -803,14 +774,14 @@ $table $bold Index$$ $cnext $pre $$ $cnext $bold Zero$$ - $cnext $pre $$ $cnext $bold Operation$$ + $cnext $pre $$ $cnext $bold Operation$$ $cnext $pre $$ $cnext $bold First$$ $cnext $pre $$ $cnext $bold Derivative$$ $cnext $pre $$ $cnext $bold Second$$ $rnext 1 $cnext $cnext 0.5 - $cnext $cnext + $cnext $cnext $latex v_1^{(1)} = x^{(1)} $$ $cnext $cnext 1 $cnext $cnext @@ -819,7 +790,7 @@ $rnext 2 $cnext $cnext 0.5 - $cnext $cnext + $cnext $cnext $latex v_2^{(1)} = 1 * v_1^{(1)}$$ $cnext $cnext 1 $cnext $cnext @@ -828,7 +799,7 @@ $rnext 3 $cnext $cnext 0.5 - $cnext $cnext + $cnext $cnext $latex v_3^{(1)} = v_2^{(1)} / 1$$ $cnext $cnext 1 $cnext $cnext @@ -837,7 +808,7 @@ $rnext 4 $cnext $cnext 1.5 - $cnext $cnext + $cnext $cnext $latex v_4^{(1)} = v_3^{(1)} $$ $cnext $cnext 1 $cnext $cnext @@ -846,7 +817,7 @@ $rnext 5 $cnext $cnext 0.25 - $cnext $cnext + $cnext $cnext $latex v_5^{(1)} = v_3^{(1)} * v_1^{(0)} + v_3^{(0)} * v_1^{(1)}$$ $cnext $cnext 1 $cnext $cnext @@ -856,7 +827,7 @@ $rnext 6 $cnext $cnext 0.125 - $cnext $cnext + $cnext $cnext $latex v_6^{(1)} = v_5^{(1)} / 2$$ $cnext $cnext 0.5 $cnext $cnext @@ -865,7 +836,7 @@ $rnext 7 $cnext $cnext 1.625 - $cnext $cnext + $cnext $cnext $latex v_7^{(1)} = v_4^{(1)} + v_6^{(1)}$$ $cnext $cnext 1.5 $cnext $cnext @@ -878,8 +849,8 @@ The second derivative of the return value for this case is $latex \[ \begin{array}{rcl} -1 -& = & +1 +& = & v_7^{(2)} = \left[ \Dpow{2}{t} v_7 \right]_{t=0} = \left[ \Dpow{2}{t} f( x^{(0)} + x^{(1)} * t , \varepsilon^{(0)} ) \right]_{t=0} @@ -897,23 +868,23 @@ introduction/exp_apx/exp_eps_for2.cpp %$$ $head Verification$$ -The file $cref exp_eps_for2.cpp$$ contains a routine +The file $cref exp_eps_for2.cpp$$ contains a routine which verifies the values computed above. It returns true for success and false for failure. $head Exercises$$ $list number$$ -Which statement in the routine defined by $cref exp_eps_for2.cpp$$ uses -the values that are calculated by the routine +Which statement in the routine defined by $cref exp_eps_for2.cpp$$ uses +the values that are calculated by the routine defined by $cref exp_eps_for1.cpp$$ ? $lnext Suppose that $latex x = .1$$, -what are the results of a zero, first, and second order forward sweep for -the operation sequence above; +what are the results of a zero, first, and second order forward sweep for +the operation sequence above; i.e., what are the corresponding values for $latex v_i^{(k)}$$ for $latex i = 1, \ldots , 7$$ and $latex k = 0, 1, 2$$. $lnext -Create a modified version of $cref exp_eps_for2.cpp$$ that verifies +Create a modified version of $cref exp_eps_for2.cpp$$ that verifies the derivative values from the previous exercise. Also create and run a main program that reports the result of calling the modified version of @@ -929,33 +900,26 @@ $section exp_eps: Second Order Reverse Sweep$$ -$index exp_eps, reverse mode$$ -$index example, reverse mode$$ -$index reverse, mode example$$ -$index mode, reverse example$$ - -$index second, order reverse$$ -$index order, second reverse$$ -$index reverse, second order$$ + $head Purpose$$ In general, a second order reverse sweep is given the $cref/first order expansion/exp_eps_for1/First Order Expansion/$$ for all of the variables in an operation sequence. -Given a choice of a particular variable, -it computes the derivative, -of that variables first order expansion coefficient, +Given a choice of a particular variable, +it computes the derivative, +of that variables first order expansion coefficient, with respect to all of the independent variables. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 -and $icode epsilon$$ is equal to .2. +and $icode epsilon$$ is equal to .2. For this case, the mathematical function for the operation sequence corresponding to $code exp_eps$$ is $latex \[ -f ( x , \varepsilon ) = 1 + x + x^2 / 2 +f ( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ The corresponding derivative of the partial derivative with respect to $latex x$$ is @@ -971,7 +935,7 @@ Since $latex \varepsilon$$ is an independent variable, it could included as an argument to all of the $latex f_j$$ functions below. -The result would be that all the partials with respect to +The result would be that all the partials with respect to $latex \varepsilon$$ would be zero and hence we drop it to simplify the presentation. @@ -980,14 +944,14 @@ compute its derivative with respect to all the independent variables. For our example, we chose the value returned by $cref exp_eps.hpp$$ which is $latex v_7$$. -We begin with the function $latex f_7$$ where $latex v_7$$ +We begin with the function $latex f_7$$ where $latex v_7$$ is both an argument and the value of the function; i.e., $latex \[ \begin{array}{rcl} -f_7 \left( - v_1^{(0)} , v_1^{(1)} , \ldots , v_7^{(0)} , v_7^{(1)} -\right) -& = & v_7^{(1)} +f_7 \left( + v_1^{(0)} , v_1^{(1)} , \ldots , v_7^{(0)} , v_7^{(1)} +\right) +& = & v_7^{(1)} \\ \D{f_7}{v_7^{(1)}} & = & 1 \end{array} @@ -998,41 +962,41 @@ The last operation has index 7, $latex \[ \begin{array}{rcl} - v_7^{(0)} & = & v_4^{(0)} + v_6^{(0)} + v_7^{(0)} & = & v_4^{(0)} + v_6^{(0)} \\ - v_7^{(1)} & = & v_4^{(1)} + v_6^{(1)} + v_7^{(1)} & = & v_4^{(1)} + v_6^{(1)} \end{array} \] $$ -We define the function +We define the function $latex f_6 \left( v_1^{(0)} , \ldots , v_6^{(1)} \right) $$ as equal to $latex f_7$$ -except that $latex v_7^{(0)}$$ and $latex v_7^{(1)}$$ are eliminated using +except that $latex v_7^{(0)}$$ and $latex v_7^{(1)}$$ are eliminated using this operation; i.e. $latex \[ -f_6 = -f_7 \left[ v_1^{(0)} , \ldots , v_6^{(1)} , +f_6 = +f_7 \left[ v_1^{(0)} , \ldots , v_6^{(1)} , v_7^{(0)} \left( v_4^{(0)} , v_6^{(0)} \right) , - v_7^{(1)} \left( v_4^{(1)} , v_6^{(1)} \right) + v_7^{(1)} \left( v_4^{(1)} , v_6^{(1)} \right) \right] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_6}{v_4^{(1)}} -& = & \D{f_7}{v_4^{(1)}} + - \D{f_7}{v_7^{(1)}} * \D{v_7^{(1)}}{v_4^{(1)}} +\D{f_6}{v_4^{(1)}} +& = & \D{f_7}{v_4^{(1)}} + + \D{f_7}{v_7^{(1)}} * \D{v_7^{(1)}}{v_4^{(1)}} & = 1 \\ -\D{f_6}{v_6^{(1)}} -& = & \D{f_7}{v_6^{(1)}} + - \D{f_7}{v_7^{(1)}} * \D{v_7^{(1)}}{v_6^{(1)}} +\D{f_6}{v_6^{(1)}} +& = & \D{f_7}{v_6^{(1)}} + + \D{f_7}{v_7^{(1)}} * \D{v_7^{(1)}}{v_6^{(1)}} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_6$$ are zero. $head Index 6: f_5$$ -The previous operation has index 6, +The previous operation has index 6, $latex \[ \begin{array}{rcl} v_6^{(0)} & = & v_5^{(0)} / 2 @@ -1040,28 +1004,28 @@ v_6^{(1)} & = & v_5^{(1)} / 2 \end{array} \] $$ -We define the function +We define the function $latex f_5 \left( v_1^{(0)} , \ldots , v_5^{(1)} \right) $$ as equal to $latex f_6 $$ -except that $latex v_6^{(0)}$$ and $latex v_6^{(1)}$$ are eliminated using +except that $latex v_6^{(0)}$$ and $latex v_6^{(1)}$$ are eliminated using this operation; i.e. $latex \[ -f_5 = -f_6 \left[ v_1^{(0)} , \ldots , v_5^{(1)} , +f_5 = +f_6 \left[ v_1^{(0)} , \ldots , v_5^{(1)} , v_6^{(0)} \left( v_5^{(0)} \right) , - v_6^{(1)} \left( v_5^{(1)} \right) + v_6^{(1)} \left( v_5^{(1)} \right) \right] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_5}{v_4^{(1)}} -& = & \D{f_6}{v_4^{(1)}} +\D{f_5}{v_4^{(1)}} +& = & \D{f_6}{v_4^{(1)}} & = 1 \\ -\D{f_5}{v_5^{(1)}} -& = & \D{f_6}{v_5} + - \D{f_6}{v_6^{(1)}} * \D{v_6^{(1)}}{v_5^{(1)}} +\D{f_5}{v_5^{(1)}} +& = & \D{f_6}{v_5} + + \D{f_6}{v_6^{(1)}} * \D{v_6^{(1)}}{v_5^{(1)}} & = 0.5 \end{array} \] $$ @@ -1076,13 +1040,13 @@ v_5^{(1)} & = & v_3^{(1)} * v_1^{(0)} + v_3^{(0)} * v_1^{(1)} \end{array} \] $$ -We define the function +We define the function $latex f_4 \left( v_1^{(0)} , \ldots , v_4^{(1)} \right) $$ as equal to $latex f_5 $$ -except that $latex v_5^{(0)}$$ and $latex v_5^{(1)}$$ are eliminated using +except that $latex v_5^{(0)}$$ and $latex v_5^{(1)}$$ are eliminated using this operation; i.e. $latex \[ -f_4 = +f_4 = f_5 \left[ v_1^{(0)} , \ldots , v_4^{(1)} , v_5^{(0)} \left( v_1^{(0)}, v_3^{(0)} \right) , v_5^{(1)} \left( v_1^{(0)}, v_1^{(1)}, v_3^{(0)} , v_3^{(1)} \right) , @@ -1099,22 +1063,22 @@ \begin{array}{rcll} \D{f_4}{v_1^{(0)}} & = & \D{f_5}{v_1^{(0)}} - + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_1^{(0)}} + + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_1^{(0)}} & = 0.5 \\ \D{f_4}{v_1^{(1)}} & = & \D{f_5}{v_1^{(1)}} - + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_1^{(1)}} + + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_1^{(1)}} & = 0.25 \\ \D{f_4}{v_3^{(0)}} & = & \D{f_5}{v_3^{(0)}} - + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_3^{(0)}} + + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_3^{(0)}} & = 0.5 \\ \D{f_4}{v_3^{(1)}} & = & \D{f_3}{v_1^{(1)}} - + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_3^{(1)}} + + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_3^{(1)}} & = 0.25 \\ \D{f_4}{v_4^{(1)}} @@ -1133,45 +1097,45 @@ v_4^{(1)} = v_3^{(1)} \end{array} \] $$ -We define the function +We define the function $latex f_3 \left( v_1^{(0)} , \ldots , v_3^{(1)} \right) $$ as equal to $latex f_4 $$ -except that $latex v_4^{(0)}$$ and $latex v_4^{(1)}$$ are eliminated using +except that $latex v_4^{(0)}$$ and $latex v_4^{(1)}$$ are eliminated using this operation; i.e. $latex \[ -f_3 = +f_3 = f_4 \left[ v_1^{(0)} , \ldots , v_3^{(1)} , v_4^{(0)} \left( v_3^{(0)} \right) , - v_4^{(1)} \left( v_3^{(1)} \right) + v_4^{(1)} \left( v_3^{(1)} \right) \right] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_3}{v_1^{(0)}} +\D{f_3}{v_1^{(0)}} & = & \D{f_4}{v_1^{(0)}} & = 0.5 \\ -\D{f_3}{v_1^{(1)}} +\D{f_3}{v_1^{(1)}} & = & \D{f_4}{v_1^{(1)}} & = 0.25 \\ -\D{f_3}{v_2^{(0)}} -& = & \D{f_4}{v_2^{(0)}} +\D{f_3}{v_2^{(0)}} +& = & \D{f_4}{v_2^{(0)}} & = 0 \\ -\D{f_3}{v_2^{(1)}} -& = & \D{f_4}{v_2^{(1)}} +\D{f_3}{v_2^{(1)}} +& = & \D{f_4}{v_2^{(1)}} & = 0 \\ -\D{f_3}{v_3^{(0)}} -& = & \D{f_4}{v_3^{(0)}} - + \D{f_4}{v_4^{(0)}} * \D{v_4^{(0)}}{v_3^{(0)}} +\D{f_3}{v_3^{(0)}} +& = & \D{f_4}{v_3^{(0)}} + + \D{f_4}{v_4^{(0)}} * \D{v_4^{(0)}}{v_3^{(0)}} & = 0.5 \\ -\D{f_3}{v_3^{(1)}} -& = & \D{f_4}{v_3^{(1)}} - + \D{f_4}{v_4^{(1)}} * \D{v_4^{(1)}}{v_3^{(1)}} +\D{f_3}{v_3^{(1)}} +& = & \D{f_4}{v_3^{(1)}} + + \D{f_4}{v_4^{(1)}} * \D{v_4^{(1)}}{v_3^{(1)}} & = 1.25 \end{array} \] $$ @@ -1186,36 +1150,36 @@ v_3^{(1)} & = & v_2^{(1)} / 1 \end{array} \] $$ -We define the function +We define the function $latex f_2 \left( v_1^{(0)} , \ldots , v_2^{(1)} \right) $$ as equal to $latex f_3 $$ -except that $latex v_3^{(0)}$$ and $latex v_3^{(1)}$$ are eliminated using +except that $latex v_3^{(0)}$$ and $latex v_3^{(1)}$$ are eliminated using this operation; i.e. $latex \[ -f_2 = +f_2 = f_3 \left[ v_1^{(0)} , \ldots , v_2^{(1)} , v_3^{(0)} \left( v_2^{(0)} \right) , v_3^{(1)} \left( v_2^{(1)} \right) \right] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_2}{v_1^{(0)}} +\D{f_2}{v_1^{(0)}} & = & \D{f_3}{v_1^{(0)}} & = 0.5 \\ -\D{f_2}{v_1^{(1)}} +\D{f_2}{v_1^{(1)}} & = & \D{f_3}{v_1^{(1)}} & = 0.25 \\ -\D{f_2}{v_2^{(0)}} -& = & \D{f_3}{v_2^{(0)}} +\D{f_2}{v_2^{(0)}} +& = & \D{f_3}{v_2^{(0)}} + \D{f_3}{v_3^{(0)}} * \D{v_3^{(0)}}{v_2^{(0)}} & = 0.5 \\ -\D{f_2}{v_2^{(1)}} -& = & \D{f_3}{v_2^{(1)}} +\D{f_2}{v_2^{(1)}} +& = & \D{f_3}{v_2^{(1)}} + \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_2^{(0)}} & = 1.25 \end{array} @@ -1230,45 +1194,45 @@ v_2^{(1)} & = & 1 * v_1^{(1)} \end{array} \] $$ -We define the function +We define the function $latex f_1 \left( v_1^{(0)} , v_1^{(1)} \right) $$ as equal to $latex f_2 $$ -except that $latex v_2^{(0)}$$ and $latex v_2^{(1)}$$ are eliminated using +except that $latex v_2^{(0)}$$ and $latex v_2^{(1)}$$ are eliminated using this operation; i.e. $latex \[ -f_1 = -f_2 \left[ v_1^{(0)} , v_1^{(1)} , +f_1 = +f_2 \left[ v_1^{(0)} , v_1^{(1)} , v_2^{(0)} \left( v_1^{(0)} \right) , - v_2^{(1)} \left( v_1^{(1)} \right) + v_2^{(1)} \left( v_1^{(1)} \right) \right] \] $$ -It follows that +It follows that $latex \[ \begin{array}{rcll} -\D{f_1}{v_1^{(0)}} +\D{f_1}{v_1^{(0)}} & = & \D{f_2}{v_1^{(0)}} + \D{f_2}{v_2^{(0)}} * \D{v_2^{(0)}}{v_1^{(0)}} & = 1 \\ -\D{f_1}{v_1^{(1)}} +\D{f_1}{v_1^{(1)}} & = & \D{f_2}{v_1^{(1)}} + \D{f_2}{v_2^{(1)}} * \D{v_2^{(1)}}{v_1^{(1)}} & = 1.5 \end{array} \] $$ Note that $latex v_1$$ is equal to $latex x$$, -so the second partial derivative of -$codei%exp_eps(%x%, %epsilon%)%$$ -at $icode x$$ equal to .5 and $icode epsilon$$ equal .2 is +so the second partial derivative of +$codei%exp_eps(%x%, %epsilon%)%$$ +at $icode x$$ equal to .5 and $icode epsilon$$ equal .2 is $latex \[ \Dpow{2}{x} v_7^{(0)} -= \D{v_7^{(1)}}{x} += \D{v_7^{(1)}}{x} = \D{f_1}{v_1^{(0)}} = 1 \] $$ There is a theorem about algorithmic differentiation that explains why the other partial of $latex f_1$$ is equal to the first partial of -$codei%exp_eps(%x%, %epsilon%)%$$ +$codei%exp_eps(%x%, %epsilon%)%$$ with respect to $latex x$$. @@ -1277,7 +1241,7 @@ %$$ $head Verification$$ -The file $cref exp_eps_rev2.cpp$$ contains a routine +The file $cref exp_eps_rev2.cpp$$ contains a routine that verifies the values computed above. It returns true for success and false for failure. It only tests the partial derivatives of @@ -1291,14 +1255,14 @@ Consider the case where $latex x = .1$$ and we first preform a zero order forward mode sweep for the operation sequence used above (in reverse order). -What are the results of a +What are the results of a first order reverse mode sweep; i.e., -what are the corresponding values for +what are the corresponding values for $latex \D{f_j}{v_k}$$ for all $latex j, k$$ such that $latex \D{f_j}{v_k} \neq 0$$. $lnext -Create a modified version of -$cref exp_eps_rev2.cpp$$ +Create a modified version of +$cref exp_eps_rev2.cpp$$ that verifies the values you obtained for the previous exercise. Also create and run a main program that reports the result of calling the modified version of diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps_rev1.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_eps_rev1.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps_rev1.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps_rev1.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_eps_rev1.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_eps_rev1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,9 +27,8 @@ $$ $section exp_eps: Verify First Order Reverse Sweep$$ +$mindex exp_eps$$ -$index reverse, exp_eps$$ -$index exp_eps, reverse$$ $codep */ # include // define size_t diff -Nru cppad-2015.00.00.9/introduction/exp_apx/exp_eps_rev2.cpp cppad-2016.00.00.1/introduction/exp_apx/exp_eps_rev2.cpp --- cppad-2015.00.00.9/introduction/exp_apx/exp_eps_rev2.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/exp_eps_rev2.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp_eps_rev2.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp_eps_rev2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,9 +27,8 @@ $$ $section exp_eps: Verify Second Order Reverse Sweep$$ +$mindex exp_eps$$ -$index reverse, exp_eps$$ -$index exp_eps, reverse$$ $codep */ # include // define size_t @@ -72,7 +71,7 @@ ok &= std::fabs( f_v0[5] - 0. ) <= 1e-10; // partial f_5 w.r.t. v_5^0 ok &= std::fabs( f_v1[5] - 0.5 ) <= 1e-10; // partial f_5 w.r.t. v_5^1 - // f_4 = f_5( v_1^0 , ... , v_4^1 , v_3^0 * v_1^0 , + // f_4 = f_5( v_1^0 , ... , v_4^1 , v_3^0 * v_1^0 , // v_3^1 * v_1^0 + v_3^0 * v_1^1 ) f_v0[1] += f_v0[5] * v0[3] + f_v1[5] * v1[3]; f_v0[3] += f_v0[5] * v0[1] + f_v1[5] * v1[1]; diff -Nru cppad-2015.00.00.9/introduction/exp_apx/main.cpp cppad-2016.00.00.1/introduction/exp_apx/main.cpp --- cppad-2015.00.00.9/introduction/exp_apx/main.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/main.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: main.cpp 3114 2014-02-22 16:20:39Z bradbell $ */ +// $Id: main.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,10 +19,8 @@ $$ $section Correctness Tests For Exponential Approximation in Introduction$$ +$mindex exp_apx main run$$ -$index exp_apx, main test$$ -$index run, exp_apx test$$ -$index test, exp_apx main$$ $head Running Tests$$ To build this program and run its correctness tests see $cref cmake_check$$. @@ -60,7 +58,7 @@ static size_t Run_error_count = 0; bool Run(bool TestOk(void), std::string name) { bool ok = true; - std::streamsize width = 20; + std::streamsize width = 20; std::cout.width( width ); std::cout.setf( std::ios_base::left ); std::cout << name.c_str(); @@ -84,7 +82,7 @@ { bool ok = true; using namespace std; - // This comment is used by OneTest + // This comment is used by OneTest // external compiled tests ok &= Run( exp_2, "exp_2" ); diff -Nru cppad-2015.00.00.9/introduction/exp_apx/makefile.am cppad-2016.00.00.1/introduction/exp_apx/makefile.am --- cppad-2015.00.00.9/introduction/exp_apx/makefile.am 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/makefile.am 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2541 2012-11-06 16:32:36Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -19,7 +19,7 @@ exp_2.omh \ exp_eps.omh # -check_PROGRAMS = exp_apx +check_PROGRAMS = exp_apx # AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) AM_CXXFLAGS = -g $(CXX_FLAGS) diff -Nru cppad-2015.00.00.9/introduction/exp_apx/makefile.in cppad-2016.00.00.1/introduction/exp_apx/makefile.in --- cppad-2015.00.00.9/introduction/exp_apx/makefile.in 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/exp_apx/makefile.in 2016-02-09 08:31:54.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = exp_apx$(EXEEXT) subdir = introduction/exp_apx -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -164,6 +173,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -194,12 +204,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -280,26 +290,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -382,7 +395,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu introduction/exp_apx/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu introduction/exp_apx/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -647,6 +659,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check ./exp_apx diff -Nru cppad-2015.00.00.9/introduction/get_started/get_started.cpp cppad-2016.00.00.1/introduction/get_started/get_started.cpp --- cppad-2015.00.00.9/introduction/get_started/get_started.cpp 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/get_started/get_started.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: get_started.cpp 3114 2014-02-22 16:20:39Z bradbell $ */ +// $Id: get_started.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -29,18 +29,14 @@ $$ $section Getting Started Using CppAD to Compute Derivatives$$ -$index getting, started$$ -$index started, getting$$ -$index simple, example$$ -$index example, simple$$ -$index start, using CppAD$$ +$mindex simple example start$$ $head Purpose$$ -Demonstrate the use of CppAD by computing the derivative +Demonstrate the use of CppAD by computing the derivative of a simple example function. $head Function$$ -The example function $latex f : \B{R} \rightarrow \B{R}$$ is defined by +The example function $latex f : \B{R} \rightarrow \B{R}$$ is defined by $latex \[ f(x) = a_0 + a_1 * x^1 + \cdots + a_{k-1} * x^{k-1} \] $$ @@ -49,15 +45,15 @@ $head Derivative$$ The derivative of $latex f(x)$$ is given by $latex \[ - f' (x) = a_1 + 2 * a_2 * x + \cdots + (k-1) * a_{k-1} * x^{k-2} + f' (x) = a_1 + 2 * a_2 * x + \cdots + (k-1) * a_{k-1} * x^{k-2} \] $$ $head Value$$ For the particular case in this example, -$latex k$$ is equal to 5, -$latex a = (1, 1, 1, 1, 1)$$, and +$latex k$$ is equal to 5, +$latex a = (1, 1, 1, 1, 1)$$, and $latex x = 3$$. -If follows that +If follows that $latex \[ f' ( 3 ) = 1 + 2 * 3 + 3 * 3^2 + 4 * 3^3 = 142 \] $$ @@ -72,7 +68,7 @@ using CppAD: $list number$$ Compute and print the derivative of $latex f(x) = 1 + x + x^2 + x^3 + x^4$$ -at the point $latex x = 2$$. +at the point $latex x = 2$$. $lnext Compute and print the derivative of $latex f(x) = 1 + x + x^2 / 2$$ at the point $latex x = .5$$. @@ -84,11 +80,11 @@ $head Program$$ $codep */ -#include // standard input/output +#include // standard input/output #include // standard vector #include // the CppAD package http://www.coin-or.org/CppAD/ -namespace { +namespace { // define y(x) = Poly(a, x) in the empty namespace template Type Poly(const std::vector &a, const Type &x) diff -Nru cppad-2015.00.00.9/introduction/get_started/makefile.am cppad-2016.00.00.1/introduction/get_started/makefile.am --- cppad-2015.00.00.9/introduction/get_started/makefile.am 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/get_started/makefile.am 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2541 2012-11-06 16:32:36Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -15,7 +15,7 @@ # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -check_PROGRAMS = get_started +check_PROGRAMS = get_started # AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) AM_CXXFLAGS = -g $(CXX_FLAGS) diff -Nru cppad-2015.00.00.9/introduction/get_started/makefile.in cppad-2016.00.00.1/introduction/get_started/makefile.in --- cppad-2015.00.00.9/introduction/get_started/makefile.in 2015-02-24 08:31:36.000000000 +0000 +++ cppad-2016.00.00.1/introduction/get_started/makefile.in 2016-02-09 08:31:54.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = get_started$(EXEEXT) subdir = introduction/get_started -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -146,6 +155,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -176,12 +186,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -263,26 +273,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -341,7 +354,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu introduction/get_started/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu introduction/get_started/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -592,6 +604,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + # test: check ./get_started diff -Nru cppad-2015.00.00.9/makefile.am cppad-2016.00.00.1/makefile.am --- cppad-2015.00.00.9/makefile.am 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/makefile.am 2016-02-09 08:31:59.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3495 2014-12-24 01:16:15Z bradbell $ +# $Id: makefile.am 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -12,7 +12,7 @@ # BUILT_SOURCES = $(top_srcdir)/cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp: cppad/configure.hpp - cp cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp + cp cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp # if CppAD_POSTFIX postfix_dir = $(POSTFIX_DIR) @@ -24,24 +24,24 @@ if CppAD_ADOLC SPEED_ADOLC_TESTS = speed/adolc else -SPEED_ADOLC_TESTS = +SPEED_ADOLC_TESTS = endif # # Did user specify a value for FADBAD_DIR in configure command line if CppAD_FADBAD SPEED_FADBAD_TESTS = speed/fadbad else -SPEED_FADBAD_TESTS = +SPEED_FADBAD_TESTS = endif # # Did user specify a value for SACADO_DIR in configure command line if CppAD_SACADO SPEED_SACADO_TESTS = speed/sacado else -SPEED_SACADO_TESTS = +SPEED_SACADO_TESTS = endif # -# Did user specify a value for IPOPT_DIR in configure command line +# Did user specify a value for IPOPT_DIR in configure command line if CppAD_IPOPT IPOPT_TESTS = \ example/ipopt_solve \ @@ -51,7 +51,7 @@ # IPOPT_DIRS = \ cppad_ipopt/src \ - $(IPOPT_TESTS) + $(IPOPT_TESTS) # IPOPT_HEADER = \ cppad_ipopt/src/cppad_ipopt_nlp.hpp @@ -76,6 +76,7 @@ speed/src \ $(SPEED_TESTS) else + SPEED_TESTS = SPEED_DIRS = endif # --------------------------------------------------------------------------- @@ -85,39 +86,19 @@ $(IPOPT_HEADER) # nobase_myinclude_HEADERS = \ - cppad/CheckNumericType.h \ - cppad/CheckSimpleVector.h \ - cppad/CppAD.h \ - cppad/CppAD_vector.h \ - cppad/ErrorHandler.h \ - cppad/LuFactor.h \ - cppad/LuInvert.h \ - cppad/LuSolve.h \ - cppad/NearEqual.h \ - cppad/OdeErrControl.h \ - cppad/OdeGearControl.h \ - cppad/OdeGear.h \ - cppad/Poly.h \ - cppad/PowInt.h \ - cppad/RombergMul.h \ - cppad/RombergOne.h \ - cppad/Rosen34.h \ - cppad/Runge45.h \ - cppad/SpeedTest.h \ - cppad/TrackNewDel.h \ - \ + cppad/utility.hpp \ cppad/base_require.hpp \ - cppad/check_numeric_type.hpp \ - cppad/check_simple_vector.hpp \ + cppad/utility/check_numeric_type.hpp \ + cppad/utility/check_simple_vector.hpp \ cppad/configure.hpp \ cppad/cppad.hpp \ - cppad/elapsed_seconds.hpp \ + cppad/utility/elapsed_seconds.hpp \ cppad/example/base_adolc.hpp \ cppad/example/cppad_eigen.hpp \ cppad/example/eigen_plugin.hpp \ cppad/example/matrix_mul.hpp \ - cppad/error_handler.hpp \ - cppad/index_sort.hpp \ + cppad/utility/error_handler.hpp \ + cppad/utility/index_sort.hpp \ cppad/ipopt/solve.hpp \ cppad/ipopt/solve_callback.hpp \ cppad/ipopt/solve_result.hpp \ @@ -125,6 +106,8 @@ cppad/local/abs.hpp \ cppad/local/abs_op.hpp \ cppad/local/acos_op.hpp \ + cppad/local/acosh.hpp \ + cppad/local/acosh_op.hpp \ cppad/local/ad_assign.hpp \ cppad/local/ad_binary.hpp \ cppad/local/ad_ctor.hpp \ @@ -135,22 +118,33 @@ cppad/local/ad_fun.hpp \ cppad/local/ad.hpp \ cppad/local/ad_tape.hpp \ + cppad/local/ad_to_string.hpp \ cppad/local/ad_valued.hpp \ cppad/local/arithmetic.hpp \ cppad/local/asin_op.hpp \ + cppad/local/asinh.hpp \ + cppad/local/asinh_op.hpp \ cppad/local/atan2.hpp \ cppad/local/atan_op.hpp \ + cppad/local/atanh.hpp \ + cppad/local/atanh_op.hpp \ cppad/local/atomic_base.hpp \ + cppad/local/azmul.hpp \ cppad/local/base_complex.hpp \ cppad/local/base_cond_exp.hpp \ cppad/local/base_double.hpp \ cppad/local/base_float.hpp \ + cppad/local/base_limits.hpp \ cppad/local/base_std_math.hpp \ + cppad/local/base_to_string.hpp \ cppad/local/bender_quad.hpp \ cppad/local/bool_fun.hpp \ cppad/local/bool_valued.hpp \ cppad/local/capacity_order.hpp \ cppad/local/checkpoint.hpp \ + cppad/local/check_for_nan.hpp \ + cppad/local/color_general.hpp \ + cppad/local/color_symmetric.hpp \ cppad/local/compare.hpp \ cppad/local/comp_op.hpp \ cppad/local/compute_assign.hpp \ @@ -177,6 +171,8 @@ cppad/local/erf.hpp \ cppad/local/erf_op.hpp \ cppad/local/exp_op.hpp \ + cppad/local/expm1.hpp \ + cppad/local/expm1_op.hpp \ cppad/local/for_jac_sweep.hpp \ cppad/local/for_one.hpp \ cppad/local/for_sparse_jac.hpp \ @@ -194,16 +190,18 @@ cppad/local/independent.hpp \ cppad/local/integer.hpp \ cppad/local/jacobian.hpp \ - cppad/local/limits.hpp \ cppad/local/load_op.hpp \ cppad/local/log_op.hpp \ + cppad/local/log1p.hpp \ + cppad/local/log1p_op.hpp \ cppad/local/lu_ratio.hpp \ - cppad/local/math_other.hpp \ cppad/local/mul_eq.hpp \ cppad/local/mul.hpp \ cppad/local/mul_op.hpp \ cppad/local/near_equal_ext.hpp \ + cppad/local/numeric_limits.hpp \ cppad/local/num_skip.hpp \ + cppad/local/old_atomic.hpp \ cppad/local/omp_max_thread.hpp \ cppad/local/op_code.hpp \ cppad/local/op.hpp \ @@ -229,6 +227,7 @@ cppad/local/rev_sparse_hes.hpp \ cppad/local/rev_sparse_jac.hpp \ cppad/local/rev_two.hpp \ + cppad/local/set_get_in_parallel.hpp \ cppad/local/sign.hpp \ cppad/local/sign_op.hpp \ cppad/local/sin_op.hpp \ @@ -236,7 +235,6 @@ cppad/local/sparse_binary_op.hpp \ cppad/local/sparse_hessian.hpp \ cppad/local/sparse.hpp \ - cppad/local/color_general.hpp \ cppad/local/sparse_jacobian.hpp \ cppad/local/sparse_list.hpp \ cppad/local/sparse_pack.hpp \ @@ -244,7 +242,8 @@ cppad/local/sparse_set.hpp \ cppad/local/sparse_unary_op.hpp \ cppad/local/sqrt_op.hpp \ - cppad/local/std_math_ad.hpp \ + cppad/local/standard_math.hpp \ + cppad/local/std_math_98.hpp \ cppad/local/std_set.hpp \ cppad/local/store_op.hpp \ cppad/local/sub_eq.hpp \ @@ -259,26 +258,28 @@ cppad/local/unary_plus.hpp \ cppad/local/undef.hpp \ cppad/local/user_ad.hpp \ - cppad/local/old_atomic.hpp \ cppad/local/value.hpp \ cppad/local/var2par.hpp \ cppad/local/vec_ad.hpp \ - cppad/lu_factor.hpp \ - cppad/lu_invert.hpp \ - cppad/lu_solve.hpp \ - cppad/memory_leak.hpp \ - cppad/nan.hpp \ - cppad/near_equal.hpp \ - cppad/ode_err_control.hpp \ - cppad/ode_gear_control.hpp \ - cppad/ode_gear.hpp \ - cppad/omp_alloc.hpp \ - cppad/poly.hpp \ - cppad/pow_int.hpp \ - cppad/romberg_mul.hpp \ - cppad/romberg_one.hpp \ - cppad/rosen_34.hpp \ - cppad/runge_45.hpp \ + cppad/local/zdouble.hpp \ + cppad/local/zmul_op.hpp \ + cppad/utility/lu_factor.hpp \ + cppad/utility/lu_invert.hpp \ + cppad/utility/lu_solve.hpp \ + cppad/utility/memory_leak.hpp \ + cppad/utility/nan.hpp \ + cppad/utility/near_equal.hpp \ + cppad/utility/ode_err_control.hpp \ + cppad/utility/ode_gear_control.hpp \ + cppad/utility/ode_gear.hpp \ + cppad/utility/omp_alloc.hpp \ + cppad/utility/poly.hpp \ + cppad/utility/pow_int.hpp \ + cppad/utility/romberg_mul.hpp \ + cppad/utility/romberg_one.hpp \ + cppad/utility/rosen_34.hpp \ + cppad/utility/runge_45.hpp \ + cppad/utility/to_string.hpp \ cppad/speed/det_33.hpp \ cppad/speed/det_by_lu.hpp \ cppad/speed/det_by_minor.hpp \ @@ -288,13 +289,13 @@ cppad/speed/ode_evaluate.hpp \ cppad/speed/sparse_hes_fun.hpp \ cppad/speed/sparse_jac_fun.hpp \ - cppad/speed_test.hpp \ + cppad/utility/speed_test.hpp \ cppad/speed/uniform_01.hpp \ - cppad/thread_alloc.hpp \ - cppad/time_test.hpp \ - cppad/track_new_del.hpp \ - cppad/vector.hpp -# End nobase_myinclude_HEADERS (check_makefile.sh uses this comment) + cppad/utility/thread_alloc.hpp \ + cppad/utility/time_test.hpp \ + cppad/utility/track_new_del.hpp \ + cppad/utility/vector.hpp +# End nobase_myinclude_HEADERS (check_makefile.sh uses this comment) # --------------------------------------------------------------- # # No objects or executables are required to install CppAD. @@ -310,7 +311,7 @@ print_for \ multi_thread \ multi_thread/test_multi \ - test_more + test_more # # note that bin/gpl_license.sh is deleted by dist-hook EXTRA_DIST = \ @@ -350,7 +351,7 @@ multi_thread/CMakeLists.txt \ multi_thread/openmp/CMakeLists.txt \ multi_thread/pthread/CMakeLists.txt \ - print_for/CMakeLists.txt + print_for/CMakeLists.txt test_directory_list = \ $(IPOPT_TESTS) \ @@ -363,10 +364,10 @@ multi_thread \ multi_thread/test_multi \ print_for \ - test_more + test_more -test: all - rm -f test.log +test: all + rm -f test.log touch test.log echo "#! /bin/sh -e" > test.sh for dir in $(test_directory_list) ; do ( \ @@ -385,10 +386,11 @@ rm $(distdir)/doc/error.wrd rm $(distdir)/bin/gpl_license.sh # -if CppAD_DOCUMENTATION doc_postfix = $(DESTDIR)$(datadir)/doc/$(postfix_dir) doc_package = $(DESTDIR)$(datadir)/doc/$(postfix_dir)/$(PACKAGE)-$(VERSION) +inc_postfix = $(DESTDIR)/$(myincludedir) install-data-hook: +if CppAD_DOCUMENTATION if [ ! -e $(doc_postfix) ] ; then mkdir -p $(doc_postfix) ; fi if [ -e $(doc_package) ] ; then rm -rf $(doc_package) ; fi cp -a $(top_srcdir)/doc $(doc_package) @@ -396,6 +398,12 @@ chmod -R u+w $(doc_package) chmod -R a+r $(doc_package) endif +if CppAD_DEPRECATED + cp -a $(top_srcdir)/cppad/deprecated/* $(inc_postfix)/cppad + chmod -R a-w $(inc_postfix)/cppad + chmod -R u+w $(inc_postfix)/cppad + chmod -R a+r $(inc_postfix)/cppad +endif # pkgconfigdir = $(datadir)/pkgconfig pkgconfig_DATA = pkgconfig/cppad.pc diff -Nru cppad-2015.00.00.9/makefile.in cppad-2016.00.00.1/makefile.in --- cppad-2015.00.00.9/makefile.in 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/makefile.in 2016-02-09 08:31:59.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -16,7 +16,17 @@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -80,19 +90,13 @@ build_triplet = @build@ host_triplet = @host@ subdir = . -DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ - $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/configure $(am__configure_deps) \ - $(top_srcdir)/cppad/configure.hpp.in \ - $(top_srcdir)/pkgconfig/cppad.pc.in \ - $(top_srcdir)/pkgconfig/cppad-uninstalled.pc.in \ - $(am__myinclude_HEADERS_DIST) $(nobase_myinclude_HEADERS) \ - COPYING ar-lib config.guess config.sub depcomp install-sh \ - missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(am__myinclude_HEADERS_DIST) \ + $(nobase_myinclude_HEADERS) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d @@ -192,6 +196,12 @@ speed/profile speed/sacado example example/atomic compare_c \ introduction/get_started introduction/exp_apx print_for \ multi_thread multi_thread/test_multi test_more +am__DIST_COMMON = $(srcdir)/makefile.in \ + $(top_srcdir)/cppad/configure.hpp.in \ + $(top_srcdir)/pkgconfig/cppad-uninstalled.pc.in \ + $(top_srcdir)/pkgconfig/cppad.pc.in AUTHORS COPYING ChangeLog \ + INSTALL NEWS README ar-lib compile config.guess config.sub \ + depcomp install-sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -334,26 +344,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -392,12 +405,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -422,7 +435,7 @@ @CppAD_SACADO_TRUE@SPEED_SACADO_TESTS = speed/sacado @CppAD_IPOPT_FALSE@IPOPT_TESTS = # -# Did user specify a value for IPOPT_DIR in configure command line +# Did user specify a value for IPOPT_DIR in configure command line @CppAD_IPOPT_TRUE@IPOPT_TESTS = \ @CppAD_IPOPT_TRUE@ example/ipopt_solve \ @CppAD_IPOPT_TRUE@ cppad_ipopt/example \ @@ -433,7 +446,7 @@ # @CppAD_IPOPT_TRUE@IPOPT_DIRS = \ @CppAD_IPOPT_TRUE@ cppad_ipopt/src \ -@CppAD_IPOPT_TRUE@ $(IPOPT_TESTS) +@CppAD_IPOPT_TRUE@ $(IPOPT_TESTS) @CppAD_IPOPT_FALSE@IPOPT_HEADER = # @@ -464,39 +477,19 @@ # nobase_myinclude_HEADERS = \ - cppad/CheckNumericType.h \ - cppad/CheckSimpleVector.h \ - cppad/CppAD.h \ - cppad/CppAD_vector.h \ - cppad/ErrorHandler.h \ - cppad/LuFactor.h \ - cppad/LuInvert.h \ - cppad/LuSolve.h \ - cppad/NearEqual.h \ - cppad/OdeErrControl.h \ - cppad/OdeGearControl.h \ - cppad/OdeGear.h \ - cppad/Poly.h \ - cppad/PowInt.h \ - cppad/RombergMul.h \ - cppad/RombergOne.h \ - cppad/Rosen34.h \ - cppad/Runge45.h \ - cppad/SpeedTest.h \ - cppad/TrackNewDel.h \ - \ + cppad/utility.hpp \ cppad/base_require.hpp \ - cppad/check_numeric_type.hpp \ - cppad/check_simple_vector.hpp \ + cppad/utility/check_numeric_type.hpp \ + cppad/utility/check_simple_vector.hpp \ cppad/configure.hpp \ cppad/cppad.hpp \ - cppad/elapsed_seconds.hpp \ + cppad/utility/elapsed_seconds.hpp \ cppad/example/base_adolc.hpp \ cppad/example/cppad_eigen.hpp \ cppad/example/eigen_plugin.hpp \ cppad/example/matrix_mul.hpp \ - cppad/error_handler.hpp \ - cppad/index_sort.hpp \ + cppad/utility/error_handler.hpp \ + cppad/utility/index_sort.hpp \ cppad/ipopt/solve.hpp \ cppad/ipopt/solve_callback.hpp \ cppad/ipopt/solve_result.hpp \ @@ -504,6 +497,8 @@ cppad/local/abs.hpp \ cppad/local/abs_op.hpp \ cppad/local/acos_op.hpp \ + cppad/local/acosh.hpp \ + cppad/local/acosh_op.hpp \ cppad/local/ad_assign.hpp \ cppad/local/ad_binary.hpp \ cppad/local/ad_ctor.hpp \ @@ -514,22 +509,33 @@ cppad/local/ad_fun.hpp \ cppad/local/ad.hpp \ cppad/local/ad_tape.hpp \ + cppad/local/ad_to_string.hpp \ cppad/local/ad_valued.hpp \ cppad/local/arithmetic.hpp \ cppad/local/asin_op.hpp \ + cppad/local/asinh.hpp \ + cppad/local/asinh_op.hpp \ cppad/local/atan2.hpp \ cppad/local/atan_op.hpp \ + cppad/local/atanh.hpp \ + cppad/local/atanh_op.hpp \ cppad/local/atomic_base.hpp \ + cppad/local/azmul.hpp \ cppad/local/base_complex.hpp \ cppad/local/base_cond_exp.hpp \ cppad/local/base_double.hpp \ cppad/local/base_float.hpp \ + cppad/local/base_limits.hpp \ cppad/local/base_std_math.hpp \ + cppad/local/base_to_string.hpp \ cppad/local/bender_quad.hpp \ cppad/local/bool_fun.hpp \ cppad/local/bool_valued.hpp \ cppad/local/capacity_order.hpp \ cppad/local/checkpoint.hpp \ + cppad/local/check_for_nan.hpp \ + cppad/local/color_general.hpp \ + cppad/local/color_symmetric.hpp \ cppad/local/compare.hpp \ cppad/local/comp_op.hpp \ cppad/local/compute_assign.hpp \ @@ -556,6 +562,8 @@ cppad/local/erf.hpp \ cppad/local/erf_op.hpp \ cppad/local/exp_op.hpp \ + cppad/local/expm1.hpp \ + cppad/local/expm1_op.hpp \ cppad/local/for_jac_sweep.hpp \ cppad/local/for_one.hpp \ cppad/local/for_sparse_jac.hpp \ @@ -573,16 +581,18 @@ cppad/local/independent.hpp \ cppad/local/integer.hpp \ cppad/local/jacobian.hpp \ - cppad/local/limits.hpp \ cppad/local/load_op.hpp \ cppad/local/log_op.hpp \ + cppad/local/log1p.hpp \ + cppad/local/log1p_op.hpp \ cppad/local/lu_ratio.hpp \ - cppad/local/math_other.hpp \ cppad/local/mul_eq.hpp \ cppad/local/mul.hpp \ cppad/local/mul_op.hpp \ cppad/local/near_equal_ext.hpp \ + cppad/local/numeric_limits.hpp \ cppad/local/num_skip.hpp \ + cppad/local/old_atomic.hpp \ cppad/local/omp_max_thread.hpp \ cppad/local/op_code.hpp \ cppad/local/op.hpp \ @@ -608,6 +618,7 @@ cppad/local/rev_sparse_hes.hpp \ cppad/local/rev_sparse_jac.hpp \ cppad/local/rev_two.hpp \ + cppad/local/set_get_in_parallel.hpp \ cppad/local/sign.hpp \ cppad/local/sign_op.hpp \ cppad/local/sin_op.hpp \ @@ -615,7 +626,6 @@ cppad/local/sparse_binary_op.hpp \ cppad/local/sparse_hessian.hpp \ cppad/local/sparse.hpp \ - cppad/local/color_general.hpp \ cppad/local/sparse_jacobian.hpp \ cppad/local/sparse_list.hpp \ cppad/local/sparse_pack.hpp \ @@ -623,7 +633,8 @@ cppad/local/sparse_set.hpp \ cppad/local/sparse_unary_op.hpp \ cppad/local/sqrt_op.hpp \ - cppad/local/std_math_ad.hpp \ + cppad/local/standard_math.hpp \ + cppad/local/std_math_98.hpp \ cppad/local/std_set.hpp \ cppad/local/store_op.hpp \ cppad/local/sub_eq.hpp \ @@ -638,26 +649,28 @@ cppad/local/unary_plus.hpp \ cppad/local/undef.hpp \ cppad/local/user_ad.hpp \ - cppad/local/old_atomic.hpp \ cppad/local/value.hpp \ cppad/local/var2par.hpp \ cppad/local/vec_ad.hpp \ - cppad/lu_factor.hpp \ - cppad/lu_invert.hpp \ - cppad/lu_solve.hpp \ - cppad/memory_leak.hpp \ - cppad/nan.hpp \ - cppad/near_equal.hpp \ - cppad/ode_err_control.hpp \ - cppad/ode_gear_control.hpp \ - cppad/ode_gear.hpp \ - cppad/omp_alloc.hpp \ - cppad/poly.hpp \ - cppad/pow_int.hpp \ - cppad/romberg_mul.hpp \ - cppad/romberg_one.hpp \ - cppad/rosen_34.hpp \ - cppad/runge_45.hpp \ + cppad/local/zdouble.hpp \ + cppad/local/zmul_op.hpp \ + cppad/utility/lu_factor.hpp \ + cppad/utility/lu_invert.hpp \ + cppad/utility/lu_solve.hpp \ + cppad/utility/memory_leak.hpp \ + cppad/utility/nan.hpp \ + cppad/utility/near_equal.hpp \ + cppad/utility/ode_err_control.hpp \ + cppad/utility/ode_gear_control.hpp \ + cppad/utility/ode_gear.hpp \ + cppad/utility/omp_alloc.hpp \ + cppad/utility/poly.hpp \ + cppad/utility/pow_int.hpp \ + cppad/utility/romberg_mul.hpp \ + cppad/utility/romberg_one.hpp \ + cppad/utility/rosen_34.hpp \ + cppad/utility/runge_45.hpp \ + cppad/utility/to_string.hpp \ cppad/speed/det_33.hpp \ cppad/speed/det_by_lu.hpp \ cppad/speed/det_by_minor.hpp \ @@ -667,14 +680,14 @@ cppad/speed/ode_evaluate.hpp \ cppad/speed/sparse_hes_fun.hpp \ cppad/speed/sparse_jac_fun.hpp \ - cppad/speed_test.hpp \ + cppad/utility/speed_test.hpp \ cppad/speed/uniform_01.hpp \ - cppad/thread_alloc.hpp \ - cppad/time_test.hpp \ - cppad/track_new_del.hpp \ - cppad/vector.hpp + cppad/utility/thread_alloc.hpp \ + cppad/utility/time_test.hpp \ + cppad/utility/track_new_del.hpp \ + cppad/utility/vector.hpp -# End nobase_myinclude_HEADERS (check_makefile.sh uses this comment) +# End nobase_myinclude_HEADERS (check_makefile.sh uses this comment) # --------------------------------------------------------------- # # No objects or executables are required to install CppAD. @@ -690,7 +703,7 @@ print_for \ multi_thread \ multi_thread/test_multi \ - test_more + test_more # # note that bin/gpl_license.sh is deleted by dist-hook @@ -731,7 +744,7 @@ multi_thread/CMakeLists.txt \ multi_thread/openmp/CMakeLists.txt \ multi_thread/pthread/CMakeLists.txt \ - print_for/CMakeLists.txt + print_for/CMakeLists.txt test_directory_list = \ $(IPOPT_TESTS) \ @@ -744,11 +757,12 @@ multi_thread \ multi_thread/test_multi \ print_for \ - test_more + test_more # -@CppAD_DOCUMENTATION_TRUE@doc_postfix = $(DESTDIR)$(datadir)/doc/$(postfix_dir) -@CppAD_DOCUMENTATION_TRUE@doc_package = $(DESTDIR)$(datadir)/doc/$(postfix_dir)/$(PACKAGE)-$(VERSION) +doc_postfix = $(DESTDIR)$(datadir)/doc/$(postfix_dir) +doc_package = $(DESTDIR)$(datadir)/doc/$(postfix_dir)/$(PACKAGE)-$(VERSION) +inc_postfix = $(DESTDIR)/$(myincludedir) # pkgconfigdir = $(datadir)/pkgconfig pkgconfig_DATA = pkgconfig/cppad.pc @@ -771,7 +785,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -1053,10 +1066,16 @@ $(am__post_remove_distdir) dist-tarZ: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) @@ -1091,16 +1110,17 @@ esac chmod -R a-w $(distdir) chmod u+w $(distdir) - mkdir $(distdir)/_build $(distdir)/_inst + mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ + --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ @@ -1194,7 +1214,6 @@ @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -@CppAD_DOCUMENTATION_FALSE@install-data-hook: clean: clean-recursive clean-am: clean-generic mostlyclean-am @@ -1289,12 +1308,15 @@ uninstall-myincludeHEADERS uninstall-nobase_myincludeHEADERS \ uninstall-pkgconfigDATA +.PRECIOUS: makefile + $(top_srcdir)/cppad/configure.hpp: cppad/configure.hpp - cp cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp + cp cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp +@CppAD_HAVE_AR_FALSE@ SPEED_TESTS = @CppAD_HAVE_AR_FALSE@ SPEED_DIRS = -test: all - rm -f test.log +test: all + rm -f test.log touch test.log echo "#! /bin/sh -e" > test.sh for dir in $(test_directory_list) ; do ( \ @@ -1312,13 +1334,17 @@ rm -rf `find . -name .svn` rm $(distdir)/doc/error.wrd rm $(distdir)/bin/gpl_license.sh -@CppAD_DOCUMENTATION_TRUE@install-data-hook: +install-data-hook: @CppAD_DOCUMENTATION_TRUE@ if [ ! -e $(doc_postfix) ] ; then mkdir -p $(doc_postfix) ; fi @CppAD_DOCUMENTATION_TRUE@ if [ -e $(doc_package) ] ; then rm -rf $(doc_package) ; fi @CppAD_DOCUMENTATION_TRUE@ cp -a $(top_srcdir)/doc $(doc_package) @CppAD_DOCUMENTATION_TRUE@ chmod -R a-w $(doc_package) @CppAD_DOCUMENTATION_TRUE@ chmod -R u+w $(doc_package) @CppAD_DOCUMENTATION_TRUE@ chmod -R a+r $(doc_package) +@CppAD_DEPRECATED_TRUE@ cp -a $(top_srcdir)/cppad/deprecated/* $(inc_postfix)/cppad +@CppAD_DEPRECATED_TRUE@ chmod -R a-w $(inc_postfix)/cppad +@CppAD_DEPRECATED_TRUE@ chmod -R u+w $(inc_postfix)/cppad +@CppAD_DEPRECATED_TRUE@ chmod -R a+r $(inc_postfix)/cppad # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru cppad-2015.00.00.9/missing cppad-2016.00.00.1/missing --- cppad-2015.00.00.9/missing 2014-11-27 17:04:26.000000000 +0000 +++ cppad-2016.00.00.1/missing 2015-08-09 16:12:42.000000000 +0000 @@ -1,9 +1,9 @@ #! /bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2012-06-26.16; # UTC +scriptversion=2013-10-28.13; # UTC -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify @@ -160,7 +160,7 @@ ;; autom4te*) echo "You might have modified some maintainer files that require" - echo "the 'automa4te' program to be rebuilt." + echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) diff -Nru cppad-2015.00.00.9/multi_thread/bthread/a11c_bthread.cpp cppad-2016.00.00.1/multi_thread/bthread/a11c_bthread.cpp --- cppad-2015.00.00.9/multi_thread/bthread/a11c_bthread.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/bthread/a11c_bthread.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: a11c_bthread.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: a11c_bthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,12 +18,9 @@ CppAD const $$ -$index boost thread, example A.1.1c$$ -$index example, boost thread A.1.1c$$ -$index A.1.1c, boost thread example$$ -$index thread, boost example$$ $section A Simple Boost Thread Example and Test$$ +$mindex A.1.1c$$ $head Purpose$$ This example just demonstrates Boost threads and does not use CppAD at all. @@ -60,11 +57,11 @@ { int i; // for some reason this function is missing on some systems // assert( bthread_is_multithreaded_np() > 0 ); - for(i = 1; i < n; i++) + for(i = 1; i < n; i++) b[i] = (a[i] + a[i-1]) / 2.0; return; } - // End of Example A.1.1.1c of OpenMP 2.5 standard document + // End of Example A.1.1.1c of OpenMP 2.5 standard document void operator()() { a1(n_, a_, b_); } }; @@ -95,13 +92,13 @@ float* b_tmp = b; worker[0].setup(n_tmp, a_tmp, b_tmp); for(j = 1; j < number_threads; j++) - { n_tmp = n + 1; + { n_tmp = n + 1; a_tmp = a_tmp + n - 1; b_tmp = b_tmp + n - 1; if( j == (number_threads - 1) ) n_tmp = n_total - j * n + 1; - worker[j].setup(n_tmp, a_tmp, b_tmp); + worker[j].setup(n_tmp, a_tmp, b_tmp); // create this thread bthread[j] = new boost::thread(worker[j]); @@ -112,14 +109,14 @@ // wait for other threads to finish for(j = 1; j < number_threads; j++) - { bthread[j]->join(); + { bthread[j]->join(); delete bthread[j]; } // check the result float eps = 100. * std::numeric_limits::epsilon(); for(i = 1; i < n ; i++) - ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; + ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; delete [] a; delete [] b; diff -Nru cppad-2015.00.00.9/multi_thread/bthread/CMakeLists.txt cppad-2016.00.00.1/multi_thread/bthread/CMakeLists.txt --- cppad-2015.00.00.9/multi_thread/bthread/CMakeLists.txt 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/bthread/CMakeLists.txt 2016-02-09 08:31:54.000000000 +0000 @@ -1,18 +1,18 @@ -# $Id: CMakeLists.txt 3114 2014-02-22 16:20:39Z bradbell $ +# $Id: CMakeLists.txt 3724 2015-09-21 05:04:18Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the multi_thread/bthread directory tests +# Build the multi_thread/bthread directory tests # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) @@ -22,7 +22,8 @@ # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) -ADD_EXECUTABLE(multi_thread_bthread EXCLUDE_FROM_ALL ../thread_test.cpp +ADD_EXECUTABLE(multi_thread_bthread EXCLUDE_FROM_ALL ../thread_test.cpp + ../../speed/src/microsoft_timer.cpp ../multi_newton_time.cpp ../multi_newton.cpp ../multi_newton_work.cpp @@ -46,7 +47,7 @@ TARGET_LINK_LIBRARIES(multi_thread_bthread ${bthread_lib}) # Add the check_multi_thread_bthread target -ADD_CUSTOM_TARGET(check_multi_thread_bthread - multi_thread_bthread simple_ad +ADD_CUSTOM_TARGET(check_multi_thread_bthread + multi_thread_bthread simple_ad DEPENDS multi_thread_bthread ) diff -Nru cppad-2015.00.00.9/multi_thread/bthread/simple_ad_bthread.cpp cppad-2016.00.00.1/multi_thread/bthread/simple_ad_bthread.cpp --- cppad-2015.00.00.9/multi_thread/bthread/simple_ad_bthread.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/bthread/simple_ad_bthread.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: simple_ad_bthread.cpp 2506 2012-10-24 19:36:49Z bradbell $ +// $Id: simple_ad_bthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,14 +18,11 @@ $$ $section A Simple Boost Threading AD: Example and Test$$ +$mindex thread AD$$ -$index boost, simple thread AD$$ -$index AD, simple boost thread$$ -$index simple, boost thread AD$$ -$index thread, simple boost AD$$ $head Purpose$$ -This example demonstrates how CppAD can be used in a +This example demonstrates how CppAD can be used in a boost multi-threading environment. $head Source Code$$ @@ -144,13 +141,13 @@ // inform CppAD that we now may be in parallel execution mode sequential_execution_ = false; - + // This master thread is already running, we need to create // num_threads - 1 more threads thread_all_[0].bthread = CPPAD_NULL; for(thread_num = 1; thread_num < num_threads; thread_num++) { // Create the thread with thread number equal to thread_num - thread_all_[thread_num].bthread = + thread_all_[thread_num].bthread = new boost::thread(run_one_worker, thread_num); } @@ -159,7 +156,7 @@ ok &= thread_num == 0; ok &= worker(thread_num, thread_all_[thread_num].info); - // now wait for the other threads to finish + // now wait for the other threads to finish for(thread_num = 1; thread_num < num_threads; thread_num++) { thread_all_[thread_num].bthread->join(); delete thread_all_[thread_num].bthread; @@ -181,7 +178,7 @@ return ok; } // ===================================================================== - // End of General purpose code + // End of General purpose code // ===================================================================== // function that does the work for one thread bool worker(size_t thread_num, problem_specific* info) @@ -192,9 +189,9 @@ ax[0] = info->x; Independent(ax); ay[0] = sqrt( ax[0] * ax[0] ); - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); - // Check function value corresponds to the identity + // Check function value corresponds to the identity double eps = 10. * CppAD::numeric_limits::epsilon(); ok &= CppAD::NearEqual(ay[0], ax[0], eps, eps); @@ -215,8 +212,8 @@ // (using thread_alloc in sequential mode) size_t thread_num; for(thread_num = 0; thread_num < num_threads; thread_num++) - { ok &= thread_alloc::inuse(thread_num) == 0; - ok &= thread_alloc::available(thread_num) == 0; + { ok &= thread_alloc::inuse(thread_num) == 0; + ok &= thread_alloc::available(thread_num) == 0; } // initialize info_all @@ -239,9 +236,9 @@ void* v_ptr = static_cast( info_all[thread_num] ); thread_alloc::return_memory( v_ptr ); // check that there is no longer any memory inuse by this thread - ok &= thread_alloc::inuse(thread_num) == 0; + ok &= thread_alloc::inuse(thread_num) == 0; // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); + thread_alloc::free_available(thread_num); } return ok; diff -Nru cppad-2015.00.00.9/multi_thread/bthread/team_bthread.cpp cppad-2016.00.00.1/multi_thread/bthread/team_bthread.cpp --- cppad-2015.00.00.9/multi_thread/bthread/team_bthread.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/bthread/team_bthread.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,25 +1,23 @@ -// $Id: team_bthread.cpp 2754 2013-02-21 04:55:55Z bradbell $ +// $Id: team_bthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -/* +/* $begin team_bthread.cpp$$ $spell bthread $$ -$index bthread, AD team$$ -$index AD, bthread team$$ -$index team, AD bthread$$ $section Boost Thread Implementation of a Team of AD Threads$$ +$mindex bthread$$ See $cref team_thread.hpp$$ for this routines specifications. $code @@ -38,9 +36,9 @@ using CppAD::thread_alloc; // number of threads in the team - size_t num_threads_ = 1; + size_t num_threads_ = 1; - // no need to cleanup up thread specific data + // no need to cleanup up thread specific data void cleanup(size_t*) { return; } @@ -160,9 +158,9 @@ num_threads_ = num_threads; // initialize two barriers, one for work done, one for new job ready - wait_for_work_ = new boost::barrier(num_threads); - wait_for_job_ = new boost::barrier(num_threads); - + wait_for_work_ = new boost::barrier(num_threads); + wait_for_job_ = new boost::barrier(num_threads); + // initial job for the threads thread_job_ = init_enum; if( num_threads > 1 ) @@ -172,7 +170,7 @@ // num_threads - 1 more threads for(thread_num = 1; thread_num < num_threads; thread_num++) { // Create the thread with thread number equal to thread_num - thread_all_[thread_num].bthread = + thread_all_[thread_num].bthread = new boost::thread(thread_work, thread_num); } @@ -197,7 +195,7 @@ // set the new job that other threads are waiting for thread_job_ = work_enum; - // Enter parallel exectuion when master thread calls wait_for_job_ + // Enter parallel exectuion when master thread calls wait_for_job_ if( num_threads_ > 1 ) sequential_execution_ = false; wait_for_job_->wait(); @@ -228,7 +226,7 @@ // set the new job that other threads are waiting for thread_job_ = join_enum; - // enter parallel exectuion soon as master thread completes wait_for_job_ + // enter parallel exectuion soon as master thread completes wait_for_job_ if( num_threads_ > 1 ) sequential_execution_ = false; wait_for_job_->wait(); @@ -241,7 +239,7 @@ delete thread_all_[thread_num].bthread; thread_all_[thread_num].bthread = CPPAD_NULL; } - // now we are down to just the master thread (thread zero) + // now we are down to just the master thread (thread zero) sequential_execution_ = true; // destroy wait_for_work_ diff -Nru cppad-2015.00.00.9/multi_thread/CMakeLists.txt cppad-2016.00.00.1/multi_thread/CMakeLists.txt --- cppad-2015.00.00.9/multi_thread/CMakeLists.txt 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/CMakeLists.txt 2016-02-09 08:31:53.000000000 +0000 @@ -1,4 +1,4 @@ -# $Id: CMakeLists.txt 3120 2014-02-25 14:04:02Z bradbell $ +# $Id: CMakeLists.txt 3632 2015-02-03 13:57:08Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # @@ -48,38 +48,47 @@ ENDIF ( pthread_ok ) ENDIF ( pthread_lib_path ) -# If boost threads found, set -# bthread_lib, bthread_lib_path and process its subdir -# -# FIND_PACKAGE(Boost) was done by ../CMakeLists.txt +# IF we find a boost multi-threadding library, define the corresponding +# bthread_lib, bthread_lib_path, and process the bthread subdirectory. IF ( Boost_FOUND ) - # - SET(CMAKE_REQUIRED_INCLUDES "${boost_prefix}/${cmake_install_includdir}") - # - SET(bthread_lib "boost_thread" ) - SET(CMAKE_REQUIRED_LIBRARIES "${bthread_lib}" ) - # - SET(bthread_lib_path "${boost_prefix}/${cppad_install_libdir}" ) - SET(CMAKE_REQUIRED_FLAGS "-L${bthread_lib_path}" ) - # - # CHECK_CXX_SOURCE_RUNS(source variable) - SET(source " + SET(bthread_lib NOTFOUND) + FOREACH(idir ${cmake_install_includedirs}) + FOREACH(ldir ${cmake_install_libdirs}) + FOREACH(lname boost_thread-mt boost_thread ) + # abort this search when find a match + IF( NOT bthread_lib ) + # + SET(CMAKE_REQUIRED_INCLUDES "${boost_prefix}/${idir}") + SET(CMAKE_REQUIRED_LIBRARIES "${lname}" ) + SET(lpath "${boost_prefix}/${ldir}" ) + SET(CMAKE_REQUIRED_FLAGS "-L${lpath}" ) + # CHECK_CXX_SOURCE_RUNS(source variable) + SET(source " # include int main(void) { boost::barrier wait(1); return 0; -}" ) - CHECK_CXX_SOURCE_RUNS("${source}" bthread_ok) +}" ) + SET(flag ${idir}_${ldir}_${lname}_ok ) + CHECK_CXX_SOURCE_RUNS("${source}" ${flag} ) + IF ( ${flag} ) + SET(bthread_lib ${lname} ) + SET(bthread_lib_path ${lpath} ) + ENDIF ( ${flag} ) + ENDIF( NOT bthread_lib ) + ENDFOREACH(lname boost_thread boost_thread-mt) + ENDFOREACH(ldir ${cmake_install_liddirs}) + ENDFOREACH(idir ${cmake_install_includedirs}) # - IF ( NOT bthread_ok ) - SET(bthread_lib "boost_thread-mt" ) - SET(CMAKE_REQUIRED_LIBRARIES "${bthread_lib}" ) - CHECK_CXX_SOURCE_RUNS("${source}" bthread_mt_ok) - ENDIF ( NOT bthread_ok ) - IF ( bthread_ok OR bthread_mt_ok ) + IF( bthread_lib ) ADD_SUBDIRECTORY(bthread) add_to_list(check_depends check_multi_thread_bthread) - ENDIF ( bthread_ok OR bthread_mt_ok ) + MESSAGE(STATUS + "boost multi-threading library = ${bthread_lib_path}/${bthread_lib}" + ) + ELSE( bthread_lib ) + MESSAGE(STATUS "Could not find boost multi-threading library") + ENDIF( bthread_lib ) ENDIF ( Boost_FOUND ) # check_multi_thread diff -Nru cppad-2015.00.00.9/multi_thread/harmonic.cpp cppad-2016.00.00.1/multi_thread/harmonic.cpp --- cppad-2015.00.00.9/multi_thread/harmonic.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/harmonic.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: harmonic.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: harmonic.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,19 +17,16 @@ num bool $$ -$index harmonic$$ -$index multi_thread, harmonic$$ -$index harmonic, multi_thread$$ -$index thread, multi harmonic$$ $section Multi-Threaded Implementation of Summation of 1/i$$ +$mindex harmonic multi_thread$$ $head Syntax$$ $icode%ok% = harmonic(%sum%, %num_sum%, %num_threads%)%$$ $head Summation$$ -Multi-threaded computation of the summation that defines the harmonic series +Multi-threaded computation of the summation that defines the harmonic series $latex \[ s = 1 + 1/2 + 1/3 + ... + 1/n \] $$ diff -Nru cppad-2015.00.00.9/multi_thread/harmonic.hpp cppad-2016.00.00.1/multi_thread/harmonic.hpp --- cppad-2015.00.00.9/multi_thread/harmonic.hpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/harmonic.hpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: harmonic.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_HARMONIC_INCLUDED -# define CPPAD_HARMONIC_INCLUDED +// $Id: harmonic.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_HARMONIC_HPP +# define CPPAD_HARMONIC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/multi_thread/harmonic_time.cpp cppad-2016.00.00.1/multi_thread/harmonic_time.cpp --- cppad-2015.00.00.9/multi_thread/harmonic_time.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/harmonic_time.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: harmonic_time.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: harmonic_time.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,21 +23,17 @@ CppAD parallelize $$ -$index harmonic_time$$ -$index summation, multi_thread speed$$ -$index multi_thread, summation speed$$ -$index speed, multi_thread summation$$ -$index time, multi_thread summation$$ $section Timing Test of Multi-Threaded Summation of 1/i$$ +$mindex harmonic_time multi_thread speed$$ $head Syntax$$ $icode%ok% = harmonic_time(%time_out%, %num_threads%, %mega_sum%)%$$ $head Purpose$$ -Runs a correctness and timing test for a multi-threaded -computation of the summation that defines the harmonic series +Runs a correctness and timing test for a multi-threaded +computation of the summation that defines the harmonic series $latex \[ 1 + 1/2 + 1/3 + ... + 1/n \] $$ @@ -60,13 +56,13 @@ %$$ The input value of the argument does not matter. Upon return it is the number of wall clock seconds required for -to compute the +to compute the $cref/summation/harmonic_time.cpp/Purpose/$$. $head test_time$$ Is the minimum amount of wall clock time that the test should take. The number of repeats for the test will be increased until this time -is reached. +is reached. The reported $icode time_out$$ is the total wall clock time divided by the number of repeats. @@ -79,12 +75,12 @@ If it is zero, the test is run without the multi-threading environment and $codei% 1 == CppAD::thread_alloc::num_threads() -%$$ +%$$ when $code harmonic_time$$ is called. If it is non-zero, the test is run with the multi-threading and $codei% %num_threads% = CppAD::thread_alloc::num_threads() -%$$ +%$$ when $code harmonic_time$$ is called. $head mega_sum$$ @@ -93,9 +89,9 @@ size_t& %mega_sum% %$$ and is greater than zero. -The value $latex n$$ in the +The value $latex n$$ in the $cref/summation/harmonic_time.cpp/Purpose/$$. -is equal to $latex 10^6$$ times $icode mega_sum$$. +is equal to $latex 10^6$$ times $icode mega_sum$$. $head Source$$ $code @@ -111,10 +107,11 @@ # include # include # include +# include // Note there is no mention of parallel mode in the documentation for // speed_test (so it is safe to use without special consideration). -# include +# include # include "harmonic.hpp" namespace { // empty namespace @@ -134,7 +131,7 @@ exit(1); } size_t num_sum = mega_sum_ * 1000000; - bool ok = harmonic(sum_, num_sum, num_threads_); + bool ok = harmonic(sum_, num_sum, num_threads_); if( ! ok ) { std::cerr << "harmonic: error" << std::endl; exit(1); @@ -173,7 +170,7 @@ size_t i = mega_sum_ * 1000000; double check = 0.; while(i) - check += 1. / double(i--); + check += 1. / double(i--); ok &= std::fabs(sum_ - check) <= eps; return ok; diff -Nru cppad-2015.00.00.9/multi_thread/harmonic_time.hpp cppad-2016.00.00.1/multi_thread/harmonic_time.hpp --- cppad-2015.00.00.9/multi_thread/harmonic_time.hpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/harmonic_time.hpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: harmonic_time.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_HARMONIC_TIME_INCLUDED -# define CPPAD_HARMONIC_TIME_INCLUDED +// $Id: harmonic_time.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_HARMONIC_TIME_HPP +# define CPPAD_HARMONIC_TIME_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/multi_thread/harmonic_work.cpp cppad-2016.00.00.1/multi_thread/harmonic_work.cpp --- cppad-2015.00.00.9/multi_thread/harmonic_work.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/harmonic_work.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: harmonic_work.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: harmonic_work.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,16 +15,10 @@ inv num $$ -$index harmonic_work$$ -$section Multi-threading Sum of 1/i Utility Routines$$ +$section Multi-threading Sum of 1/i Utility Routines$$ +$mindex harmonic_work setup worker combine$$ -$index harmonic_setup$$ -$index harmonic_worker$$ -$index harmonic_combine$$ -$index setup, harmonic$$ -$index worker, harmonic$$ -$index combine, harmonic$$ $head Syntax$$ @@ -66,7 +60,7 @@ $head harmonic_worker$$ Calling this function does the computation for one thread. Following a call to $code harmonic_setup$$, -this function should be called by each of the $icode num_threads$$ threads. +this function should be called by each of the $icode num_threads$$ threads. $head harmonic_combine$$ After the $icode num_threads$$ threads have completed their @@ -122,7 +116,7 @@ size_t i = stop; while( i > start ) { i--; - sum += 1. / double(i); + sum += 1. / double(i); } work_all_[thread_num]->sum = sum; @@ -150,7 +144,7 @@ work_all_[0]->start = 1; else { size_t index = (num_sum * thread_num) / num_threads; - work_all_[thread_num-1]->stop = index; + work_all_[thread_num-1]->stop = index; work_all_[thread_num]->start = index; } } @@ -158,7 +152,7 @@ return ok; } // ----------------------------------------------------------------------- -// get the result of the work +// get the result of the work bool harmonic_combine(double& sum) { // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 bool ok = true; @@ -172,7 +166,7 @@ ok &= work_all_[thread_num]->ok; // add this threads contribution to the sum sum += work_all_[thread_num]->sum; - // delete problem specific information + // delete problem specific information void* v_ptr = static_cast( work_all_[thread_num] ); thread_alloc::return_memory( v_ptr ); // check that there is no longer any memory inuse by this thread diff -Nru cppad-2015.00.00.9/multi_thread/harmonic_work.hpp cppad-2016.00.00.1/multi_thread/harmonic_work.hpp --- cppad-2015.00.00.9/multi_thread/harmonic_work.hpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/harmonic_work.hpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: harmonic_work.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_HARMONIC_WORK_INCLUDED -# define CPPAD_HARMONIC_WORK_INCLUDED +// $Id: harmonic_work.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_HARMONIC_WORK_HPP +# define CPPAD_HARMONIC_WORK_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/multi_thread/makefile.am cppad-2016.00.00.1/multi_thread/makefile.am --- cppad-2015.00.00.9/multi_thread/makefile.am 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/makefile.am 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2556 2012-11-10 00:53:00Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -17,7 +17,7 @@ if CppAD_OPENMP OPENMP_TEST = openmp_test else -OPENMP_TEST = +OPENMP_TEST = endif # if CppAD_BTHREAD @@ -28,21 +28,21 @@ endif else # BTHREAD_LIB empty in this case -BTHREAD_TEST = -BOOST_LIB = +BTHREAD_TEST = +BOOST_LIB = endif # if CppAD_PTHREAD PTHREAD_TEST = pthread_test else -PTHREAD_TEST = +PTHREAD_TEST = endif # -check_PROGRAMS = $(OPENMP_TEST) $(BTHREAD_TEST) $(PTHREAD_TEST) +check_PROGRAMS = $(OPENMP_TEST) $(BTHREAD_TEST) $(PTHREAD_TEST) # if CppAD_MS_COMPILER -# AM_CXXFLAGS = -EHsc -g $(CXX_FLAGS) -AM_CXXFLAGS = -EHsc -DNDEBUG -O2 $(CXX_FLAGS) +# AM_CXXFLAGS = -EHsc -g $(CXX_FLAGS) +AM_CXXFLAGS = -EHsc -DNDEBUG -O2 $(CXX_FLAGS) else # AM_CXXFLAGS = -g $(CXX_FLAGS) AM_CXXFLAGS = -DNDEBUG -O2 $(CXX_FLAGS) @@ -68,7 +68,7 @@ team_example.cpp team_example.hpp \ harmonic_time.cpp harmonic_time.hpp \ harmonic.cpp harmonic.hpp \ - harmonic_work.cpp harmonic_work.hpp + harmonic_work.cpp harmonic_work.hpp # bthread_test_SOURCES = \ $(SHARED_SRC) \ @@ -80,13 +80,13 @@ $(SHARED_SRC) \ openmp/team_openmp.cpp \ openmp/a11c_openmp.cpp \ - openmp/simple_ad_openmp.cpp + openmp/simple_ad_openmp.cpp # pthread_test_SOURCES = \ $(SHARED_SRC) \ pthread/team_pthread.cpp \ pthread/a11c_pthread.cpp \ - pthread/simple_ad_pthread.cpp + pthread/simple_ad_pthread.cpp # dist_noinst_SCRIPTS = test.sh # diff -Nru cppad-2015.00.00.9/multi_thread/makefile.in cppad-2016.00.00.1/multi_thread/makefile.in --- cppad-2015.00.00.9/multi_thread/makefile.in 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/makefile.in 2016-02-09 08:31:53.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -80,12 +90,12 @@ host_triplet = @host@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) subdir = multi_thread -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(dist_noinst_SCRIPTS) $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(dist_noinst_SCRIPTS) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -188,6 +198,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -218,12 +229,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -304,26 +315,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -377,8 +391,8 @@ # AM_CXXFLAGS = -g $(CXX_FLAGS) @CppAD_MS_COMPILER_FALSE@AM_CXXFLAGS = -DNDEBUG -O2 $(CXX_FLAGS) # -# AM_CXXFLAGS = -EHsc -g $(CXX_FLAGS) -@CppAD_MS_COMPILER_TRUE@AM_CXXFLAGS = -EHsc -DNDEBUG -O2 $(CXX_FLAGS) +# AM_CXXFLAGS = -EHsc -g $(CXX_FLAGS) +@CppAD_MS_COMPILER_TRUE@AM_CXXFLAGS = -EHsc -DNDEBUG -O2 $(CXX_FLAGS) # AM_CPPFLAGS = \ -I. \ @@ -401,7 +415,7 @@ team_example.cpp team_example.hpp \ harmonic_time.cpp harmonic_time.hpp \ harmonic.cpp harmonic.hpp \ - harmonic_work.cpp harmonic_work.hpp + harmonic_work.cpp harmonic_work.hpp # bthread_test_SOURCES = \ @@ -415,14 +429,14 @@ $(SHARED_SRC) \ openmp/team_openmp.cpp \ openmp/a11c_openmp.cpp \ - openmp/simple_ad_openmp.cpp + openmp/simple_ad_openmp.cpp # pthread_test_SOURCES = \ $(SHARED_SRC) \ pthread/team_pthread.cpp \ pthread/a11c_pthread.cpp \ - pthread/simple_ad_pthread.cpp + pthread/simple_ad_pthread.cpp # dist_noinst_SCRIPTS = test.sh @@ -442,7 +456,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu multi_thread/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu multi_thread/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -762,6 +775,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + # test: check $(srcdir)/test.sh diff -Nru cppad-2015.00.00.9/multi_thread/multi_newton.cpp cppad-2016.00.00.1/multi_thread/multi_newton.cpp --- cppad-2015.00.00.9/multi_thread/multi_newton.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/multi_newton.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: multi_newton.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: multi_newton.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,29 +23,27 @@ df $$ -$index multi_newton, threading$$ -$index thread, multi_newton$$ -$index newton, multi-threading$$ $section A Multi-Threaded Newton's Method$$ +$mindex multi_newton threading thread multi-threading$$ $head Syntax$$ -$icode%ok% = %multi_newton(%xout%, +$icode%ok% = %multi_newton(%xout%, %fun%, %num_sub%, %xlow%, %xup%, %epsilon%, %max_itr%, %num_threads% )%$$ $head Purpose$$ -Multi-threaded determination of the argument values $latex x$$, -in the interval $latex [a, b]$$ (where $latex a < b$$), +Multi-threaded determination of the argument values $latex x$$, +in the interval $latex [a, b]$$ (where $latex a < b$$), such that $latex f(x) = 0$$. $head Method$$ -For $latex i = 0 , \ldots , n$$, +For $latex i = 0 , \ldots , n$$, we define the $th i$$ grid point $latex g_i$$ by $latex \[ g_i = a \frac{n - i}{n} + b \frac{i}{n} \] $$ -For $latex i = 0 , \ldots , n-1$$, +For $latex i = 0 , \ldots , n-1$$, we define the $th i$$ sub-interval of $latex [a, b]$$ by $latex \[ I_i = [ g_i , g_{i+1} ] @@ -69,11 +67,11 @@ %$$ The input size and value of the elements of $icode xout$$ do not matter. Upon return from $code multi_newton$$, -the size of $icode xout$$ is less than or equal +the size of $icode xout$$ is less than or equal the number of sub-intervals $latex n$$ and $latex \[ | f( xout[i] ) | \leq epsilon -\] $$ +\] $$ for each valid index $codei%0% <= %i% < %xout%.size()%$$. Two $latex x$$ solutions are considered equal (and joined as one) if the absolute difference between the solutions is less than @@ -85,14 +83,14 @@ void %fun% (double %x%, double& %f%, double& %df%) %$$ This function must evaluate $latex f(x)$$, -and its derivative $latex f^{(1)} (x)$$, +and its derivative $latex f^{(1)} (x)$$, using the syntax $codei% %fun%(%x%, %f%, %df%) %$$ where the arguments to $icode fun$$ have the prototypes $codei% - double %x% + double %x% double& %f% double& %df% %$$. @@ -158,21 +156,21 @@ --------------------------------------------------------------------------- */ // BEGIN C++ -// general purpose multi-threading interface +// general purpose multi-threading interface # include "team_thread.hpp" // special utilities for the multi_newton problem # include "multi_newton_work.hpp" bool multi_newton( - CppAD::vector &xout , - void fun(double x, double& f, double& df) , - size_t num_sub , - double xlow , - double xup , - double epsilon , + CppAD::vector &xout , + void fun(double x, double& f, double& df) , + size_t num_sub , + double xlow , + double xup , + double epsilon , size_t max_itr , size_t num_threads ) -{ +{ bool ok = true; using CppAD::AD; using CppAD::vector; diff -Nru cppad-2015.00.00.9/multi_thread/multi_newton.hpp cppad-2016.00.00.1/multi_thread/multi_newton.hpp --- cppad-2015.00.00.9/multi_thread/multi_newton.hpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/multi_newton.hpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: multi_newton.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_MULTI_NEWTON_INCLUDED -# define CPPAD_MULTI_NEWTON_INCLUDED +// $Id: multi_newton.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_MULTI_NEWTON_HPP +# define CPPAD_MULTI_NEWTON_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -13,12 +13,12 @@ -------------------------------------------------------------------------- */ extern bool multi_newton( - CppAD::vector &xout , - void fun(double x, double& f, double& df) , - size_t num_sub , - double xlow , - double xup , - double epsilon , + CppAD::vector &xout , + void fun(double x, double& f, double& df) , + size_t num_sub , + double xlow , + double xup , + double epsilon , size_t max_itr , size_t num_threads ); diff -Nru cppad-2015.00.00.9/multi_thread/multi_newton_time.cpp cppad-2016.00.00.1/multi_thread/multi_newton_time.cpp --- cppad-2015.00.00.9/multi_thread/multi_newton_time.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/multi_newton_time.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: multi_newton_time.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: multi_newton_time.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,18 +19,15 @@ alloc openmp $$ -$index multi_newton_time$$. -$index multi_thread, Newton AD speed$$ -$index thread, multi_newton AD speed$$ -$index AD, speed multi_thread Newton$$ -$index newton, multi_thread AD speed$$ +. $section Timing Test of Multi-Threaded Newton Method$$ +$mindex multi_newton_time multi_thread AD speed$$ $head Syntax$$ -$icode%ok% = multi_newton_time(%time_out%, %num_threads%, +$icode%ok% = multi_newton_time(%time_out%, %num_threads%, %num_zero%, %num_sub%, %num_sum%, %use_ad% -)%$$ +)%$$ $head Purpose$$ Runs correctness and timing test for a multi-threaded Newton method. @@ -56,13 +53,13 @@ double& %time_out% %$$ The input value of the argument does not matter. -Upon return it is the number of wall clock seconds required for +Upon return it is the number of wall clock seconds required for the multi-threaded Newton method can compute all the zeros. $head test_time$$ Is the minimum amount of wall clock time that the test should take. The number of repeats for the test will be increased until this time -is reached. +is reached. The reported $icode time_out$$ is the total wall clock time divided by the number of repeats. @@ -71,9 +68,9 @@ $codei% size_t %num_threads% %$$ -It specifies the number of threads that +It specifies the number of threads that are available for this test. -If it is zero, the test is run without multi-threading and +If it is zero, the test is run without multi-threading and $codei% 1 == CppAD::thread_alloc::num_threads() %$$ @@ -91,7 +88,7 @@ %$$ and it must be greater than one. It specifies the actual number of zeros in the test function -$latex \sin(x)$$. +$latex \sin(x)$$. To be specific, $code multi_newton_time$$ will attempt to determine all of the values of $latex x$$ for which $latex \sin(x) = 0 $$ and $latex x$$ is in the interval @@ -129,13 +126,13 @@ %$$ If $icode use_ad$$ is $code true$$, then derivatives will be computed using CppAD. -Note that this derivative computation includes +Note that this derivative computation includes re-taping the function for each value of $latex x$$ (even though re-taping is not necessary). $pre $$ -If $icode use_ad$$ is $code false$$, +If $icode use_ad$$ is $code false$$, derivatives will be computed using a hand coded routine. $head Source$$ @@ -147,15 +144,15 @@ */ // BEGIN C++ # include -# include +# include # include # include # include "multi_newton.hpp" -namespace { // empty namespace +namespace { // empty namespace // values correspond to arguments in previous call to multi_newton_time - size_t num_threads_;// value passed to multi_newton_time + size_t num_threads_;// value passed to multi_newton_time size_t num_zero_; // number of zeros of f(x) in the total interval size_t num_sub_; // number of sub-intervals to split calculation into size_t num_sum_; // larger values make f(x) take longer to calculate @@ -192,7 +189,7 @@ void fun_ad(double x, double& f, double& df) { // use CppAD::vector because it uses fast multi-threaded memory alloc using CppAD::vector; - using CppAD::AD; + using CppAD::AD; vector< AD > X(1), Y(1); X[0] = x; CppAD::Independent(X); @@ -204,10 +201,10 @@ f = Value( Y[0] ); df = dy[0]; return; - } + } // evaulate the function and its derivative - void fun_no(double x, double& f, double& df) + void fun_no(double x, double& f, double& df) { f = f_eval(x); df = df_direct(x); return; @@ -220,13 +217,13 @@ { std::cerr << "multi_newton_time: num_zero == 0" << std::endl; exit(1); } - double pi = 4. * std::atan(1.); + double pi = 4. * std::atan(1.); double xlow = 0.; double xup = (num_zero_ - 1) * pi; - double eps = + double eps = xup * 100. * CppAD::numeric_limits::epsilon(); size_t max_itr = 20; - + bool ok = multi_newton( xout_ , fun_ , @@ -235,7 +232,7 @@ xup , eps , max_itr , - num_threads_ + num_threads_ ); if( ! ok ) { std::cerr << "multi_newton: error" << std::endl; @@ -258,10 +255,10 @@ double test_time , size_t num_threads , size_t num_zero , - size_t num_sub , + size_t num_sub , size_t num_sum , bool use_ad -) +) { bool ok = true; using CppAD::thread_alloc; @@ -283,7 +280,7 @@ time_out = CppAD::time_test(test_repeat, test_time); // Call test_once for a correctness check - double pi = 4. * std::atan(1.); + double pi = 4. * std::atan(1.); double xup = (num_zero_ - 1) * pi; double eps = xup * 100. * CppAD::numeric_limits::epsilon(); ok &= (xout_.size() == num_zero); diff -Nru cppad-2015.00.00.9/multi_thread/multi_newton_time.hpp cppad-2016.00.00.1/multi_thread/multi_newton_time.hpp --- cppad-2015.00.00.9/multi_thread/multi_newton_time.hpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/multi_newton_time.hpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: multi_newton_time.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_MULTI_NEWTON_TIME_INCLUDED -# define CPPAD_MULTI_NEWTON_TIME_INCLUDED +// $Id: multi_newton_time.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_MULTI_NEWTON_TIME_HPP +# define CPPAD_MULTI_NEWTON_TIME_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,9 @@ double test_time , size_t num_thread , size_t num_zero , - size_t num_sub , + size_t num_sub , size_t num_sum , bool use_ad -); +); # endif diff -Nru cppad-2015.00.00.9/multi_thread/multi_newton_work.cpp cppad-2016.00.00.1/multi_thread/multi_newton_work.cpp --- cppad-2015.00.00.9/multi_thread/multi_newton_work.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/multi_newton_work.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: multi_newton_work.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: multi_newton_work.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,9 +14,9 @@ $spell num $$ -$index multi_newton_work$$ -$section Multi-threading Newton Method Utility Routines$$ +$section Multi-threading Newton Method Utility Routines$$ +$mindex multi_newton_work setup worker combine$$ $spell Cpp xlow @@ -27,12 +27,6 @@ df $$ -$index multi_newton_setup$$ -$index multi_newton_worker$$ -$index multi_newton_combine$$ -$index setup, multi_newton$$ -$index worker, multi_newton$$ -$index combine, multi_newton$$ $head Syntax$$ $icode%ok% = multi_newton_setup( @@ -57,14 +51,14 @@ void %fun% (double %x%, double& %f%, double& %df%) %$$ This argument must evaluate the function $latex f(x)$$, -and its derivative $latex f^{(1)} (x)$$, +and its derivative $latex f^{(1)} (x)$$, using the syntax $codei% %fun%(%x%, %f%, %df%) %$$ where the arguments have the prototypes $codei% - double %x% + double %x% double& %f% double& %df% %$$. @@ -76,7 +70,7 @@ $codei% size_t %num_sub% %$$ -It specifies the number of sub-intervals; i.e., $latex n$$ +It specifies the number of sub-intervals; i.e., $latex n$$ in to split the calculation into. $head xlow$$ @@ -120,12 +114,12 @@ $head multi_newton_worker$$ Calling this function does the computation for one thread. Following a call to $code multi_newton_setup$$, -this function should be called by each of the $icode num_threads$$ threads. +this function should be called by each of the $icode num_threads$$ threads. $head multi_newton_combine$$ After the $icode num_threads$$ threads have completed their calls to $code multi_newton_worker$$, -this function call will combine the results and return the final +this function call will combine the results and return the final set of approximate zeros for $latex f(x)$$. $subhead xout$$ @@ -138,8 +132,8 @@ the size of $icode xout$$ is less than or equal $latex n$$ and $codei% | %f%( %xout%[%i%] ) | <= %epsilon% -%$$ -for each valid index $icode i$$. +%$$ +for each valid index $icode i$$. In addition, the elements of $icode xout$$ are in ascending order and $codei% %xout%[i+1] - %xout%[%i%] >= 0.5 * (%xup% - %xlow%) / %num_sub% @@ -185,12 +179,12 @@ // beginning of interval (worker input) double xlow; // end of interval (worker input) - double xup; + double xup; // vector of zero candidates (worker output) // after call to multi_newton_setup: x.size() == 0 // after call to multi_newton_work: x.size() is number of zeros // after call to multi_newton_combine: x.size() == 0 - vector x; + vector x; // false if an error occurs, true otherwise (worker output) bool ok; } work_one_t; @@ -245,7 +239,8 @@ // Newton iterations bool more_itr = true; size_t itr = 0; - double fcur, dfcur; + // initialize these values to avoid MSC C++ warning + double fcur=0.0, dfcur=0.0; while( more_itr ) { fun_(xcur, fcur, dfcur); @@ -253,9 +248,9 @@ if( fabs(fcur) <= epsilon_ ) more_itr = false; if( (xcur == xlow_i ) & (fcur * dfcur > 0.) ) - more_itr = false; + more_itr = false; if( (xcur == xup_i) & (fcur * dfcur < 0.) ) - more_itr = false; + more_itr = false; // next Newton iterate if( more_itr ) @@ -268,13 +263,13 @@ } } if( fabs( fcur ) <= epsilon_ ) - { // check for case where xcur is lower bound for this + { // check for case where xcur is lower bound for this // sub-interval and upper bound for previous sub-interval if( fabs(xcur - xlast) >= sub_length_ ) { x.push_back( xcur ); xlast = xcur; flast = fcur; - } + } else if( fabs(fcur) < fabs(flast) ) { x[ x.size() - 1] = xcur; xlast = xcur; @@ -288,7 +283,7 @@ // setup the work up for multiple threads bool multi_newton_setup( void (fun)(double x, double& f, double& df) , - size_t num_sub , + size_t num_sub , double xlow , double xup , double epsilon , @@ -312,7 +307,7 @@ sub_length_ = (xup - xlow) / double(num_sub); // determine values that are specific to each thread - size_t num_min = num_sub / num_threads; // minimum num_sub + size_t num_min = num_sub / num_threads; // minimum num_sub size_t num_more = num_sub % num_threads; // number that have one more size_t sum_num = 0; // sum with respect to thread of num_sub size_t thread_num, num_sub_thread; @@ -340,7 +335,7 @@ // when thread_num == 0, xlow_thread == xlow double xlow_thread = xlow + sum_num * sub_length_; - // when thread_num == num_threads - 1, xup_thread = xup + // when thread_num == num_threads - 1, xup_thread = xup double xup_thread = xlow + (sum_num + num_sub_thread) * sub_length_; if( thread_num == num_threads - 1 ) xup_thread = xup; @@ -361,7 +356,7 @@ return ok; } // ----------------------------------------------------------------------- -// get the result of the work +// get the result of the work bool multi_newton_combine(CppAD::vector& xout) { // number of threads in the calculation size_t num_threads = std::max(num_threads_, size_t(1)); @@ -371,8 +366,8 @@ bool ok = true; size_t thread_num; - // initialize as more that sub_lenght_ / 2 from any possible solution - double xlast = - sub_length_; + // initialize as more that sub_lenght_ / 2 from any possible solution + double xlast = - sub_length_; for(thread_num = 0; thread_num < num_threads; thread_num++) { vector& x = work_all_[thread_num]->x; @@ -380,7 +375,7 @@ for(i = 0; i < x.size(); i++) { // check for case where this point is lower limit for this // thread and upper limit for previous thread - if( fabs(x[i] - xlast) >= sub_length_ ) + if( fabs(x[i] - xlast) >= sub_length_ ) { xout.push_back( x[i] ); xlast = x[i]; } @@ -404,14 +399,14 @@ # if USE_THREAD_ALLOC_FOR_WORK_ALL // call the destructor for CppAD::vector destructor work_all_[thread_num]->x.~vector(); - // delete the raw memory allocation + // delete the raw memory allocation void* v_ptr = static_cast( work_all_[thread_num] ); thread_alloc::return_memory( v_ptr ); # else delete work_all_[thread_num]; # endif // Note that xout corresponds to memroy that is inuse by master - // (so we can only chech have freed all their memory). + // (so we can only chech have freed all their memory). if( thread_num > 0 ) { // check that there is no longer any memory inuse by this thread ok &= thread_alloc::inuse(thread_num) == 0; diff -Nru cppad-2015.00.00.9/multi_thread/multi_newton_work.hpp cppad-2016.00.00.1/multi_thread/multi_newton_work.hpp --- cppad-2015.00.00.9/multi_thread/multi_newton_work.hpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/multi_newton_work.hpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: multi_newton_work.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_MULTI_NEWTON_WORK_INCLUDED -# define CPPAD_MULTI_NEWTON_WORK_INCLUDED +// $Id: multi_newton_work.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_MULTI_NEWTON_WORK_HPP +# define CPPAD_MULTI_NEWTON_WORK_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,7 +16,7 @@ extern bool multi_newton_setup( void (fun)(double x, double& f, double& df) , - size_t num_sub , + size_t num_sub , double xlow , double xup , double epsilon , diff -Nru cppad-2015.00.00.9/multi_thread/openmp/a11c_openmp.cpp cppad-2016.00.00.1/multi_thread/openmp/a11c_openmp.cpp --- cppad-2015.00.00.9/multi_thread/openmp/a11c_openmp.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/openmp/a11c_openmp.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: a11c_openmp.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: a11c_openmp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,12 +16,9 @@ CppAD const $$ -$index OpenMP, example A.1.1c$$ -$index example, OpenMP A.1.1c$$ -$index A.1.1c, OpenMP example$$ -$index thread, OpenMP example$$ $section A Simple OpenMP Example and Test$$ +$mindex A.1.1c thread$$ $head Purpose$$ This example just demonstrates OpenMP and does not use CppAD at all. @@ -47,7 +44,7 @@ # pragma omp parallel for for(i = 1; i < n; i++) /* i is private by default */ { assert( omp_get_num_threads() == NUMBER_THREADS ); - b[i] = (a[i] + a[i-1]) / 2.0; + b[i] = (a[i] + a[i-1]) / float(2); } } // End of Example A.1.1.1c of OpenMP 2.5 standard document --------------- @@ -64,14 +61,14 @@ int n_thread = NUMBER_THREADS; // number of threads in parallel regions omp_set_dynamic(0); // off dynamic thread adjust - omp_set_num_threads(n_thread); // set the number of threads + omp_set_num_threads(n_thread); // set the number of threads a1(n, a, b); // check the result - float eps = 100. * std::numeric_limits::epsilon(); + float eps = float(100) * std::numeric_limits::epsilon(); for(i = 1; i < n ; i++) - ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; + ok &= std::fabs( (float(2) * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; delete [] a; delete [] b; diff -Nru cppad-2015.00.00.9/multi_thread/openmp/CMakeLists.txt cppad-2016.00.00.1/multi_thread/openmp/CMakeLists.txt --- cppad-2015.00.00.9/multi_thread/openmp/CMakeLists.txt 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/openmp/CMakeLists.txt 2016-02-09 08:31:54.000000000 +0000 @@ -1,18 +1,18 @@ -# $Id: CMakeLists.txt 3114 2014-02-22 16:20:39Z bradbell $ +# $Id: CMakeLists.txt 3724 2015-09-21 05:04:18Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the multi_thread/openmp directory tests +# Build the multi_thread/openmp directory tests # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) @@ -22,11 +22,12 @@ # Cannot find specifications for CMAKE_CXX_FLAGS in version 2.6 documentation # so using ADD_DEFINITIONS instead. ADD_DEFINITIONS( ${OpenMP_CXX_FLAGS} ) - + # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) -ADD_EXECUTABLE(multi_thread_openmp EXCLUDE_FROM_ALL ../thread_test.cpp +ADD_EXECUTABLE(multi_thread_openmp EXCLUDE_FROM_ALL ../thread_test.cpp + ../../speed/src/microsoft_timer.cpp ../multi_newton_time.cpp ../multi_newton.cpp ../multi_newton_work.cpp @@ -46,7 +47,7 @@ SET(CMAKE_EXE_LINKER_FLAGS ${OpenMP_CXX_FLAGS} ) # Add the check_multi_thread_openmp target -ADD_CUSTOM_TARGET(check_multi_thread_openmp +ADD_CUSTOM_TARGET(check_multi_thread_openmp multi_thread_openmp simple_ad DEPENDS multi_thread_openmp ) diff -Nru cppad-2015.00.00.9/multi_thread/openmp/simple_ad_openmp.cpp cppad-2016.00.00.1/multi_thread/openmp/simple_ad_openmp.cpp --- cppad-2015.00.00.9/multi_thread/openmp/simple_ad_openmp.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/openmp/simple_ad_openmp.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: simple_ad_openmp.cpp 2506 2012-10-24 19:36:49Z bradbell $ +// $Id: simple_ad_openmp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,13 +18,11 @@ $$ $section A Simple OpenMP AD: Example and Test$$ +$mindex AD$$ -$index openmp, simple AD$$ -$index AD, simple openmp$$ -$index simple, openmp AD$$ $head Purpose$$ -This example demonstrates how CppAD can be used in a +This example demonstrates how CppAD can be used in a OpenMP multi-threading environment. $head Source Code$$ @@ -55,7 +53,7 @@ // ------------------------------------------------------------------ // used to inform CppAD when we are in parallel execution mode bool in_parallel(void) - { return static_cast( omp_in_parallel() ); } + { return omp_in_parallel() != 0; } // ------------------------------------------------------------------ // used to inform CppAD of the current thread number size_t thread_number(void) @@ -74,7 +72,7 @@ bool run_all_workers(size_t num_threads, problem_specific* info_all[]) { bool ok = true; - // initialize thread_all_ + // initialize thread_all_ int thread_num, int_num_threads = int(num_threads); for(thread_num = 0; thread_num < int_num_threads; thread_num++) { // initialize as false to make sure gets called for all threads @@ -128,9 +126,9 @@ ax[0] = info->x; Independent(ax); ay[0] = sqrt( ax[0] * ax[0] ); - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); - // Check function value corresponds to the identity + // Check function value corresponds to the identity double eps = 10. * CppAD::numeric_limits::epsilon(); ok &= NearEqual(ay[0], ax[0], eps, eps); @@ -151,8 +149,8 @@ // (using thread_alloc in sequential mode) size_t thread_num; for(thread_num = 0; thread_num < num_threads; thread_num++) - { ok &= thread_alloc::inuse(thread_num) == 0; - ok &= thread_alloc::available(thread_num) == 0; + { ok &= thread_alloc::inuse(thread_num) == 0; + ok &= thread_alloc::available(thread_num) == 0; } // initialize info_all @@ -175,9 +173,9 @@ void* v_ptr = static_cast( info_all[thread_num] ); thread_alloc::return_memory( v_ptr ); // check that there is no longer any memory inuse by this thread - ok &= thread_alloc::inuse(thread_num) == 0; + ok &= thread_alloc::inuse(thread_num) == 0; // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); + thread_alloc::free_available(thread_num); } return ok; diff -Nru cppad-2015.00.00.9/multi_thread/openmp/team_openmp.cpp cppad-2016.00.00.1/multi_thread/openmp/team_openmp.cpp --- cppad-2015.00.00.9/multi_thread/openmp/team_openmp.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/openmp/team_openmp.cpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,23 +1,20 @@ -// $Id: team_openmp.cpp 2506 2012-10-24 19:36:49Z bradbell $ +// $Id: team_openmp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -/* +/* $begin team_openmp.cpp$$ $spell openmp $$ -$index openmp, AD team$$ -$index AD, openmp team$$ -$index team, AD openmp$$ $section OpenMP Implementation of a Team of AD Threads$$ See $cref team_thread.hpp$$ for this routines specifications. @@ -41,11 +38,11 @@ // used to inform CppAD when we are in parallel execution mode bool in_parallel(void) - { return static_cast ( omp_in_parallel() ); } + { return omp_in_parallel() != 0; } // used to inform CppAD of the current thread number size_t thread_num(void) - { return static_cast( omp_get_thread_num() ); } + { return static_cast( omp_get_thread_num() ); } } bool team_create(size_t num_threads) @@ -60,7 +57,7 @@ // Set the number of OpenMP threads omp_set_num_threads( int(num_threads) ); - // setup for using CppAD::AD in parallel + // setup for using CppAD::AD in parallel thread_alloc::parallel_setup(num_threads, in_parallel, thread_num); thread_alloc::hold_memory(true); CppAD::parallel_ad(); @@ -81,7 +78,7 @@ # pragma omp parallel for for(thread_num = 0; thread_num < number_threads; thread_num++) worker(); -// end omp parallel for +// end omp parallel for return ok; } diff -Nru cppad-2015.00.00.9/multi_thread/pthread/a11c_pthread.cpp cppad-2016.00.00.1/multi_thread/pthread/a11c_pthread.cpp --- cppad-2015.00.00.9/multi_thread/pthread/a11c_pthread.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/pthread/a11c_pthread.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: a11c_pthread.cpp 2939 2013-10-14 11:06:18Z bradbell $ */ +// $Id: a11c_pthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,12 +18,9 @@ CppAD const $$ -$index OpenMP, example A.1.1c$$ -$index example, OpenMP A.1.1c$$ -$index A.1.1c, OpenMP example$$ -$index thread, OpenMP example$$ $section A Simple Parallel Pthread Example and Test$$ +$mindex OpenMP A.1.1c thread$$ $head Purpose$$ This example just demonstrates pthreads and does not use CppAD at all. @@ -43,7 +40,7 @@ // define CPPAD_NULPTR # include -# if CPPAD_HAS_NULLPTR +# if CPPAD_USE_CPLUSPLUS_2011 # define CPPAD_NULL nullptr # else # define CPPAD_NULL 0 @@ -62,7 +59,7 @@ { int i; // for some reason this function is missing on some systems // assert( pthread_is_multithreaded_np() > 0 ); - for(i = 1; i < n; i++) + for(i = 1; i < n; i++) b[i] = (a[i] + a[i-1]) / 2.0; return; } @@ -93,7 +90,7 @@ int n_thread = NUMBER_THREADS; // the threads pthread_t thread[NUMBER_THREADS]; - // arguments to start_routine + // arguments to start_routine struct start_arg arg[NUMBER_THREADS]; // attr pthread_attr_t attr; @@ -127,7 +124,7 @@ // check the result float eps = 100. * std::numeric_limits::epsilon(); for(i = 1; i < n ; i++) - ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; + ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; delete [] a; delete [] b; diff -Nru cppad-2015.00.00.9/multi_thread/pthread/CMakeLists.txt cppad-2016.00.00.1/multi_thread/pthread/CMakeLists.txt --- cppad-2015.00.00.9/multi_thread/pthread/CMakeLists.txt 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/pthread/CMakeLists.txt 2016-02-09 08:31:53.000000000 +0000 @@ -1,18 +1,18 @@ -# $Id: CMakeLists.txt 3619 2015-01-28 14:11:13Z bradbell $ +# $Id: CMakeLists.txt 3724 2015-09-21 05:04:18Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the multi_thread/pthread directory tests +# Build the multi_thread/pthread directory tests # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) @@ -22,7 +22,8 @@ # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) -ADD_EXECUTABLE(multi_thread_pthread EXCLUDE_FROM_ALL ../thread_test.cpp +ADD_EXECUTABLE(multi_thread_pthread EXCLUDE_FROM_ALL ../thread_test.cpp + ../../speed/src/microsoft_timer.cpp ../multi_newton_time.cpp ../multi_newton.cpp ../multi_newton_work.cpp @@ -46,7 +47,7 @@ TARGET_LINK_LIBRARIES(multi_thread_pthread ${pthread_lib}) # Add the check_multi_thread_pthread target -ADD_CUSTOM_TARGET(check_multi_thread_pthread - multi_thread_pthread simple_ad +ADD_CUSTOM_TARGET(check_multi_thread_pthread + multi_thread_pthread simple_ad DEPENDS multi_thread_pthread ) diff -Nru cppad-2015.00.00.9/multi_thread/pthread/simple_ad_pthread.cpp cppad-2016.00.00.1/multi_thread/pthread/simple_ad_pthread.cpp --- cppad-2015.00.00.9/multi_thread/pthread/simple_ad_pthread.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/pthread/simple_ad_pthread.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: simple_ad_pthread.cpp 2506 2012-10-24 19:36:49Z bradbell $ +// $Id: simple_ad_pthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,13 +18,11 @@ $$ $section A Simple pthread AD: Example and Test$$ +$mindex AD$$ -$index pthread, simple AD$$ -$index AD, simple pthread$$ -$index simple, pthread AD$$ $head Purpose$$ -This example demonstrates how CppAD can be used in a +This example demonstrates how CppAD can be used in a pthread multi-threading environment. $head Source Code$$ @@ -53,7 +51,7 @@ // ===================================================================== using CppAD::thread_alloc; // ------------------------------------------------------------------ - // key for accessing thread specific information + // key for accessing thread specific information pthread_key_t thread_specific_key_; // no need to destroy thread specific information @@ -71,7 +69,7 @@ // used to inform CppAD of current thread number thread_number() size_t thread_number(void) { // get thread specific information - void* thread_num_vptr = pthread_getspecific(thread_specific_key_); + void* thread_num_vptr = pthread_getspecific(thread_specific_key_); size_t* thread_num_ptr = static_cast(thread_num_vptr); size_t thread_num = *thread_num_ptr; return thread_num; @@ -103,7 +101,7 @@ ok &= thread_num != 0; // This is not the master thread, so thread specific infromation - // has not yet been set. We use it to inform other routines + // has not yet been set. We use it to inform other routines // of this threads number. // We must do this before calling thread_alloc::thread_num(). int rc = pthread_setspecific( @@ -150,7 +148,7 @@ // create a key for thread specific information rc = pthread_key_create( &thread_specific_key_, thread_specific_destructor - ); + ); ok &= (rc == 0); // set thread specific information for this (master thread) @@ -171,7 +169,7 @@ // inform CppAD that we now may be in parallel execution mode sequential_execution_ = false; - + // structure used to create the threads pthread_t pthread_id; // default for pthread_attr_setdetachstate is PTHREAD_CREATE_JOINABLE @@ -199,7 +197,7 @@ ok &= thread_num == 0; ok &= worker(thread_num, thread_all_[thread_num].info); - // now wait for the other threads to finish + // now wait for the other threads to finish for(thread_num = 1; thread_num < num_threads; thread_num++) { void* no_status = CPPAD_NULL; rc = pthread_join( @@ -226,7 +224,7 @@ return ok; } // ===================================================================== - // End of General purpose code + // End of General purpose code // ===================================================================== // function that does the work for one thread bool worker(size_t thread_num, problem_specific* info) @@ -237,9 +235,9 @@ ax[0] = info->x; Independent(ax); ay[0] = sqrt( ax[0] * ax[0] ); - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); - // Check function value corresponds to the identity + // Check function value corresponds to the identity double eps = 10. * CppAD::numeric_limits::epsilon(); ok &= CppAD::NearEqual(ay[0], ax[0], eps, eps); @@ -260,8 +258,8 @@ // (using thread_alloc in sequential mode) size_t thread_num; for(thread_num = 0; thread_num < num_threads; thread_num++) - { ok &= thread_alloc::inuse(thread_num) == 0; - ok &= thread_alloc::available(thread_num) == 0; + { ok &= thread_alloc::inuse(thread_num) == 0; + ok &= thread_alloc::available(thread_num) == 0; } // initialize info_all @@ -284,9 +282,9 @@ void* v_ptr = static_cast( info_all[thread_num] ); thread_alloc::return_memory( v_ptr ); // check that there is no longer any memory inuse by this thread - ok &= thread_alloc::inuse(thread_num) == 0; + ok &= thread_alloc::inuse(thread_num) == 0; // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); + thread_alloc::free_available(thread_num); } return ok; diff -Nru cppad-2015.00.00.9/multi_thread/pthread/team_pthread.cpp cppad-2016.00.00.1/multi_thread/pthread/team_pthread.cpp --- cppad-2015.00.00.9/multi_thread/pthread/team_pthread.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/pthread/team_pthread.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,32 +1,28 @@ -// $Id: team_pthread.cpp 2506 2012-10-24 19:36:49Z bradbell $ +// $Id: team_pthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -/* +/* $begin team_pthread.cpp$$ $spell Cygwin pthread $$ -$index pthread, AD team$$ -$index AD, pthread team$$ -$index team, AD pthread$$ $section Pthread Implementation of a Team of AD Threads$$ +$mindex pthread_exit$$ See $cref team_thread.hpp$$ for this routines specifications. $head Bug in Cygwin$$ -$index bug, cygwin pthread_exit$$ -$index cygwin, bug in pthread_exit$$ -$index pthread_exit, bug in cygwin$$ + There is a bug in $code pthread_exit$$, using cygwin 5.1 and g++ version 4.3.4, whereby calling $code pthread_exit$$ is not the same as returning from @@ -56,9 +52,9 @@ using CppAD::thread_alloc; // number of threads in the team - size_t num_threads_ = 1; + size_t num_threads_ = 1; - // key for accessing thread specific information + // key for accessing thread specific information pthread_key_t thread_specific_key_; // no need to destroy thread specific information @@ -103,7 +99,7 @@ // thread_number() size_t thread_number(void) { // get thread specific information - void* thread_num_vptr = pthread_getspecific(thread_specific_key_); + void* thread_num_vptr = pthread_getspecific(thread_specific_key_); size_t* thread_num_ptr = static_cast(thread_num_vptr); size_t thread_num = *thread_num_ptr; if( thread_num >= num_threads_ ) @@ -126,7 +122,7 @@ size_t thread_num = *static_cast(thread_num_vptr); // master thread does not use this routine - ok &= thread_num > 0; + ok &= thread_num > 0; while( true ) { @@ -144,7 +140,7 @@ worker_(); // Use wait_for_work_ to inform master that our work is done and - // that this thread will not use global information until + // that this thread will not use global information until // passing its barrier wait_for_job_ above. rc = pthread_barrier_wait(&wait_for_work_); ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD); @@ -185,7 +181,7 @@ thread_all_[0].pthread_id = pthread_self(); // create a key for thread specific information - rc = pthread_key_create(&thread_specific_key_,thread_specific_destructor); + rc = pthread_key_create(&thread_specific_key_,thread_specific_destructor); ok &= (rc == 0); // set thread specific information for this (master thread) @@ -200,7 +196,7 @@ thread_alloc::hold_memory(true); CppAD::parallel_ad(); - // Now change num_threads_ to its final value. Waiting till now allows + // Now change num_threads_ to its final value. Waiting till now allows // calls to thread_number during parallel_setup to check thread_num == 0. num_threads_ = num_threads; @@ -208,13 +204,13 @@ pthread_barrierattr_t* no_barrierattr = CPPAD_NULL; rc = pthread_barrier_init( &wait_for_work_, no_barrierattr, num_threads - ); + ); ok &= (rc == 0); rc = pthread_barrier_init( &wait_for_job_, no_barrierattr, num_threads - ); + ); ok &= (rc == 0); - + // structure used to create the threads pthread_t pthread_id; // default for pthread_attr_setdetachstate is PTHREAD_CREATE_JOINABLE @@ -228,7 +224,7 @@ // This master thread is already running, we need to create // num_threads - 1 more threads for(thread_num = 1; thread_num < num_threads; thread_num++) - { + { // Create the thread with thread number equal to thread_num thread_num_vptr = static_cast ( &(thread_all_[thread_num].thread_num) @@ -264,7 +260,7 @@ // set the new job that other threads are waiting for thread_job_ = work_enum; - // enter parallel execution soon as master thread completes wait_for_job_ + // enter parallel execution soon as master thread completes wait_for_job_ if( num_threads_ > 1 ) sequential_execution_ = false; @@ -299,13 +295,13 @@ // set the new job that other threads are waiting for thread_job_ = join_enum; - // Enter parallel exectuion soon as master thread completes wait_for_job_ + // Enter parallel exectuion soon as master thread completes wait_for_job_ if( num_threads_ > 1 ) sequential_execution_ = false; rc = pthread_barrier_wait(&wait_for_job_); ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD); - // now wait for the other threads to exit + // now wait for the other threads to exit size_t thread_num; for(thread_num = 1; thread_num < num_threads_; thread_num++) { void* no_status = CPPAD_NULL; @@ -315,7 +311,7 @@ ok &= (rc == 0); } - // now we are down to just the master thread (thread zero) + // now we are down to just the master thread (thread zero) sequential_execution_ = true; // destroy the key for thread specific data diff -Nru cppad-2015.00.00.9/multi_thread/team_example.cpp cppad-2016.00.00.1/multi_thread/team_example.cpp --- cppad-2015.00.00.9/multi_thread/team_example.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/team_example.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: team_example.cpp 2506 2012-10-24 19:36:49Z bradbell $ +// $Id: team_example.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,16 +17,14 @@ $$ $section Using a Team of AD Threads: Example and Test$$ +$mindex thread$$ -$index thread, team example AD$$ -$index AD, example team$$ -$index example, team AD$$ $head Purpose$$ This example demonstrates how use a team threads with CppAD. $head thread_team$$ -The following three implementations of the +The following three implementations of the $cref team_thread.hpp$$ specifications are included: $table $rref team_openmp.cpp$$ @@ -73,9 +71,9 @@ ax[0] = work_all_[thread_num]->x; Independent(ax); ay[0] = sqrt( ax[0] * ax[0] ); - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); - // Check function value corresponds to the identity + // Check function value corresponds to the identity double eps = 10. * CppAD::numeric_limits::epsilon(); ok &= NearEqual(ay[0], ax[0], eps, eps); @@ -100,8 +98,8 @@ // (using thread_alloc in sequential mode) size_t thread_num; for(thread_num = 0; thread_num < num_threads; thread_num++) - { ok &= thread_alloc::inuse(thread_num) == 0; - ok &= thread_alloc::available(thread_num) == 0; + { ok &= thread_alloc::inuse(thread_num) == 0; + ok &= thread_alloc::available(thread_num) == 0; } // initialize work_all_ @@ -112,7 +110,7 @@ work_all_[thread_num] = static_cast(v_ptr); // incase this thread's worker does not get called work_all_[thread_num]->ok = false; - // parameter that defines the work for this thread + // parameter that defines the work for this thread work_all_[thread_num]->x = double(thread_num) + 1.; } @@ -125,7 +123,7 @@ while(thread_num--) { // check that this thread was ok with the work it did ok &= work_all_[thread_num]->ok; - // delete problem specific information + // delete problem specific information void* v_ptr = static_cast( work_all_[thread_num] ); thread_alloc::return_memory( v_ptr ); // check that there is no longer any memory inuse by this thread diff -Nru cppad-2015.00.00.9/multi_thread/team_example.hpp cppad-2016.00.00.1/multi_thread/team_example.hpp --- cppad-2015.00.00.9/multi_thread/team_example.hpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/team_example.hpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,11 +1,11 @@ -/* $Id: team_example.hpp 2506 2012-10-24 19:36:49Z bradbell $ */ -# ifndef CPPAD_TEAM_EXAMPLE_INCLUDED -# define CPPAD_TEAM_EXAMPLE_INCLUDED +// $Id: team_example.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_TEAM_EXAMPLE_HPP +# define CPPAD_TEAM_EXAMPLE_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/multi_thread/team_thread.hpp cppad-2016.00.00.1/multi_thread/team_thread.hpp --- cppad-2015.00.00.9/multi_thread/team_thread.hpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/team_thread.hpp 2016-02-09 08:31:54.000000000 +0000 @@ -1,17 +1,17 @@ -/* $Id: team_thread.hpp 2859 2013-05-28 06:03:21Z bradbell $ */ -# ifndef CPPAD_TEAM_THREAD_INCLUDED -# define CPPAD_TEAM_THREAD_INCLUDED +// $Id: team_thread.hpp 3757 2015-11-30 12:03:07Z bradbell $ +# ifndef CPPAD_TEAM_THREAD_HPP +# define CPPAD_TEAM_THREAD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -/* +/* $begin team_thread.hpp$$ $spell pthreads @@ -27,9 +27,6 @@ $$ $section Specifications for A Team of AD Threads$$ -$index thread, AD team$$ -$index AD, thread team$$ -$index team, AD threads$$ $head Syntax$$ $codei%include "team_thread.hpp" @@ -56,7 +53,7 @@ ($cref/in_parallel/ta_in_parallel/$$ must be false). $head team_create$$ -The argument +The argument $icode%num_threads% > 0%$$ has type $code size_t$$ and specifies the number of threads in this team. This initializes both $code AD$$ and $code team_work$$ @@ -72,7 +69,7 @@ $codei%bool %worker%(void)%$$. Each call to $code team_work$$ runs $icode num_threads$$ versions of $icode worker$$ with the corresponding value of -$cref/thread_num/ta_thread_num/$$ +$cref/thread_num/ta_thread_num/$$ between zero and $icode%num_threads% - 1%$$ and different for each thread, @@ -88,7 +85,7 @@ The return value has prototype $codei% const char* %name% -%$$ +%$$ and is a statically allocated $code '\0'$$ terminated C string. $head ok$$ @@ -116,7 +113,7 @@ $tend $head Speed Test of Implementation$$ -Speed tests of using CppAD with the team implementations above +Speed tests of using CppAD with the team implementations above can be found in: $table $rref harmonic.cpp$$ diff -Nru cppad-2015.00.00.9/multi_thread/test_multi/makefile.am cppad-2016.00.00.1/multi_thread/test_multi/makefile.am --- cppad-2015.00.00.9/multi_thread/test_multi/makefile.am 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/test_multi/makefile.am 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2506 2012-10-24 19:36:49Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -17,7 +17,7 @@ if CppAD_OPENMP TEST_OPENMP_FLAG = -DCPPAD_TEST_OPENMP else -TEST_OPENMP_FLAG = +TEST_OPENMP_FLAG = endif # check_PROGRAMS = test_multi @@ -35,7 +35,7 @@ # test_multi_SOURCES = \ test_multi.cpp \ - user_atomic.cpp + user_atomic.cpp test: check ./test_multi diff -Nru cppad-2015.00.00.9/multi_thread/test_multi/makefile.in cppad-2016.00.00.1/multi_thread/test_multi/makefile.in --- cppad-2015.00.00.9/multi_thread/test_multi/makefile.in 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/test_multi/makefile.in 2016-02-09 08:31:53.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = test_multi$(EXEEXT) subdir = multi_thread/test_multi -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -146,6 +155,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -176,12 +186,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -262,26 +272,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -337,7 +350,7 @@ # test_multi_SOURCES = \ test_multi.cpp \ - user_atomic.cpp + user_atomic.cpp all: all-am @@ -355,7 +368,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu multi_thread/test_multi/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu multi_thread/test_multi/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -607,6 +619,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check ./test_multi diff -Nru cppad-2015.00.00.9/multi_thread/test_multi/test_multi.cpp cppad-2016.00.00.1/multi_thread/test_multi/test_multi.cpp --- cppad-2015.00.00.9/multi_thread/test_multi/test_multi.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/test_multi/test_multi.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: test_multi.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: test_multi.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,7 +14,7 @@ # include // memory leak checker -# include +# include // various examples / tests extern bool user_atomic_openmp(void); @@ -25,7 +25,7 @@ static size_t Run_error_count = 0; bool Run(bool TestOk(void), std::string name) { bool ok = true; - std::streamsize width = 20; + std::streamsize width = 20; std::cout.width( width ); std::cout.setf( std::ios_base::left ); std::cout << name; diff -Nru cppad-2015.00.00.9/multi_thread/test_multi/user_atomic.cpp cppad-2016.00.00.1/multi_thread/test_multi/user_atomic.cpp --- cppad-2015.00.00.9/multi_thread/test_multi/user_atomic.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/test_multi/user_atomic.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: user_atomic.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: user_atomic.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,37 +28,37 @@ size_t thread_number(void) { return static_cast( omp_get_thread_num() ); } # endif - + // y[0] = x[0] + x[1] bool user_atomic_forward( size_t id , - size_t k , + size_t k , size_t n , size_t m , const CppAD::vector& vx , CppAD::vector& vy , - const CppAD::vector& tx , + const CppAD::vector& tx , CppAD::vector& ty ) { assert(n >= 3 && m == 2); - if( k > 0 ) + if( k > 0 ) return false; ty[0] = tx[0] + tx[1]; ty[1] = tx[1] + tx[2]; - + if( vy.size() > 0 ) { vy[0] = (vx[0] | vx[1]); vy[1] = (vx[1] | vx[2]); } - return true; + return true; } bool user_atomic_reverse( size_t id , - size_t k , - size_t n , - size_t m , - const CppAD::vector& tx , + size_t k , + size_t n , + size_t m , + const CppAD::vector& tx , const CppAD::vector& ty , CppAD::vector& px , const CppAD::vector& py ) @@ -102,7 +102,7 @@ user_atomic_reverse , user_atomic_for_jac_sparse , user_atomic_rev_jac_sparse , - user_atomic_rev_hes_sparse + user_atomic_rev_hes_sparse ) bool user_atomic(int call_index) @@ -117,14 +117,14 @@ for(j = 0; j < n; j++) ax[j] = AD(j + 1); CppAD::Independent(ax); - + // use user atomic function size_t id = 0; my_user_atomic(id, ax, ay); - + // create function CppAD::ADFun g(ax, ay); - + // now use the tape with the user atomic function vector x(n), y(m); for(j = 0; j < n; j++) @@ -134,7 +134,7 @@ ok &= (y[0] == x[0] + x[1]); // y[1] = x[1] + x[2] ok &= (y[0] == x[0] + x[1]); - + return ok; } } @@ -182,8 +182,8 @@ ok &= ok_all[call_index]; // -------------------------------------------------------------------- - // Free all temporary work space associated with user_atomic objects. - // (If there are future calls to user atomic functions, they will + // Free all temporary work space associated with user_atomic objects. + // (If there are future calls to user atomic functions, they will // create new temporary work space.) CppAD::user_atomic::clear(); diff -Nru cppad-2015.00.00.9/multi_thread/thread_test.cpp cppad-2016.00.00.1/multi_thread/thread_test.cpp --- cppad-2015.00.00.9/multi_thread/thread_test.cpp 2015-02-24 08:31:35.000000000 +0000 +++ cppad-2016.00.00.1/multi_thread/thread_test.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: thread_test.cpp 3114 2014-02-22 16:20:39Z bradbell $ */ +// $Id: thread_test.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,14 +23,10 @@ openmp bthread $$ -$index thread_test, example$$ -$index thread_test, speed$$ -$index speed, thread_test$$ -$index example, thread_test$$ -$index thread, multi example$$ $section Run Multi-Threading Examples and Speed Tests$$ +$mindex thread_test multi openmp pthread bthread$$ $head Syntax$$ $codei%./multi_thread_%threading% a11c @@ -39,7 +35,7 @@ ./multi_thread_%threading% harmonic %test_time% %max_threads% %mega_sum% ./multi_thread_%threading% multi_newton %test_time% %max_threads% \ %num_zero% %num_sub% %num_sum% %use_ad% -%$$ +%$$ $head Running Tests$$ You can build this program and run the default version of its test @@ -52,24 +48,21 @@ for the different valid values of $icode threading$$: $subhead threading$$ -$index openmp, run tests$$ -$index pthread, run tests$$ -$index bthread, run tests$$ -If the $cref cmake$$ command output indicates that +If the $cref cmake$$ command output indicates that $code openmp$$ is supported by your system, you can execute the syntax above with $icode threading$$ equal to $code openmp$$. $pre $$ -If the $cref cmake$$ command output indicates that +If the $cref cmake$$ command output indicates that $code pthreads$$ with barriers is supported by your system, you can execute the syntax above with $icode threading$$ equal to $code pthread$$. $pre $$ -If the $cref cmake$$ command output indicates that +If the $cref cmake$$ command output indicates that $code boost$$ threads is supported is by your system, you can execute the syntax above with $icode threading$$ equal to $code bthread$$. @@ -95,37 +88,37 @@ %$$ $head a11c$$ -The examples +The examples $cref a11c_openmp.cpp$$, $cref a11c_bthread.cpp$$, and $cref a11c_pthread.cpp$$ -demonstrate simple multi-threading, +demonstrate simple multi-threading, without algorithmic differentiation. $head simple_ad$$ -The examples +The examples $cref simple_ad_openmp.cpp$$, $cref simple_ad_bthread.cpp$$, and $cref simple_ad_pthread.cpp$$ -demonstrate simple multi-threading, +demonstrate simple multi-threading, with algorithmic differentiation, using OpenMP, boost threads and pthreads respectively. $head team_example$$ The $cref team_example.cpp$$ routine demonstrates simple multi-threading with algorithmic differentiation -and using a $cref/team of threads/team_thread.hpp/$$. +and using a $cref/team of threads/team_thread.hpp/$$. $head harmonic$$ The $cref harmonic_time.cpp$$ routine -preforms a timing test for a multi-threading +preforms a timing test for a multi-threading example without algorithmic differentiation using a team of threads. $subhead test_time$$ Is the minimum amount of wall clock time that the test should take. The number of repeats for the test will be increased until this time -is reached. +is reached. The reported time is the total wall clock time divided by the number of repeats. @@ -139,19 +132,19 @@ The value of zero corresponds to not using the multi-threading system. $subhead mega_sum$$ -The command line argument $icode mega_sum$$ +The command line argument $icode mega_sum$$ is an integer greater than or equal one and has the same meaning as in $cref/harmonic_time.cpp/harmonic_time.cpp/mega_sum/$$. $head multi_newton$$ The $cref multi_newton_time.cpp$$ routine -preforms a timing test for a multi-threading +preforms a timing test for a multi-threading example with algorithmic differentiation using a team of threads. $subhead test_time$$ Is the minimum amount of wall clock time that the test should take. The number of repeats for the test will be increased until this time -is reached. +is reached. The reported time is the total wall clock time divided by the number of repeats. @@ -165,22 +158,22 @@ The value of zero corresponds to not using the multi-threading system. $subhead num_zero$$ -The command line argument $icode num_zero$$ +The command line argument $icode num_zero$$ is an integer greater than or equal two and has the same meaning as in $cref/multi_newton_time.cpp/multi_newton_time.cpp/num_zero/$$. $subhead num_sub$$ -The command line argument $icode num_sub$$ +The command line argument $icode num_sub$$ is an integer greater than or equal one and has the same meaning as in $cref/multi_newton_time.cpp/multi_newton_time.cpp/num_sub/$$. $subhead num_sum$$ -The command line argument $icode num_sum$$ +The command line argument $icode num_sum$$ is an integer greater than or equal one and has the same meaning as in $cref/multi_newton_time.cpp/multi_newton_time.cpp/num_sum/$$. $subhead use_ad$$ -The command line argument $icode use_ad$$ is either +The command line argument $icode use_ad$$ is either $code true$$ or $code false$$ and has the same meaning as in $cref/multi_newton_time.cpp/multi_newton_time.cpp/use_ad/$$. @@ -216,8 +209,8 @@ namespace { size_t arg2size_t( - const char* arg , - int limit , + const char* arg , + int limit , const char* error_msg ) { int i = std::atoi(arg); if( i >= limit ) @@ -227,8 +220,8 @@ exit(1); } double arg2double( - const char* arg , - double limit , + const char* arg , + double limit , const char* error_msg ) { double d = std::atof(arg); if( d >= limit ) @@ -246,7 +239,7 @@ using std::endl; // commnd line usage message - const char* usage = + const char* usage = "./_test a11c\n" "./_test simple_ad\n" "./_test team_example\n" @@ -265,12 +258,12 @@ const char* gmt = std::asctime( std::gmtime( &rawtime ) ); size_t len = size_t( std::strlen(gmt) ); cout << "gmtime = '"; - for(size_t i = 0; i < len; i++) + for(size_t i = 0; i < len; i++) if( gmt[i] != '\n' ) cout << gmt[i]; cout << "';" << endl; // CppAD version number - cout << "cppad_version = '" << CPPAD_PACKAGE_STRING << "';" << endl; + cout << "cppad_version = '" << CPPAD_PACKAGE_STRING << "';" << endl; // put the team name in the output file cout << "team_name = '" << team_name() << "';" << endl; @@ -293,12 +286,12 @@ if( run_a11c || run_simple_ad || run_team_example ) ok = (argc == 2); else if( run_harmonic ) - ok = (argc == 5); + ok = (argc == 5); else if( run_multi_newton ) ok = (argc == 8); if( ! ok ) - { std::cerr << "test_name = " << test_name << endl; - std::cerr << "argc = " << argc << endl; + { std::cerr << "test_name = " << test_name << endl; + std::cerr << "argc = " << argc << endl; std::cerr << usage << endl; exit(1); } @@ -320,20 +313,20 @@ return ! ok; } - // test_time - double test_time = arg2double( *++argv, 0., + // test_time + double test_time = arg2double( *++argv, 0., "run: test_time is less than zero" ); - // max_threads - size_t max_threads = arg2size_t( *++argv, 0, + // max_threads + size_t max_threads = arg2size_t( *++argv, 0, "run: max_threads is less than zero" ); size_t mega_sum = 0; // assignment to avoid compiler warning if( run_harmonic ) { // mega_sum - mega_sum = arg2size_t( *++argv, 1, + mega_sum = arg2size_t( *++argv, 1, "run: mega_sum is less than one" ); } @@ -349,8 +342,8 @@ num_sub = arg2size_t( *++argv, 1, "run: num_sub is less than one" ); - - // num_sum + + // num_sum num_sum = arg2size_t( *++argv, 1, "run: num_sum is less than one" ); @@ -383,7 +376,7 @@ inuse_this_thread = thread_alloc::inuse(0); // run the requested test - if( run_harmonic ) ok &= + if( run_harmonic ) ok &= harmonic_time(time_out, test_time, num_threads, mega_sum); else { ok &= run_multi_newton; diff -Nru cppad-2015.00.00.9/omh/addon.omh cppad-2016.00.00.1/omh/addon.omh --- cppad-2015.00.00.9/omh/addon.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/addon.omh 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1,97 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +$begin addon$$ +$spell + Addons + addon + libdir + includedir + libcppad + adcomp + CppAD + cppad.hpp + ons + namespace + cg + pycppad +$$ + + +$section CppAD Addons$$ + +$head Name$$ +Each CppAD addon has a short name which we denote by $icode name$$ below, +a longer name $icode longer$$ and a $icode description$$: + +$table +$icode name$$ $pre $$ $cnext +$icode longer$$ $pre $$ $cnext +$icode description$$ +$rnext +$href%https://github.com/joaoleal/CppADCodeGen/%cg%$$ $cnext + $code CppADCodeGen$$ $cnext + C++ Source Code Generation of CppAD Derivative Calculations +$rnext +$href%http://www.seanet.com/~bradbell/pycppad/pycppad.htm%py%$$ $cnext + $code pycppad$$ $cnext + A Python Interface to CppAD +$rnext +$href%https://github.com/kaskr/adcomp%tmb%$$ $cnext + $code adcomp$$ $cnext + An R Interface to CppAD with Random Effects Modeling Utilities +$rnext +$href%http://moby.ihme.washington.edu/bradbell/cppad_mixed%mixed%$$ + $cnext $code cppad_mixed$$ $cnext + A C++ Interface to Random Effects Laplace Approximation +$tend + +$head Include Files$$ +If $icode includedir$$ is the directory where the include files are installed, +the file +$codei% + %includedir%/cppad/%name%.hpp +%$$ +and the directory +$codei% + %includedir%/cppad/%name% +%$$ +are reserved for use by the $icode name$$ addon. + +$head Library Files$$ +If $icode libdir$$ is the directory where CppAD library files are installed, +files with the name +$codei% + %libdir%/libcppad_%name%.%ext% + %libdir%/libcppad_%name%_%anything%.%ext% +%$$ +where $icode anything$$ and $icode ext$$ are arbitrary, +are reserved for use by the $icode name$$ addon. + +$head Preprocessor Symbols$$ +C++ preprocessor symbols that begin with +$codei% + CPPAD_%NAME%_ +%$$ +where $icode NAME$$ is a upper-case version of $icode name$$, +are reserved for use by the $icode name$$ addon. + +$head Namespace$$ +The C++ namespace +$codei% + CppAD::%name% +%$$ +is reserved for use by the $icode name$$ addon. + + +$end + + diff -Nru cppad-2015.00.00.9/omh/appendix.omh cppad-2016.00.00.1/omh/appendix.omh --- cppad-2015.00.00.9/omh/appendix.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/appendix.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: appendix.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: appendix.omh 3759 2015-11-30 19:54:58Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,11 +21,12 @@ omh/theory/theory.omh% omh/glossary.omh% omh/bib.omh% - omh/bugs.omh% omh/wish_list.omh% omh/whats_new/whats_new.omh% omh/deprecated/deprecated.omh% compare_c/CMakeLists.txt% + omh/numeric_ad.omh% + omh/addon.omh% omh/license.omh %$$ diff -Nru cppad-2015.00.00.9/omh/atomic_base.omh cppad-2016.00.00.1/omh/atomic_base.omh --- cppad-2015.00.00.9/omh/atomic_base.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/atomic_base.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: atomic_base.omh 3505 2014-12-26 15:06:54Z bradbell $ */ +/* $Id: atomic_base.omh 3717 2015-08-31 22:16:15Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,6 +11,7 @@ -------------------------------------------------------------------------- */ $begin atomic_base$$ $spell + ctor cppad hpp afun @@ -29,16 +30,12 @@ $$ $section User Defined Atomic AD Functions$$ -$index atomic, user function$$ -$index user, atomic function$$ -$index operation, user atomic$$ -$index function, user atomic$$ $head Syntax$$ $codei% -%atomic_user% %afun%(%n%, %m%, %use_set%, %user_arg_list%) +%atomic_user% %afun%(%ctor_arg_list%) %afun%(%ax%, %ay%) %ok% = %afun%.forward(%p%, %q%, %vx%, %vy%, %tx%, %ty%) %ok% = %afun%.reverse(%q%, %tx%, %ty%, %px%, %py%) @@ -48,16 +45,16 @@ atomic_base<%Base%>::clear()%$$ $head Purpose$$ -In some cases, the user knows how to compute derivatives of a function +In some cases, the user knows how to compute derivatives of a function $latex \[ - y = f(x) \; {\rm where} \; f : B^n \rightarrow B^m + y = f(x) \; {\rm where} \; f : B^n \rightarrow B^m \] $$ -more efficiently than by coding it using $codei%AD<%Base%>%$$ +more efficiently than by coding it using $codei%AD<%Base%>%$$ $cref/atomic/glossary/Operation/Atomic/$$ operations and letting CppAD do the rest. In this case $codei%atomic_base%<%Base%>%$$ can use the user code for $latex f(x)$$, and its derivatives, -as $codei%AD<%Base%>%$$ atomic operations. +as $codei%AD<%Base%>%$$ atomic operations. $head Virtual Functions$$ User defined derivatives are implemented by defining the @@ -69,11 +66,11 @@ $cref/rev_sparse_hes/atomic_rev_sparse_hes/$$. These virtual functions have a default implementation that returns $icode%ok% == false%$$. -The $code forward$$ function, +The $code forward$$ function, for the case $icode%q% == 0%$$, must be implemented. Otherwise, only those functions -required by the your calculations need to be implemented. -For example, +required by the your calculations need to be implemented. +For example, $icode forward$$ for the case $icode%q% == 2%$$ can just return $icode%ok% == false%$$ unless you require forward mode calculation of second derivatives. @@ -83,6 +80,7 @@ example/atomic/get_started.cpp% example/atomic/norm_sq.cpp% example/atomic/reciprocal.cpp% + example/atomic/sparsity.cpp% example/atomic/tangent.cpp% example/atomic/hes_sparse.cpp% example/atomic/mat_mul.cpp diff -Nru cppad-2015.00.00.9/omh/atomic.omh cppad-2016.00.00.1/omh/atomic.omh --- cppad-2015.00.00.9/omh/atomic.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/atomic.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: atomic.omh 2859 2013-05-28 06:03:21Z bradbell $ */ +// $Id: atomic.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,10 +12,7 @@ $begin atomic$$ $section Atomic AD Functions$$ -$index atomic, ad function$$ -$index ad, atomic function$$ -$index operation, ad atomic$$ -$index function, ad atomic$$ +$mindex operation$$ $childtable% cppad/local/checkpoint.hpp% diff -Nru cppad-2015.00.00.9/omh/base_example.omh cppad-2016.00.00.1/omh/base_example.omh --- cppad-2015.00.00.9/omh/base_example.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/base_example.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/* $Id: base_example.omh 2506 2012-10-24 19:36:49Z bradbell $ */ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -$begin base_example$$ - -$section Example AD Base Types That are not AD$$ - -$contents% - example/base_alloc.hpp% - example/base_require.cpp% - cppad/example/base_adolc.hpp% - cppad/local/base_float.hpp% - cppad/local/base_double.hpp% - cppad/local/base_complex.hpp -%$$ - -$end diff -Nru cppad-2015.00.00.9/omh/base_identical.omh cppad-2016.00.00.1/omh/base_identical.omh --- cppad-2015.00.00.9/omh/base_identical.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/base_identical.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -// $Id: base_identical.omh 2506 2012-10-24 19:36:49Z bradbell $$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin base_identical$$ -$spell - alloc - adolc - Op - const - CppAD - adolc - namespace - bool - inline -$$ - -$section Base Type Requirements for Identically Equal Comparisons$$ - -$head EqualOpSeq$$ -$index EqualOpSeq, base require$$ -$index base, EqualOpSeq require$$ -$index require, base EqualOpSeq$$ -If function $cref EqualOpSeq$$ is used with -arguments of type $codei%AD<%Base%>%$$, -the type $icode Base$$ must support the syntax -$codei% - %b% = CppAD::EqualOpSeq(%u%, %v%) -%$$ -This should return true if and only if -$icode u$$ is identically equal to $icode v$$ -and it makes no different which one is used. -The arguments $icode u$$ and $icode v$$ have prototype -$codei% - const %Base%& %u% - const %Base%& %v% -%$$ -The return value $icode b$$ has prototype -$codei% - bool %b% -%$$ - -$subhead The Simple Case$$ -If $icode Base$$ is a relatively simple type, -the $code EqualOpSeq$$ function can be defined by -$codei% -namespace CppAD { - inline %Base% EqualOpSeq(const %Base%& u, const %Base%& v) - { return u == v; } -} -%$$ -For example, see -$cref/base_alloc/base_alloc.hpp/EqualOpSeq/$$. - -$subhead More Complicated Cases$$ -The variables -$icode u$$ and $icode v$$ are not identically equal in the following case -(which CppAD automatically defines $code EqualOpSeq$$ for): -The type $icode Base$$ is $codei%AD%$$, -$icode x[0] = x[1] = 1.$$, -then $cref independent$$ is used to make $icode x$$ the independent -variable vector, -and then $icode u = x[0]$$, $icode v = x[1]$$, -Note that during a future $cref Forward$$ calculation, -$icode u$$ and $icode v$$ could correspond to different values. -For example, see -$cref/adolc EqualOpSeq/base_adolc.hpp/EqualOpSeq/$$. - -$head Identical$$ -$index identical, base require$$ -$index base, identical require$$ -$index require, base identical$$ - -$subhead IdenticalPar$$ -A $icode Base$$ is a $cref/parameter/glossary/Parameter/$$ -when used in an $codei%AD<%Base%>%$$ operation sequence. -It is however still possible for a parameter to change its value. -For example, -the $icode Base$$ value $icode u$$ is not identically a parameter -equal in the following case -(which CppAD automatically defines $code IdenticalPar$$ for): -The type $icode Base$$ is $codei%AD%$$, -$icode x[0] = 1.$$, -then $cref independent$$ is used to make $icode x$$ the independent -variable vector, -and then $icode u = x[0]$$, -Note that during a future $cref Forward$$ calculation, -$icode u$$ could correspond to different values. - -$subhead Prototypes$$ -The argument $icode u$$ has prototype -$codei% - const %Base% %u% -%$$ -If it is present, the argument $icode v$$ has prototype -$codei% - const %Base% %v% -%$$ -The result $icode b$$ has prototype -$codei% - bool %b% -%$$ - -$subhead Identical Functions$$ -The type $icode Base$$ must support the following functions -(in the CppAD namespace): -$table -$bold Syntax$$ $cnext $bold Result$$ -$rnext -$icode%b% = IdenticalPar(%u%)%$$ $pre $$ - $cnext the $icode Base$$ value will always be the same -$rnext -$icode%b% = IdenticalZero(%u%)%$$ $pre $$ - $cnext $icode u$$ equals zero and $codei%IdenticalPar(%u%)%$$ -$rnext -$icode%b% = IdenticalOne(%u%)%$$ $pre $$ - $cnext $icode u$$ equals one and $codei%IdenticalPar(%u%)%$$ -$rnext -$icode%b% = IdenticalEqualPar(%u%, %v%)%$$ $pre $$ - $cnext $icode u$$ equals $icode v$$, - $codei%IdenticalPar(%u%)%$$ and - $codei%IdenticalPar(%v%)%$$ -$tend - -$subhead Examples$$ -See -$cref/base_alloc/base_alloc.hpp/Identical/$$. - -$end -*/ diff -Nru cppad-2015.00.00.9/omh/base_member.omh cppad-2016.00.00.1/omh/base_member.omh --- cppad-2015.00.00.9/omh/base_member.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/base_member.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/* $Id: base_member.omh 2506 2012-10-24 19:36:49Z bradbell $ */ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -$begin base_member$$ -$spell - bool - const - op - Bool - definition - alloc -$$ - -$section Required Base Class Member Functions$$ - -$head Notation$$ -$table -$bold Symbol$$ $cnext $bold Meaning$$ $rnext -$icode Base$$ $cnext - The base type corresponding to $codei%AD<%Base%>%$$ -$rnext -$icode b$$ $cnext - An object of type $code bool$$ -$rnext -$icode d$$ $cnext - An object of type $code double$$ -$rnext -$icode x$$ $cnext - An object of type $codei%const %Base%&%$$ -$rnext -$icode y$$ $cnext - An object of type $codei%const %Base%&%$$ -$rnext -$icode z$$ $cnext - An object of type $icode Base$$ -$rnext -$tend - -$head Default Constructor$$ -$icode%Base z%$$ - -$head Double Constructor$$ -$icode%Base z%(%d%)%$$ - -$head Copy Constructor$$ -$icode%Base z%(%x%)%$$ - -$head Unary Operators$$ -For $code op$$ equal to -$code +$$, -$code -$$ -the following operation must be supported: -$codei% - %z% = %op% %x%$$ - -$head Assignment Operators$$ -For $icode op$$ equal to -$icode =$$, -$code +=$$, -$code -=$$, -$code *=$$, and -$code /=$$ the following operation must be supported: -$codei% - %z% %op% %x%$$ - -$head Binary Operators$$ -For $icode op$$ equal to -$code +$$, -$code -$$, -$code *$$, and -$code /$$ the following operation must be supported: -$codei% - %z% = %x% %op% %y%$$ - -$head Bool Operators$$ -For $icode op$$ equal to -$code ==$$, -$code !=$$, -$code <=$$, -the following operation must be supported: -$codei% - %b% = %x% %op% %y%$$ - -$head Example$$ -See the heading Class Definition in -$cref/base_alloc/base_alloc.hpp/Class Definition/$$. - -$end diff -Nru cppad-2015.00.00.9/omh/base_ordered.omh cppad-2016.00.00.1/omh/base_ordered.omh --- cppad-2015.00.00.9/omh/base_ordered.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/base_ordered.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -// $Id: base_ordered.omh 2506 2012-10-24 19:36:49Z bradbell $$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ -/* -$begin base_ordered$$ -$spell - alloc - abs_geq - const - bool - namespace - CppAD - inline -$$ - -$section Base Type Requirements for Ordered Comparisons$$ - -$head Purpose$$ -The following operations -(in the CppAD namespace) are required to use the type -$codei%AD<%Base%>%$$: - -$table -$bold Syntax$$ $cnext $bold Result$$ -$rnext -$icode%b% = GreaterThanZero(%x%)%$$ $pre $$ - $cnext $latex x > 0$$ -$rnext -$icode%b% = GreaterThanOrZero(%x%)%$$ $pre $$ - $cnext $latex x \geq 0$$ -$rnext -$icode%b% = LessThanZero(%x%)%$$ $pre $$ - $cnext $latex x < 0$$ -$rnext -$icode%b% = LessThanOrZero(%x%)%$$ $pre $$ - $cnext $latex x \leq 0$$ -$rnext -$icode%b% = abs_geq(%x%, %y%)%$$ $pre $$ - $cnext $latex |x| \geq |y|$$. -$tend -where the arguments and return value have the prototypes -$codei% - const %Base%& %x% - const %Base%& %y% - bool %% %b% -%$$ - -$head Ordered Type$$ -If the type $icode Base$$ supports ordered operations, -these functions should have their corresponding definitions. -For example, -$codei% -namespace CppAD { - inline bool GreaterThanZero(const %Base% &x) - { return (x > 0); - } -} -%$$ -The other functions would replace $code >$$ by the corresponding operator. -For example, see -$cref/base_alloc/base_alloc.hpp/Ordered/$$. - - -$head Not Ordered$$ -If the type $icode Base$$ does not support ordering, -one might (but need not) define $code GreaterThanZero$$ as follows: -$codei% -namespace CppAD { - inline bool GreaterThanZero(const %Base% &x) - { // attempt to use GreaterThanZero with a %Base% argument - assert(0); - return x; - } -} -%$$ -The other functions would have the corresponding definition. -For example, see -$cref/complex Ordered/base_complex.hpp/Ordered/$$. - -$end -*/ diff -Nru cppad-2015.00.00.9/omh/base_require/base_example.omh cppad-2016.00.00.1/omh/base_require/base_example.omh --- cppad-2015.00.00.9/omh/base_require/base_example.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/base_require/base_example.omh 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1,25 @@ +/* $Id: base_example.omh 3665 2015-02-26 04:59:01Z bradbell $ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +$begin base_example$$ + +$section Example AD Base Types That are not AD$$ + +$contents% + example/base_alloc.hpp% + example/base_require.cpp% + cppad/example/base_adolc.hpp% + cppad/local/base_float.hpp% + cppad/local/base_double.hpp% + cppad/local/base_complex.hpp +%$$ + +$end diff -Nru cppad-2015.00.00.9/omh/base_require/base_identical.omh cppad-2016.00.00.1/omh/base_require/base_identical.omh --- cppad-2015.00.00.9/omh/base_require/base_identical.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/base_require/base_identical.omh 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1,133 @@ +// $Id: base_identical.omh 3757 2015-11-30 12:03:07Z bradbell $$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin base_identical$$ +$spell + alloc + adolc + Op + const + CppAD + adolc + namespace + bool + inline +$$ + +$section Base Type Requirements for Identically Equal Comparisons$$ +$mindex require$$ + +$head EqualOpSeq$$ +If function $cref EqualOpSeq$$ is used with +arguments of type $codei%AD<%Base%>%$$, +the type $icode Base$$ must support the syntax +$codei% + %b% = CppAD::EqualOpSeq(%u%, %v%) +%$$ +This should return true if and only if +$icode u$$ is identically equal to $icode v$$ +and it makes no different which one is used. +The arguments $icode u$$ and $icode v$$ have prototype +$codei% + const %Base%& %u% + const %Base%& %v% +%$$ +The return value $icode b$$ has prototype +$codei% + bool %b% +%$$ + +$subhead The Simple Case$$ +If $icode Base$$ is a relatively simple type, +the $code EqualOpSeq$$ function can be defined by +$codei% +namespace CppAD { + inline %Base% EqualOpSeq(const %Base%& u, const %Base%& v) + { return u == v; } +} +%$$ +For example, see +$cref/base_alloc/base_alloc.hpp/EqualOpSeq/$$. + +$subhead More Complicated Cases$$ +The variables +$icode u$$ and $icode v$$ are not identically equal in the following case +(which CppAD automatically defines $code EqualOpSeq$$ for): +The type $icode Base$$ is $codei%AD%$$, +$icode x[0] = x[1] = 1.$$, +then $cref independent$$ is used to make $icode x$$ the independent +variable vector, +and then $icode u = x[0]$$, $icode v = x[1]$$, +Note that during a future $cref Forward$$ calculation, +$icode u$$ and $icode v$$ could correspond to different values. +For example, see +$cref/adolc EqualOpSeq/base_adolc.hpp/EqualOpSeq/$$. + +$head Identical$$ + +$subhead IdenticalPar$$ +A $icode Base$$ is a $cref/parameter/glossary/Parameter/$$ +when used in an $codei%AD<%Base%>%$$ operation sequence. +It is however still possible for a parameter to change its value. +For example, +the $icode Base$$ value $icode u$$ is not identically a parameter +equal in the following case +(which CppAD automatically defines $code IdenticalPar$$ for): +The type $icode Base$$ is $codei%AD%$$, +$icode x[0] = 1.$$, +then $cref independent$$ is used to make $icode x$$ the independent +variable vector, +and then $icode u = x[0]$$, +Note that during a future $cref Forward$$ calculation, +$icode u$$ could correspond to different values. + +$subhead Prototypes$$ +The argument $icode u$$ has prototype +$codei% + const %Base% %u% +%$$ +If it is present, the argument $icode v$$ has prototype +$codei% + const %Base% %v% +%$$ +The result $icode b$$ has prototype +$codei% + bool %b% +%$$ + +$subhead Identical Functions$$ +The type $icode Base$$ must support the following functions +(in the CppAD namespace): +$table +$bold Syntax$$ $cnext $bold Result$$ +$rnext +$icode%b% = IdenticalPar(%u%)%$$ $pre $$ + $cnext the $icode Base$$ value will always be the same +$rnext +$icode%b% = IdenticalZero(%u%)%$$ $pre $$ + $cnext $icode u$$ equals zero and $codei%IdenticalPar(%u%)%$$ +$rnext +$icode%b% = IdenticalOne(%u%)%$$ $pre $$ + $cnext $icode u$$ equals one and $codei%IdenticalPar(%u%)%$$ +$rnext +$icode%b% = IdenticalEqualPar(%u%, %v%)%$$ $pre $$ + $cnext $icode u$$ equals $icode v$$, + $codei%IdenticalPar(%u%)%$$ and + $codei%IdenticalPar(%v%)%$$ +$tend + +$subhead Examples$$ +See +$cref/base_alloc/base_alloc.hpp/Identical/$$. + +$end +*/ diff -Nru cppad-2015.00.00.9/omh/base_require/base_member.omh cppad-2016.00.00.1/omh/base_require/base_member.omh --- cppad-2015.00.00.9/omh/base_require/base_member.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/base_require/base_member.omh 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1,96 @@ +/* $Id: base_member.omh 3665 2015-02-26 04:59:01Z bradbell $ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +$begin base_member$$ +$spell + bool + const + op + Bool + definition + alloc +$$ + +$section Required Base Class Member Functions$$ + +$head Notation$$ +$table +$bold Symbol$$ $cnext $bold Meaning$$ $rnext +$icode Base$$ $cnext + The base type corresponding to $codei%AD<%Base%>%$$ +$rnext +$icode b$$ $cnext + An object of type $code bool$$ +$rnext +$icode d$$ $cnext + An object of type $code double$$ +$rnext +$icode x$$ $cnext + An object of type $codei%const %Base%&%$$ +$rnext +$icode y$$ $cnext + An object of type $codei%const %Base%&%$$ +$rnext +$icode z$$ $cnext + An object of type $icode Base$$ +$rnext +$tend + +$head Default Constructor$$ +$icode%Base z%$$ + +$head Double Constructor$$ +$icode%Base z%(%d%)%$$ + +$head Copy Constructor$$ +$icode%Base z%(%x%)%$$ + +$head Unary Operators$$ +For $code op$$ equal to +$code +$$, +$code -$$ +the following operation must be supported: +$codei% + %z% = %op% %x%$$ + +$head Assignment Operators$$ +For $icode op$$ equal to +$icode =$$, +$code +=$$, +$code -=$$, +$code *=$$, and +$code /=$$ the following operation must be supported: +$codei% + %z% %op% %x%$$ + +$head Binary Operators$$ +For $icode op$$ equal to +$code +$$, +$code -$$, +$code *$$, and +$code /$$ the following operation must be supported: +$codei% + %z% = %x% %op% %y%$$ + +$head Bool Operators$$ +For $icode op$$ equal to +$code ==$$, +$code !=$$, +$code <=$$, +the following operation must be supported: +$codei% + %b% = %x% %op% %y%$$ + +$head Example$$ +See the heading Class Definition in +$cref/base_alloc/base_alloc.hpp/Class Definition/$$. + +$end diff -Nru cppad-2015.00.00.9/omh/base_require/base_ordered.omh cppad-2016.00.00.1/omh/base_require/base_ordered.omh --- cppad-2015.00.00.9/omh/base_require/base_ordered.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/base_require/base_ordered.omh 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1,89 @@ +// $Id: base_ordered.omh 3665 2015-02-26 04:59:01Z bradbell $$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +$begin base_ordered$$ +$spell + alloc + abs_geq + const + bool + namespace + CppAD + inline +$$ + +$section Base Type Requirements for Ordered Comparisons$$ + +$head Purpose$$ +The following operations +(in the CppAD namespace) are required to use the type +$codei%AD<%Base%>%$$: + +$table +$bold Syntax$$ $cnext $bold Result$$ +$rnext +$icode%b% = GreaterThanZero(%x%)%$$ $pre $$ + $cnext $latex x > 0$$ +$rnext +$icode%b% = GreaterThanOrZero(%x%)%$$ $pre $$ + $cnext $latex x \geq 0$$ +$rnext +$icode%b% = LessThanZero(%x%)%$$ $pre $$ + $cnext $latex x < 0$$ +$rnext +$icode%b% = LessThanOrZero(%x%)%$$ $pre $$ + $cnext $latex x \leq 0$$ +$rnext +$icode%b% = abs_geq(%x%, %y%)%$$ $pre $$ + $cnext $latex |x| \geq |y|$$. +$tend +where the arguments and return value have the prototypes +$codei% + const %Base%& %x% + const %Base%& %y% + bool %% %b% +%$$ + +$head Ordered Type$$ +If the type $icode Base$$ supports ordered operations, +these functions should have their corresponding definitions. +For example, +$codei% +namespace CppAD { + inline bool GreaterThanZero(const %Base% &x) + { return (x > 0); + } +} +%$$ +The other functions would replace $code >$$ by the corresponding operator. +For example, see +$cref/base_alloc/base_alloc.hpp/Ordered/$$. + + +$head Not Ordered$$ +If the type $icode Base$$ does not support ordering, +one might (but need not) define $code GreaterThanZero$$ as follows: +$codei% +namespace CppAD { + inline bool GreaterThanZero(const %Base% &x) + { // attempt to use GreaterThanZero with a %Base% argument + assert(0); + return x; + } +} +%$$ +The other functions would have the corresponding definition. +For example, see +$cref/complex Ordered/base_complex.hpp/Ordered/$$. + +$end +*/ diff -Nru cppad-2015.00.00.9/omh/bib.omh cppad-2016.00.00.1/omh/bib.omh --- cppad-2015.00.00.9/omh/bib.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/bib.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: bib.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: bib.omh 3785 2016-02-08 12:53:06Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,8 +43,8 @@ $head Evaluating Derivatives$$ Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, -Andreas Griewank, -SIAM, +Andreas Griewank, +SIAM, Philadelphia, 2000 diff -Nru cppad-2015.00.00.9/omh/bugs.omh cppad-2016.00.00.1/omh/bugs.omh --- cppad-2015.00.00.9/omh/bugs.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/bugs.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -$Id: bugs.omh 2506 2012-10-24 19:36:49Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -$begin Bugs$$ -$spell - adolc - uninitialized - stl - usr - Dir - CppAD - Gcc - Cygwin - std -$$ - -$section Know Bugs and Problems Using CppAD$$ -$index bugs, using CppAD$$ -$index problem, using CppAD$$ - - - -$head gcc 3.4.4 -O2$$ -$index gcc 3.4.4, bug$$ -$index bug, gcc 3.4.4$$ -There appears to be a problem with gcc version 3.4.4 -under Cygwin using the compiler option $code -O2$$. - -$subhead Example$$ -If you are running gcc 3.4.4, try using the -$cref/configure/installUnix/Configure/$$ option -$codep - CPP_ERROR_WARN="-O2 -Wall -ansi -pedantic-errors -std=c++98" -$$ -If the $code -O2$$ compiler option is a problem for your compiler, -you will get warnings that do not make sense when executing the -$code make$$ command in the $code Example$$ sub-directory. -In addition, the $code example/Example$$ program will generate a -segmentation fault. - -$subhead Adolc$$ -If you are running gcc 3.4.4, try using the -$cref/configure/installUnix/Configure/$$ options -$codei% - ./configure \ - ADOLC_DIR=%adolc_dir% \ - CPP_ERROR_WARN="-Wall" \ - BOOST_DIR=%boost_dir% -%$$ -the following warning occurs during the $code make$$ command: -$codep -/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82: -warning: '__cur' might be used uninitialized in this function -$$ -This appears to be the same problem discussed in -$pre - $$ -$href%http://www.cygwin.com/ml/cygwin-apps/2005-06/msg00159.html%$$ -$pre -$$ -and its follow up messages. - - -$end diff -Nru cppad-2015.00.00.9/omh/check_for_nan.omh cppad-2016.00.00.1/omh/check_for_nan.omh --- cppad-2015.00.00.9/omh/check_for_nan.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/check_for_nan.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -$Id: check_for_nan.omh 3214 2014-03-18 20:50:38Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -$begin check_for_nan$$ -$spell - Cpp - const - bool -$$ -$section Check an ADFun Object For Nan$$ -$index nan, check ADFun$$ -$index check, nan in ADFun$$ -$index ADFun, check nan$$. - -$head Syntax$$ -$codei%f%.check_for_nan(%b%) -%$$ -$icode%b% = %f%.check_for_nan() -%$$ - -$head Purpose$$ -If $code NDEBUG$$ is not defined and -the result of a $cref/forward/forward_order/$$ or $cref/reverse/reverse_any/$$ -calculation contains a $cref nan$$, -CppAD halts with an error message. -This can be suppressed using $code check_for_nan$$. - -$head f$$ -For the syntax where $icode b$$ is an argument, -$icode f$$ has prototype -$codei% - ADFun<%Base%> %f% -%$$ -(see $codei%ADFun<%Base%>%$$ $cref/constructor/FunConstruct/$$). -For the syntax where $icode b$$ is the result, -$icode f$$ has prototype -$codei% - const ADFun<%Base%> %f% -%$$ - -$head b$$ -This argument or result has prototype -$codei% - bool %b% -%$$ -Future calls to $icode%f%.Forward%$$ will (will not) check for $code nan$$. -depending on if $icode b$$ is true (false). - -$head Default$$ -The value for this setting after construction of $icode f$$) is true. -The value of this setting is not affected by calling -$cref Dependent$$ for this function object. - -$head Example$$ -$children% - example/check_for_nan.cpp -%$$ -The file -$cref check_for_nan.cpp$$ -contains an example and test of these operations. -It returns true if it succeeds and false otherwise. - -$end diff -Nru cppad-2015.00.00.9/omh/cos_forward.omh cppad-2016.00.00.1/omh/cos_forward.omh --- cppad-2015.00.00.9/omh/cos_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/cos_forward.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: cos_forward.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: cos_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,20 +18,18 @@ Taylor $$ -$index cos, forward theory$$ -$index theory, cos forward$$ -$index forward, cos theory$$ $section Cosine Function Forward Taylor Polynomial Theory$$ +$mindex cos$$ -If $latex F(x) = \cos(x) $$ +If $latex F(x) = \cos(x) $$ $latex \[ 1 * F^{(1)} (x) - 0 * F (x) = - \sin(x) \] $$ and in the $xref/ - ForwardTheory/ - Standard Math Functions/ + ForwardTheory/ + Standard Math Functions/ Differential Equation/ standard math function differential equation/ 1 @@ -40,10 +38,10 @@ $latex B(x) = 1$$, and $latex D(x) = - \sin(x)$$. We use $latex a$$, $latex b$$, $latex d$$, $latex s$$ -and $latex z$$ to denote the +and $latex z$$ to denote the Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, $latex \sin [ X(t) ]$$, and $latex F [ X(t) ] $$ respectively. @@ -60,28 +58,28 @@ \begin{array}{rcl} z^{(0)} & = & \cos ( x^{(0)} ) \\ -e^{(j)} +e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & -s^{(j)} \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \\ -& = & - \frac{1}{j+1} - \sum_{k=1}^{j+1} k x^{(k)} s^{(j+1-k)} +& = & - \frac{1}{j+1} + \sum_{k=1}^{j+1} k x^{(k)} s^{(j+1-k)} \end{array} -\] $$ +\] $$ Using $latex c$$ for the Taylor coefficients of $latex \cos[ X(t) ]$$ the order $latex j+1$$ coefficient can be generated using the lower order coefficients for $latex \sin[ X(t) ]$$ and $latex \cos[ X(t) ]$$ by the following formula: $latex \[ -c^{(j+1)} = - \frac{1}{j+1} - \sum_{k=1}^{j+1} k x^{(k)} s^{(j+1-k)} +c^{(j+1)} = - \frac{1}{j+1} + \sum_{k=1}^{j+1} k x^{(k)} s^{(j+1-k)} \] $$ $end diff -Nru cppad-2015.00.00.9/omh/deprecated/compare_change.omh cppad-2016.00.00.1/omh/deprecated/compare_change.omh --- cppad-2015.00.00.9/omh/deprecated/compare_change.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/deprecated/compare_change.omh 2016-02-09 08:31:48.000000000 +0000 @@ -0,0 +1,82 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +$begin CompareChange$$ +$spell + const +$$ + +$section Comparison Changes During Zero Order Forward Mode$$ +$mindex ADFun CompareChange$$ + + +$head Syntax$$ +$icode%c% = %f%.CompareChange()%$$ +$pre +$$ +$bold See Also$$ +$cref FunCheck$$ + +$head Deprecated 2015-01-20$$ +This routine has been deprecated, use $cref compare_change$$ +instead. + +$head Purpose$$ +We use $latex F : B^n \rightarrow B^m$$ to denote the +$cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. +This function may be not agree with the algorithm that was used +to create the corresponding +AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ +because of changes in AD +$cref/comparison/Compare/$$ results. +The $code CompareChange$$ function can be used to detect these changes. + +$head f$$ +The object $icode f$$ has prototype +$codei% + const ADFun<%Base%> %f% +%$$ + +$head c$$ +The result $icode c$$ has prototype +$codei% + size_t %c% +%$$ +It is the number of +$codei%AD<%Base%>%$$ $cref/comparison/Compare/$$ +operations, +corresponding to the previous call to $cref Forward$$ +$codei% + %f%.Forward(0, %x%) +%$$ +that have a different result from +when $icode F$$ was created by taping an algorithm. + +$head Discussion$$ +If $icode c$$ is not zero, +the boolean values resulting from some of the +$cref/comparison operations/Compare/$$ corresponding to $icode x$$ +are different from when the +AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ was created. +In this case, you may want to re-tape the algorithm with the +$cref/independent variables/glossary/Tape/Independent Variable/$$ +equal to the values in $icode x$$ +(so AD operation sequence properly represents the algorithm +for this value of independent variables). +On the other hand, re-taping the AD operation sequence usually takes +significantly more time than evaluation using $cref forward_zero$$. +If the functions values have not changed (see $cref FunCheck$$) +it may not be worth re-taping a new AD operation sequence. + + +$end diff -Nru cppad-2015.00.00.9/omh/deprecated/deprecated.omh cppad-2016.00.00.1/omh/deprecated/deprecated.omh --- cppad-2015.00.00.9/omh/deprecated/deprecated.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/deprecated/deprecated.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: deprecated.omh 2859 2013-05-28 06:03:21Z bradbell $ */ +// $Id: deprecated.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,25 +20,28 @@ $childtable% omh/deprecated/include_deprecated.omh% omh/deprecated/fun_deprecated.omh% + omh/deprecated/compare_change.omh% cppad/local/omp_max_thread.hpp% - cppad/track_new_del.hpp% + cppad/utility/track_new_del.hpp% omh/deprecated/omp_alloc.omh% - cppad/memory_leak.hpp% + cppad/utility/memory_leak.hpp% cppad/local/epsilon.hpp% cppad/local/test_vector.hpp% cppad_ipopt/src/cppad_ipopt_nlp.hpp% - cppad/local/old_atomic.hpp + cppad/local/old_atomic.hpp% + cppad/local/zdouble.hpp %$$ $table -$cref/CppADCreateUnaryBool/BoolFun/Deprecated/$$ $cnext - $title BoolFun$$ +$cref/CppADCreateUnaryBool/BoolFun/Deprecated 2007-07-31/$$ $cnext + $title BoolFun$$ $rnext -$cref/CppADCreateDiscrete/Discrete/Deprecated/$$ $cnext +$cref/CppADCreateDiscrete/Discrete/CppADCreateDiscrete Deprecated 2007-07-28/$$ $cnext $title Discrete$$ $rnext -$cref InstallUnix$$ $cnext - $title InstallUnix$$ +$cref auto_tools$$ $cnext $title auto_tools$$ +$rnext +$cref/nan(zero)/nan/nan(zero)/$$ $cnext $codei%nan(%zero%)%$$ $tend diff -Nru cppad-2015.00.00.9/omh/deprecated/fun_deprecated.omh cppad-2016.00.00.1/omh/deprecated/fun_deprecated.omh --- cppad-2015.00.00.9/omh/deprecated/fun_deprecated.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/deprecated/fun_deprecated.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,16 +1,16 @@ -$Id: fun_deprecated.omh 3214 2014-03-18 20:50:38Z bradbell $ +$Id: fun_deprecated.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin FunDeprecated$$ -$spell +$spell bool VecAD CppAD @@ -47,14 +47,12 @@ version of CppAD. $head Dependent$$ -$index ADFun, Dependent$$ -$index Dependent, ADFun$$ A recording of and AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ is started by a call of the form $codei% Independent(%x%) -%$$ +%$$ If there is only one such recording at the current time, you can use $icode%f%.Dependent(%y%)%$$ in place of $codei% @@ -62,49 +60,45 @@ %$$ See $cref Dependent$$ for a description of this operation. -$subhead Deprecated$$ +$subhead Deprecated 2007-08-07$$ This syntax was deprecated when CppAD was extended to allow for more than one $codei%AD<%Base%>%$$ recording to be -active at one time. +active at one time. This was necessary to allow for multiple threading applications. $head Order$$ -$index ADFun, Order$$ -$index Order, ADFun$$ -The result $icode o$$ has prototype +The result $icode o$$ has prototype $codei% size_t %o% %$$ and is the order of the previous forward operation using the function $icode f$$. -This is the highest order of the +This is the highest order of the $cref/Taylor coefficients/glossary/Taylor Coefficient/$$ that are currently stored in $icode f$$. -$subhead Deprecated$$ +$subhead Deprecated 2006-03-31$$ Zero order corresponds to function values being stored in $icode f$$. In the future, we would like to be able to erase the function -values so that $icode f$$ uses less memory. +values so that $icode f$$ uses less memory. In this case, the return value of $code Order$$ would not make sense. -Use $cref size_order$$ to obtain +Use $cref size_order$$ to obtain the number of Taylor coefficients currently stored -in the ADFun object $icode f$$ +in the ADFun object $icode f$$ (which is equal to the order plus one). $head Memory$$ -$index ADFun, Memory$$ -$index Memory, ADFun$$ -The result +The result $codei% size_t %m% %$$ and is the number of memory units ($code sizeof$$) required for the information currently stored in $icode f$$. -This memory is returned to the system when the destructor for +This memory is returned to the system when the destructor for $icode f$$ is called. -$subhead Deprecated$$ +$subhead Deprecated 2006-03-31$$ It used to be the case that an ADFun object just kept increasing its buffers to the maximum size necessary during its lifetime. It would then return the buffers to the system when its destructor @@ -114,8 +108,6 @@ Thus the $code Memory$$ function is no longer well defined. $head Size$$ -$index ADFun, Size$$ -$index Size, ADFun$$ The result $icode s$$ has prototype $codei% size_t %s% @@ -126,16 +118,14 @@ The amount of work and memory necessary for computing function values and derivatives using $icode f$$ is roughly proportional to $icode s$$. -$subhead Deprecated$$ +$subhead Deprecated 2006-04-03$$ There are other sizes attached to an ADFun object, for example, the number of operations in the sequence. In order to avoid confusion with these other sizes, -use $cref/size_var/seq_property/size_var/$$ to obtain +use $cref/size_var/seq_property/size_var/$$ to obtain the number of variables in the operation sequence. $head taylor_size$$ -$index ADFun, taylor_size$$ -$index taylor_size, ADFun$$ The result $icode t$$ has prototype $codei% size_t %t% @@ -143,12 +133,10 @@ and is the number of Taylor coefficient orders currently calculated and stored in the ADFun object $icode f$$. -$subhead Deprecated$$ +$subhead Deprecated 2006-06-17$$ This function has been replaced by $cref size_order$$. $head use_VecAD$$ -$index ADFun, use_VecAD$$ -$index use_VecAD, ADFun$$ The result $icode u$$ has prototype $codei% bool %u% @@ -156,19 +144,17 @@ If it is true, the AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ -stored in $icode f$$ contains +stored in $icode f$$ contains $cref/VecAD/VecAD/VecAD::reference/$$ operands. Otherwise $icode u$$ is false. -$subhead Deprecated$$ +$subhead Deprecated 2006-04-08$$ You can instead use $codei% %u% = %f%.size_VecAD() > 0 %$$ $head size_taylor$$ -$index ADFun, size_taylor$$ -$index size_taylor, ADFun$$ The result $icode v$$ has prototype $codei% size_t %v% @@ -176,12 +162,10 @@ and is the number of Taylor coefficient orders currently calculated and stored in the ADFun object $icode f$$. -$subhead Deprecated$$ +$subhead Deprecated 2014-03-18$$ This function has been replaced by $cref size_order$$. $head capacity_taylor$$ -$index ADFun, capacity_taylor$$ -$index capacity_taylor, ADFun$$ The result $icode w$$ has prototype $codei% size_t %w% @@ -189,7 +173,7 @@ and is the number of Taylor coefficient orders currently allocated in the ADFun object $icode f$$. -$subhead Deprecated$$ +$subhead Deprecated 2014-03-18$$ This function has been replaced by $cref capacity_order$$. diff -Nru cppad-2015.00.00.9/omh/deprecated/include_deprecated.omh cppad-2016.00.00.1/omh/deprecated/include_deprecated.omh --- cppad-2015.00.00.9/omh/deprecated/include_deprecated.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/deprecated/include_deprecated.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: include_deprecated.omh 2652 2012-12-27 03:54:50Z bradbell $ +$Id: include_deprecated.omh 3762 2015-12-01 14:35:37Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,13 +27,19 @@ $section Deprecated Include Files$$ -$index deprecated, include file$$ -$index include, deprecated file$$ -$index file, deprecated include$$ - -$head Purpose$$ -The following is a list of deprecated include file names -and the corresponding names that should be used. +$head Deprecated 2015-11-30$$ +The $cref utility$$ individual include files have been deprecated; e.g., +$codep + # include +$$ +You should instead use +$codep + # include +$$ + +$head Deprecated 2006-12-17$$ +The following is a list of deprecated include file names +and the corresponding names that should be used. For example, if your program uses the deprecated preprocessor command $codep # include @@ -49,22 +55,22 @@ $codei% # include %$$ -will refer to the older versions of CppAD unless you preform the +will refer to the older versions of CppAD unless you preform the following steps (this only needs to be done once, not for every install): $codei% cp %prefix_dir%/include sudo mv CppAD CppAD.old sudo ln -s cppad CppAD %$$ -where -$cref/prefix_dir/InstallUnix/prefix_dir/$$ +where +$cref/prefix_dir/auto_tools/prefix_dir/$$ is the prefix directory corresponding to your -$cref/Unix installation/InstallUnix/$$. +$cref/Unix installation/auto_tools/$$. This will link form the deprecated commands to the commands that should be used: $table -$bold Deprecated$$ $pre $$ $cnext $bold Should Use$$ +$bold Deprecated$$ $pre $$ $cnext $bold Should Use$$ $pre $$ $cnext $bold Documentation$$ $rnext @@ -120,6 +126,10 @@ $pre $$ $cnext $cref Poly$$ $rnext +CppAD/PowInt.h $pre $$ $cnext cppad/pow_int.hpp + $pre $$ $cnext $cref pow_int$$ +$rnext + CppAD/RombergMul.h $pre $$ $cnext cppad/romberg_mul.hpp $pre $$ $cnext $cref RombergMul$$ $rnext diff -Nru cppad-2015.00.00.9/omh/deprecated/omp_alloc.omh cppad-2016.00.00.1/omh/deprecated/omp_alloc.omh --- cppad-2015.00.00.9/omh/deprecated/omp_alloc.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/deprecated/omp_alloc.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: omp_alloc.omh 2652 2012-12-27 03:54:50Z bradbell $ */ +// $Id: omp_alloc.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,16 +12,13 @@ $begin omp_alloc$$ $spell openmp - cppad/omp_alloc.hpp + cppad/utility/omp_alloc.hpp CppAD $$ $section A Quick OpenMP Memory Allocator Used by CppAD$$ +$mindex multi-threading allocation$$ -$index multi-threading, memory allocation$$ -$index openmp, memory allocation$$ -$index memory, multi-threading allocation$$ -$index allocation, multi-threading$$ $head Syntax$$ $code # include $$ @@ -32,7 +29,7 @@ Once memory is obtained for a thread, the $code omp_alloc$$ memory allocator keeps that memory $cref omp_available$$ for the thread so that it can be re-used without waiting for a lock. -All the CppAD memory allocations use this utility. +All the CppAD memory allocations use this utility. The $cref omp_free_available$$ function should be used to return memory to the system (once it is no longer required by a thread). @@ -42,9 +39,12 @@ $code cppad/cppad.hpp$$, but it can also be included separately with out the rest of the $code CppAD$$. +$head Deprecated 2011-08-23$$ +Use $cref thread_alloc$$ instead. + $childtable% - cppad/omp_alloc.hpp% - example/omp_alloc.cpp + cppad/utility/omp_alloc.hpp% + test_more/omp_alloc.cpp %$$ $end diff -Nru cppad-2015.00.00.9/omh/det_33_hpp.omh cppad-2016.00.00.1/omh/det_33_hpp.omh --- cppad-2015.00.00.9/omh/det_33_hpp.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/det_33_hpp.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: det_33_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: det_33_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: det_33$$ +$mindex source$$ -$index det_33, source$$ -$index source, det_33$$ $code -# ifndef CPPAD_DET_33_INCLUDED +# ifndef CPPAD_DET_33_HPP $pre $$ -# define CPPAD_DET_33_INCLUDED +# define CPPAD_DET_33_HPP $verbatim%cppad/speed/det_33.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/det_by_lu_hpp.omh cppad-2016.00.00.1/omh/det_by_lu_hpp.omh --- cppad-2015.00.00.9/omh/det_by_lu_hpp.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/det_by_lu_hpp.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: det_by_lu_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: det_by_lu_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: det_by_lu$$ +$mindex source$$ -$index det_by_lu, source$$ -$index source, det_by_lu$$ $code -# ifndef CPPAD_DET_BY_LU_INCLUDED +# ifndef CPPAD_DET_BY_LU_HPP $pre $$ -# define CPPAD_DET_BY_LU_INCLUDED +# define CPPAD_DET_BY_LU_HPP $verbatim%cppad/speed/det_by_lu.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/det_by_minor_hpp.omh cppad-2016.00.00.1/omh/det_by_minor_hpp.omh --- cppad-2015.00.00.9/omh/det_by_minor_hpp.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/det_by_minor_hpp.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: det_by_minor_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: det_by_minor_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: det_by_minor$$ +$mindex source$$ -$index det_by_minor, source$$ -$index source, det_by_minor$$ $code -# ifndef CPPAD_DET_BY_MINOR_INCLUDED +# ifndef CPPAD_DET_BY_MINOR_HPP $pre $$ -# define CPPAD_DET_BY_MINOR_INCLUDED +# define CPPAD_DET_BY_MINOR_HPP $verbatim%cppad/speed/det_by_minor.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/det_grad_33_hpp.omh cppad-2016.00.00.1/omh/det_grad_33_hpp.omh --- cppad-2015.00.00.9/omh/det_grad_33_hpp.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/det_grad_33_hpp.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: det_grad_33_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: det_grad_33_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: det_grad_33$$ +$mindex source$$ -$index det_grad_33, source$$ -$index source, det_grad_33$$ $code -# ifndef CPPAD_DET_GRAD_33_INCLUDED +# ifndef CPPAD_DET_GRAD_33_HPP $pre $$ -# define CPPAD_DET_GRAD_33_INCLUDED +# define CPPAD_DET_GRAD_33_HPP $verbatim%cppad/speed/det_grad_33.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/det_of_minor_hpp.omh cppad-2016.00.00.1/omh/det_of_minor_hpp.omh --- cppad-2015.00.00.9/omh/det_of_minor_hpp.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/det_of_minor_hpp.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: det_of_minor_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: det_of_minor_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: det_of_minor$$ +$mindex source$$ -$index det_of_minor, source$$ -$index source, det_of_minor$$ $code -# ifndef CPPAD_DET_OF_MINOR_INCLUDED +# ifndef CPPAD_DET_OF_MINOR_HPP $pre $$ -# define CPPAD_DET_OF_MINOR_INCLUDED +# define CPPAD_DET_OF_MINOR_HPP $verbatim%cppad/speed/det_of_minor.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/example_list.omh cppad-2016.00.00.1/omh/example_list.omh --- cppad-2015.00.00.9/omh/example_list.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/example_list.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: example_list.omh 3526 2014-12-29 21:56:45Z bradbell $ +$Id: example_list.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,15 +17,13 @@ Cpp $$ -$index example, general$$ -$index general, example$$ -$index realistic, example$$ -$section General Examples$$ +$section General Examples$$ +$mindex realistic$$ $head Description$$ Most of the examples in CppAD are part of the documentation -for a specific feature; for example, $cref add.cpp$$ is an +for a specific feature; for example, $cref add.cpp$$ is an example using the $cref/addition operator/ad_binary/$$. The examples list in this section are of a more general nature. @@ -61,18 +59,18 @@ example/example.cpp% speed/example/example.cpp% example/lu_vec_ad.cpp -%$$ +%$$ $end ----------------------------------------------------------------------------- $begin ListAllExamples$$ -$spell +$spell CppAD $$ $section List of All the CppAD Examples$$ -$comment +$comment omit: TestOne.cpp OneCase.cpp lu_vec_ad.cpp $$ @@ -82,45 +80,55 @@ $rref a11c_pthread.cpp$$ $rref abort_recording.cpp$$ $rref Abs.cpp$$ -$rref Acos.cpp$$ +$rref acos.cpp$$ +$rref acosh.cpp$$ $rref add.cpp$$ $rref AddEq.cpp$$ $rref ad_assign.cpp$$ $rref ad_ctor.cpp$$ $rref ad_fun.cpp$$ -$rref ad_in_c.cpp$$ $rref ad_input.cpp$$ +$rref ad_in_c.cpp$$ $rref ad_output.cpp$$ -$rref Asin.cpp$$ -$rref atan2.cpp$$ +$rref asin.cpp$$ +$rref asinh.cpp$$ $rref atan.cpp$$ +$rref atan2.cpp$$ +$rref atanh.cpp$$ $rref atomic_get_started.cpp$$ +$rref atomic_hes_sparse.cpp$$ $rref atomic_matrix_mul.hpp$$ $rref atomic_mat_mul.cpp$$ -$cref atomic_norm_sq.cpp$$ -$cref atomic_reciprocal.cpp$$ -$cref atomic_tangent.cpp$$ +$rref atomic_norm_sq.cpp$$ +$rref atomic_reciprocal.cpp$$ +$rref atomic_sparsity.cpp$$ +$rref atomic_tangent.cpp$$ +$rref azmul.cpp$$ $rref base_adolc.hpp$$ $rref base_alloc.hpp$$ $rref base_complex.hpp$$ $rref base_require.cpp$$ $rref bender_quad.cpp$$ $rref bool_fun.cpp$$ +$rref bool_sparsity.cpp$$ $rref capacity_order.cpp$$ -$rref change_const.cpp$$ +$rref change_param.cpp$$ +$rref checkpoint.cpp$$ $rref check_for_nan.cpp$$ $rref check_numeric_type.cpp$$ $rref check_simple_vector.cpp$$ -$rref checkpoint.cpp$$ -$rref colpack.cpp$$ -$rref compare_change.cpp$$ +$rref colpack_hes.cpp$$ +$rref colpack_jac.cpp$$ $rref compare.cpp$$ +$rref compare_change.cpp$$ $rref complex_poly.cpp$$ $rref cond_exp.cpp$$ $rref conj_grad.cpp$$ $rref cos.cpp$$ $rref cosh.cpp$$ +$rref cppad_eigen.hpp$$ $rref cppad_vector.cpp$$ +$rref dependency.cpp$$ $rref det_by_lu.cpp$$ $rref det_by_minor.cpp$$ $rref det_of_minor.cpp$$ @@ -128,27 +136,31 @@ $rref div_eq.cpp$$ $rref eigen_array.cpp$$ $rref eigen_det.cpp$$ +$rref eigen_plugin.hpp$$ +$rref elapsed_seconds.cpp$$ $rref equal_op_seq.cpp$$ $rref erf.cpp$$ $rref error_handler.cpp$$ $rref example.cpp$$ $rref exp.cpp$$ -$rref for_one.cpp$$ -$rref for_sparse_jac.cpp$$ -$rref for_two.cpp$$ +$rref expm1.cpp$$ +$rref expm1.cpp$$ $rref forward.cpp$$ $rref forward_dir.cpp$$ $rref forward_order.cpp$$ +$rref for_one.cpp$$ +$rref for_sparse_jac.cpp$$ +$rref for_two.cpp$$ $rref fun_assign.cpp$$ $rref fun_check.cpp$$ $rref get_started.cpp$$ $rref harmonic.cpp$$ $rref harmonic_time.cpp$$ $rref harmonic_work.cpp$$ +$rref hessian.cpp$$ $rref hes_lagrangian.cpp$$ $rref hes_lu_det.cpp$$ $rref hes_minor_det.cpp$$ -$rref hessian.cpp$$ $rref hes_times_dir.cpp$$ $rref independent.cpp$$ $rref index_sort.cpp$$ @@ -156,43 +168,43 @@ $rref interface2c.cpp$$ $rref interp_onetape.cpp$$ $rref interp_retape.cpp$$ -$rref ipopt_solve_get_started.cpp$$ -$rref ipopt_solve_ode_inverse.cpp$$ -$rref ipopt_solve_retape.cpp$$ +$rref ipopt_solve_get_started.cpp$$ +$rref ipopt_solve_ode_inverse.cpp$$ +$rref ipopt_solve_retape.cpp$$ +$rref jacobian.cpp$$ $rref jac_lu_det.cpp$$ $rref jac_minor_det.cpp$$ -$rref jacobian.cpp$$ -$rref limits.cpp$$ -$rref log10.cpp$$ $rref log.cpp$$ +$rref log10.cpp$$ +$rref log1p.cpp$$ $rref lu_factor.cpp$$ $rref lu_invert.cpp$$ $rref lu_ratio.cpp$$ $rref lu_solve.cpp$$ $rref lu_vec_ad_ok.cpp$$ +$rref mat_sum_sq.cpp$$ $rref mul.cpp$$ +$rref multi_newton.cpp$$ +$rref multi_newton_time.cpp$$ +$rref multi_newton_work.cpp$$ $rref mul_eq.cpp$$ +$rref mul_level.cpp$$ $rref mul_level_adolc.cpp$$ $rref mul_level_adolc_ode.cpp$$ -$rref mul_level.cpp$$ $rref mul_level_ode.cpp$$ -$rref multi_newton.cpp$$ -$rref multi_newton_time.cpp$$ -$rref multi_newton_work.cpp$$ $rref nan.cpp$$ $rref near_equal.cpp$$ $rref near_equal_ext.cpp$$ $rref number_skip.cpp$$ $rref numeric_type.cpp$$ +$rref num_limits.cpp$$ $rref ode_err_control.cpp$$ $rref ode_err_maxabs.cpp$$ $rref ode_evaluate.cpp$$ -$rref ode_gear_control.cpp$$ $rref ode_gear.cpp$$ +$rref ode_gear_control.cpp$$ $rref ode_stiff.cpp$$ $rref ode_taylor.cpp$$ -$rref old_reciprocal.cpp$$ -$rref omp_alloc.cpp$$ $rref optimize.cpp$$ $rref opt_val_hes.cpp$$ $rref par_var.cpp$$ @@ -221,16 +233,20 @@ $rref simple_vector.cpp$$ $rref sin.cpp$$ $rref sinh.cpp$$ -$rref sparse_hes_fun.cpp$$ $rref sparse_hessian.cpp$$ -$rref sparse_jac_fun.cpp$$ +$rref sparse_hes_fun.cpp$$ $rref sparse_jacobian.cpp$$ +$rref sparse_jac_fun.cpp$$ +$rref sparse_sub_hes.cpp$$ +$rref sparsity_sub.cpp$$ +$rref speed_example.cpp$$ $rref speed_program.cpp$$ $rref speed_test.cpp$$ $rref sqrt.cpp$$ $rref stack_machine.cpp$$ $rref sub.cpp$$ $rref sub_eq.cpp$$ +$rref sub_sparse_hes.cpp$$ $rref tan.cpp$$ $rref tanh.cpp$$ $rref tape_index.cpp$$ @@ -241,17 +257,14 @@ $rref team_thread.hpp$$ $rref thread_alloc.cpp$$ $rref thread_test.cpp$$ +$rref time_test.cpp$$ +$rref to_string.cpp$$ $rref unary_minus.cpp$$ $rref unary_plus.cpp$$ -$rref old_mat_mul.cpp$$ -$rref old_mat_mul.hpp$$ -$rref old_usead_1.cpp$$ -$rref old_usead_2.cpp$$ -$rref old_tan.cpp$$ $rref value.cpp$$ $rref var2par.cpp$$ -$rref vec_ad.cpp$$ $rref vector_bool.cpp$$ +$rref vec_ad.cpp$$ $tend $end diff -Nru cppad-2015.00.00.9/omh/example.omh cppad-2016.00.00.1/omh/example.omh --- cppad-2015.00.00.9/omh/example.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/example.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: example.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: example.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,13 +25,12 @@ $$ $section Examples$$ -$index example$$ $head Introduction$$ This section organizes the information related to the CppAD examples. Each CppAD operation has its own specific example, -for example $cref add.cpp$$ is an example for +for example $cref add.cpp$$ is an example for $cref/addition/ad_binary/$$. Some of the examples are of a more general nature (not connected of a specific feature of CppAD). @@ -39,16 +38,16 @@ by the examples. $head Running Examples$$ -The +The $cref/installation instructions/Install/$$ show how the examples can be run on your system. $head The CppAD Test Vector Template Class$$ -Many of the examples use the -$small $cref/CPPAD_TESTVECTOR/testvector/$$ $$ preprocessor symbol +Many of the examples use the +$small $cref/CPPAD_TESTVECTOR/testvector/$$ $$ preprocessor symbol to determine which $cref SimpleVector$$ template class is used with -the examples. +the examples. $contents% diff -Nru cppad-2015.00.00.9/omh/faq.omh cppad-2016.00.00.1/omh/faq.omh --- cppad-2015.00.00.9/omh/faq.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/faq.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: faq.omh 3526 2014-12-29 21:56:45Z bradbell $ +$Id: faq.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,13 +27,10 @@ Lu $$ -$index FAQ$$ $section Frequently Asked Questions and Answers$$ +$mindex FAQ operator reporting ErrorHandler avoid record taping mode CPPAD_TESTVECTOR standard math function storage$$ $head Assignment and Independent$$ -$index assignment, operator$$ -$index operator, assignment$$ -$index independent$$ Why does the code sequence $codei% Independent(%u%); @@ -51,7 +48,6 @@ and in the second case it is a parameter. $head Bugs$$ -$index bugs, reporting$$ What should I do if I suspect that there is a bug in CppAD ? $pre @@ -63,29 +59,30 @@ If this does not solve your problem, continue to the next step. $lnext -The second step is to check the -$cref whats_new$$ messages from the date +The second step is to check the +$cref whats_new$$ messages from the date of the release that you are using to the current date. If the bug has been mentioned and fixed, then $cref install$$ the current version of CppAD. If this does not solve your problem, continue to the next step. $lnext -Send an e-mail message to the mailing list +Create a simple as possible demonstration of the bug; +see the file $code bug/template.sh$$ for a template that you can +edit for that purpose. +The smaller the program, the better the bug report. +$lnext +Send an e-mail message to the mailing list $href% http://list.coin-or.org/mailman/listinfo/cppad% cppad@list.coin-or.org %$$ with a description of the bug. -Attaching a small source code sample program that -demonstrates the bug is always helpful. -The smaller the program, the better the bug report. +Attaching your program that demonstrates the bug. $lend $head CompareChange$$ -$index CompareChange$$ -$index NDEBUG$$ -If you attempt to use the +If you attempt to use the $cref CompareChange$$ function when $code NDEBUG$$ is true, you will get an error message stating that @@ -93,7 +90,6 @@ $cref ADFun$$ template class. $head Complex Types$$ -$index complex, faq$$ Which of the following complex types is better: $codei% AD< std::complex<%Base%> > @@ -106,16 +102,13 @@ $codei% std::complex< AD<%Base%> > %$$ -On the other hand, the C++ standard only specifies -$codei%std::complex<%Type%>%$$ where $icode Type$$ is +On the other hand, the C++ standard only specifies +$codei%std::complex<%Type%>%$$ where $icode Type$$ is $code float$$, $code double$$, or $code lone double$$. -The effect of instantiating the template complex for any other type -is unspecified. +The effect of instantiating the template complex for any other type +is unspecified. $head Exceptions$$ -$index test, exception$$ -$index exception, test$$ -$index ErrorHandler$$ Why, in all the examples, do you pass back a boolean variable instead of throwing an exception ? $pre @@ -130,57 +123,30 @@ Specifications for redefining this action are provided. $head Independent Variables$$ -$index independent variable$$ -$index tape, avoid$$ -$index record, avoid$$ -$index speed, avoid taping$$ -Is it possible to evaluate the same tape recording with different values +Is it possible to evaluate the same tape recording with different values for the independent variables ? $pre $$ -Yes (see $cref forward_zero$$). - -$head Math Functions$$ -$index math, functions$$ -$index function, math$$ -Are there plans to add more math functions to CppAD ? -$pre - -$$ -Yes. The $cref std_math_ad$$ and $cref MathOther$$ section contains -a list of the math functions included so far. -Contact the mailing list -$href% - http://list.coin-or.org/mailman/listinfo/cppad% - cppad@list.coin-or.org -%$$ -if you need a math function that is has not yet been included. - - +Yes (see $cref forward_zero$$). $head Matrix Inverse$$ -$index inverse, matrix$$ -$index matrix, inverse$$ Is it possible to differentiate (with respect to the matrix elements) -the computation of the inverse of a matrix -where the computation of the inverse uses pivoting ? +the computation of the inverse of a matrix +where the computation of the inverse uses pivoting ? $pre $$ The example routine $cref LuSolve$$ can be used to do this because the inverse is a special case of the solution of linear equations. -The examples +The examples $cref jac_lu_det.cpp$$ and $cref hes_lu_det.cpp$$ -use LuSolve to compute derivatives of the +use LuSolve to compute derivatives of the determinant with respect to the components of the matrix. $head Mode: Forward or Reverse$$ -$index forward$$ -$index reverse$$ -$index mode$$ -When evaluating derivatives, -one always has a choice between +When evaluating derivatives, +one always has a choice between forward and reverse mode. How does one decide which mode to use ? $pre @@ -188,32 +154,28 @@ $$ In general, the best mode depends on the number of domain and range components in the function that your are differentiating. -Each call to $cref Forward$$ computes the derivative of all +Each call to $cref Forward$$ computes the derivative of all the range directions with respect to one domain direction. -Each call to $cref Reverse$$ computes the derivative of one +Each call to $cref Reverse$$ computes the derivative of one range direction with respect to all the domain directions. -The times required for (speed of) -calls $code Forward$$ and $code Reverse$$ are about equal. -The $cref/Parameter/seq_property/Parameter/$$ -function can be used to quickly determine that +The times required for (speed of) +calls $code Forward$$ and $code Reverse$$ are about equal. +The $cref/Parameter/seq_property/Parameter/$$ +function can be used to quickly determine that some range directions have derivative zero. $head Namespace$$ -$index namespace$$ $subhead Test Vector Preprocessor Symbol$$ -$index CPPAD_TESTVECTOR$$ -$index preprocessor, symbols$$ -$index symbols, preprocessor$$ Why do you use $code CPPAD_TESTVECTOR$$ instead of a namespace for the CppAD $cref testvector$$ class ? $pre $$ -The preprocessor symbol +The preprocessor symbol $small $cref/CPPAD_TESTVECTOR/testvector/$$ $$ determines which $cref SimpleVector$$ template class is used for extensive testing. @@ -224,14 +186,11 @@ (some old deprecated symbols begin with $code CppAD$$). $subhead Using$$ -$index standard, math function$$ -$index math, standard function$$ -$index using, namespace$$ Why do I have trouble when the following command $codep using namespace CppAD $$ -is at the global level +is at the global level (not within a function or some other limited scope). $pre @@ -246,8 +205,6 @@ in order to shadow these improper global definitions. $head Speed$$ -$index speed$$ -$index NDEBUG$$ How do I get the best speed performance out of CppAD ? $subhead NDEBUG$$ @@ -256,10 +213,10 @@ (The $cref speed_cppad$$ tests do this.) Note that defining $code NDEBUG$$ will turn off all of the error checking and reporting that -is done using $cref ErrorHandler$$. +is done using $cref ErrorHandler$$. $subhead Optimize$$ -It is also possible that preforming a tape +It is also possible that preforming a tape $cref/optimization/optimize/$$ will improve the speed of evaluation more than the time required for the optimization. @@ -269,10 +226,6 @@ $cref/value/ta_hold_memory/value/$$ equal to true. $head Tape Storage: Disk or Memory$$ -$index storage, tape$$ -$index tape, storage$$ -$index memory, tape$$ -$index disk, tape$$ Does CppAD store the tape on disk or in memory ? $pre @@ -281,7 +234,7 @@ for each $codei%AD<%Base%>%$$ type that is used. If you have a very large number calculations that are recorded on a tape, the tape will keep growing to hold the necessary information. -Eventually, virtual memory may be used to store the tape +Eventually, virtual memory may be used to store the tape and the calculations may slow down because of necessary disk access. diff -Nru cppad-2015.00.00.9/omh/forward/compare_change.omh cppad-2016.00.00.1/omh/forward/compare_change.omh --- cppad-2015.00.00.9/omh/forward/compare_change.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/forward/compare_change.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,99 +1,158 @@ -/* $Id: compare_change.omh 3173 2014-03-09 17:09:49Z bradbell $ */ +// $Id: compare_change.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -$begin CompareChange$$ -$spell +$begin compare_change$$ +$spell + op const $$ -$section Comparison Changes During Zero Order Forward Mode$$ +$section Comparison Changes Between Taping and Zero Order Forward$$ +$mindex ADFun compare_change$$ -$index ADFun, CompareChange$$ -$index CompareChange, ADFun$$ -$index zero, order forward$$ -$index forward, zero order$$ $head Syntax$$ -$icode%c% = %f%.CompareChange()%$$ -$pre -$$ +$icode%f%.compare_change_count(%count%) +%$$ +$icode%number% = %f%.compare_change_number() +%$$ +$icode%op_index% = %f%.compare_change_op_index() + +%$$ $bold See Also$$ $cref FunCheck$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the -$cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. -This function may be not agree with the algorithm that was used -to create the corresponding -AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$ -because of changes in AD -$cref/comparison/Compare/$$ results. -The $code CompareChange$$ function can be used to detect these changes. +$cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$; i.e, +given $latex x \in B^n$$, $latex F(x)$$ is defined by +$codei% + %F%(%x%) = %f%.Forward(0, %x%) +%$$ +see $cref forward_zero$$. +If $latex x$$ is such that +all the algorithm $cref/comparison/Compare/$$ operations +have the same result as when the algorithm was taped, +The function $latex F(x)$$ and the algorithm will have the same values. +(This is a sufficient, but not necessary condition). + + + + $head f$$ -The object $icode f$$ has prototype +In the $code compare_change_number$$ and $code compare_change_op_index$$ +syntax, the object $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ +In the $code compare_change_count$$ +syntax, the object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ -$head c$$ -The result $icode c$$ has prototype +$head count$$ +The argument $icode count$$ has prototype +$icode% + size_t %count% +%$$ +It specifies which comparison change should correspond to the +information stored in $icode f$$ during subsequent calls to +$cref forward_zero$$; i.e., $codei% - size_t %c% + %f%.Forward(0, %x%) %$$ -It is the number of -$codei%AD<%Base%>%$$ $cref/comparison/Compare/$$ -operations, -corresponding to the previous call to $cref Forward$$ +For example, if $icode%count% == 1%$$, +the operator index corresponding to the first comparison change +will be stored. +This is the default value used if $icode count$$ is not specified. + +$subhead Speed$$ +The special case where $icode count == 0$$, should be faster because +the comparisons are not checked during $codei% %f%.Forward(0, %x%) %$$ -that have a different result from -when $icode F$$ was created by taping an algorithm. -$head Discussion$$ -If $icode c$$ is not zero, -the boolean values resulting from some of the -$cref/comparison operations/Compare/$$ corresponding to $icode x$$ -are different from when the -AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$ was created. -In this case, you may want to re-tape the algorithm with the -$cref/independent variables/glossary/Tape/Independent Variable/$$ -equal to the values in $icode x$$ -(so AD operation sequence properly represents the algorithm -for this value of independent variables). -On the other hand, re-taping the AD operation sequence usually takes +$head number$$ +The return value $icode number$$ has prototype +$codei% + size_t %number% +%$$ +If $icode count$$ is non-zero, +$icode number$$ is the number of +$codei%AD<%Base%>%$$ $cref/comparison/Compare/$$ operations, +corresponding to the previous call to +$codei% + %f%.Forward(0, %x%) +%$$ +that have a different result for this value of $icode x$$ +than the value used when $icode f$$ was created by taping an algorithm. +If $icode count$$ is zero, +or if no calls to $icode%f%.Forward(0, %x%)%$$ follow the previous +setting of $icode count$$, +$icode number$$ is zero. + +$subhead Discussion$$ +If $icode count$$ and $icode number$$ are non-zero, +you may want to re-tape the algorithm with the +$cref/independent variables/glossary/Tape/Independent Variable/$$ +equal to the values in $icode x$$, +so the AD operation sequence properly represents the algorithm +for this value of independent variables. +On the other hand, re-taping the AD operation sequence usually takes significantly more time than evaluation using $cref forward_zero$$. If the functions values have not changed (see $cref FunCheck$$) -it may not be worth re-taping a new AD operation sequence. +it may not be worth re-taping a new AD operation sequence. -$head Restrictions$$ -$index NDEBUG, CompareChange$$ -Computation of this function requires extra operations in the tape. -If $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined, -of if a tape $cref/optimization/optimize/$$ has been preformed, -these operations are not included in the tape and -the value of $icode c$$ is always zero (and does not correspond -to the actual number of comparison changes). +$head op_index$$ +The return value $icode op_index$$ has prototype +$codei% + size_t %op_index% +%$$ +If $icode count$$ is non-zero, +$icode op_index$$ is the operator index corresponding the +$icode count$$-th comparison change during the previous call to +$codei% + %f%.Forward(0, %x%) +%$$ +If $icode count$$ is greater than the corresponding +$icode number$$, there is no such comparison change and $icode op_index$$ +will also be zero. +If $icode count$$ is zero, +if the function $icode f$$ has been $cref/optimized/optimize/$$, +or if no calls to $icode%f%.Forward(0, %x%)%$$ follow the previous +setting of $icode count$$, +$icode op_index$$ is zero. + +$subhead Purpose$$ +The operator index can be used to generate an error during the taping +process so that the corresponding algorithm can be inspected. +In some cases, it is possible to re-design this part of the +algorithm to avoid the particular comparison operation. +For example, using an $cref/conditional expression/CondExp/$$ +may be appropriate in some cases. +See $cref/abort_op_index/Independent/abort_op_index/$$ in the syntax +$codei% + Independent(%x%, %abort_op_index%) +%$$ -$head Example$$ $children% example/compare_change.cpp %$$ -The file +$head Example$$ $cref compare_change.cpp$$ contains an example and test of this operation. -They return true if they succeed and false otherwise. +It returns true if they succeed and false otherwise. $end diff -Nru cppad-2015.00.00.9/omh/forward/forward_dir.omh cppad-2016.00.00.1/omh/forward/forward_dir.omh --- cppad-2015.00.00.9/omh/forward/forward_dir.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/forward/forward_dir.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_dir.omh 3301 2014-05-24 05:20:21Z bradbell $ */ +// $Id: forward_dir.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,24 +22,20 @@ ostream $$ -$section Multiple Directions Forward Mode$$ +$section Multiple Directions Forward Mode$$ -$index forward, mode$$ -$index mode, forward$$ -$index direction, multiple$$ -$index multiple, direction$$ $head Syntax$$ -$icode%yq% = %f%.Forward(%q%, %r%, %xq%) +$icode%yq% = %f%.Forward(%q%, %r%, %xq%) %$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. Given a function $latex X : B \rightarrow B^n$$, -defined by its +defined by its $cref/Taylor coefficients/glossary/Taylor Coefficient/$$, -forward mode computes the Taylor coefficients for the function +forward mode computes the Taylor coefficients for the function $latex \[ Y (t) = F [ X(t) ] \]$$ @@ -75,7 +71,7 @@ It specifies the order of Taylor Coefficient that we are calculating and must be greater than zero. The zero order coefficients can only have one direction computed -and stored in $icode f$$ so use $cref forward_zero$$ +and stored in $icode f$$ so use $cref forward_zero$$ to compute the zero order coefficients. $head r$$ @@ -97,14 +93,14 @@ (see $cref/Vector/forward_dir/Vector/$$ below). For $latex \ell = 0 , \ldots , r-1$$, $latex j = 0 , \ldots , n-1$$, -the $th j$$ component of the $th q$$ order Taylor coefficient +the $th j$$ component of the $th q$$ order Taylor coefficient for $latex X_\ell (t)$$ is defined by $pre $$ $latex x_j^{(q),\ell} = $$ $icode%xq%[ %r% * %j% + %ell% ]%$$ $head Zero Order$$ For $latex j = 0 , \ldots , n-1$$, -the $th j$$ component of the zero order Taylor coefficient +the $th j$$ component of the zero order Taylor coefficient for $latex X_\ell (t)$$ is defined by $pre $$ $latex x_j^{(0)} = $$ $icode%xk%[ %j% ]%$$ @@ -118,7 +114,7 @@ For $latex \ell = 0 , \ldots , r-1$$, $latex j = 0 , \ldots , n-1$$, $latex k = 1, \ldots , q-1$$, -the $th j$$ component of the $th k$$ order Taylor coefficient +the $th j$$ component of the $th k$$ order Taylor coefficient for $latex X_\ell (t)$$ is defined by $pre $$ $latex x_j^{(k),\ell} = $$ $icode%xk%[ %r% * %j% + %ell% ]%$$ @@ -134,14 +130,14 @@ the Taylor coefficients $latex x^{(k),\ell} \in B^n$$: $latex \[ X_\ell (t) = x^{(0)} + x^{(1),\ell} * t^1 + \cdots + x^{(q),\ell} t^q -\] $$ +\] $$ Note that the $th k$$ derivative of $latex X_\ell (t)$$ is related to -its Taylor coefficients by +its Taylor coefficients by $latex \[ \begin{array}{rcl} x^{(0)} & = & X_\ell (0) \\ - x^{(k), \ell} & = & \frac{1}{k !} X_\ell^{(k)} (0) + x^{(k), \ell} & = & \frac{1}{k !} X_\ell^{(k)} (0) \end{array} \] $$ for $latex k = 1 , \ldots , q$$. @@ -151,20 +147,20 @@ $latex Y_\ell : B \rightarrow B^m$$ is defined by $latex Y_\ell (t) = F[ X_\ell (t) ] $$. We use $latex y^{(0)}$$ for the zero order coefficient -and $latex y^{(k),\ell} \in B^m$$ to denote the +and $latex y^{(k),\ell} \in B^m$$ to denote the hight order coefficients; i.e., $latex \[ -Y_\ell (t) = y^{(0)} + y^{(1),\ell} * t^1 + \cdots + y^{(q),\ell} * t^q +Y_\ell (t) = y^{(0)} + y^{(1),\ell} * t^1 + \cdots + y^{(q),\ell} * t^q + o( t^q ) -\] $$ +\] $$ where $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. Note that the $th k$$ derivative of $latex Y_\ell (t)$$ is related to -its Taylor coefficients by +its Taylor coefficients by $latex \[ \begin{array}{rcl} y^{(0)} & = & Y_\ell (0) \\ - y^{(k), \ell} & = & \frac{1}{k !} Y_\ell^{(k)} (0) + y^{(k), \ell} & = & \frac{1}{k !} Y_\ell^{(k)} (0) \end{array} \] $$ for $latex k = 1 , \ldots , q$$. @@ -178,7 +174,7 @@ (see $cref/Vector/forward_dir/Vector/$$ below). For $latex \ell = 0 , \ldots , r-1$$, $latex i = 0 , \ldots , m-1$$, -the $th i$$ component of the $th q$$ order Taylor coefficient +the $th i$$ component of the $th q$$ order Taylor coefficient for $latex Y_\ell (t)$$ is given by $pre $$ $latex y_i^{(q),\ell} = $$ $icode%yq%[ %r% * %i% + %ell% ]%$$ diff -Nru cppad-2015.00.00.9/omh/forward/forward.omh cppad-2016.00.00.1/omh/forward/forward.omh --- cppad-2015.00.00.9/omh/forward/forward.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/forward/forward.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward.omh 3301 2014-05-24 05:20:21Z bradbell $ */ +// $Id: forward.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/omh/forward/forward_one.omh cppad-2016.00.00.1/omh/forward/forward_one.omh --- cppad-2015.00.00.9/omh/forward/forward_one.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/forward/forward_one.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_one.omh 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: forward_one.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,8 @@ $$ $section First Order Forward Mode: Derivative Values$$ +$mindex one$$ -$index Forward, order one$$ -$index one, order Forward$$ -$index order, one Forward$$ $head Syntax$$ @@ -33,8 +31,8 @@ $latex \[ y1 = F^{(1)} (x0) * x1 \] $$ -where $latex F^{(1)} (x0)$$ is the Jacobian of $latex F$$ -evaluated at $icode x0$$. +where $latex F^{(1)} (x0)$$ is the Jacobian of $latex F$$ +evaluated at $icode x0$$. $head f$$ The object $icode f$$ has prototype @@ -60,7 +58,7 @@ %f%.Forward(0, %x0%) %$$ If there is no previous call with the first argument zero, -the value of the $cref/independent/Independent/$$ variables +the value of the $cref/independent/Independent/$$ variables during the recording of the AD sequence of operations is used for $icode x0$$. @@ -92,11 +90,11 @@ \begin{array}{rcl} Y(t) & = & F[ X(t) ] \\ -X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) +X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) \\ -Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) +Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) \end{array} -\] $$ +\] $$ and $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. For this special case, $latex q = 1$$, $latex x^{(0)}$$ $codei%= %x0%$$, @@ -104,13 +102,13 @@ $latex X(t) = x^{(0)} + x^{(1)} t$$, and $latex \[ y^{(0)} + y^{(1)} t = F [ x^{(0)} + x^{(1)} t ] + o(t) -\] $$ -Taking the derivative with respect to $latex t$$, at $latex t = 0$$, +\] $$ +Taking the derivative with respect to $latex t$$, at $latex t = 0$$, we obtain $latex \[ y^{(1)} = F^{(1)} [ x^{(0)} ] x^{(1)} \] $$ -which agrees with the specifications for +which agrees with the specifications for $icode y1$$ in the $cref/purpose/forward_one/Purpose/$$ above. $end diff -Nru cppad-2015.00.00.9/omh/forward/forward_order.omh cppad-2016.00.00.1/omh/forward/forward_order.omh --- cppad-2015.00.00.9/omh/forward/forward_order.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/forward/forward_order.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_order.omh 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: forward_order.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,13 +25,9 @@ yq $$ -$section Multiple Order Forward Mode$$ +$section Multiple Order Forward Mode$$ +$mindex any$$ -$index forward, mode$$ -$index mode, forward$$ -$index order, any$$ -$index order, multiple$$ -$index multiple, order$$ $head Syntax$$ $icode%yq% = %f%.Forward(%q%, %xq% ) @@ -44,9 +40,9 @@ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. Given a function $latex X : B \rightarrow B^n$$, -defined by its +defined by its $cref/Taylor coefficients/glossary/Taylor Coefficient/$$, -forward mode computes the Taylor coefficients for the function +forward mode computes the Taylor coefficients for the function $latex \[ Y (t) = F [ X(t) ] \]$$ @@ -109,7 +105,7 @@ (see $cref/Vector/forward_order/Vector/$$ below). As above, we use $icode n$$ to denote the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. -The size of $icode xq$$ must be either $icode n$$ or +The size of $icode xq$$ must be either $icode n$$ or $icode%n%*(%q%+1)%$$. After this call we will have $codei% @@ -118,12 +114,12 @@ $subhead One Order$$ If $icode%xq%.size() == %n%$$, -the $th q$$ order Taylor coefficient for $latex X(t)$$ +the $th q$$ order Taylor coefficient for $latex X(t)$$ is defined by $pre $$ $latex x^{(q)} = $$ $icode xq$$. For $latex k = 0 , \ldots , q-1$$, -the Taylor coefficient $latex x^{(k)}$$ +the Taylor coefficient $latex x^{(k)}$$ is defined by $icode xk$$ in the previous call to $codei% %f%.Forward(%k%, %xk%) @@ -133,7 +129,7 @@ If $icode%xq%.size() == %n%*(%q%+1)%$$, For $latex k = 0 , \ldots , q$$, $latex j = 0 , \ldots , n-1$$, -the $th j$$ component of the $th k$$ order Taylor coefficient +the $th j$$ component of the $th k$$ order Taylor coefficient for $latex X(t)$$ is defined by $pre $$ $latex x_j^{(k)} = $$ $icode%%xq%[ (%q%+1) * %j% + %k% ]%$$ @@ -160,29 +156,29 @@ $latex X : B \rightarrow B^n$$ is defined using the Taylor coefficients $latex x^{(k)} \in B^n$$: $latex \[ - X(t) = x^{(0)} * t^0 + x^{(1)} * t^1 + \cdots + x^{(q)} * t^q -\] $$ + X(t) = x^{(0)} * t^0 + x^{(1)} * t^1 + \cdots + x^{(q)} * t^q +\] $$ Note that for $latex k = 0 , \ldots , q$$, -the $th k$$ derivative of $latex X(t)$$ is related to the +the $th k$$ derivative of $latex X(t)$$ is related to the Taylor coefficients by the equation $latex \[ - x^{(k)} = \frac{1}{k !} X^{(k)} (0) + x^{(k)} = \frac{1}{k !} X^{(k)} (0) \] $$ $head Y(t)$$ The function $latex Y : B \rightarrow B^m$$ is defined by $latex Y(t) = F[ X(t) ] $$. -We use $latex y^{(k)} \in B^m$$ +We use $latex y^{(k)} \in B^m$$ to denote the $th k$$ order Taylor coefficient of $latex Y(t)$$; i.e., $latex \[ - Y(t) = y^{(0)} * t^0 + y^{(1)} * t^1 + \cdots + y^{(q)} * t^q + o( t^q ) -\] $$ + Y(t) = y^{(0)} * t^0 + y^{(1)} * t^1 + \cdots + y^{(q)} * t^q + o( t^q ) +\] $$ where $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. -Note that $latex y^{(k)}$$ is related to +Note that $latex y^{(k)}$$ is related to the $th k$$ derivative of $latex Y(t)$$ by the equation $latex \[ - y^{(k)} = \frac{1}{k !} Y^{(k)} (0) + y^{(k)} = \frac{1}{k !} Y^{(k)} (0) \] $$ $head yq$$ @@ -195,8 +191,8 @@ $subhead One Order$$ If $icode%xq%.size() == %n%$$, the vector $icode yq$$ has size $icode m$$. -The $th q$$ order Taylor coefficient for $latex Y(t)$$ -is returned as +The $th q$$ order Taylor coefficient for $latex Y(t)$$ +is returned as $codei% %yq%$$ $latex = y^{(q)}$$. @@ -205,10 +201,10 @@ the vector $icode yq$$ has size $icode%m%*(%q%+1)%$$. For $latex k = 0 , \ldots , q$$, for $latex i = 0 , \ldots , m-1$$, -the $th i$$ component of the $th k$$ order Taylor coefficient +the $th i$$ component of the $th k$$ order Taylor coefficient for $latex Y(t)$$ is returned as $codei% - %yq%[ (%q%+1) * %i% + %k% ]%$$ $latex = y_i^{(k)}$$ + %yq%[ (%q%+1) * %i% + %k% ]%$$ $latex = y_i^{(k)}$$ $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with @@ -218,22 +214,22 @@ if this is not the case. $head Zero Order$$ -The case where +The case where $latex q = 0$$ and $icode%xq%.size() == %n%$$, corresponds to the zero order -$cref/special case/forward_zero/Special Case/$$. +$cref/special case/forward_zero/Special Case/$$. $head First Order$$ -The case where +The case where $latex q = 1$$ and $icode%xq%.size() == %n%$$, corresponds to the first order -$cref/special case/forward_one/Special Case/$$. +$cref/special case/forward_one/Special Case/$$. $head Second Order$$ -The case where +The case where $latex q = 2$$ and $icode%xq%.size() == %n%$$, corresponds to the second order -$cref/special case/forward_two/Special Case/$$. +$cref/special case/forward_two/Special Case/$$. $children% example/forward.cpp% diff -Nru cppad-2015.00.00.9/omh/forward/forward_two.omh cppad-2016.00.00.1/omh/forward/forward_two.omh --- cppad-2015.00.00.9/omh/forward/forward_two.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/forward/forward_two.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_two.omh 3472 2014-12-15 13:29:52Z bradbell $ */ +// $Id: forward_two.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,8 @@ $$ $section Second Order Forward Mode: Derivative Values$$ +$mindex two$$ -$index Forward, order two$$ -$index two, order Forward$$ -$index order, two Forward$$ $head Syntax$$ @@ -37,9 +35,9 @@ $pre $$ where -$latex F^{(1)} (x0)$$ is the Jacobian of $latex F$$, and +$latex F^{(1)} (x0)$$ is the Jacobian of $latex F$$, and $latex F_i^{(2)} (x0)$$ is the Hessian of th $th i$$ component of $latex F$$, -evaluated at $icode x0$$. +evaluated at $icode x0$$. $head f$$ The object $icode f$$ has prototype @@ -62,7 +60,7 @@ %f%.Forward(0, %x0%) %$$ If there is no previous call with the first argument zero, -the value of the $cref/independent/Independent/$$ variables +the value of the $cref/independent/Independent/$$ variables during the recording of the AD sequence of operations is used for $icode x0$$. @@ -113,38 +111,38 @@ \begin{array}{rcl} Y(t) & = F[ X(t) ] \\ -X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) +X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) \\ -Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) +Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) \end{array} -\] $$ +\] $$ and $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. For this special case, $latex q = 2$$, $latex x^{(0)}$$ $codei%= %x0%$$, $latex x^{(1)}$$ $codei%= %x1%$$, $latex X(t) = x^{(0)} + x^{(1)} t + x^{(2)} t^2$$, and $latex \[ -y^{(0)} + y^{(1)} t + y^{(2)} t^2 -= +y^{(0)} + y^{(1)} t + y^{(2)} t^2 += F [ x^{(0)} + x^{(1)} t + x^{(2)} t^2 ] + o(t^2) -\] $$ +\] $$ Restricting our attention to the $th i$$ component, and taking the derivative with respect to $latex t$$, we obtain $latex \[ -y_i^{(1)} + 2 y_i^{(2)} t -= -F_i^{(1)} [ x^{(0)} + x^{(1)} t + x^{(2)} t^2 ] [ x^{(1)} + 2 x^{(2)} t ] -+ +y_i^{(1)} + 2 y_i^{(2)} t += +F_i^{(1)} [ x^{(0)} + x^{(1)} t + x^{(2)} t^2 ] [ x^{(1)} + 2 x^{(2)} t ] ++ o(t) \] $$ -Taking a second derivative with respect to $latex t$$, +Taking a second derivative with respect to $latex t$$, and evaluating at $latex t = 0$$, we obtain $latex \[ 2 y_i^{(2)} = [ x^{(1)} ]^T F_i^{(2)} [ x^{(0)} ] x^{(1)} + -F_i^{(1)} [ x^{(0)} ] 2 x^{(2)} +F_i^{(1)} [ x^{(0)} ] 2 x^{(2)} \] $$ which agrees with the specification for $icode%y2%[%i%]%$$ in the $cref/purpose/forward_two/Purpose/$$ above. diff -Nru cppad-2015.00.00.9/omh/forward/forward_zero.omh cppad-2016.00.00.1/omh/forward/forward_zero.omh --- cppad-2015.00.00.9/omh/forward/forward_zero.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/forward/forward_zero.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_zero.omh 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: forward_zero.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ dy Jacobian $$ -$index Forward, order zero$$ -$index zero, order Forward$$ -$index order, zero Forward$$ $section Zero Order Forward Mode: Function Values$$ @@ -77,7 +74,7 @@ %Vector% %y0% %$$ (see $cref/Vector/forward_zero/Vector/$$ below) -and its value is $latex F(x)$$ at $icode%x% = %x0%$$. +and its value is $latex F(x)$$ at $icode%x% = %x0%$$. The size of $icode y0$$ is equal to $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. @@ -100,11 +97,11 @@ \begin{array}{rcl} Y(t) & = & F[ X(t) ] \\ -X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) +X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) \\ -Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) +Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) \end{array} -\] $$ +\] $$ and $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. For this special case, $latex q = 0$$, $latex x^{(0)}$$ $codei%= %x0%$$, @@ -112,7 +109,7 @@ $latex \[ y^{(0)} = Y(t) = F[ X(t) ] = F( x^{(0)} ) \] $$ -which agrees with the specifications for +which agrees with the specifications for $icode y0$$ in the $cref/purpose/forward_zero/Purpose/$$ above. diff -Nru cppad-2015.00.00.9/omh/forward/size_order.omh cppad-2016.00.00.1/omh/forward/size_order.omh --- cppad-2015.00.00.9/omh/forward/size_order.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/forward/size_order.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: size_order.omh 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: size_order.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,8 +26,8 @@ $head Purpose$$ Determine the number of Taylor coefficient orders, per variable,direction, -currently calculated and stored in the ADFun object $icode f$$. -See the discussion under +currently calculated and stored in the ADFun object $icode f$$. +See the discussion under $cref/Constructor/size_order/Constructor/$$, $cref/Forward/size_order/Forward/$$, and $cref/capacity_order/size_order/capacity_order/$$ @@ -45,7 +45,7 @@ $codei% size_t %s% %$$ -and is the number of Taylor coefficient orders, +and is the number of Taylor coefficient orders, per variable,direction in the AD operation sequence, currently calculated and stored in the ADFun object $icode f$$. @@ -64,10 +64,10 @@ $codei% %f%.Forward(%q%, %x_q%) %$$ -the value of $icode s$$ returned by $code size_order$$ +the value of $icode s$$ returned by $code size_order$$ would be $latex q + 1$$. The call to $code Forward$$ above -uses the lower order Taylor coefficients to compute and store +uses the lower order Taylor coefficients to compute and store the $th q$$ order Taylor coefficients for all the variables in the operation sequence corresponding to $icode f$$. Thus there are $latex q + 1$$ (order zero through $icode q$$) @@ -77,7 +77,7 @@ $head capacity_order$$ If the number of Taylor coefficient orders -currently stored in $icode f$$ is less than or equal $icode c$$, +currently stored in $icode f$$ is less than or equal $icode c$$, a call to $cref capacity_order$$ with the syntax $codei% %f%.capacity_order(%c%) @@ -86,7 +86,7 @@ Otherwise, the value $icode s$$ returned by $code size_order$$ is equal to $icode c$$ -(only Taylor coefficients of order zero through $latex c-1$$ +(only Taylor coefficients of order zero through $latex c-1$$ have been retained). $head Example$$ diff -Nru cppad-2015.00.00.9/omh/glossary.omh cppad-2016.00.00.1/omh/glossary.omh --- cppad-2015.00.00.9/omh/glossary.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/glossary.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: glossary.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: glossary.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,6 +26,7 @@ $$ $section Glossary$$ +$mindex efficient$$ @@ -34,36 +35,34 @@ there is a corresponding AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. This operation sequence -defines a function +defines a function $latex F : B^n \rightarrow B^m $$ where $icode B$$ is the space corresponding to objects of type $icode Base$$, $icode n$$ is the size of the $cref/domain/seq_property/Domain/$$ space, and $icode m$$ is the size of the $cref/range/seq_property/Range/$$ space. -We refer to $latex F$$ as the AD function corresponding to +We refer to $latex F$$ as the AD function corresponding to the operation sequence stored in the object $icode f$$. (See the $cref/FunCheck discussion/FunCheck/Discussion/$$ for possible differences between $latex F(x)$$ and the algorithm that defined the operation sequence.) $head AD of Base$$ -An object is called an AD of $icode Base$$ object its type is -either $codei%AD<%Base%>%$$ -(see the default and copy $cref/constructors/ad_ctor/$$ +An object is called an AD of $icode Base$$ object its type is +either $codei%AD<%Base%>%$$ +(see the default and copy $cref/constructors/ad_ctor/$$ or $codei%VecAD<%Base%>::reference%$$ (see $cref VecAD$$) for some $icode Base$$ type. -$head AD Levels Above Base$$ -$index level, AD$$ -$index AD, level$$ -If $icode Base$$ is a type, -the AD levels above $icode Base$$ +$head AD Type Above Base$$ +If $icode Base$$ is a type, +an AD type above $icode Base$$ is the following sequence of types: $codei% AD<%Base%> %,% AD< AD<%Base%> > %,% AD< AD< AD<%Base%> > > %,% %...% %$$ $head Base Function$$ -A function $latex f : B \rightarrow B$$ +A function $latex f : B \rightarrow B$$ is referred to as a $icode Base$$ function, if $icode Base$$ is a C++ type that represent elements of the domain and range space of $icode f$$; i.e. elements of $latex B$$. @@ -90,7 +89,7 @@ more basic operations. $subhead Sequence$$ -A sequence of atomic $icode Type$$ operations +A sequence of atomic $icode Type$$ operations is called a $icode Type$$ operation sequence. A sequence of atomic $cref/AD of Base/glossary/AD of Base/$$ operations is referred to as an AD of $icode Base$$ operation sequence. @@ -99,7 +98,7 @@ $subhead Dependent$$ Suppose that $icode x$$ and $icode y$$ are $icode Type$$ objects and -the result of +the result of $codei% %x% < %y% %$$ @@ -108,7 +107,7 @@ $codei% if( %x% < %y% ) %y% = cos(%x%); - else %y% = sin(%x%); + else %y% = sin(%x%); %$$ the choice above depends on the value of $icode x$$ and $icode y$$ and the two choices result in a different $icode Type$$ operation sequence. @@ -126,32 +125,29 @@ %y% += %x%[%i%]; %$$ does not depend on the value of $icode x$$ or $icode y$$. -In this case, we say that the $icode Type$$ operation sequence +In this case, we say that the $icode Type$$ operation sequence is independent of $icode y$$ and the elements of $icode x$$. $head Parameter$$ All $icode Base$$ objects are parameters. An $codei%AD<%Base%>%$$ object $icode u$$ is currently a parameter if -its value does not depend on the value of +its value does not depend on the value of an $cref Independent$$ variable vector for an $cref/active tape/glossary/Tape/Active/$$. -If $icode u$$ is a parameter, the function +If $icode u$$ is a parameter, the function $cref/Parameter(u)/ParVar/$$ returns true and $cref/Variable(u)/ParVar/$$ returns false. $head Sparsity Pattern$$ -$index sparsity, pattern$$ -$index pattern, sparsity$$ -$index efficient, sparsity$$ CppAD describes a sparse matrix as a vector of sets with each -vector component corresponding to a row +vector component corresponding to a row and the elements of the set corresponding to the possibly non-zero columns. A vector of $code bool$$ can represent a vector of sets using one bit per element. (Some vectors of $code bool$$ use one byte per element but $cref/vectorBool/CppAD_vector/vectorBool/$$ is an example class that uses one bit per element.) -The problem is that this representation uses one bit for both the elements +The problem is that this representation uses one bit for both the elements that are there and the ones that are not. $pre @@ -160,25 +156,25 @@ represent the elements that are not present, but it uses about three $code size_t$$ values for each element that is present. -For example, if $code size_t$$ uses 32 bits, +For example, if $code size_t$$ uses 32 bits, a vector of $code std::set$$ uses -about 100 bits for each element that is present in the +about 100 bits for each element that is present in the vector of sets. -Thus, a vector of $code std::set$$ should be more efficient for +Thus, a vector of $code std::set$$ should be more efficient for very sparse matrix representations. $subhead Vector of Boolean$$ -Given a matrix +Given a matrix $latex A \in B^{m \times n}$$, -a vector of $code bool$$ $latex B$$ of length $latex m \times n$$ -is a sparsity pattern for $latex A$$ if +a vector of $code bool$$ $latex B$$ of length $latex m \times n$$ +is a sparsity pattern for $latex A$$ if for $latex i = 0, \ldots , m-1$$ and $latex j = 0 , \ldots n-1$$, $latex \[ -A_{i,j} \neq 0 -\; \Rightarrow \; +A_{i,j} \neq 0 +\; \Rightarrow \; B_{i * n + j} = {\rm true} \] $$ -Given two sparsity patterns $latex B$$ and $icode C$$ +Given two sparsity patterns $latex B$$ and $icode C$$ for a matrix $icode A$$, we say that $icode B$$ is more efficient than $icode C$$ if $icode B$$ has fewer true elements than $icode C$$. For example, if $latex A$$ is the identity matrix, @@ -188,16 +184,16 @@ defines an efficient sparsity pattern for $latex A$$. $subhead Vector of Sets$$ -Given a matrix +Given a matrix $latex A \in B^{m \times n}$$, -a vector of sets $latex S$$ of length $latex m$$ is a -sparsity pattern for $latex A$$ if -for $latex i = 0, \ldots , m-1$$ +a vector of sets $latex S$$ of length $latex m$$ is a +sparsity pattern for $latex A$$ if +for $latex i = 0, \ldots , m-1$$ $latex \[ -A_{i,j} \neq 0 -\; \Rightarrow \; j \in S_i +A_{i,j} \neq 0 +\; \Rightarrow \; j \in S_i \] $$ -Given two sparsity patterns $latex S$$ and $icode T$$ +Given two sparsity patterns $latex S$$ and $icode T$$ for a matrix $icode A$$, we say that $icode S$$ is more efficient than $icode T$$ if $icode S$$ has fewer elements than $icode T$$. For example, if $latex A$$ is the identity matrix, @@ -209,7 +205,7 @@ $head Tape$$ $subhead Active$$ -A new tape is created and becomes active +A new tape is created and becomes active after each call of the form (see $cref Independent$$) $codei% Independent(%x%) @@ -232,36 +228,36 @@ After such a transfer, the tape becomes inactive. $subhead Independent Variable$$ -While the tape is active, we refer to the elements of $icode x$$ +While the tape is active, we refer to the elements of $icode x$$ as the independent variables for the tape. When the tape becomes inactive, -the corresponding objects become +the corresponding objects become $cref/parameters/glossary/Parameter/$$. $subhead Dependent Variables$$ While the tape is active, we use the term dependent variables for the tape for any objects whose value depends on the independent variables for the tape. When the tape becomes inactive, -the corresponding objects become +the corresponding objects become $cref/parameters/glossary/Parameter/$$. - + $head Taylor Coefficient$$ -Suppose $latex X : B \rightarrow B^n$$ is a +Suppose $latex X : B \rightarrow B^n$$ is a is $latex p$$ times continuously differentiable function in some neighborhood of zero. -For $latex k = 0 , \ldots , p$$, -we use the column vector $latex x^{(k)} \in B^n$$ for the $th k$$ order -Taylor coefficient corresponding to $latex X$$ +For $latex k = 0 , \ldots , p$$, +we use the column vector $latex x^{(k)} \in B^n$$ for the $th k$$ order +Taylor coefficient corresponding to $latex X$$ which is defined by $latex \[ x^{(k)} = \frac{1}{k !} \Dpow{k}{t} X(0) \] $$ -It follows that +It follows that $latex \[ X(t) = x^{(0)} + x^{(1)} t + \cdots + x^{(p)} t^p + R(t) \]$$ -where the remainder $latex R(t)$$ divided by $latex t^p$$ +where the remainder $latex R(t)$$ divided by $latex t^p$$ converges to zero and $latex t$$ goes to zero. @@ -270,8 +266,8 @@ its value depends on an independent variable vector for a currently $cref/active tape/glossary/Tape/Active/$$. If $icode u$$ is a variable, -$cref/Variable(u)/ParVar/$$ returns true and -$cref/Parameter(u)/ParVar/$$ returns false. +$cref/Variable(u)/ParVar/$$ returns true and +$cref/Parameter(u)/ParVar/$$ returns false. For example, directly after the code sequence $codei% @@ -290,7 +286,7 @@ $pre $$ -Note that we often drop the word currently and +Note that we often drop the word currently and just refer to an $codei%AD<%Base%>%$$ object as a variable or parameter. diff -Nru cppad-2015.00.00.9/omh/install/adolc_prefix.omh cppad-2016.00.00.1/omh/install/adolc_prefix.omh --- cppad-2015.00.00.9/omh/install/adolc_prefix.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/adolc_prefix.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: adolc_prefix.omh 2942 2013-10-15 05:48:45Z bradbell $ */ +// $Id: adolc_prefix.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,9 +26,7 @@ $$ $section Including the ADOL-C Examples and Tests$$ -$index adolc, example$$ -$index example, adolc$$ -$index test, adolc$$ +$mindex adolc prefix get$$ $head Purpose$$ CppAD includes examples and tests that can use the AD package @@ -36,17 +34,15 @@ The includes speed comparison with other AD packages; see $cref speed_adolc$$. It also includes examples that combine ADOL-C with -CppAD; see +CppAD; see $table $rref base_adolc.hpp$$ -$rref mul_level_adolc.cpp$$ +$rref mul_level_adolc.cpp$$ $rref mul_level_adolc_ode.cpp$$ $tend $head adolc_prefix$$ -$index adolc, prefix$$ -$index prefix, adolc$$ -If ADOL-C is installed on your system, you can +If ADOL-C is installed on your system, you can specify a value for its install $icode adolc_prefix$$ on the $cref cmake$$ command line. The value of $icode adolc_prefix$$ must be such that, @@ -55,7 +51,7 @@ $codei% %adolc_prefix%/%dir%/adolc/adouble.h %$$ -is a valid way to reference to the include file $code adouble.h$$; +is a valid way to reference to the include file $code adouble.h$$; Note that CppAD assumes ADOL-C has been configured with its sparse matrix computations enabled; i.e, using $codei% @@ -66,8 +62,6 @@ $cref get_colpack.sh$$. $head Examples$$ -$index adolc, examples$$ -$index examples, adolc$$ If you include $icode adolc_prefix$$ on the $cref cmake$$ command line, you will be able to run the ADOL-C examples listed above by executing the following commands starting in the @@ -82,27 +76,23 @@ have passed their correctness check. $head Speed Tests$$ -$index adolc, speed$$ -$index speed, adolc$$ If you include $icode adolc_prefix$$ on the $cref cmake$$ command line, -you will be able to run the ADOL-C speed correctness tests +you will be able to run the ADOL-C speed correctness tests by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd build/speed/adolc make check_speed_adolc %$$ -After executing $code make check_speed_adolc$$, -you can run a specific ADOL-C speed tests +After executing $code make check_speed_adolc$$, +you can run a specific ADOL-C speed tests by executing the command $code ./speed_adolc$$; see $cref speed_main$$ for the meaning of the command line options to this program. $head Unix$$ -$index adolc, unix$$ -$index unix, adolc$$ -If you are using Unix, -you may have to add +If you are using Unix, +you may have to add $icode adolc_prefix$$ to $code LD_LIBRARY_PATH$$. For example, if you use the $code bash$$ shell to run your programs, you could include @@ -113,9 +103,7 @@ in your $code @HOME/.bashrc$$ file. $head Cygwin$$ -$index adolc, cygwin$$ -$index cygwin, adolc$$ -If you are using Cygwin, +If you are using Cygwin, you may have to add to following lines to the file $code .bashrc$$ in your home directory: $codei% @@ -125,7 +113,7 @@ in order for ADOL-C to run properly. If $icode adolc_prefix$$ begins with a disk specification, you must use the Cygwin format for the disk specification. -For example, +For example, if $code d:/adolc_base$$ is the proper directory, $code /cygdrive/d/adolc_base$$ should be used for $icode adolc_prefix$$. @@ -133,8 +121,6 @@ bin/get_adolc.sh %$$ $head get_adolc$$ -$index get, adolc$$ -$index adolc, get$$ If you are using Unix, you can download and install a copy of Adolc using $cref get_adolc.sh$$. The corresponding $icode adolc_prefix$$ would be diff -Nru cppad-2015.00.00.9/omh/install/auto_tools.omh cppad-2016.00.00.1/omh/install/auto_tools.omh --- cppad-2015.00.00.9/omh/install/auto_tools.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/auto_tools.omh 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1,574 @@ +$Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +$begin auto_tools$$ +$escape $$ +$dollar ^$$ +$spell + ctor + testvector + Eigen + colpack + num + cxx + boostvector + inv + fopenmp + openmp + cout + Addr + sizeof + op_arg + err_retu + const + printf + avector.h + Ipopt + Ip + gzip + Linux + fi + exp_apx + tgz + gpl + Dev + sed + cppad + gprof + config + stdvector + std + ublas + hpp + adouble + badiff + usr + cygdrive + htm + xml + Dir + xvzf + gz + workspace + Makefile + exe + Cygwin + Microsoft + dsw + CppAD + Adolc + Fadbad + Sacado + ls + aclocal + yum + devel +$$ + + +$section Auto Tools Unix Test and Installation$$ +$mindex speed profile prefix std vector boost eigen sparse internal sets ctor implicit explicit compile flags OpenMP postfix Adolc Fadbad Ipopt Sacado memory usage tape$$ + +$head Deprecated 2012-12-26$$ +These install instructions have been deprecated and no improvements +have been added since 2012. +For example, this install procedure will not detect any of the +$code c++11$$ extensions. +You should use the $cref cmake$$ instructions to install CppAD. + +$head Distribution Directory$$ +You must first obtain a copy of the CppAD distribution directory +using the $cref download$$ instructions. +The install instructions below correspond to the +$cref/current version/download/Compressed Archives/Current Version/$$ +which has distribution directory $code cppad-20121230$$. + +$head Work Directory$$ +Create the directory $code cppad-20121230/build$$, +which will be referred to as the build directory below. + +$head Configure$$ +Execute the following command in the build directory: +$codei% +./configure \ + --prefix=%prefix_dir% \ + --with-Documentation \ + --with-%test%vector \ + --with-sparse_%option% \ + --with-deprecated \ + MAX_NUM_THREADS=%max_num_threads% \ + CXX_FLAGS=%cxx_flags% \ + OPENMP_FLAGS=%openmp_flags% \ + POSTFIX_DIR=%postfix_dir% \ + ADOLC_DIR=%adolc_dir% \ + BOOST_DIR=%boost_dir% \ + EIGEN_DIR=%eigen_dir% \ + FADBAD_DIR=%fadbad_dir% \ + SADADO_DIR=%sacado_dir% \ + IPOPT_DIR=%ipopt_dir% \ + TAPE_ADDR_TYPE=%tape_addr_type% \ + TAPE_ID_TYPE=%tape_id_type% +%$$ +where only the $code configure$$ line need appear; i.e., +the entries in all of the other lines are optional. +The text in italic is replaced values that you choose; +see discussion below. + +$head make$$ +CppAD has some object libraries that are used for its correctness tests. +(Currently, none of these libraries get installed.) +You can build these libraries by executing the command +$codei% + make +%$$ +in the build directory. + +$subhead Examples and Tests$$ +Once you have executed the $code make$$ command, +you can run the correctness and speed tests. +$pre + +$$ +The following command will build all the correctness and speed tests. +In addition, it will run all the correctness tests: +$codep + make test +$$ +$pre + +$$ +The following links describe how to build and run subsets of these tests: +$table +$cref/get_started/get_started.cpp/Running/$$ + $cnext $title get_started.cpp$$ +$rnext +$cref/exp_apx_main/exp_apx_main.cpp/Running Tests/$$ + $cnext $title exp_apx_main.cpp$$ +$rnext +$cref/example/example.cpp/Running Tests/$$ + $cnext $title example.cpp$$ +$rnext +$cref/print_for_cout/print_for_cout.cpp/Running/$$ + $cnext $title print_for_cout.cpp$$ +$rnext +$cref/speed_example/speed_example.cpp/Running Tests/$$ + $cnext $title speed_example.cpp$$ +$rnext +$cref/speed_double/speed_double/Running Tests/$$ + $cnext $title speed_double$$ +$rnext +$cref/speed_adolc/speed_adolc/Running Tests/$$ + $cnext $title speed_adolc$$ +$rnext +$cref/speed_cppad/speed_cppad/Running Tests/$$ + $cnext $title speed_cppad$$ +$rnext +$cref/speed_fadbad/speed_fadbad/Running Tests/$$ + $cnext $title speed_fadbad$$ +$rnext +$cref/speed_sacado/speed_sacado/Running Tests/$$ + $cnext $title speed_sacado$$ +$tend +In addition, +you can run a large subset of correctness tests +(that are not intended to be examples) +by executing the following commands starting in the build directory: +$codei% + cd test_more + make test +%$$ + +$head Profiling CppAD$$ +The CppAD derivative speed tests mentioned above can be profiled. +You can test that the results computed during this profiling are correct +by executing the following commands starting in the build directory: +$codei% + cd speed/profile + make test +%$$ +After executing $code make test$$, you can run a profile speed test +by executing the command $code ./profile$$; +see $cref speed_main$$ for the meaning of the command line +options to this program. +$pre + +$$ +After you have run a profiling speed test, +you can then obtain the profiling results with +$codei% + gprof -b profile +%$$ +If you are using a windows operating system with Cygwin or MinGW, +you may have to replace $code profile$$ by $code profile.exe$$ +in the $code gprof$$ command above; i.e., +$codep + gprof -b profile.exe +$$ +In C++, template parameters and argument types become part of a +routines's name. +This can make the $code gprof$$ output hard to read +(the routine names can be very long). +You can remove the template parameters and argument types from the +routine names by executing the following command +$codep + gprof -b profile | sed -f gprof.sed +$$ +If you are using a windows operating system with Cygwin or MinGW, +you would need to use +$codep + gprof -b profile.exe | sed -f gprof.sed +$$ + +$head prefix_dir$$ +The default value for prefix directory is $code ^HOME$$ +i.e., by default the CppAD include files +will $cref/install/auto_tools/make install/$$ below $code ^HOME$$. +If you want to install elsewhere, you will have to use this option. +As an example of using the $codei%--prefix=%prefix_dir%$$ option, +if you specify +$codep + ./configure --prefix=/usr/local +$$ +the CppAD include files will be installed in the directory +$codei% + /usr/local/include/cppad +%$$ +If $cref/--with-Documentation/auto_tools/--with-Documentation/$$ +is specified, the CppAD documentation files will be installed in the directory +$codei% + /usr/local/share/doc/cppad-20121230 +%$$ + +$head --with-Documentation$$ +If the command line argument $code --with-Documentation$$ is specified, +the CppAD documentation HTML and XML files are copied to the directory +$codei% + %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230 +%$$ +(see $cref/postfix_dir/auto_tools/postfix_dir/$$). +The top of the CppAD HTML documentation tree +(with mathematics displayed as LaTex command) will be located at +$codei% + %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230/cppad.htm +%$$ +and the top of the XML documentation tree +(with mathematics displayed as MathML) will be located at +$codei% + %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230/cppad.xml +%$$ + +$head --with-testvector$$ +The $cref/CPPAD_TESTVECTOR/testvector/$$ +template class is used for many of the CppAD examples and tests. +The default for this template class is $codei%CppAD::vector<%Scalar%>%$$. +If one, and only one, of the following command line arguments is specified: +$codep + --with-stdvector + --with-boostvector + --with-eigenvector +$$ +the corresponding of the following template classes is used +$codei% + std::vector<%Scalar%> + boost::numeric::ublas::vector<%Scalar%> + Eigen::matrix<%Scalar%, Eigen::Dynamic, 1> +%$$ +See also, +$cref/boost_dir/auto_tools/boost_dir/$$ +and +$cref/eigen_dir/auto_tools/eigen_dir/$$. + + +$head --with-sparse_option$$ +There are two options for the preprocessor symbol +$code CPPAD_INTERNAL_SPARSE_SET$$. +If $code --with-sparse_set$$ +($code --with-sparse_list$$) is specified, +this symbol is $code sparse_set$$ ($code sparse_list$$). +This should affect the speed and memory required by the +$cref sparse_jacobian$$, $cref sparse_hessian$$, and the +$cref/sparse drivers/sparse/$$. + +$head --with-deprecated$$ +If this configure argument is present, then all the +$cref deprecated$$ features are included in the install. +Otherwise, they are not included. + +$head max_num_threads$$ +this specifies the value for the default value for the preprocessor symbol +$cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$. +It must be greater than or equal to four; i.e., +$icode%max_num_threads% >= 4%$$. + +$head cxx_flags$$ +If the command line argument $icode CompilerFlags$$ is present, +it specifies compiler flags. +For example, +$codei% + CXX_FLAGS="-Wall -ansi" +%$$ +would specify that warning flags $code -Wall$$ +and $code -ansi$$ should be included +in all the C++ compile commands. +The error and warning flags chosen must be valid options +for the C++ compiler. +The default value for $icode CompilerFlags$$ is the +empty string. + +$head openmp_flags$$ +If the command line argument $icode OpenmpFlags$$ is present, +it specifies the necessary flags so that the compiler will +properly interpret OpenMP directives. +For example, when using the GNU $code g++$$ compiler, +the following setting includes the OpenMP tests: +$codei% + OPENMP_FLAGS=-fopenmp +%$$ +If you specify configure command, +the CppAD OpenMP correctness and speed tests will be built; see +$cref/threading/thread_test.cpp/Running Tests/threading/$$ +multi-threading tests. + +$head postfix_dir$$ +By default, the postfix directory is empty; i.e., there +is no postfix directory. +As an example of using the $codei%POSTFIX_DIR=%postfix_dir%$$ option, +if you specify +$codep + ./configure --prefix=/usr/local POSTFIX_DIR=coin +$$ +the CppAD include files will be +$cref/installed/auto_tools/make install/$$ in the directory +$codei% + /usr/local/include/coin/cppad +%$$ +If $cref/--with-Documentation/auto_tools/--with-Documentation/$$ +is specified, the CppAD documentation files will be installed in the directory +$codei% + /usr/local/share/doc/coin/cppad-20121230 +%$$ + +$head adolc_dir$$ +If you have +$href%https://projects.coin-or.org/ADOL-C%ADOL-C%$$ +installed on your system, you can +specify a value for $icode adolc_dir$$ in the +$cref/configure/auto_tools/Configure/$$ command line. +The value of $icode adolc_dir$$ must be such that +$codei% + %adolc_dir%/include/adolc/adouble.h +%$$ +is a valid way to reference $code adouble.h$$. +In this case, you can run the Adolc speed correctness tests +by executing the following commands starting in the build directory: +$codei% + cd speed/adolc + make test +%$$ +After executing $code make test$$, you can run an Adolc speed tests +by executing the command $code ./adolc$$; +see $cref speed_main$$ for the meaning of the command line +options to this program. +Note that these speed tests assume Adolc has been configure with +its sparse matrix computations enabled using +$codei% + --with-colpack=%colpack_dir% +%$$ + +$subhead Linux$$ +If you are using Linux, +you will have to add $icode%adolc_dir%/lib%$$ to $code LD_LIBRARY_PATH$$. +For example, if you use the $code bash$$ shell to run your programs, +you could include +$codei% + LD_LIBRARY_PATH=%adolc_dir%/lib:^{LD_LIBRARY_PATH} + export LD_LIBRARY_PATH +%$$ +in your $code ^HOME/.bash_profile$$ file. + +$subhead Cygwin$$ +If you are using Cygwin, +you will have to add to following lines to the file +$code .bash_profile$$ in your home directory: +$codei% + PATH=%adolc_dir%/bin:^{PATH} + export PATH +%$$ +in order for Adolc to run properly. +If $icode adolc_dir$$ begins with a disk specification, +you must use the Cygwin format for the disk specification. +For example, +if $code d:/adolc_base$$ is the proper directory, +$code /cygdrive/d/adolc_base$$ should be used for $icode adolc_dir$$. + +$head boost_dir$$ +If the command line argument +$codei% + BOOST_DIR=%boost_dir% +%$$ +is present, it must be such that files +$codei% + %boost_dir%/include/boost/numeric/ublas/vector.hpp + %boost_dir%/include/boost/thread.hpp +%$$ +are present. +In this case, these files will be used by CppAD. +See also, $cref/--with-boostvector/auto_tools/--with-testvector/$$ + +$head eigen_dir$$ +If you have +$href%http://eigen.tuxfamily.org%Eigen%$$ +installed on your system, you can +specify a value for $icode eigen_dir$$. +It must be such that +$codei% + %eigen_dir%/include/Eigen/Core +%$$ +is a valid include file. +In this case CppAD will compile and test the Eigen examples; e.g., +$cref eigen_array.cpp$$. +See also, $cref/--with-eigenvector/auto_tools/--with-testvector/$$ + +$head fadbad_dir$$ +If you have +$href% + http://www.fadbad.com/% + Fadbad 2.1 +%$$ +installed on your system, you can +specify a value for $icode fadbad_dir$$. +It must be such that +$codei% + %fadbad_dir%/include/FADBAD++/badiff.h +%$$ +is a valid reference to $code badiff.h$$. +In this case, you can run the Fadbad speed correctness tests +by executing the following commands starting in the build directory: +$codei% + cd speed/fadbad + make test +%$$ +After executing $code make test$$, you can run a Fadbad speed tests +by executing the command $code ./fadbad$$; +see $cref speed_main$$ for the meaning of the command line +options to this program. + +$head ipopt_dir$$ +If you have +$href% + http://www.coin-or.org/projects/Ipopt.xml% + Ipopt +%$$ +installed on your system, you can +specify a value for $icode ipopt_dir$$. +It must be such that +$codei% + %ipopt_dir%/include/coin/IpIpoptApplication.hpp +%$$ +is a valid reference to $code IpIpoptApplication.hpp$$. +In this case, the CppAD interface to Ipopt +$cref/examples/cppad_ipopt_nlp/Example/$$ can be built and tested +by executing the following commands starting in the build directory: +$codei% + make + # + cd cppad_ipopt/example + make test + # + cd ../test + make test + # + cd ../speed + make test +%$$ +Once this has been done, you can execute the program +$code ./speed$$ in the $code build/cppad_ipopt/speed$$ directory; +see $cref ipopt_ode_speed.cpp$$. + +$head sacado_dir$$ +If you have +$href% + http://trilinos.sandia.gov/packages/sacado/% + Sacado +%$$ +installed on your system, you can +specify a value for $icode sacado_dir$$. +It must be such that +$codei% + %sacado_dir%/include/Sacado.hpp +%$$ +is a valid reference to $code Sacado.hpp$$. +In this case, you can run the Sacado speed correctness tests +by executing the following commands starting in the build directory: +$codei% + cd speed/sacado + make test +%$$ +After executing $code make test$$, you can run a Sacado speed tests +by executing the command $code ./sacado$$; +see $cref speed_main$$ for the meaning of the command line +options to this program. + + +$head tape_addr_type$$ +If the command line argument $icode tape_addr_type$$ is present, +it specifies the type used for address in the AD recordings (tapes). +The valid values for this argument are +$code unsigned short int$$, +$code unsigned int$$, +$code size_t$$. +The smaller the value of $icode%sizeof(%tape_addr_type%)%$$, +the less memory is used. +On the other hand, the value +$codei% + std::numeric_limits<%tape_addr_type%>::max() +%$$ +must be larger than any of the following: +$cref/size_op/seq_property/size_op/$$, +$cref/size_op_arg/seq_property/size_op_arg/$$, +$cref/size_par/seq_property/size_text/$$, +$cref/size_par/seq_property/size_par/$$, +$cref/size_par/seq_property/size_VecAD/$$. + + +$head tape_id_type$$ +If the command line argument $icode tape_id_type$$ is present, +it specifies the type used for identifying tapes. +The valid values for this argument are +$code unsigned short int$$, +$code unsigned int$$, +$code size_t$$. +The smaller the value of $icode%sizeof(%tape_id_type%)%$$, +the less memory is used. +On the other hand, the value +$codei% + std::numeric_limits<%tape_id_type%>::max() +%$$ +must be larger than the maximum number of tapes per thread +times $cref/max_num_threads/auto_tools/max_num_threads/$$. + +$head make install$$ +Once you are satisfied that the tests are giving correct results, +you can install CppAD into easy to use directories by executing the command +$codep + make install +$$ +This will install CppAD in the location specified by +$cref/prefix_dir/auto_tools/prefix_dir/$$. +You must have permission to write in the $icode prefix_dir$$ +directory to execute this command. +You may optionally specify a destination directory for the install; i.e., +$codei% + make install DESTDIR=%DestinationDirectory% +%$$ + +$end diff -Nru cppad-2015.00.00.9/omh/install/cmake_check.omh cppad-2016.00.00.1/omh/install/cmake_check.omh --- cppad-2015.00.00.9/omh/install/cmake_check.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/cmake_check.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cmake_check.omh 3114 2014-02-22 16:20:39Z bradbell $ */ +/* $Id: cmake_check.omh 3726 2015-09-21 13:25:17Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,14 +23,14 @@ $section Checking the CppAD Examples and Tests$$ $head Purpose$$ -After you configure your system with the +After you configure your system with the $cref/cmake command/cmake/CMake Command/$$ you -can run the CppAD example and tests to make sure that +can run the CppAD example and tests to make sure that CppAD functions properly on your system. $head Check All$$ -In the $code build$$ subdirectory of the +In the $code build$$ subdirectory of the $cref/distribution directory/download/Distribution Directory/$$ execute the command $codep @@ -38,42 +38,49 @@ $$ This will build and run all of the tests that are support by your system and the $cref cmake$$ command options. + +$subhead Windows$$ If you created $code nmake$$ makefiles, you will have -to use $code nmake$$ instead of $code make$$ in the command above; see -the $cref/generator/cmake/generator/$$ option for the $code cmake$$ command. +to use $code nmake$$ instead of $code make$$ in the commands +above and below; see +$cref/windows file extraction and testing + /download + /Compressed Archives + /Windows File Extraction and Testing +/$$. $head Subsets$$ -It is possible to build and run the following subsets of the +It is possible to build and run the following subsets of the examples and tests: $table -Command $cnext +Command $cnext Description $rnext -$code make check_compare_c$$ $cnext - $tref compare_c$$ +$code make check_compare_c$$ $cnext + $tref compare_c$$ $rnext -$code make check_introduction$$ $cnext +$code make check_introduction$$ $cnext the programs in the $cref Introduction$$ $rnext -$code make check_example$$ $cnext +$code make check_example$$ $cnext most of the $cref Example$$ programs $rnext -$code make check_print_for$$ $cnext +$code make check_print_for$$ $cnext the $cref PrintFor$$ command $rnext -$code make check_test_more$$ $cnext - correctness tests that are not examples +$code make check_test_more$$ $cnext + correctness tests that are not examples $rnext -$code make check_multi_thread$$ $cnext - $cref multi_thread$$ tests (run correctness only) +$code make check_multi_thread$$ $cnext + $cref multi_thread$$ tests (run correctness only) $rnext -$code make check_speed$$ $cnext +$code make check_speed$$ $cnext single threading $cref speed$$ tests (run correctness only) $rnext -$code make check_cppad_ipopt$$ $cnext +$code make check_cppad_ipopt$$ $cnext the $cref cppad_ipopt_nlp$$ speed and correctness tests $rnext $tend - + $end diff -Nru cppad-2015.00.00.9/omh/install/cmake.omh cppad-2016.00.00.1/omh/install/cmake.omh --- cppad-2015.00.00.9/omh/install/cmake.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/cmake.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: cmake.omh 3476 2014-12-16 17:15:01Z bradbell $ +$Id: cmake.omh 3760 2015-12-01 04:12:28Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -49,7 +49,7 @@ docdir includedirs libdirs - cxx + cxx max num postfix id @@ -57,69 +57,76 @@ $$ $section Using CMake to Configure CppAD$$ -$index cmake, configure cppad$$ -$index configure, cppad$$ -$index cppad, cmake configure$$ +$mindex makefile install prefix postfix include directories lib datadir documentation package compile flags profile maximum number threads sparsity internal structure vector sets memory usage tape ctor implicit explicit$$ $head The CMake Program$$ -$index cmake$$ -The -$href%http://www.cmake.org/cmake/help/install.html%cmake%$$ +The +$href%http://www.cmake.org/cmake/help/install.html%cmake%$$ program enables one to create a single set of scripts, -called $code CMakeLists.txt$$, +called $code CMakeLists.txt$$, that can be used to test and install a program on Unix, Microsoft, or -Apple operating systems. +Apple operating systems. For example, one can use it to automatically generate Microsoft project files. - + $head CMake Command$$ -$index cmake, command$$ -$index configure, cppad$$ -$index cppad, configure$$ The command below assumes that $code cmake$$ is in your execution -path. If not, you can put the path to $code cmake$$ in font the command. +path with version greater than or equal 2.8. +If not, you can put the path to the version of $code cmake$$ +in font the command. Only the $code cmake$$ command and the path to the distribution directory ($code ..$$ at the end of the command below) are required. In other words, the first and last lines below are required and all of the other lines are optional. $subhead Build Directory$$ -Create a $code build$$ subdirectory of the +Create a $code build$$ subdirectory of the $cref/distribution directory/download/Distribution Directory/$$, -change into the $code build$$ directory, +change into the $code build$$ directory, and execute the following command: $codei% -cmake %% \ - -G %generator% \ - -D cmake_install_prefix=%cmake_install_prefix% \ - -D cmake_install_includedirs=%cmake_install_includedirs% \ - -D cmake_install_datadir=%cmake_install_datadir% \ - -D cmake_install_docdir=%cmake_install_docdir% \ - -D cmake_install_libdirs=%cmake_install_libdirs% \ - -D cmake_install_postfix=%cmake_install_postfix% \ - \ - -D adolc_prefix=%adolc_prefix% \ - -D colpack_prefix=%colpack_prefix% \ - -D eigen_prefix=%eigen_prefix% \ - -D fadbad_prefix=%fadbad_prefix% \ - -D ipopt_prefix=%ipopt_prefix% \ - -D sacado_prefix=%sacado_prefix% \ +cmake %% \ + -D CMAKE_VERBOSE_MAKEFILE=%cmake_verbose_makefile% \ + -G %generator% \ \ - -D cppad_cxx_flags=%cppad_cxx_flags% \ + -D cppad_prefix=%cppad_prefix% \ + -D cppad_postfix=%cppad_postfix% \ \ - -D cppad_testvector=%cppad_testvector% \ - -D cppad_max_num_threads=%cppad_max_num_threads% \ - -D cppad_sparse_list=%cppad_sparse_list% \ - -D cppad_tape_id_type=%cppad_tape_id_type% \ - -D cppad_tape_addr_type=%cppad_tape_addr_type% \ - -D cppad_implicit_ctor_from_any_type=%cppad_implicit_ctor_from_any_type% \ + -D cmake_install_includedirs=%cmake_install_includedirs% \ + -D cmake_install_libdirs=%cmake_install_libdirs% \ \ - .. + -D cmake_install_datadir=%cmake_install_datadir% \ + -D cmake_install_docdir=%cmake_install_docdir% \ + \ + -D adolc_prefix=%adolc_prefix% \ + -D colpack_prefix=%colpack_prefix% \ + -D eigen_prefix=%eigen_prefix% \ + -D fadbad_prefix=%fadbad_prefix% \ + -D ipopt_prefix=%ipopt_prefix% \ + -D sacado_prefix=%sacado_prefix% \ + \ + -D cppad_cxx_flags=%cppad_cxx_flags% \ + -D cppad_profile_flag=%cppad_profile_flag% \ + \ + -D cppad_testvector=%cppad_testvector% \ + -D cppad_max_num_threads=%cppad_max_num_threads% \ + -D cppad_sparse_list=%cppad_sparse_list% \ + -D cppad_tape_id_type=%cppad_tape_id_type% \ + -D cppad_tape_addr_type=%cppad_tape_addr_type% \ + -D cppad_deprecated=%cppad_deprecated% \ + \ + .. %$$ +$head cmake_verbose_makefile$$ +This value should be either $code YES$$ or $code NO$$. +The default value, when it is not present, is $code NO$$. +If it is $code YES$$, then the output of the $code make$$ commands +will include all of the files and flags used to run the compiler +and linker. This can be useful for seeing how to compile and link +your own applications. + $head generator$$ -$index makefile, generator$$ -$index generator, makefile$$ The CMake program is capable of generating different kinds of files. Below is a table with a few of the possible files $table @@ -127,114 +134,105 @@ $code "Unix Makefiles"$$ $cnext make files for unix operating system $rnext $code "NMake Makefiles"$$ $cnext make files for Visual Studio $tend -Other generator choices are available; see the cmake +Other generator choices are available; see the cmake $href%http://www.cmake.org/cmake/help/cmake2.6docs.html#section_Generators% generators%$$ documentation. -$head cmake_install_prefix$$ -$index install, prefix$$ -$index prefix, install$$ -This is the prefix directory for the CppAD files that get installed by the +$head cppad_prefix$$ +This is the top level absolute path below which +all of the CppAD files are installed by the command $codei% make install %$$ -All of the installed files will be placed below this directory. -The default value for this directory is $code /usr$$. - -$head cmake_install_includedirs$$ -$index install, include directories$$ -$index include directories, install$$ -This can be one directory, or a list of directories separated -by spaces or by semi-colons. -This first entry in the list is the directory, -below the $icode cmake_install_prefix$$, -where the CppAD include files will be installed. -This directory, and the others in the list, are used for searching -for include files. -The default value for this directory list is $code include$$. -For example, if -$icode cmake_install_prefix$$, -$icode cmake_install_includedirs$$, and -$icode cmake_install_postfix$$, are not specified, -the file $code cppad.hpp$$ will be installed in the location +For example, +if $icode cppad_prefix$$ is $code /usr$$, +$icode cmake_install_includedirs$$ is $code include$$, and +$icode cppad_postfix$$ is not specified, +the file $code cppad.hpp$$ is installed in the location $codei% /usr/include/cppad/cppad.hpp %$$ +The default value for $icode cppad_prefix$$ is $code /usr$$. -$head cmake_install_datadir$$ -$index install, data directory$$ -$index data directory, install$$ -This is the directory, -below the $icode cmake_install_prefix$$, -where the data files will be installed. -The default value for this directory is $code share$$. -For example, if -$icode cmake_install_prefix$$ and -$icode cmake_install_postfix$$ are not specified, -the $cref pkgconfig$$ file $code cppad.pc$$ will be installed in the location +$head cppad_postfix$$ +This is the bottom level relative path below which +all of the CppAD files are installed. +For example, +if $icode cppad_prefix$$ is $code /usr$$, +$icode cmake_install_includedirs$$ is $code include$$, and +$icode cppad_postfix$$ is $code coin$$, +the file $code cppad.hpp$$ is installed in the location $codei% - /usr/share/pkgconfig/cppad.pc + /usr/include/coin/cppad/cppad.hpp %$$ +The default value for $icode cppad_postfix$$ is empty; i.e, +there is no bottom level relative directory for the installed files. -$head cmake_install_docdir$$ -$index install, data directory$$ -$index data directory, install$$ -This is the directory is present, the documentation files are installed -in this sub-directory below the $icode cmake_install_prefix$$. -For example, if -$icode cmake_install_prefix$$ and -$icode cmake_install_postfix$$ are not specified, and -$codei% - -D cmake_install_docdir=share/doc -%$$ -the file $code cppad.xml$$ will be installed in the location + +$head cmake_install_includedirs$$ +This is one directory, or a list of directories separated +by spaces or by semi-colons. +This first entry in the list is the middle level relative path below which +the CppAD include files are installed. +The entire list is used for searching for include files. +For example, +if $icode cppad_prefix$$ is $code /usr$$, +$icode cmake_install_includedirs$$ is $code include$$, and +$icode cppad_postfix$$ is not specified, +the file $code cppad.hpp$$ is installed in the location $codei% - /usr/share/doc/cppad/cppad.xml + /usr/include/cppad/cppad.hpp %$$ +The default value for this directory list is $code include$$. + $head cmake_install_libdirs$$ -$index install, library directories$$ -$index library directories, install$$ -This can be one directory, or a list of directories separated -by spaces or semi-colons. -The first entry in the list is the directory, -below the $icode cmake_install_prefix$$, -where the CppAD library files will be installed. -This directory, and the others in the list, are used for searching -for library files. -The default value for this directory list is $code lib$$. -For example, if -$icode cmake_install_prefix$$, -$icode cmake_install_postfix$$, -$icode cmake_install_libdirs$$ are not specified, and -$icode ipopt_prefix$$ is specified, -the file $code libcppad_ipopt.a$$ will be installed in the location +This is one directory, or a list of directories separated +by spaces or by semi-colons. +This first entry in the list is the middle level relative path below which +the CppAD library files are installed. +The entire list is used for searching for library files. +For example, +if $icode cppad_prefix$$ is $code /usr$$, +$icode cmake_install_libdirs$$ is $code lib$$, +$icode cppad_postfix$$ is not specified, +and $icode ipopt_prefix$$ is specified, +the file $code libcppad_ipopt.a$$ is installed in the location $codei% /usr/lib/libcppad_ipopt.a %$$ +The default value for this directory list is $code lib$$. -$head cmake_install_postfix$$ -$index install, postfix$$ -$index postfix, install$$ -This is the directory, -below the include, data, and library directories, -where files will be installed. -The default value for this directory is empty -(as the example cases above demonstrate). -For example, -if $icode cmake_install_prefix$$ and -$icode cmake_install_postfix$$ are not specified, and +$head cmake_install_datadir$$ +This is the middle level relative path below which +the CppAD data files are installed. +For example, +if $icode cppad_prefix$$ is $code /usr$$, +$icode cmake_install_datadir$$ is $code share$$, and +$icode cppad_postfix$$ is not specified, +the $cref pkgconfig$$ file $code cppad.pc$$ is installed in the location $codei% - -D cmake_install_postfix=coin + /usr/share/pkgconfig/cppad.pc %$$ -the $cref pkgconfig$$ file $code cppad.pc$$ will be installed in the location +The default value for $icode cmake_install_datadir$$ is $code share$$. + +$head cmake_install_docdir$$ +This is the middle level relative path below which +the CppAD documentation files are installed. +For example, +if $icode cppad_prefix$$ is $code /usr$$, +$icode cmake_install_docdir$$ is $code share/doc$$, and +$icode cppad_postfix$$ is not specified, +the file $code cppad.xml$$ is installed in the location $codei% - /usr/share/coin/pkgconfig/cppad.pc + /usr/share/doc/cppad/cppad.xml %$$ +There is no default value for $icode cmake_install_docdir$$. +If it is not specified, the documentation files are not installed. $head package_prefix$$ -$index package, prefix$$ -$index prefix, package$$ +Each of these packages corresponds to optional CppAD examples, +that can be compiled and tested if the corresponding prefix is provided: $table $rref adolc_prefix$$ $rref colpack_prefix$$ @@ -245,9 +243,6 @@ $tend $head cppad_cxx_flags$$ -$index c++, compile flags$$ -$index compile, c++ flags$$ -$index flags, c++ compile$$ This specifies the addition compiler flags, besides the debug and release flags, that are used when compiling the CppAD examples and tests. @@ -256,20 +251,31 @@ on your system. For example, if you are using $code g++$$ you could specify $codep - -D cppad_cxx_flags="-Wall -ansi -pedantic-errors -std=c++98 -Wshadow" + -D cppad_cxx_flags="-Wall -ansi -pedantic-errors -std=c++11 -Wshadow" $$ +$subhead C++11$$ +In order for the compiler to take advantage of features that are new in C++11, +the $icode cppad_cxx_flags$$ must enable these features. +The compiler may still be used with a flag that disables the new features +(unless it is a Microsoft compiler; i.e., $code _MSC_VER$$ is defined). + +$head cppad_profile_flag$$ +This specifies an addition compiler and link flag that is used +for $cref/profiling/speed_main/package/profile/$$ the speed tests. +A profile version of the speed test is only build when this argument +is present. + +$subhead Eigen and Fadbad$$ The packages $cref/eigen/eigen_prefix/$$ and $cref/fadbad/fadbad_prefix/$$ currently generate a lot of shadowed variable warnings. -Hence the $code -Wshadow$$ flag is automatically removed when +If the $code -Wshadow$$ flag is present, it is automatically removed when compiling examples and test that use these packages. $head cppad_testvector$$ See $tref cppad_testvector$$. $head cppad_max_num_threads$$ -$index maximum, number threads$$ -$index threads, maximum number$$ The value $icode cppad_max_num_threads$$ must be greater than or equal to four; i.e., $icode%max_num_threads% >= 4%$$. @@ -280,10 +286,8 @@ $cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$. $head cppad_sparse_list$$ -$index sparsity, internal structure$$ -$index sparsity, vector of sets$$ There are two possible values for this option, $code YES$$ and $code NO$$. -This affect the internal data structure used to store a +This affect the internal data structure used to store a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ when the users version of the sparsity pattern is a vector of $code std::set$$. If $icode cppad_sparse_list$$ is $code NO$$ @@ -296,10 +300,7 @@ The default value for $icode cppad_sparse_list$$ is $code YES$$ $head cppad_tape_id_type$$ -$index memory, usage$$ -$index memory, tape$$ -$index tape, memory$$ -The type $icode cppad_tape_id_type$$ +The type $icode cppad_tape_id_type$$ is used for identifying different tapes. The valid values for this type are $code unsigned char$$, @@ -324,10 +325,7 @@ $code uint64_t$$. $head cppad_tape_addr_type$$ -$index memory, usage$$ -$index memory, tape$$ -$index tape, memory$$ -The type $icode cppad_tape_addr_type$$ +The type $icode cppad_tape_addr_type$$ is used for address in the AD recordings (tapes). The valid values for this argument are $code unsigned char$$, @@ -355,18 +353,14 @@ $code uint32_t$$, $code uint64_t$$. -$head cppad_implicit_ctor_from_any_type$$ -$index ctor, implicit or explicit$$ -$index implicit, ctor$$ -$index explicit, ctor$$ -The default value for $icode cppad_implicit_ctor_from_any_type$$ is $code NO$$. -If it is $code YES$$, there is a -$cref/deprecated/ad_ctor/x/deprecated/$$ -implicit type constructor (type conversion) -from any type to $codei%AD<%Base%>%$$. -Otherwise this constructor is -$cref/explicit/ad_ctor/x/explicit/$$. - +$head cppad_deprecated$$ +The default value for $icode cppad_deprecated$$ is $code NO$$. +If it is $code YES$$, then all the CppAD +$cref deprecated$$ features are included in the +$cref/installation/install/Instructions/Step 4: Installation/$$. +Otherwise, some of the deprecated features +may be excluded from the installation. +(The intention here is to exclude more deprecated features as time marches on.) $children% omh/install/adolc_prefix.omh% diff -Nru cppad-2015.00.00.9/omh/install/colpack_prefix.omh cppad-2016.00.00.1/omh/install/colpack_prefix.omh --- cppad-2015.00.00.9/omh/install/colpack_prefix.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/colpack_prefix.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: colpack_prefix.omh 3309 2014-05-28 00:08:58Z bradbell $ */ +// $Id: colpack_prefix.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,19 +25,16 @@ $$ $section Including the ColPack Sparsity Calculations$$ -$index colpack, sparsity$$ -$index sparsity, colpack$$ +$mindex prefix get$$ $head Purpose$$ -If you specify a $icode colpack_prefix$$ on the +If you specify a $icode colpack_prefix$$ on the $cref/cmake command/cmake/CMake Command/$$ line, the CppAD $cref sparse_jacobian$$ calculations use the -$href%http://http://cscapes.cs.purdue.edu/coloringpage/%ColPack%$$ package. +$href%http://cscapes.cs.purdue.edu/dox/ColPack/html%ColPack%$$ package. $head colpack_prefix$$ -$index colpack, prefix$$ -$index prefix, colpack$$ -If ColPack is installed on your system, you can +If ColPack is installed on your system, you can specify a value for its install $icode colpack_prefix$$ on the $cref cmake$$ command line. The value of $icode colpack_prefix$$ must be such that, @@ -48,39 +45,27 @@ %$$ is a valid way to reference to the include file $code ColPackHeaders.h$$. -$head cppad_colpack.cpp$$ -$index cppad_colpack.cpp$$ +$head cppad_lib$$ The ColPack header files has a $codei% using namespace std %$$ -at the global level. +at the global level. For this reason, CppAD does not include these files. -It is therefore necessary to compile and link the short file -$codei% - %prefix%/%dir%/cppad/cppad_colpack.cpp -%$$ -where $icode dir$$ is the -$cref/cmake_install_datadir/cmake/cmake_install_datadir/$$ and -where $icode prefix$$ is such that $code cppad.hpp$$ was installed in -$codei% - %prefix%/include/cppad/cppad.hpp -%$$ -Hopefully, future versions of ColPack will not have this problem -and it will no longer be necessary to do this. +It is therefore necessary to link the object library $code cppad_lib$$ +when using ColPack. -$children% - example/colpack.cpp% - bin/get_colpack.sh +$children%example/colpack_jac.cpp + %example/colpack_hes.cpp + %bin/get_colpack.sh %$$ $head Example$$ -The file $cref colpack.cpp$$ contains an example and test of using -ColPack to compute the coloring for sparse Jacobians. +The file $cref colpack_jac.cpp$$ ($cref colpack_hes.cpp$$) +contains an example and test of using ColPack to compute the coloring for +sparse Jacobians (Hessians). It returns true, if it succeeds and false otherwise. $head get_colpack$$ -$index get, colpack$$ -$index colpack, get$$ If you are using Unix, you can download and install a copy of ColPack using $cref get_colpack.sh$$. The corresponding $icode colpack_prefix$$ would be diff -Nru cppad-2015.00.00.9/omh/install/download.omh cppad-2016.00.00.1/omh/install/download.omh --- cppad-2015.00.00.9/omh/install/download.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/download.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: download.omh 3661 2015-02-23 22:19:20Z bradbell $ +$Id: download.omh 3786 2016-02-08 13:14:26Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -13,6 +13,10 @@ $begin download$$ $escape $$ $spell + vcdir + vcvarsall + Microsoft + tarball yyyy mm dd @@ -42,8 +46,6 @@ $dollar @$$ $section Download The CppAD Source Code$$ -$index download, cppad$$ -$index cppad, download$$ $head Purpose$$ CppAD is an include file library and you therefore need the source @@ -51,7 +53,7 @@ This section discusses how to download the different versions of CppAD. $head Distribution Directory$$ -We refer to the CppAD source directory created by the download instruction +We refer to the CppAD source directory created by the download instruction below as the distribution directory. To be specific, the distribution directory contains the file $code cppad/cppad.hpp$$. @@ -60,22 +62,22 @@ These files have been archived using $code tar$$ and compressed using $code gzip$$: $table -$bold version$$ $pre $$ $cnext $bold license$$ $pre $$ $cnext $bold link$$ +$bold version$$ $pre $$ $cnext $bold license$$ $pre $$ $cnext $bold link$$ $rnext current $cnext EPL $cnext $href% -http://www.coin-or.org/download/source/CppAD/cppad-20150000.9.epl.tgz% -cppad-20150000.9.epl.tgz%$$ +http://www.coin-or.org/download/source/CppAD/cppad-20160000.1.epl.tgz% +cppad-20160000.1.epl.tgz%$$ $rnext current $cnext GPL $cnext $href% -http://www.coin-or.org/download/source/CppAD/cppad-20150000.9.gpl.tgz% -cppad-20150000.9.gpl.tgz%$$ +http://www.coin-or.org/download/source/CppAD/cppad-20160000.1.gpl.tgz% +cppad-20160000.1.gpl.tgz%$$ $rnext -old $cnext Both $cnext +old $cnext Both $cnext $href%http://www.coin-or.org/download/source/CppAD/%CppAD download page%$$ $tend $subhead Current Version$$ -The current versions listed above correspond to the subversion +The current versions listed above correspond to the subversion $href%https://projects.coin-or.org/CppAD/browser/trunk%trunk%$$ and the git $href%https://github.com/bradbell/cppad%master%$$. @@ -89,18 +91,18 @@ $codei% cppad-%yyyymmdd%.%rel%.%lic%.tgz %$$ -The license code $icode lic$$ +The license code $icode lic$$ is $code gpl$$, $code epl$$ or $code cpl$$ where $code gpl$$ denotes the GNU General Public License, $code epl$$ denotes the Eclipse Public License, and -$code cpl$$ denotes the Common Public License +$code cpl$$ denotes the Common Public License (not being used for new versions). -The version number $icode yyyymmdd$$ +The version number $icode yyyymmdd$$ is the date at which the features of the program were frozen where -$icode yyyy$$ is the year, $icode mm$$ is the month, and $icode dd$$ +$icode yyyy$$ is the year, $icode mm$$ is the month, and $icode dd$$ is the day. -The release number $icode rel$$ +The release number $icode rel$$ corresponds to a bug fix index where higher numbers corresponding to more bug fixes. @@ -113,7 +115,7 @@ $codei% cppad-%yyyy%0101.%lic%.tgz %$$ -where the license code $icode lic$$ +where the license code $icode lic$$ is $code gpl$$ or $code epl$$ and $icode yyyy$$ is the current year. @@ -131,38 +133,54 @@ cppad-%version%/cppad/cppad.hpp %$$ -$subhead Windows File Extraction$$ -If you know how to extract the distribution directory from +$subhead Windows File Extraction and Testing$$ +If you know how to extract the distribution directory from the tar file, just do so. Otherwise, below is one way you can do it. -(Note that if $code 7z.exe$$, $code cmake.exe$$, and $code nmake.exe$$ are you +(Note that if $code 7z.exe$$, $code cmake.exe$$, and $code nmake.exe$$ are you your execution path, you will not need to specify their paths below.) $list number$$ Download and install the open source program $href%http://www.7-zip.org%$$. $lnext -In a command window, use the command -$codei% - %path_to_7-zip%\7z x cppad-%version%.%lic%.tgz +Download and install the Visual Studio Express; for example +$href%http://www.microsoft.com/en-us/download/confirmation.aspx?id=44914 + %Visual Studio 2013 %$$ -where $icode path_to_7-zip$$ is the location where -$code 7z.exe$$ was installed. $lnext -Then execute the command +In a command window, execute the following commands: +$codei| + set PATH=|path_to_7_zip|;%PATH% + set PATH=|path_to_cmake|;%PATH% + set VCDIR=|path_to_vcdir|;%PATH% + call "%VCDIR%\vcvarsall.bat" x86 +|$$ +For example, on one machine these paths had the following values: +$codei| + |path_to_7_zip|=C:\Program Files\7-zip + |path_to_cmake|=C:\Program Files (x86)\CMake\bin + |path_to_vcdir|=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC +|$$ +$lnext +Use the following commands to extract the distribution from the tarball: $codei% - %path_to_7-zip%\7z x cppad-%version%.%lic%.tar + 7z x cppad-%version%.%lic%.tgz + 7z x cppad-%version%.%lic%.tar %$$ $lnext To see if this has been done correctly, check for the following file: $codei% cppad-%version%\cppad\cppad.hpp %$$ -In addition, you can try the following commands: +$lnext +The commands below are optional. +They run the CppAD tests using the default $cref cmake$$ settings +(except for the $cref/generator/cmake/generator/$$ option) $codei% mkdir build cd build - %path_to_cmake%\cmake -G "NMake Makefiles" .. - %path_to_nmake%\nmake check + cmake -G "NMake Makefiles" .. + nmake check %$$ $lend @@ -170,7 +188,7 @@ $subhead Install Instructions$$ The instructions on the web correspond to the current version of CppAD. If you are using an old version of CppAD -You should follow the install instructions in +You should follow the install instructions in the $code doc$$ subdirectory of the distribution directory. @@ -179,14 +197,14 @@ $subhead Limitations$$ This download procedure has the following limitations: $list number$$ -The $href%http://subversion.tigris.org/%subversion%$$ +The $href%http://subversion.tigris.org/%subversion%$$ program must be installed on your system. $lnext No documentation is included by this download procedure, though it can be build from the source code; see $cref/install instructions/download/Subversion/Install Instructions/$$ below. $lnext -Only the +Only the $href%http://opensource.org/licenses/EPL-1.0%EPL licensed%$$ version of CppAD can be obtained by this download procedure (some old versions correspond to CPL instead of EPL). @@ -201,16 +219,16 @@ $codei% %dir%/cppad/cppad.hpp %$$ -We refer to your directory choice $icode dir$$ above +We refer to your directory choice $icode dir$$ above as the distribution directory. $subhead Stable Versions$$ Subversion downloads are available for a set of stable versions (after the specified date, only bug fixes get applied). The following link will list the available $icode dir$$ values -corresponding to +corresponding to $href%https://projects.coin-or.org/CppAD/browser/stable% stable versions%$$. -The following command will download a +The following command will download a stable version of the CppAD source code: $codei% svn export https://projects.coin-or.org/svn/CppAD/stable/%dir% %dir% @@ -219,18 +237,18 @@ $codei% %dir%/cppad/cppad.hpp %$$ -Note that it will correspond to the most recent release for this stable +Note that it will correspond to the most recent release for this stable version. $subhead Release Versions$$ Subversion downloads are available for a set of release versions (no changes are applied). The following link will list the available $icode dir$$ values -corresponding to +corresponding to $href%https://projects.coin-or.org/CppAD/browser/releases% - release versions + release versions %$$. -The following command will download a +The following command will download a release version of the CppAD source code: $codei% svn export https://projects.coin-or.org/svn/CppAD/releases/%dir% %dir% @@ -251,12 +269,12 @@ which omhelp $$ shows it is in your path. -Once you have done this, +Once you have done this, in the distribution directory execute the following command: $codei% ./build.sh omhelp %$$ -You will then be able to follow the install instructions in +You will then be able to follow the install instructions in the $code doc$$ subdirectory of the distribution directory. diff -Nru cppad-2015.00.00.9/omh/install/eigen_prefix.omh cppad-2016.00.00.1/omh/install/eigen_prefix.omh --- cppad-2015.00.00.9/omh/install/eigen_prefix.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/eigen_prefix.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: eigen_prefix.omh 2792 2013-04-28 09:25:28Z bradbell $ */ +// $Id: eigen_prefix.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,12 +24,10 @@ $$ $section Including the Eigen Examples and Tests$$ -$index eigen, example$$ -$index example, eigen$$ -$index test, eigen$$ +$mindex prefix get$$ $head Purpose$$ -CppAD can include the following examples and tests that +CppAD can include the following examples and tests that use the linear algebra package $href%http://eigen.tuxfamily.org%Eigen%$$: $table $rref cppad_eigen.hpp$$ @@ -39,9 +37,7 @@ $head eigen_prefix$$ -$index eigen, prefix$$ -$index prefix, eigen$$ -If Eigen is installed on your system, you can +If Eigen is installed on your system, you can specify a value for its install $icode eigen_prefix$$ on the $cref cmake$$ command line. The value of $icode eigen_prefix$$ must be such that, @@ -53,8 +49,6 @@ is a valid way to reference to the include file $code Core$$; $head Examples$$ -$index example, eigen$$ -$index eigen, example$$ If you include $icode eigen_prefix$$ on the $cref cmake$$ command line, you will be able to run the Eigen examples list above by executing the following commands starting in the @@ -71,21 +65,17 @@ options to this program. $head Test Vector$$ -$index vector, eigen$$ -$index eigen, vector$$ If you have specified $icode eigen_prefix$$ you can choose $codei% -D cppad_testvector=eigen %$$ on the $cref/cmake command/cmake/CMake Command/$$ line. -This we set the CppAD $cref testvector$$ to use Eigen vectors. +This we set the CppAD $cref testvector$$ to use Eigen vectors. $children% bin/get_eigen.sh %$$ $head get_eigen$$ -$index get, eigen$$ -$index eigen, get$$ If you are using Unix, you can download and install a copy of Eigen using $cref get_eigen.sh$$. The corresponding $icode eigen_prefix$$ would be diff -Nru cppad-2015.00.00.9/omh/install/fadbad_prefix.omh cppad-2016.00.00.1/omh/install/fadbad_prefix.omh --- cppad-2015.00.00.9/omh/install/fadbad_prefix.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/fadbad_prefix.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: fadbad_prefix.omh 2791 2013-04-26 11:59:58Z bradbell $ */ +// $Id: fadbad_prefix.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,8 +21,7 @@ $$ $section Including the FADBAD Speed Tests$$ -$index fadbad, speed$$ -$index speed, fadbad$$ +$mindex prefix get$$ $head Purpose$$ CppAD includes speed comparisons for the AD package @@ -31,9 +30,7 @@ $head fadbad_prefix$$ -$index fadbad, prefix$$ -$index prefix, fadbad$$ -If FADBAD is installed on your system, you can +If FADBAD is installed on your system, you can specify a value for its install $icode fadbad_prefix$$ on the $cref cmake$$ command line. The value of $icode fadbad_prefix$$ must be such that, @@ -42,20 +39,18 @@ $codei% %fadbad_prefix%/%dir%/FADBAD++/badiff.h %$$ -is a valid way to reference to the include file $code badiff.h$$; +is a valid way to reference to the include file $code badiff.h$$; $head Speed Tests$$ -$index speed, fadbad$$ -$index fadbad, speed$$ If you include $icode fadbad_prefix$$ on the $cref cmake$$ command line, -you will be able to run the FADBAD speed correctness tests +you will be able to run the FADBAD speed correctness tests by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd build/speed/fadbad make check_speed_fadbad %$$ -After executing $code make check$$, you can run a specific FADBAD speed test +After executing $code make check$$, you can run a specific FADBAD speed test by executing the command $code ./speed_fadbad$$; see $cref speed_main$$ for the meaning of the command line options to this program. @@ -64,8 +59,6 @@ bin/get_fadbad.sh %$$ $head get_fadbad$$ -$index get, fadbad$$ -$index fadbad, get$$ If you are using Unix, you can download and install a copy of Fadbad using $cref get_fadbad.sh$$. The corresponding $icode fadbad_prefix$$ would be diff -Nru cppad-2015.00.00.9/omh/install/install.omh cppad-2016.00.00.1/omh/install/install.omh --- cppad-2015.00.00.9/omh/install/install.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/install.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: install.omh 3114 2014-02-22 16:20:39Z bradbell $ +$Id: install.omh 3760 2015-12-01 04:12:28Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,8 +20,6 @@ CppAD $$ -$index install$$ -$index test$$ $section CppAD Download, Test, and Install Instructions$$ @@ -34,10 +32,10 @@ Use the $cref cmake$$ instructions to configure CppAD. $subhead Step 3: Check$$ -Use the $cref cmake_check$$ instructions to check the +Use the $cref cmake_check$$ instructions to check the CppAD examples and tests. -$subhead Step 4: Install$$ +$subhead Step 4: Installation$$ Use the command $codep make install @@ -48,7 +46,7 @@ $codep nmake install $$ -see the +see the $cref/generator/cmake/generator/$$ option for the $code cmake$$ command. @@ -57,7 +55,7 @@ omh/install/cmake.omh% omh/install/cmake_check.omh% omh/install/pkgconfig.omh% - omh/install/unix.omh + omh/install/auto_tools.omh %$$ diff -Nru cppad-2015.00.00.9/omh/install/ipopt_prefix.omh cppad-2016.00.00.1/omh/install/ipopt_prefix.omh --- cppad-2015.00.00.9/omh/install/ipopt_prefix.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/ipopt_prefix.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ipopt_prefix.omh 2778 2013-04-16 14:56:10Z bradbell $ */ +// $Id: ipopt_prefix.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,21 +21,18 @@ $$ $section Including the cppad_ipopt Library and Tests$$ -$index ipopt, cppad library$$ -$index library, cppad_ipopt$$ +$mindex ipopt cppad prefix get$$ $head Purpose$$ -Includes the $cref cppad_ipopt_nlp$$ +Includes the $cref cppad_ipopt_nlp$$ example and tests as well as installing the $code cppad_ipopt$$ library -during the $code make install$$ step. +during the $code make install$$ step. $head ipopt_prefix$$ -$index ipopt, prefix$$ -$index prefix, ipopt$$ If you have $href%http://www.coin-or.org/projects/Ipopt.xml%Ipopt%$$ -installed on your system, you can +installed on your system, you can specify the value for $icode ipopt_prefix$$ on the $cref cmake$$ command line. The value of $icode ipopt_prefix$$ must be such that, @@ -44,14 +41,12 @@ $codei% %ipopt_prefix%/%dir%/coin/IpIpoptApplication.hpp %$$ -is a valid way to reference to the include file +is a valid way to reference to the include file $code IpIpoptApplication.hpp$$. $head Examples and Tests$$ -$index example, ipopt$$ -$index ipopt, example$$ If you include $icode ipopt_prefix$$ on the $cref cmake$$ command line, -you will be able to run the Ipopt examples and tests +you will be able to run the Ipopt examples and tests by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% @@ -63,8 +58,6 @@ bin/get_ipopt.sh %$$ $head get_ipopt$$ -$index get, ipopt$$ -$index ipopt, get$$ If you are using Unix, you can download and install a copy of Ipopt using $cref get_ipopt.sh$$. The corresponding $icode ipopt_prefix$$ would be diff -Nru cppad-2015.00.00.9/omh/install/pkgconfig.omh cppad-2016.00.00.1/omh/install/pkgconfig.omh --- cppad-2015.00.00.9/omh/install/pkgconfig.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/pkgconfig.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -// $Id: pkgconfig.omh 3114 2014-02-22 16:20:39Z bradbell $ +// $Id: pkgconfig.omh 3760 2015-12-01 04:12:28Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,18 +26,16 @@ $$ $section CppAD pkg-config Files$$ -$index pkg-config, files$$ -$index files, pkg-config$$ -$index pc, pkg-config$$ +$mindex pc$$ $head Purpose$$ -The $code pkg-config$$ package helps with the use of installed libraries; +The $code pkg-config$$ package helps with the use of installed libraries; see its $href%http://people.freedesktop.org/~dbn/pkg-config-guide.html%guide%$$ for more information. $head Usage$$ -The necessary flags for compiling code that includes CppAD can +The necessary flags for compiling code that includes CppAD can be obtained with the command $codep pkg-config --cflags cppad @@ -82,23 +80,24 @@ $tend $head CppAD Configuration Files$$ -In the table below, +In the table below, $icode builddir$$ is the build directory; i.e., the directory where the CppAD -$cref/Configure/InstallUnix/Configure/$$ command is executed. +$cref/cmake command/cmake/CMake Command/$$ is executed. The directory $icode prefix$$ is the value of -$cref/cmake_install_prefix/cmake/cmake_install_prefix/$$ during configuration. +$cref/cppad_prefix/cmake/cppad_prefix/$$ during configuration. The directory $icode datadir$$ is the value of $cref/cmake_install_datadir/cmake/cmake_install_datadir/$$. The following configuration files contain the information above $table -$icode File$$ $cnext +$icode File$$ $cnext $icode Description$$ $rnext -$icode%prefix%/%datadir%/pkgconfig/cppad.pc%$$ $cnext - for use after $cref/make install/install/Instructions/Step 4: Install/$$ +$icode%prefix%/%datadir%/pkgconfig/cppad.pc%$$ $cnext + for use after + $cref/make install/install/Instructions/Step 4: Installation/$$ $rnext -$icode%builddir%/pkgconfig/cppad-uninstalled.pc%$$ $cnext - for testing before $code make install$$ +$icode%builddir%/pkgconfig/cppad-uninstalled.pc%$$ $cnext + for testing before $code make install$$ $tend $end diff -Nru cppad-2015.00.00.9/omh/install/sacado_prefix.omh cppad-2016.00.00.1/omh/install/sacado_prefix.omh --- cppad-2015.00.00.9/omh/install/sacado_prefix.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/sacado_prefix.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sacado_prefix.omh 2792 2013-04-28 09:25:28Z bradbell $ */ +// $Id: sacado_prefix.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,8 +21,7 @@ $$ $section Including the Sacado Speed Tests$$ -$index sacado, speed$$ -$index speed, sacado$$ +$mindex prefix get$$ $head Purpose$$ CppAD includes speed comparisons for the AD package @@ -31,9 +30,7 @@ $head sacado_prefix$$ -$index sacado, prefix$$ -$index prefix, sacado$$ -If Sacado is installed on your system, you can +If Sacado is installed on your system, you can specify a value for its install $icode sacado_prefix$$ on the $cref cmake$$ command line. The value of $icode sacado_prefix$$ must be such that, @@ -42,21 +39,19 @@ $codei% %sacado_prefix%/%dir%/Sacado.hpp %$$ -is a valid way to reference to the include file $code Sacado.hpp$$; +is a valid way to reference to the include file $code Sacado.hpp$$; $head Speed Tests$$ -$index speed, sacado$$ -$index sacado, speed$$ If you include $icode sacado_prefix$$ on the $cref cmake$$ command line, -you will be able to run the Sacado speed correctness tests +you will be able to run the Sacado speed correctness tests by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd build/speed/sacado make check_speed_sacado %$$ -After executing $code make check_speed_sacado$$, -you can run a specific Sacado speed test +After executing $code make check_speed_sacado$$, +you can run a specific Sacado speed test by executing the command $code ./speed_sacado$$; see $cref speed_main$$ for the meaning of the command line options to this program. @@ -65,8 +60,6 @@ bin/get_sacado.sh %$$ $head get_sacado$$ -$index get, sacado$$ -$index sacado, get$$ If you are using Unix, you can download and install a copy of Sacado using $cref get_sacado.sh$$. The corresponding $icode sacado_prefix$$ would be diff -Nru cppad-2015.00.00.9/omh/install/testvector.omh cppad-2016.00.00.1/omh/install/testvector.omh --- cppad-2015.00.00.9/omh/install/testvector.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/testvector.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: testvector.omh 2577 2012-11-17 18:22:22Z bradbell $ */ +// $Id: testvector.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,36 +21,35 @@ $$ $section Choosing the CppAD Test Vector Template Class$$ -$index cppad, test vector$$ -$index test, cppad vector$$ -$index vector, cppad test$$ $head Purpose$$ -The $cref/CPPAD_TESTVECTOR/testvector/$$ -template class is used for many of the CppAD examples and tests. -If you are going to use -$code boost$$, $code cppad$$, $code eigen$$, or $code std$$ vectors -in your CppAD code, you many want to test CppAD with the -type of vectors you will be using. - -$head cppad_testvector$$ -$index cppad_testvector$$ -The must be one of the following choices: -$code boost$$, $code cppad$$, $code eigen$$ or $code std$$. -It specifies which type of vectors are used for the -$code CPPAD_TESTVECTOR$$ template class. -The default value for $code cppad_testvector$$ is $code cppad$$. +The value $icode cppad_testvector$$ +in the $cref/cmake command/cmake/CMake Command/$$ must be one of the +following: +$code boost$$, $code cppad$$, $code eigen$$, or $code std$$. +It specifies which type of vector is corresponds to the template class +$cref/CPPAD_TESTVECTOR/testvector/$$ +which is used for many of the CppAD examples and tests. + +$head std$$ +If $icode%cppad_testvector%$$ is $icode std$$, +the $code std::vector$$ template class is used to define +$code CPPAD_TESTVECTOR$$. + +$head cppad$$ +If $icode%cppad_testvector%$$ is $icode cppad$$, +the $cref cppad_vector$$ template class is used to define +$code CPPAD_TESTVECTOR$$. $head boost$$ -$index boost, vector$$ -$index vector, boost$$ -If $icode cppad_testvector$$ is set to $code boost$$, the +If $icode%cppad_testvector%$$ is $icode boost$$, $href% http://www.boost.org/doc/libs/1_52_0/libs/numeric/ublas/doc/vector.htm% boost ublas vector %$$ -include files must be installed on your system. -In addition, +template class is used to define +$code CPPAD_TESTVECTOR$$. +In this case, the $href% http://www.cmake.org/cmake/help/cmake2.6docs.html#module:FindBoost% cmake FindBoost @@ -58,10 +57,11 @@ module must be able to automatically figure out where Boost is installed. $head eigen$$ -$index eigen, vector$$ -$index vector, eigen$$ -If $icode cppad_testvector$$ is set to $code eigen$$, -$cref eigen_prefix$$ must be specified on the $code cmake$$ command line. +If $icode%cppad_testvector%$$ is $icode eigen$$, +one of the eigen template classes is used to define +$code CPPAD_TESTVECTOR$$. +In this case, +$cref eigen_prefix$$ must be specified on the $code cmake$$ command line. $end diff -Nru cppad-2015.00.00.9/omh/install/unix.omh cppad-2016.00.00.1/omh/install/unix.omh --- cppad-2015.00.00.9/omh/install/unix.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/install/unix.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,624 +0,0 @@ -$Id: unix.omh 3542 2014-12-31 18:37:57Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -$begin InstallUnix$$ -$escape $$ -$dollar ^$$ -$spell - ctor - testvector - Eigen - colpack - num - cxx - boostvector - inv - fopenmp - openmp - cout - Addr - sizeof - op_arg - err_retu - const - printf - avector.h - Ipopt - Ip - gzip - Linux - fi - exp_apx - tgz - gpl - Dev - sed - cppad - gprof - config - stdvector - std - ublas - hpp - adouble - badiff - usr - cygdrive - htm - xml - Dir - xvzf - gz - workspace - Makefile - exe - Cygwin - Microsoft - dsw - CppAD - Adolc - Fadbad - Sacado - ls - aclocal - yum - devel -$$ - -$index CppAD, unix install$$ -$index unix, CppAD install$$ -$index free, unix install$$ -$index install, unix CppAD$$ - -$section Deprecated Unix Test and Installation$$ - -$head Deprecated$$ -These install instructions have been deprecated and no improvements -have been added since 2012. -For example, this install procedure will not detect any of the -$code c++11$$ extensions. -You should use the $cref cmake$$ instructions to install CppAD. - -$head Distribution Directory$$ -You must first obtain a copy of the CppAD distribution directory -using the $cref download$$ instructions. -The install instructions below correspond to the -$cref/current version/download/Compressed Archives/Current Version/$$ -which has distribution directory $code cppad-20121230$$. - -$head Work Directory$$ -Create the directory $code cppad-20121230/build$$, -which will be referred to as the build directory below. - -$head Configure$$ -Execute the following command in the build directory: -$index configure$$ -$codei% -./configure \ - --prefix=%prefix_dir% \ - --with-Documentation \ - --with-%test%vector \ - --with-sparse_%option% \ - --with-implicit_ctor \ - MAX_NUM_THREADS=%max_num_threads% \ - CXX_FLAGS=%cxx_flags% \ - OPENMP_FLAGS=%openmp_flags% \ - POSTFIX_DIR=%postfix_dir% \ - ADOLC_DIR=%adolc_dir% \ - BOOST_DIR=%boost_dir% \ - EIGEN_DIR=%eigen_dir% \ - FADBAD_DIR=%fadbad_dir% \ - SADADO_DIR=%sacado_dir% \ - IPOPT_DIR=%ipopt_dir% \ - TAPE_ADDR_TYPE=%tape_addr_type% \ - TAPE_ID_TYPE=%tape_id_type% -%$$ -where only the $code configure$$ line need appear; i.e., -the entries in all of the other lines are optional. -The text in italic is replaced values that you choose; -see discussion below. - -$head make$$ -CppAD has some object libraries that are used for its correctness tests. -(Currently, none of these libraries get installed.) -You can build these libraries by executing the command -$codei% - make -%$$ -in the build directory. - -$subhead Examples and Tests$$ -Once you have executed the $code make$$ command, -you can run the correctness and speed tests. -$pre - -$$ -The following command will build all the correctness and speed tests. -In addition, it will run all the correctness tests: -$codep - make test -$$ -$pre - -$$ -The following links describe how to build and run subsets of these tests: -$table -$cref/get_started/get_started.cpp/Running/$$ - $cnext $title get_started.cpp$$ -$rnext -$cref/exp_apx_main/exp_apx_main.cpp/Running Tests/$$ - $cnext $title exp_apx_main.cpp$$ -$rnext -$cref/example/example.cpp/Running Tests/$$ - $cnext $title example.cpp$$ -$rnext -$cref/print_for_cout/print_for_cout.cpp/Running/$$ - $cnext $title print_for_cout.cpp$$ -$rnext -$cref/speed_example/speed_example.cpp/Running Tests/$$ - $cnext $title speed_example.cpp$$ -$rnext -$cref/speed_double/speed_double/Running Tests/$$ - $cnext $title speed_double$$ -$rnext -$cref/speed_adolc/speed_adolc/Running Tests/$$ - $cnext $title speed_adolc$$ -$rnext -$cref/speed_cppad/speed_cppad/Running Tests/$$ - $cnext $title speed_cppad$$ -$rnext -$cref/speed_fadbad/speed_fadbad/Running Tests/$$ - $cnext $title speed_fadbad$$ -$rnext -$cref/speed_sacado/speed_sacado/Running Tests/$$ - $cnext $title speed_sacado$$ -$tend -In addition, -you can run a large subset of correctness tests -(that are not intended to be examples) -by executing the following commands starting in the build directory: -$codei% - cd test_more - make test -%$$ - -$head Profiling CppAD$$ -$index speed, profile cppad$$ -$index profile, cppad speed$$ -$index cppad, profile speed$$ -The CppAD derivative speed tests mentioned above can be profiled. -You can test that the results computed during this profiling are correct -by executing the following commands starting in the build directory: -$codei% - cd speed/profile - make test -%$$ -After executing $code make test$$, you can run a profile speed test -by executing the command $code ./profile$$; -see $cref speed_main$$ for the meaning of the command line -options to this program. -$pre - -$$ -After you have run a profiling speed test, -you can then obtain the profiling results with -$codei% - gprof -b profile -%$$ -If you are using a windows operating system with Cygwin or MinGW, -you may have to replace $code profile$$ by $code profile.exe$$ -in the $code gprof$$ command above; i.e., -$codep - gprof -b profile.exe -$$ -In C++, template parameters and argument types become part of a -routines's name. -This can make the $code gprof$$ output hard to read -(the routine names can be very long). -You can remove the template parameters and argument types from the -routine names by executing the following command -$codep - gprof -b profile | sed -f gprof.sed -$$ -If you are using a windows operating system with Cygwin or MinGW, -you would need to use -$codep - gprof -b profile.exe | sed -f gprof.sed -$$ - -$head prefix_dir$$ -$index configure, prefix directory$$ -$index prefix, configure directory$$ -$index directory, configure prefix$$ -The default value for prefix directory is $code ^HOME$$ -i.e., by default the CppAD include files -will $cref/install/InstallUnix/make install/$$ below $code ^HOME$$. -If you want to install elsewhere, you will have to use this option. -As an example of using the $codei%--prefix=%prefix_dir%$$ option, -if you specify -$codep - ./configure --prefix=/usr/local -$$ -the CppAD include files will be installed in the directory -$codei% - /usr/local/include/cppad -%$$ -If $cref/--with-Documentation/InstallUnix/--with-Documentation/$$ -is specified, the CppAD documentation files will be installed in the directory -$codei% - /usr/local/share/doc/cppad-20121230 -%$$ - -$head --with-Documentation$$ -$index documentation, install$$ -$index install, documentation$$ -If the command line argument $code --with-Documentation$$ is specified, -the CppAD documentation HTML and XML files are copied to the directory -$codei% - %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230 -%$$ -(see $cref/postfix_dir/InstallUnix/postfix_dir/$$). -The top of the CppAD HTML documentation tree -(with mathematics displayed as LaTex command) will be located at -$codei% - %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230/cppad.htm -%$$ -and the top of the XML documentation tree -(with mathematics displayed as MathML) will be located at -$codei% - %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230/cppad.xml -%$$ - -$head --with-testvector$$ -$index std, test vector$$ -$index boost, test vector$$ -$index eigen, test vector$$ -$index test, vector$$ -$index vector, test$$ -The $cref/CPPAD_TESTVECTOR/testvector/$$ -template class is used for many of the CppAD examples and tests. -The default for this template class is $codei%CppAD::vector<%Scalar%>%$$. -If one, and only one, of the following command line arguments is specified: -$codep - --with-stdvector - --with-boostvector - --with-eigenvector -$$ -the corresponding of the following template classes is used -$codei% - std::vector<%Scalar%> - boost::numeric::ublas::vector<%Scalar%> - Eigen::matrix<%Scalar%, Eigen::Dynamic, 1> -%$$ -See also, -$cref/boost_dir/InstallUnix/boost_dir/$$ -and -$cref/eigen_dir/InstallUnix/eigen_dir/$$. - - -$head --with-sparse_option$$ -$index sparse, internal vector sets$$ -$index internal, sparse vector sets$$ -$index sets, internal sparse vector$$ -There are two options for the preprocessor symbol -$code CPPAD_INTERNAL_SPARSE_SET$$. -If $code --with-sparse_set$$ -($code --with-sparse_list$$) is specified, -this symbol is $code sparse_set$$ ($code sparse_list$$). -This should affect the speed and memory required by the -$cref sparse_jacobian$$, $cref sparse_hessian$$, and the -$cref/sparse drivers/sparse/$$. - -$head --with-implicit_ctor$$ -$index ctor, implicit or explicit$$ -$index implicit, ctor$$ -$index explicit, ctor$$ -If this configure argument is present, there is a -$cref/deprecated/ad_ctor/x/deprecated/$$ -implicit type constructor (type conversion) -from any type to $codei%AD<%Base%>%$$. -Otherwise this constructor is -$cref/explicit/ad_ctor/x/explicit/$$. - - -$head max_num_threads$$ -this specifies the value for the default value for the preprocessor symbol -$cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$. -It must be greater than or equal to four; i.e., -$icode%max_num_threads% >= 4%$$. - -$head cxx_flags$$ -$index compile, unix flags$$ -$index flags, unix compile$$ -If the command line argument $icode CompilerFlags$$ is present, -it specifies compiler flags. -For example, -$codei% - CXX_FLAGS="-Wall -ansi" -%$$ -would specify that warning flags $code -Wall$$ -and $code -ansi$$ should be included -in all the C++ compile commands. -The error and warning flags chosen must be valid options -for the C++ compiler. -The default value for $icode CompilerFlags$$ is the -empty string. - -$head openmp_flags$$ -$index OpenMP, compile flags$$ -$index compile, OpenMP flags$$ -$index flags, OpenMP compile$$ -If the command line argument $icode OpenmpFlags$$ is present, -it specifies the necessary flags so that the compiler will -properly interpret OpenMP directives. -For example, when using the GNU $code g++$$ compiler, -the following setting includes the OpenMP tests: -$codei% - OPENMP_FLAGS=-fopenmp -%$$ -If you specify configure command, -the CppAD OpenMP correctness and speed tests will be built; see -$cref/threading/thread_test.cpp/Running Tests/threading/$$ -multi-threading tests. - -$head postfix_dir$$ -$index configure, postfix directory$$ -$index postfix, configure directory$$ -$index directory, configure postfix$$ -By default, the postfix directory is empty; i.e., there -is no postfix directory. -As an example of using the $codei%POSTFIX_DIR=%postfix_dir%$$ option, -if you specify -$codep - ./configure --prefix=/usr/local POSTFIX_DIR=coin -$$ -the CppAD include files will be -$cref/installed/InstallUnix/make install/$$ in the directory -$codei% - /usr/local/include/coin/cppad -%$$ -If $cref/--with-Documentation/InstallUnix/--with-Documentation/$$ -is specified, the CppAD documentation files will be installed in the directory -$codei% - /usr/local/share/doc/coin/cppad-20121230 -%$$ - -$head adolc_dir$$ -$index Adolc, unix$$ -If you have -$href% - http://www.math.tu-dresden.de/~adol-c/% - Adolc 1.10.2 -%$$ -installed on your system, you can -specify a value for $icode adolc_dir$$ in the -$cref/configure/InstallUnix/Configure/$$ command line. -The value of $icode adolc_dir$$ must be such that -$codei% - %adolc_dir%/include/adolc/adouble.h -%$$ -is a valid way to reference $code adouble.h$$. -In this case, you can run the Adolc speed correctness tests -by executing the following commands starting in the build directory: -$codei% - cd speed/adolc - make test -%$$ -After executing $code make test$$, you can run an Adolc speed tests -by executing the command $code ./adolc$$; -see $cref speed_main$$ for the meaning of the command line -options to this program. -Note that these speed tests assume Adolc has been configure with -its sparse matrix computations enabled using -$codei% - --with-colpack=%colpack_dir% -%$$ - -$subhead Linux$$ -If you are using Linux, -you will have to add $icode%adolc_dir%/lib%$$ to $code LD_LIBRARY_PATH$$. -For example, if you use the $code bash$$ shell to run your programs, -you could include -$codei% - LD_LIBRARY_PATH=%adolc_dir%/lib:^{LD_LIBRARY_PATH} - export LD_LIBRARY_PATH -%$$ -in your $code ^HOME/.bash_profile$$ file. - -$subhead Cygwin$$ -If you are using Cygwin, -you will have to add to following lines to the file -$code .bash_profile$$ in your home directory: -$codei% - PATH=%adolc_dir%/bin:^{PATH} - export PATH -%$$ -in order for Adolc to run properly. -If $icode adolc_dir$$ begins with a disk specification, -you must use the Cygwin format for the disk specification. -For example, -if $code d:/adolc_base$$ is the proper directory, -$code /cygdrive/d/adolc_base$$ should be used for $icode adolc_dir$$. - -$head boost_dir$$ -$index boost, unix$$ -If the command line argument -$codei% - BOOST_DIR=%boost_dir% -%$$ -is present, it must be such that files -$codei% - %boost_dir%/include/boost/numeric/ublas/vector.hpp - %boost_dir%/include/boost/thread.hpp -%$$ -are present. -In this case, these files will be used by CppAD. -See also, $cref/--with-boostvector/InstallUnix/--with-testvector/$$ - -$head eigen_dir$$ -$index Eigen, unix$$ -If you have -$href%http://eigen.tuxfamily.org%Eigen%$$ -installed on your system, you can -specify a value for $icode eigen_dir$$. -It must be such that -$codei% - %eigen_dir%/include/Eigen/Core -%$$ -is a valid include file. -In this case CppAD will compile and test the Eigen examples; e.g., -$cref eigen_array.cpp$$. -See also, $cref/--with-eigenvector/InstallUnix/--with-testvector/$$ - -$head fadbad_dir$$ -$index Fadbad, unix$$ -If you have -$href% - http://www.fadbad.com/% - Fadbad 2.1 -%$$ -installed on your system, you can -specify a value for $icode fadbad_dir$$. -It must be such that -$codei% - %fadbad_dir%/include/FADBAD++/badiff.h -%$$ -is a valid reference to $code badiff.h$$. -In this case, you can run the Fadbad speed correctness tests -by executing the following commands starting in the build directory: -$codei% - cd speed/fadbad - make test -%$$ -After executing $code make test$$, you can run a Fadbad speed tests -by executing the command $code ./fadbad$$; -see $cref speed_main$$ for the meaning of the command line -options to this program. - -$head ipopt_dir$$ -$index Ipopt, unix$$ -If you have -$href% - http://www.coin-or.org/projects/Ipopt.xml% - Ipopt -%$$ -installed on your system, you can -specify a value for $icode ipopt_dir$$. -It must be such that -$codei% - %ipopt_dir%/include/coin/IpIpoptApplication.hpp -%$$ -is a valid reference to $code IpIpoptApplication.hpp$$. -In this case, the CppAD interface to Ipopt -$cref/examples/cppad_ipopt_nlp/Example/$$ can be built and tested -by executing the following commands starting in the build directory: -$codei% - make - # - cd cppad_ipopt/example - make test - # - cd ../test - make test - # - cd ../speed - make test -%$$ -Once this has been done, you can execute the program -$code ./speed$$ in the $code build/cppad_ipopt/speed$$ directory; -see $cref ipopt_ode_speed.cpp$$. - -$head sacado_dir$$ -$index Sacado, unix$$ -If you have -$href% - http://trilinos.sandia.gov/packages/sacado/% - Sacado -%$$ -installed on your system, you can -specify a value for $icode sacado_dir$$. -It must be such that -$codei% - %sacado_dir%/include/Sacado.hpp -%$$ -is a valid reference to $code Sacado.hpp$$. -In this case, you can run the Sacado speed correctness tests -by executing the following commands starting in the build directory: -$codei% - cd speed/sacado - make test -%$$ -After executing $code make test$$, you can run a Sacado speed tests -by executing the command $code ./sacado$$; -see $cref speed_main$$ for the meaning of the command line -options to this program. - - -$head tape_addr_type$$ -$index memory, usage$$ -$index memory, tape$$ -$index tape, memory$$ -If the command line argument $icode tape_addr_type$$ is present, -it specifies the type used for address in the AD recordings (tapes). -The valid values for this argument are -$code unsigned short int$$, -$code unsigned int$$, -$code size_t$$. -The smaller the value of $icode%sizeof(%tape_addr_type%)%$$, -the less memory is used. -On the other hand, the value -$codei% - std::numeric_limits<%tape_addr_type%>::max() -%$$ -must be larger than any of the following: -$cref/size_op/seq_property/size_op/$$, -$cref/size_op_arg/seq_property/size_op_arg/$$, -$cref/size_par/seq_property/size_text/$$, -$cref/size_par/seq_property/size_par/$$, -$cref/size_par/seq_property/size_VecAD/$$. - - -$head tape_id_type$$ -$index memory, usage$$ -$index memory, tape$$ -$index tape, memory$$ -If the command line argument $icode tape_id_type$$ is present, -it specifies the type used for identifying tapes. -The valid values for this argument are -$code unsigned short int$$, -$code unsigned int$$, -$code size_t$$. -The smaller the value of $icode%sizeof(%tape_id_type%)%$$, -the less memory is used. -On the other hand, the value -$codei% - std::numeric_limits<%tape_id_type%>::max() -%$$ -must be larger than the maximum number of tapes per thread -times $cref/max_num_threads/InstallUnix/max_num_threads/$$. - -$head make install$$ -Once you are satisfied that the tests are giving correct results, -you can install CppAD into easy to use directories by executing the command -$codep - make install -$$ -This will install CppAD in the location specified by -$cref/prefix_dir/InstallUnix/prefix_dir/$$. -You must have permission to write in the $icode prefix_dir$$ -directory to execute this command. -You may optionally specify a destination directory for the install; i.e., -$codei% - make install DESTDIR=%DestinationDirectory% -%$$ - -$end diff -Nru cppad-2015.00.00.9/omh/introduction.omh cppad-2016.00.00.1/omh/introduction.omh --- cppad-2015.00.00.9/omh/introduction.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/introduction.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: introduction.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: introduction.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,49 +18,46 @@ $$ -$index introduction, AD$$ -$index AD, introduction$$ -$index Algorithmic Differentiation, introduction$$ -$index Automatic Differentiation, introduction$$ $section An Introduction by Example to Algorithmic Differentiation$$ +$mindex AD Automatic$$ $head Purpose$$ This is an introduction by example to Algorithmic Differentiation. Its purpose is to aid in understand what AD calculates, how the calculations are preformed, -and the amount of computation and memory required +and the amount of computation and memory required for a forward or reverse sweep. $head Preface$$ $subhead Algorithmic Differentiation$$ -Algorithmic Differentiation +Algorithmic Differentiation (often referred to as Automatic Differentiation or just AD) -uses the software representation +uses the software representation of a function to obtain an efficient method for calculating its derivatives. -These derivatives can be of arbitrary order and are analytic in nature +These derivatives can be of arbitrary order and are analytic in nature (do not have any truncation error). $subhead Forward Mode$$ -A forward mode sweep computes +A forward mode sweep computes the partial derivative of all the dependent variables with respect -to one independent variable (or independent variable direction). +to one independent variable (or independent variable direction). $subhead Reverse Mode$$ -A reverse mode sweep computes +A reverse mode sweep computes the derivative of one dependent variable -(or one dependent variable direction) +(or one dependent variable direction) with respect to all the independent variables. $subhead Operation Count$$ -The number of floating point operations for either a +The number of floating point operations for either a forward or reverse mode sweep -is a small multiple of the number required to evaluate the original function. +is a small multiple of the number required to evaluate the original function. Thus, using reverse mode, -you can evaluate the derivative of a scalar valued function +you can evaluate the derivative of a scalar valued function with respect to thousands of variables in a small multiple of the work to evaluate the original function. @@ -75,12 +72,12 @@ $head Outline$$ $list Alpha$$ -Demonstrate the use of CppAD to calculate derivatives of a +Demonstrate the use of CppAD to calculate derivatives of a polynomial: $cref get_started.cpp$$. $lnext Present two algorithms that approximate the exponential function. -The first algorithm $cref exp_2.hpp$$ is simpler and does not +The first algorithm $cref exp_2.hpp$$ is simpler and does not include any logical variables or loops. The second algorithm $cref exp_eps.hpp$$ includes logical operations and a $code while$$ loop. @@ -101,7 +98,7 @@ Compute a reverse sweep derivative of the operation sequence ($cref exp_2_rev1$$ and $cref exp_eps_rev1$$). $lnext -Use CppAD to compute both a forward and reverse sweep +Use CppAD to compute both a forward and reverse sweep of the operation sequence ($cref exp_2_cppad$$ and $cref exp_eps_cppad$$). $lend @@ -113,14 +110,14 @@ $lend $head Reference$$ -An in-depth review of AD theory and methods can be found in +An in-depth review of AD theory and methods can be found in the book -$icode +$icode Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation $$, Andreas Griewank, -SIAM Frontiers in Applied Mathematics, +SIAM Frontiers in Applied Mathematics, 2000. $childtable% diff -Nru cppad-2015.00.00.9/omh/library.omh cppad-2016.00.00.1/omh/library.omh --- cppad-2015.00.00.9/omh/library.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/library.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -$Id: library.omh 2506 2012-10-24 19:36:49Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -$begin library$$ -$spell - CppAD - namespace -$$ - -$index numerical, C++ template library$$ -$index template, numerical C++ library$$ -$index C++, numerical template library$$ -$index library, numerical C++ template$$ - -$section The CppAD General Purpose Library$$ - -$children% - cppad/error_handler.hpp% - - cppad/near_equal.hpp% - cppad/speed_test.hpp% - cppad/time_test.hpp% - - omh/numeric_type.omh% - cppad/check_numeric_type.hpp% - omh/simple_vector.omh% - cppad/check_simple_vector.hpp% - - cppad/nan.hpp% - cppad/pow_int.hpp% - cppad/poly.hpp% - omh/lu_det_and_solve.omh% - cppad/romberg_one.hpp% - cppad/romberg_mul.hpp% - cppad/runge_45.hpp% - cppad/rosen_34.hpp% - cppad/ode_err_control.hpp% - cppad/ode_gear.hpp% - cppad/ode_gear_control.hpp% - - cppad/vector.hpp% - omh/thread_alloc.omh% - cppad/index_sort.hpp% - - cppad/local/bender_quad.hpp% - cppad/local/opt_val_hes.hpp% - cppad/local/lu_ratio.hpp -%$$ - -$head Error Handler$$ -All of the routines in the CppAD namespace use the following -general purpose error handler: -$table -$rref ErrorHandler$$ -$tend - -$head Testing Utilities$$ -The routines listed below support numerical correctness and speed testing: -$table -$rref NearEqual$$ -$rref time_test$$ -$rref speed_test$$ -$rref SpeedTest$$ -$tend - -$head C++ Concepts$$ -$index concept, C++$$ -We refer to a the set of classes that satisfy certain conditions -as a C++ concept. -The following concepts are used by the CppAD Template library: -$table -$rref NumericType$$ -$rref CheckNumericType$$ -$rref SimpleVector$$ -$rref CheckSimpleVector$$ -$tend - - -$head CppAD Numerical Template Library$$ -The routines listed below are general purpose numerical routines -written with the floating point type a C++ template parameter. -This enables them to be used with algorithmic differentiation types, -as well as for other purposes. -$table -$rref nan$$ -$rref pow_int$$ -$rref Poly$$ -$rref LuDetAndSolve$$ -$rref RombergOne$$ -$rref RombergMul$$ -$rref Runge45$$ -$rref Rosen34$$ -$rref OdeErrControl$$ -$rref OdeGear$$ -$rref OdeGearControl$$ -$tend - -$head General Purpose Utilities$$ -The classes and routines below are of general use -(not necessarily AD related). -$table -$rref CppAD_vector$$ -$rref thread_alloc$$ -$rref index_sort$$ -$tend - -$head Numerical AD Library$$ -The routines listed below are numerical routines that are specially -designed to work with CppAD in particular. -$table -$rref BenderQuad$$ -$rref opt_val_hes$$ -$rref LuRatio$$ -$tend - -$end diff -Nru cppad-2015.00.00.9/omh/license.omh cppad-2016.00.00.1/omh/license.omh --- cppad-2015.00.00.9/omh/license.omh 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/omh/license.omh 2016-02-09 08:31:59.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: license.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: license.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/omh/lu_det_and_solve.omh cppad-2016.00.00.1/omh/lu_det_and_solve.omh --- cppad-2015.00.00.9/omh/lu_det_and_solve.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/lu_det_and_solve.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: lu_det_and_solve.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: lu_det_and_solve.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,21 +12,15 @@ $begin LuDetAndSolve$$ -$index matrix, factor$$ -$index matrix, determinant$$ -$index matrix, linear equation$$ - -$index factor, matrix$$ -$index determinant$$ -$index linear, equation$$ -$index equation, linear$$ + $section Compute Determinants and Solve Equations by LU Factorization$$ +$mindex matrix factor linear$$ $childtable% - cppad/lu_solve.hpp% - cppad/lu_factor.hpp% - cppad/lu_invert.hpp + cppad/utility/lu_solve.hpp% + cppad/utility/lu_factor.hpp% + cppad/utility/lu_invert.hpp %$$ $end diff -Nru cppad-2015.00.00.9/omh/lu_factor_hpp.omh cppad-2016.00.00.1/omh/lu_factor_hpp.omh --- cppad-2015.00.00.9/omh/lu_factor_hpp.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/lu_factor_hpp.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: lu_factor_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: lu_factor_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,17 +18,16 @@ $$ $section Source: LuFactor$$ +$mindex source$$ -$index LuFactor, source$$ -$index source, LuFactor$$ $code -# ifndef CPPAD_LU_FACTOR_INCLUDED +# ifndef CPPAD_LU_FACTOR_HPP $pre $$ -# define CPPAD_LU_FACTOR_INCLUDED +# define CPPAD_LU_FACTOR_HPP -$verbatim%cppad/lu_factor.hpp%0%// BEGIN C++%// END C++%$$ +$verbatim%cppad/utility/lu_factor.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2015.00.00.9/omh/lu_invert_hpp.omh cppad-2016.00.00.1/omh/lu_invert_hpp.omh --- cppad-2015.00.00.9/omh/lu_invert_hpp.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/lu_invert_hpp.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: lu_invert_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: lu_invert_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,17 +18,16 @@ $$ $section Source: LuInvert$$ +$mindex source$$ -$index LuInvert, source$$ -$index source, LuInvert$$ $code -# ifndef CPPAD_LU_INVERT_INCLUDED +# ifndef CPPAD_LU_INVERT_HPP $pre $$ -# define CPPAD_LU_INVERT_INCLUDED +# define CPPAD_LU_INVERT_HPP -$verbatim%cppad/lu_invert.hpp%0%// BEGIN C++%// END C++%$$ +$verbatim%cppad/utility/lu_invert.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2015.00.00.9/omh/lu_solve_hpp.omh cppad-2016.00.00.1/omh/lu_solve_hpp.omh --- cppad-2015.00.00.9/omh/lu_solve_hpp.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/lu_solve_hpp.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: lu_solve_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: lu_solve_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,17 +18,16 @@ $$ $section Source: LuSolve$$ +$mindex source$$ -$index LuSolve, source$$ -$index source, LuSolve$$ $code -# ifndef CPPAD_LU_SOLVE_INCLUDED +# ifndef CPPAD_LU_SOLVE_HPP $pre $$ -# define CPPAD_LU_SOLVE_INCLUDED +# define CPPAD_LU_SOLVE_HPP -$verbatim%cppad/lu_solve.hpp%0%// BEGIN C++%// END C++%$$ +$verbatim%cppad/utility/lu_solve.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2015.00.00.9/omh/mat_sum_sq_hpp.omh cppad-2016.00.00.1/omh/mat_sum_sq_hpp.omh --- cppad-2015.00.00.9/omh/mat_sum_sq_hpp.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/mat_sum_sq_hpp.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: mat_sum_sq_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: mat_sum_sq_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: mat_sum_sq$$ +$mindex source$$ -$index mat_sum_sq, source$$ -$index source, mat_sum_sq$$ $code -# ifndef CPPAD_MAT_SUM_SQ_INCLUDED +# ifndef CPPAD_MAT_SUM_SQ_HPP $pre $$ -# define CPPAD_MAT_SUM_SQ_INCLUDED +# define CPPAD_MAT_SUM_SQ_HPP $verbatim%cppad/speed/mat_sum_sq.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/mul_level.omh cppad-2016.00.00.1/omh/mul_level.omh --- cppad-2015.00.00.9/omh/mul_level.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/mul_level.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: mul_level.omh 2780 2013-04-20 03:07:14Z bradbell $ +$Id: mul_level.omh 3735 2015-10-01 13:43:46Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,127 +20,131 @@ Arg $$ -$index multiple, AD level$$ -$index AD, multiple level$$ -$index level, multiple AD$$ $section Using Multiple Levels of AD$$ $head Background$$ If $icode f$$ is an $codei%ADFun<%Base%>%$$ object, -the vectors returned by +the vectors returned by $cref/f.Forward/Forward/$$, and $cref/f.Reverse/Reverse/$$, -have values in the base type ($icode Base$$) and not +have values of type $icode Base$$ and not $codei%AD<%Base%>%$$. This reflects the fact that operations used to calculate these function values are not recorded by the tape corresponding to -$codei%AD<%Base%>%$$ operations. +$codei%AD<%Base%>%$$ operations. $head Motivation$$ -Suppose that you uses derivatives of one or more inner functions -as part of the operations +Suppose that you use derivatives of one or more inner functions +as part of the operations needed to compute an outer function. For example, the derivatives returned by $icode%f%.Forward%$$ -might be used as part of +might be used as part of Taylor's method for solving ordinary -differential equations. +differential equations. In addition, we might want to differentiate the solution of a differential equation with respect to parameters in the equation. This can be accomplished in the following way: $list number$$ -The operations during the calculations of the function defining the -differential equation could be preformed using the a class of the form -$codei% AD< AD >%$$. +The function defining the +differential equation could be calculated using the class +$codei AD< AD >$$. $lnext The operations during the calculation of Taylor's method -could be preformed using the $codei% AD%$$ class. +could be done using the $codei AD$$ class. $lnext -The results of the solution of the differential equation -could then be preformed using the $code double$$ class. +Derivatives of the solution of the differential equation +could then be calculated using the $code double$$ class. $lend -$head General Solution$$ -Provided that we are currently recording -$codei% AD%$$ operations, -and $icode fin$$ is an $codei%ADFun< AD >%$$ object, -the operations used to compute the vectors -returned by -$icode%fin%.Forward%$$, -$icode%fin%.Rev%$$, -and -$icode%fin%.RevTwo%$$, -will be recorded on the tape corresponding to -$codei%AD%$$ operations. - +$head Procedure$$ -$head General Procedure$$ +$subhead First Start AD$$ +If some of the $cref/parameters/glossary/Parameter/$$ +in the $codei AD< AD >$$ recording depend on the +$cref/variables/glossary/Variable/$$ +in the $codei AD$$ recording, +we must first declaring these variables; i.e., +$codei% + Independent(%a1x%) +%$$ +where $icode a1x$$ is +a $cref SimpleVector$$ with elements of type $codei AD$$. +This will start recording a new tape of +operations performed using $codei AD$$ class objects. -$subhead Start ADBaseTape$$ -The first step is to declare the independent variables using +$subhead Start AD< AD > Recording$$ +The next step is to declare the independent variables using $codei% - Independent(%x%) + Independent(%a2x%) %$$ -where $icode x$$ is -a $cref SimpleVector$$ with elements of type $codei%AD%$$. +where $icode a2x$$ is +a $cref SimpleVector$$ with elements of type +$codei AD< AD >$$. This will start recording a new tape of -operations performed using $codei%AD%$$ class objects. +operations performed using $codei AD< AD >$$ class objects. -$subhead Start ADDBaseTape$$ -The next step is to declare the independent variables using +$subhead Inner Function$$ +The next step is to calculation the inner function +using $codei AD< AD >$$ class objects. +We then stop the recording using +$codei% + %a1f%.Dependent(%a2x%, %a2y%) +%$$ +where $icode a2y$$ is +a $cref SimpleVector$$ with elements of type +$codei AD< AD >$$ +and $icode a1f$$ is an $codei%ADFun< AD >%$$ object. + +$subhead Second Start AD< AD >$$ +If none of the $cref/parameters/glossary/Parameter/$$ +in the $codei AD< AD >$$ recording depend on the +$cref/variables/glossary/Variable/$$ +in the $codei AD$$ recording, +it is preferred to delay declaring these variables to this point; i.e., $codei% - Independent(%X%) + Independent(%a1x%) %$$ -where $icode X$$ is -a $cref SimpleVector$$ with elements of type -$codei%AD< AD) >%$$. -This will start recording a new tape of -operations performed using $codei%AD< AD >%$$ class objects. - -$subhead Inner Function Calculations$$ -The next step is to calculation -the inner functions -using $codei%AD< AD >%$$ class objects. - -$subhead Derivative of Inner Function$$ -The next step is to create the -$codei%ADFun< AD >%$$ function object $icode fin$$. -This will also stop recording of -operations performed using $codei%AD< AD >%$$ class objects. -The $icode fin$$ object can then be used to calculate -the derivatives needed to compute the outer function. +where $icode a1x$$ is +a $cref SimpleVector$$ with elements of type $codei AD$$. +This will start recording a new tape of +operations performed using $codei AD$$ class objects. $subhead Outer Function$$ -The next step is to compute the -outer function -using $codei%AD%$$ class objects. - -$subhead Derivative of Outer Function$$ -The next step is to create the -$codei%ADFun%$$ function object $icode fout$$. -This will also stop the recording of -operations performed using $codei%AD%$$ class objects. -The $icode fout$$ object can then be used to calculate -the derivatives of the outer function. +The next step is to calculation the outer function +using $codei AD$$ class objects. +Note that derivatives of the inner function can be included +in the calculation of the outer function using $icode a1f$$. +We then stop the recording of $codei AD$$ operations using +$codei% + %g%.Dependent(%a1x%, %a1y%) +%$$ +where $icode a1y$$ is +a $cref SimpleVector$$ with elements of type +$codei AD$$ +and $icode g$$ is an $codei%ADFun%$$ object. +$subhead Derivatives of Outer Function$$ +The AD function object $icode g$$ can then be used to calculate +the derivatives of the outer function. $children% example/mul_level.cpp% - example/change_const.cpp + example/change_param.cpp %$$ $head Example$$ The files -$cref mul_level.cpp$$ and $cref change_const.cpp$$ -contain an examples and tests of this procedure. +$cref mul_level.cpp$$ and $cref change_param.cpp$$ +contain an examples and tests of this procedure. They return true if they succeed and false otherwise. The file $cref mul_level_ode.cpp$$ is a more complex example use of multiple tapes. diff -Nru cppad-2015.00.00.9/omh/multi_thread.omh cppad-2016.00.00.1/omh/multi_thread.omh --- cppad-2015.00.00.9/omh/multi_thread.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/multi_thread.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: multi_thread.omh 2765 2013-03-03 15:48:35Z bradbell $ */ +// $Id: multi_thread.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,21 +19,15 @@ $$ $section Using CppAD in a Multi-Threading Environment$$ -$index parallel, mode$$ -$index execution, parallel$$ -$index mode, parallel$$ -$index multi-threading$$ +$mindex mode execution maximum number$$ $head Purpose$$ -Extra steps and care must be taken to use CppAD -in $cref/parallel/ta_in_parallel/$$ execution mode. +Extra steps and care must be taken to use CppAD +in $cref/parallel/ta_in_parallel/$$ execution mode. This section collects this information in one place. $head CPPAD_MAX_NUM_THREADS$$ -$index maximum, number of threads$$ -$index threads, maximum number of$$ -$index CPPAD_MAX_NUM_THREADS$$ -The value $code CPPAD_MAX_NUM_THREADS$$ is an absolute maximum for +The value $code CPPAD_MAX_NUM_THREADS$$ is an absolute maximum for the number of threads that CppAD should support. If this preprocessor symbol is defined before including any CppAD header files, @@ -47,7 +41,7 @@ $head parallel_setup$$ Using any of the following routines in a multi-threading environment -requires that $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ +requires that $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ has been completed: $cref/CppAD::vector/CppAD_vector/Memory and Parallel Mode/$$, $cref/CheckSimpleVector/CheckSimpleVector/Parallel Mode/$$, @@ -57,12 +51,12 @@ $head hold_memory$$ Memory allocation should be much faster after calling $code hold_memory$$ with -$cref/value/ta_hold_memory/value/$$ equal to true. +$cref/value/ta_hold_memory/value/$$ equal to true. This may even be true if there is only one thread. $head Parallel AD$$ One must first call -$cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ +$cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ and then call $cref parallel_ad$$ before using $code AD$$ types in $cref/parallel/ta_in_parallel/$$ execution mode. diff -Nru cppad-2015.00.00.9/omh/new_feature.omh cppad-2016.00.00.1/omh/new_feature.omh --- cppad-2015.00.00.9/omh/new_feature.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/new_feature.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: new_feature.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: new_feature.omh 3785 2016-02-08 12:53:06Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,15 +27,15 @@ $section Adding a New Feature to the CppAD Distribution$$ $head Overview$$ -Suppose that you add a new feature to CppAD and the +Suppose that you add a new feature to CppAD and the corresponding include file is $icode%Name%.h%$$. -You should check each of the following steps: +You should check each of the following steps: $list number$$ Add the new file $icode%Name%.h%$$ to the cvs repository. $lnext -Add a test file called $codei%example/%Name%.cpp%$$ that check +Add a test file called $codei%example/%Name%.cpp%$$ that check for correct results (and run the test to make sure it works). $lnext @@ -45,7 +45,7 @@ Add a call to the new test in the file $code example/example.cpp$$. $lnext -Add the file $icode%Name%.cpp%$$ to the list of +Add the file $icode%Name%.cpp%$$ to the list of $code Example_SOURCES$$ in the file $code example/Makefile.am$$. $lnext @@ -53,7 +53,7 @@ corresponding to the Microsoft C++ project file $code example/Example.dsp$$. $lnext -Add the file $icode%Name%.h%$$ to the list of +Add the file $icode%Name%.h%$$ to the list of $code nobase_include_HEADERS$$ in the file $code Makefile.am$$. $lnext diff -Nru cppad-2015.00.00.9/omh/numeric_ad.omh cppad-2016.00.00.1/omh/numeric_ad.omh --- cppad-2015.00.00.9/omh/numeric_ad.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/numeric_ad.omh 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1,31 @@ +$Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +$begin numeric_ad$$ +$spell + CppAD + namespace + alloc +$$ + + +$section Some Numerical AD Utilities$$ +The routines listed below are numerical utilities that are +designed to work with CppAD in particular. + +$childtable% + cppad/local/bender_quad.hpp% + cppad/local/opt_val_hes.hpp% + cppad/local/lu_ratio.hpp +%$$ + +$end diff -Nru cppad-2015.00.00.9/omh/numeric_type.omh cppad-2016.00.00.1/omh/numeric_type.omh --- cppad-2015.00.00.9/omh/numeric_type.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/numeric_type.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: numeric_type.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: numeric_type.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,24 +18,21 @@ valarray $$ -$index numeric, type$$ -$index type, numeric$$ $section Definition of a Numeric Type$$ +$mindex int$$ $head Type Requirements$$ A $icode NumericType$$ is any type that satisfies the requirements below. The following is a list of some numeric types: -$code int$$, $code float$$, $code double$$, +$code int$$, $code float$$, $code double$$, $code AD$$, $code AD< AD >$$. The routine $cref CheckNumericType$$ can be used to check that a type satisfies these conditions. $head Default Constructor$$ -$index default, numeric constructor$$ -$index constructor, numeric$$ -The syntax +The syntax $codei% %NumericType% %x%; %$$ @@ -43,10 +40,8 @@ with an unspecified value. $head Constructor From Integer$$ -$index int, numeric constructor$$ -$index constructor, numeric$$ If $icode i$$ is an $code int$$, -the syntax +the syntax $codei% %NumericType% %x%(%i%); %$$ @@ -54,10 +49,8 @@ equal to $icode i$$ where $icode i$$ can be $code const$$. $head Copy Constructor$$ -$index copy, numeric constructor$$ -$index constructor, numeric copy$$ If $icode x$$ is a $icode NumericType$$ object -the syntax +the syntax $codei% %NumericType% %y%(%x%); %$$ @@ -85,7 +78,7 @@ $icode NumericType$$ objects where $icode x$$ and $icode y$$ may be $code const$$. In the result type column, -$icode NumericType$$ can be replaced by any type that can +$icode NumericType$$ can be replaced by any type that can be used just like a $icode NumericType$$ object. $table $bold Operation$$ $cnext $bold Description$$ $cnext @@ -109,7 +102,7 @@ $icode%z% *= %y%$$ $cnext computed assignment multiplication $cnext unspecified $rnext $icode%z% /= %y%$$ $cnext computed assignment division $cnext - unspecified + unspecified $tend $head Example$$ @@ -123,13 +116,12 @@ (It is easy to modify to test additional numeric types.) $head Exercise$$ -$index exercise, numeric type$$ $list number$$ List three operators that are not supported by every numeric type but that are supported by the numeric types -$code int$$, -$code float$$, +$code int$$, +$code float$$, $code double$$. $lnext diff -Nru cppad-2015.00.00.9/omh/ode_evaluate.omh cppad-2016.00.00.1/omh/ode_evaluate.omh --- cppad-2015.00.00.9/omh/ode_evaluate.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/ode_evaluate.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: ode_evaluate.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: ode_evaluate.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,15 +17,14 @@ $$ $section Source: ode_evaluate$$ +$mindex source$$ -$index ode_evaluate, source$$ -$index source, ode_evaluate$$ $code -# ifndef CPPAD_ODE_EVALUATE_INCLUDED +# ifndef CPPAD_ODE_EVALUATE_HPP $pre $$ -# define CPPAD_ODE_EVALUATE_INCLUDED +# define CPPAD_ODE_EVALUATE_HPP $verbatim%cppad/speed/ode_evaluate.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/omp_alloc_dep.omh cppad-2016.00.00.1/omh/omp_alloc_dep.omh --- cppad-2015.00.00.9/omh/omp_alloc_dep.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/omp_alloc_dep.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: omp_alloc_dep.omh 2859 2013-05-28 06:03:21Z bradbell $ */ +/* $Id: omp_alloc_dep.omh 3740 2015-10-07 03:47:28Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,12 +19,9 @@ $$ $section Check If A Memory Allocation is Efficient for Another Use$$ -$index efficient, omp_alloc$$ -$index omp_alloc, efficient$$ -$index memory, reuse$$ -$index reuse, memory$$ +$mindex omp_alloc reuse$$ -$head Deprecated$$ +$head Deprecated 2011-07-29$$ This function has been deprecated because speed tests seem to indicate it is just as fast, or faster, to free and then reallocate the memory. @@ -32,7 +29,7 @@ $codei%flag% = omp_alloc::efficient(%v_ptr%, %num_bytes%)%$$ $head Purpose$$ -Check if memory that is currently in use is an efficient +Check if memory that is currently in use is an efficient allocation for a specified number of bytes. $head v_ptr$$ @@ -48,7 +45,7 @@ $codei% size_t %num_bytes% %$$ -It specifies the number of bytes of the memory allocated by $icode v_ptr$$ +It specifies the number of bytes of the memory allocated by $icode v_ptr$$ that we want to use. $head flag$$ @@ -56,8 +53,8 @@ $codei% bool %flag% %$$ -It is true, -a call to $code get_memory$$ with +It is true, +a call to $code get_memory$$ with $cref/min_bytes/get_memory/min_bytes/$$ equal to $icode num_bytes$$ would result in a value for $cref/cap_bytes/get_memory/cap_bytes/$$ that is the same as when $code v_ptr$$ @@ -68,13 +65,13 @@ $head Thread$$ Either the $cref/current thread/get_thread_num/$$ must be the same as during the corresponding call to $cref get_memory$$, -or the current execution mode must be sequential +or the current execution mode must be sequential (not $cref/parallel/in_parallel/$$). $head NDEBUG$$ If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). Otherwise, a list of in use pointers is searched to make sure -that $icode v_ptr$$ is in the list. +that $icode v_ptr$$ is in the list. $end ------------------------------------------------------------------------------- @@ -86,15 +83,9 @@ omp_alloc $$ $section Set Maximum Number of Threads for omp_alloc Allocator$$ +$mindex max_num_threads parallel OpenMP initialize$$ + -$index max_num_threads, omp_alloc$$ -$index omp_alloc, max_num_threads$$ -$index parallel, max_num_threads$$ -$index threads, number of$$ - -$index OpenMP, initialize memory$$ -$index memory, initialize OpenMP$$ -$index initialize, OpenMP memory$$ $head Removed$$ This function has been removed from the CppAD API. @@ -112,12 +103,12 @@ The argument $icode number$$ has prototype $codei% size_t %number% -%$$ -It must be greater than zero and specifies the maximum number of +%$$ +It must be greater than zero and specifies the maximum number of OpenMP threads that will be active at one time. $head Restrictions$$ -This function must be called before the program enters +This function must be called before the program enters $cref/parallel/in_parallel/$$ execution mode. $end diff -Nru cppad-2015.00.00.9/omh/poly_hpp.omh cppad-2016.00.00.1/omh/poly_hpp.omh --- cppad-2015.00.00.9/omh/poly_hpp.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/poly_hpp.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: poly_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: poly_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,17 +18,16 @@ $$ $section Source: Poly$$ +$mindex source$$ -$index Poly, source$$ -$index source, Poly$$ $code -# ifndef CPPAD_POLY_INCLUDED +# ifndef CPPAD_POLY_HPP $pre $$ -# define CPPAD_POLY_INCLUDED +# define CPPAD_POLY_HPP -$verbatim%cppad/poly.hpp%0%// BEGIN C++%// END C++%$$ +$verbatim%cppad/utility/poly.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2015.00.00.9/omh/preprocessor.omh cppad-2016.00.00.1/omh/preprocessor.omh --- cppad-2015.00.00.9/omh/preprocessor.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/preprocessor.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: preprocessor.omh 2939 2013-10-14 11:06:18Z bradbell $ */ +// $Id: preprocessor.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,7 @@ $$ $section CppAD API Preprocessor Symbols$$ -$index preprocessor, CPPAD_ symbol$$ -$index symbol, preprocessor CPPAD_$$ -$index CPPAD_, preprocessor symbol$$ +$mindex CPPAD_ NULL pointer$$ $head Purpose$$ The CppAD include files define preprocessor symbols all of which begin @@ -33,15 +31,18 @@ $head Documented Here$$ $subhead CPPAD_NULL$$ -$index NULL, pointer$$ -$index CPPAD_NULL$$ Is a null pointer used by CppAD, instead of just using the value zero which was often done in C++98, which has been replaced by the value $code nullptr$$ in C++11. -$head CPPAD_PACKAGE_STRING$$ +$subhead CPPAD_PACKAGE_STRING$$ Is a $code const char*$$ representation of this version of CppAD. +$subhead CPPAD_USE_CPLUSPLUS_2011$$ +This preprocessor symbol has the value has the value $code 1$$ +if C++11 features are being used by CppAD. +Otherwise it has the value zero. + $head Documented Elsewhere$$ $table @@ -53,18 +54,24 @@ $rnext $cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ $rnext +$cref/CPPAD_NUMERIC_LIMITS/base_limits/CPPAD_NUMERIC_LIMITS/$$ +$rnext +$cref/CPPAD_STANDARD_MATH_UNARY/base_std_math/CPPAD_STANDARD_MATH_UNARY/$$ +$rnext $cref/CPPAD_TAPE_ADDR_TYPE/cmake/cppad_tape_addr_type/$$ $rnext $cref/CPPAD_TAPE_ID_TYPE/cmake/cppad_tape_id_type/$$ $rnext $cref/CPPAD_TESTVECTOR/testvector/$$ +$rnext +$cref/CPPAD_TO_STRING/base_to_string/CPPAD_TO_STRING/$$ $tend $head Deprecated$$ $table -$cref/CppADCreateDiscrete/Discrete/Deprecated/$$ +$cref/CppADCreateDiscrete/Discrete/CppADCreateDiscrete Deprecated 2007-07-28/$$ $rnext -$cref/CppADvector/test_vector/Deprecated/$$ +$cref/CppADvector/test_vector/Deprecated 2012-07-03/$$ $rnext $cref/CPPAD_TEST_VECTOR/test_vector/$$ $rnext diff -Nru cppad-2015.00.00.9/omh/reverse/reverse_any.omh cppad-2016.00.00.1/omh/reverse/reverse_any.omh --- cppad-2015.00.00.9/omh/reverse/reverse_any.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/reverse/reverse_any.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse_any.omh 3348 2014-09-21 09:24:45Z bradbell $ */ +// $Id: reverse_any.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,13 +24,10 @@ Taylor $$ -$section Any Order Reverse Mode$$ +$section Any Order Reverse Mode$$ +$mindex derivative$$ -$index reverse, any order mode$$ -$index any, order reverse mode$$ -$index mode, any order reverse$$ -$index derivative, reverse mode$$ $head Syntax$$ $icode%dw% = %f%.Reverse(%q%, %w%)%$$ @@ -42,7 +39,7 @@ Reverse mode computes the derivative of the $cref Forward$$ mode $cref/Taylor coefficients/glossary/Taylor Coefficient/$$ with respect to the domain variable $latex x$$. -To be specific, it computes the derivative +To be specific, it computes the derivative $latex W^{(1)} (u)$$ at $latex u = x$$ which is specified by the following notation: @@ -50,14 +47,14 @@ $subhead u^(k)$$ For $latex k = 0, \ldots , q-1$$, -the vector $latex u^{(k)} \in B^n$$ is defined as the value of +the vector $latex u^{(k)} \in B^n$$ is defined as the value of $icode x_k$$ in the previous calls of the form $codei% %f%.Forward(%k%, %x_k%) -%$$ +%$$ If there is no previous call with $latex k = 0$$, -$latex u^{(0)}$$ is the value of the independent variables when the -corresponding +$latex u^{(0)}$$ is the value of the independent variables when the +corresponding AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ was recorded. @@ -66,13 +63,13 @@ The function $latex X : B \times B^{n \times q} \rightarrow B^n$$ is defined by $latex \[ - X ( t , u ) = u^{(0)} + u^{(1)} * t + \cdots + u^{(q-1)} * t^{q-1} -\] $$ + X ( t , u ) = u^{(0)} + u^{(1)} * t + \cdots + u^{(q-1)} * t^{q-1} +\] $$ Note that for $latex k = 0 , \ldots , q-1$$, -$latex u^{(k)}$$ is related to the $th k$$ partial of $latex X(t, u)$$ +$latex u^{(k)}$$ is related to the $th k$$ partial of $latex X(t, u)$$ with respect to $latex t$$ by $latex \[ - u^{(k)} = \frac{1}{k !} \Dpow{k}{t} X(0, u) + u^{(k)} = \frac{1}{k !} \Dpow{k}{t} X(0, u) \] $$ $subhead Y(t, u)$$ @@ -133,10 +130,10 @@ const %Vector% &%w% %$$ (see $cref/Vector/reverse_any/Vector/$$ below) -and its size -must be equal to $icode m$$ or $icode%m% * %q%$$, +and its size +must be equal to $icode m$$ or $icode%m% * %q%$$, It specifies the weighting vector $icode w$$ -in the definition of +in the definition of $cref/W(u)/reverse_any/Notation/W(u)/$$. @@ -150,34 +147,34 @@ For $latex j = 0, \ldots, n-1$$ and $latex k = 0 , \ldots , q-1$$ If the argument $icode w$$ has size $icode%m% * %q%$$, $latex \[ - dw[ j * q + k ] = W^{(1)} ( x )_{j,k} + dw[ j * q + k ] = W^{(1)} ( x )_{j,k} \] $$ -where $latex u = x$$ is value of the Taylor coefficients where the +where $latex u = x$$ is value of the Taylor coefficients where the derivative is evaluated. $pre $$ If the argument $icode w$$ has size $icode m$$, $latex \[ - dw[ j * q + q - k - 1 ] = W^{(1)} ( x )_{j,k} + dw[ j * q + q - k - 1 ] = W^{(1)} ( x )_{j,k} \] $$ -where $latex u = x$$ is value of the Taylor coefficients where the +where $latex u = x$$ is value of the Taylor coefficients where the derivative is evaluated. Note the reverse order in which the order indices are stored. This is an unfortunate consequence of keeping $code Reverse$$ backward compatible. $head First Order$$ -We consider the case where +We consider the case where $icode%q% = 1%$$ and $icode%w%.size() == %m%$$. In this case $latex \[ \begin{array}{rcl} W(u) & = & w_0 Y_0 (0, u) + \cdots + w_m Y_m (0, u) -\\ +\\ W(u) & = & w_0 F_0 [ X(0, u) ] + \cdots + w_m F_m [ X(0, u) ] -\\ -W^{(1)} (x) & = & +\\ +W^{(1)} (x) & = & w_0 F_0^{(1)} ( x^{(0)} ) + \cdots + w_m F_m^{(1)} ( x^{(0)} ) \end{array} \] $$ @@ -185,35 +182,35 @@ $head Second Order$$ -We consider the case where +We consider the case where $icode%q% = 2%$$ and $icode%w%.size() == %m%$$. In this case $latex \[ \begin{array}{rcl} W(u) & = & w_0 \partial_t Y_0 (0, u) + \cdots + w_m \partial_t Y_m (0, u) -\\ +\\ W(u) & = & w_0 \partial_t \{ F_0 [ X(t, u) ] \}_{t = 0} - + \cdots + + + \cdots + w_m \partial_t \{ F_m [ X(t, u) ] \}_{t = 0} -\\ +\\ W(u) & = & - w_0 F_0^{(1)} ( u^{(0)} ) u^{(1)} - + \cdots + - w_0 F_m^{(1)} ( u^{(0)} ) u^{(1)} + w_0 F_0^{(1)} ( u^{(0)} ) u^{(1)} + + \cdots + + w_0 F_m^{(1)} ( u^{(0)} ) u^{(1)} \\ \partial_{u(0)} W(x) & = & - w_0 ( x^{(1)} )^\R{T} F_0^{(2)} ( x^{(0)} ) - + \cdots + - w_m ( x^{(1)} )^\R{T} F_m^{(2)} ( x^{(0)} ) + w_0 ( x^{(1)} )^\R{T} F_0^{(2)} ( x^{(0)} ) + + \cdots + + w_m ( x^{(1)} )^\R{T} F_m^{(2)} ( x^{(0)} ) \\ \partial_{u(1)} W(x) & = & - w_0 F_0^{(1)} ( x^{(0)} ) - + \cdots + - w_m F_m^{(1)} ( x^{(0)} ) + w_0 F_0^{(1)} ( x^{(0)} ) + + \cdots + + w_m F_m^{(1)} ( x^{(0)} ) \end{array} \] $$ -where $latex \partial{u(0)} $$ +where $latex \partial{u(0)} $$ denotes partial with respect to $latex u^{(0)}$$. These are the same as the result documented in $cref reverse_two$$. diff -Nru cppad-2015.00.00.9/omh/reverse/reverse.omh cppad-2016.00.00.1/omh/reverse/reverse.omh --- cppad-2015.00.00.9/omh/reverse/reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/reverse/reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse.omh 3301 2014-05-24 05:20:21Z bradbell $ */ +// $Id: reverse.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/omh/reverse/reverse_one.omh cppad-2016.00.00.1/omh/reverse/reverse_one.omh --- cppad-2015.00.00.9/omh/reverse/reverse_one.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/reverse/reverse_one.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse_one.omh 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: reverse_one.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,16 +12,13 @@ $begin reverse_one$$ $section First Order Reverse Mode$$ -$spell +$mindex derivative$$ +$spell taylor const dw $$ -$index reverse, first order mode$$ -$index first, order reverse mode$$ -$index mode, first order reverse$$ -$index derivative, reverse mode$$ $head Syntax$$ $icode%dw% = %f%.Reverse(1, %w%)%$$ @@ -33,13 +30,13 @@ The function $latex W : B^n \rightarrow B$$ is defined by $latex \[ W(x) = w_0 * F_0 ( x ) + \cdots + w_{m-1} * F_{m-1} (x) -\] $$ -The result of this operation is the derivative +\] $$ +The result of this operation is the derivative $latex dw = W^{(1)} (x)$$; i.e., $latex \[ dw = w_0 * F_0^{(1)} ( x ) + \cdots + w_{m-1} * F_{m-1}^{(1)} (x) \] $$ -Note that if $latex w$$ is the $th i$$ +Note that if $latex w$$ is the $th i$$ $cref/elementary vector/glossary/Elementary Vector/$$, $latex dw = F_i^{(1)} (x)$$. @@ -62,7 +59,7 @@ %f%.Forward(0, %x%) %$$ If there is no previous call with the first argument zero, -the value of the $cref/independent/Independent/$$ variables +the value of the $cref/independent/Independent/$$ variables during the recording of the AD sequence of operations is used for $icode x$$. @@ -72,7 +69,7 @@ const %Vector% &%w% %$$ (see $cref/Vector/reverse_one/Vector/$$ below) -and its size +and its size must be equal to $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. @@ -83,7 +80,7 @@ %$$ (see $cref/Vector/reverse_one/Vector/$$ below) and its value is the derivative $latex W^{(1)} (x)$$. -The size of $icode dw$$ +The size of $icode dw$$ is equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. diff -Nru cppad-2015.00.00.9/omh/reverse/reverse_two.omh cppad-2016.00.00.1/omh/reverse/reverse_two.omh --- cppad-2015.00.00.9/omh/reverse/reverse_two.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/reverse/reverse_two.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse_two.omh 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: reverse_two.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,16 +12,13 @@ $begin reverse_two$$ $section Second Order Reverse Mode$$ -$spell +$mindex derivative$$ +$spell taylor const dw $$ -$index reverse, second order mode$$ -$index second, order reverse mode$$ -$index mode, second order reverse$$ -$index derivative, reverse mode$$ $head Syntax$$ $icode%dw% = %f%.Reverse(2, %w%)%$$ @@ -35,41 +32,41 @@ $head x^(k)$$ For $latex k = 0, 1$$, -the vector $latex x^{(k)} \in B^n$$ is defined as the value of +the vector $latex x^{(k)} \in B^n$$ is defined as the value of $icode x_k$$ in the previous call (counting this call) of the form $codei% %f%.Forward(%k%, %x_k%) -%$$ +%$$ If there is no previous call with $latex k = 0$$, -$latex x^{(0)}$$ is the value of the independent variables when the -corresponding +$latex x^{(0)}$$ is the value of the independent variables when the +corresponding AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ was recorded. $head W$$ -The functions -$latex W_0 : B^n \rightarrow B$$ and -$latex W_1 : B^n \rightarrow B$$ +The functions +$latex W_0 : B^n \rightarrow B$$ and +$latex W_1 : B^n \rightarrow B$$ are defined by $latex \[ \begin{array}{rcl} W_0 ( u ) & = & w_0 * F_0 ( u ) + \cdots + w_{m-1} * F_{m-1} (u) \\ -W_1 ( u ) & = & -w_0 * F_0^{(1)} ( u ) * x^{(1)} +W_1 ( u ) & = & +w_0 * F_0^{(1)} ( u ) * x^{(1)} + \cdots + w_{m-1} * F_{m-1}^{(1)} (u) * x^{(1)} \end{array} -\] $$ -This operation computes the derivatives +\] $$ +This operation computes the derivatives $latex \[ \begin{array}{rcl} -W_0^{(1)} (u) & = & +W_0^{(1)} (u) & = & w_0 * F_0^{(1)} ( u ) + \cdots + w_{m-1} * F_{m-1}^{(1)} (u) \\ -W_1^{(1)} (u) & = & - w_0 * \left( x^{(1)} \right)^\R{T} * F_0^{(2)} ( u ) - + \cdots + +W_1^{(1)} (u) & = & + w_0 * \left( x^{(1)} \right)^\R{T} * F_0^{(2)} ( u ) + + \cdots + w_{m-1} * \left( x^{(1)} \right)^\R{T} F_{m-1}^{(2)} (u) \end{array} \] $$ @@ -92,7 +89,7 @@ const %Vector% &%w% %$$ (see $cref/Vector/reverse_two/Vector/$$ below) -and its size +and its size must be equal to $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. @@ -104,20 +101,20 @@ (see $cref/Vector/reverse_two/Vector/$$ below). It contains both the derivative $latex W^{(1)} (x)$$ and the derivative $latex U^{(1)} (x)$$. -The size of $icode dw$$ -is equal to $latex n \times 2$$, +The size of $icode dw$$ +is equal to $latex n \times 2$$, where $latex n$$ is the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. $subhead First Order Partials$$ For $latex j = 0 , \ldots , n - 1$$, $latex \[ -dw [ j * 2 + 0 ] -= -\D{ W_0 }{ u_j } \left( x^{(0)} \right) +dw [ j * 2 + 0 ] += +\D{ W_0 }{ u_j } \left( x^{(0)} \right) = w_0 * \D{ F_0 }{ u_j } \left( x^{(0)} \right) -+ \cdots + ++ \cdots + w_{m-1} * \D{ F_{m-1} }{ u_j } \left( x^{(0)} \right) \] $$ This part of $icode dw$$ contains the same values as are returned @@ -126,13 +123,13 @@ $subhead Second Order Partials$$ For $latex j = 0 , \ldots , n - 1$$, $latex \[ -dw [ j * 2 + 1 ] -= -\D{ W_1 }{ u_j } \left( x^{(0)} \right) +dw [ j * 2 + 1 ] += +\D{ W_1 }{ u_j } \left( x^{(0)} \right) = \sum_{\ell=0}^{n-1} x_\ell^{(1)} \left[ w_0 * \DD{ F_0 }{ u_\ell }{ u_j } \left( x^{(0)} \right) -+ \cdots + ++ \cdots + w_{m-1} * \DD{ F_{m-1} }{ u_\ell }{ u_j } \left( x^{(0)} \right) \right] \] $$ @@ -147,14 +144,14 @@ $head Hessian Times Direction$$ -Suppose that $latex w$$ is the $th i$$ elementary vector. +Suppose that $latex w$$ is the $th i$$ elementary vector. It follows that for $latex j = 0, \ldots, n-1$$ $latex \[ \begin{array}{rcl} -dw[ j * 2 + 1 ] -& = & -w_i \sum_{\ell=0}^{n-1} -\DD{F_i}{ u_j }{ u_\ell } \left( x^{(0)} \right) x_\ell^{(1)} +dw[ j * 2 + 1 ] +& = & +w_i \sum_{\ell=0}^{n-1} +\DD{F_i}{ u_j }{ u_\ell } \left( x^{(0)} \right) x_\ell^{(1)} \\ & = & \left[ F_i^{(2)} \left( x^{(0)} \right) * x^{(1)} \right]_j @@ -163,7 +160,7 @@ Thus the vector $latex ( dw[1], dw[3], \ldots , dw[ n * q - 1 ] )$$ is equal to the Hessian of $latex F_i (x)$$ times the direction $latex x^{(1)}$$. -In the special case where +In the special case where $latex x^{(1)}$$ is the $th l$$ $cref/elementary vector/glossary/Elementary Vector/$$, $latex \[ diff -Nru cppad-2015.00.00.9/omh/seq_property.omh cppad-2016.00.00.1/omh/seq_property.omh --- cppad-2015.00.00.9/omh/seq_property.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/seq_property.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: seq_property.omh 3214 2014-03-18 20:50:38Z bradbell $ +$Id: seq_property.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,7 +11,7 @@ -------------------------------------------------------------------------- */ $begin seq_property$$ -$spell +$spell inuse Addr CppAD @@ -57,7 +57,7 @@ The operations above return properties of the AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ -stored in the ADFun object $icode f$$. +stored in the ADFun object $icode f$$. (If there is no operation sequence stored in $icode f$$, $code size_var$$ returns zero.) @@ -69,8 +69,6 @@ (see $codei%ADFun<%Base%>%$$ $cref/constructor/FunConstruct/$$). $head Domain$$ -$index ADFun, Domain$$ -$index Domain, ADFun$$ The result $icode n$$ has prototype $codei% size_t %n% @@ -80,13 +78,11 @@ $codei% Independent(%x%) %$$ -that starting recording the operation sequence +that starting recording the operation sequence currently stored in $icode f$$ -(see $cref FunConstruct$$ and $cref Dependent$$). +(see $cref FunConstruct$$ and $cref Dependent$$). $head Range$$ -$index ADFun, Range$$ -$index Range, ADFun$$ The result $icode m$$ has prototype $codei% size_t %m% @@ -101,11 +97,9 @@ %f%.Dependent(%y%) %$$ depending on which stored the operation sequence currently in $icode f$$ -(see $cref FunConstruct$$ and $cref Dependent$$). +(see $cref FunConstruct$$ and $cref Dependent$$). $head Parameter$$ -$index ADFun, Parameter$$ -$index Parameter, ADFun$$ The argument $icode i$$ has prototype $codei% size_t %i% @@ -126,8 +120,6 @@ for $latex j = 0 , \ldots , n-1$$ and all $latex x \in B^n$$. $head size_var$$ -$index ADFun, size_var$$ -$index size_var, ADFun$$ The result $icode s$$ has prototype $codei% size_t %s% @@ -137,7 +129,7 @@ one for each component of the range that is a parameter. The amount of work and memory necessary for computing function values and derivatives using $icode f$$ is roughly proportional to $icode s$$. -(The function call $cref/f.size_order()/size_order/$$ +(The function call $cref/f.size_order()/size_order/$$ returns the number of Taylor coefficient orders, per variable,direction, currently stored in $icode f$$.) $pre @@ -148,8 +140,6 @@ (see $cref/default constructor/FunConstruct/Default Constructor/$$). $head size_par$$ -$index ADFun, size_par$$ -$index size_par, ADFun$$ The result $icode s$$ has prototype $codei% size_t %s% @@ -157,8 +147,8 @@ and is the number of parameters in the operation sequence. Parameters differ from variables in that only values (and not derivatives) need to be stored for each parameter. -These parameters are considered part of the operation -sequence, as opposed to the Taylor coefficients which are +These parameters are considered part of the operation +sequence, as opposed to the Taylor coefficients which are considered extra data in the function object $icode f$$. Note that one $icode Base$$ value is required for each parameter. @@ -167,13 +157,13 @@ $codei% size_t %s% %$$ -and is the number of operations in the operation sequence. +and is the number of operations in the operation sequence. Some operators, like comparison operators, do not correspond to a variable. Other operators, like the sine operator, correspond to two variables. -Thus, this value will be different from -$cref/size_var/seq_property/size_var/$$. +Thus, this value will be different from +$cref/size_var/seq_property/size_var/$$. Note that one $code enum$$ value is required for each operator. $head size_op_arg$$ @@ -185,7 +175,7 @@ For example, Binary operators (e.g. addition) have two arguments. Note that one integer index is stored in the operation sequence for each argument. -Also note that, as of 2013-10-20, there is an extra +Also note that, as of 2013-10-20, there is an extra phantom argument with index 0 that is not used. $head size_text$$ @@ -197,15 +187,13 @@ in this operation sequence. $head size_VecAD$$ -$index ADFun, size_VecAD$$ -$index size_VecAD, ADFun$$ The result $icode s$$ has prototype $codei% size_t %s% %$$ and is the number of $cref VecAD$$ vectors, plus the number of elements in the vectors. -Only $code VecAD$$ vectors that depend on the +Only $code VecAD$$ vectors that depend on the independent variables are stored in the operation sequence. $head size_op_seq$$ @@ -234,7 +222,7 @@ example/seq_property.cpp %$$ The file -$cref seq_property.cpp$$ +$cref seq_property.cpp$$ contains an example and test of these operations. It returns true if it succeeds and false otherwise. diff -Nru cppad-2015.00.00.9/omh/simple_vector.omh cppad-2016.00.00.1/omh/simple_vector.omh --- cppad-2015.00.00.9/omh/simple_vector.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/simple_vector.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: simple_vector.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: simple_vector.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,12 +20,9 @@ Resize $$ -$index vector, simple$$ -$index simple, vector$$ -$index class, simple vector$$ -$index template, simple vector class$$ $section Definition of a Simple Vector$$ +$mindex value_type [] NDEBUG$$ $head Template Class Requirements$$ A simple vector template class $icode SimpleVector$$, @@ -34,10 +31,10 @@ The following is a list of some simple vector template classes: $table $bold Name$$ $cnext $bold Documentation$$ $rnext -$code std::vector$$ $cnext Section 16.3 of +$code std::vector$$ $cnext Section 16.3 of $cref/The C++ Programming Language/Bib/The C++ Programming Language/$$ $rnext -$code std::valarray$$ $cnext Section 22.4 of +$code std::valarray$$ $cnext Section 22.4 of $cref/The C++ Programming Language/Bib/The C++ Programming Language/$$ $rnext $code CppAD::vector$$ $cnext $tref CppAD_vector$$ @@ -53,9 +50,7 @@ that a class is a simple vector class with a specified element type. $head Default Constructor$$ -$index default, vector constructor$$ -$index constructor, vector default$$ -The syntax +The syntax $codei% %SimpleVector%<%Scalar%> %x%; %$$ @@ -64,9 +59,7 @@ (see $cref/resize/SimpleVector/Resize/$$ below). $head Sizing Constructor$$ -$index size, vector constructor$$ -$index constructor, size vector$$ -If $icode n$$ has type $code size_t$$, +If $icode n$$ has type $code size_t$$, $codei% %SimpleVector%<%Scalar%> %x%(%n%) %$$ @@ -74,8 +67,6 @@ each of the specified type. $head Copy Constructor$$ -$index copy, vector constructor$$ -$index constructor, copy vector$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object, $codei% %SimpleVector%<%Scalar%> %y%(%x%) @@ -91,22 +82,19 @@ and may be $code const$$. $head Element Constructor and Destructor$$ -$index constructor, element$$ -$index destructor, element$$ The default constructor for type $icode Scalar$$ is called for every element in a vector when the vector element is created. The $icode Scalar$$ destructor is called when it is removed from the vector (this includes when the vector is destroyed). $head Assignment$$ -$index assignment, vector$$ -If $icode x$$ and $icode y$$ are +If $icode x$$ and $icode y$$ are $icode%SimpleVector%<%Scalar%>%$$ objects, $codei% %y% = %x% %$$ uses the $icode Scalar$$ assignment operator ( $code =$$ ) -to set each element of $icode y$$ equal to +to set each element of $icode y$$ equal to the corresponding element of $icode x$$. This is a `deep assignment' in that the values of the elements of $icode x$$ and $icode y$$ can be set independently after the assignment. @@ -125,7 +113,6 @@ would not be valid. $head Size$$ -$index size, vector$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $code n$$ has type $code size_t$$, $codei% @@ -135,7 +122,6 @@ The object $icode x$$ may be $code const$$. $head Resize$$ -$index resize, vector$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $code n$$ has type $code size_t$$, $codei% @@ -149,7 +135,6 @@ (The object $icode x$$ can not be $code const$$.) $head Value Type$$ -$index value_type, vector$$ If $icode Vector$$ is any simple vector class, the syntax $codei% @@ -162,7 +147,6 @@ is equal to $icode Scalar$$. $head Element Access$$ -$index [], vector$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $icode i$$ has type $code size_t$$, $codei% @@ -206,7 +190,6 @@ (It is easy to modify to test additional simple vector template classes.) $head Exercise$$ -$index exercise, simple vector$$ $list number$$ If $icode Vector$$ is a simple vector template class, the following code may not be valid: @@ -218,8 +201,7 @@ above where $icode Vector$$ is each of the following cases: $code std::vector$$, $code CppAD::vector$$. -$index NDEBUG$$ -Do this both where the compiler option +Do this both where the compiler option $code -DNDEBUG$$ is and is not present on the compilation command line. $lnext If $icode Vector$$ is a simple vector template class, @@ -235,7 +217,7 @@ above where $icode Vector$$ is each of the following cases: $code std::valarray$$, $code CppAD::vector$$. -Do this both where the compiler option +Do this both where the compiler option $code -DNDEBUG$$ is and is not present on the compilation command line. $lend diff -Nru cppad-2015.00.00.9/omh/sin_forward.omh cppad-2016.00.00.1/omh/sin_forward.omh --- cppad-2015.00.00.9/omh/sin_forward.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/sin_forward.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: sin_forward.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: sin_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,20 +18,18 @@ Taylor $$ -$index sin, forward theory$$ -$index theory, sin forward$$ -$index forward, sin theory$$ $section Sine Function Forward Taylor Polynomial Theory$$ +$mindex sin$$ -If $latex F(x) = \sin(x) $$ +If $latex F(x) = \sin(x) $$ $latex \[ 1 * F^{(1)} (x) - 0 * F (x) = \cos(x) \] $$ and in the $xref/ - ForwardTheory/ - Standard Math Functions/ + ForwardTheory/ + Standard Math Functions/ Differential Equation/ standard math function differential equation/ 1 @@ -40,10 +38,10 @@ $latex B(x) = 1$$, and $latex D(x) = \cos(x)$$. We use $latex a$$, $latex b$$, $latex d$$, $latex c$$ -and $latex z$$ to denote the +and $latex z$$ to denote the Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, $latex \cos [ X(t) ]$$, and $latex F [ X(t) ] $$ respectively. @@ -60,28 +58,28 @@ \begin{array}{rcl} z^{(0)} & = & \sin ( x^{(0)} ) \\ -e^{(j)} +e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & c^{(j)} \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \\ -& = & \frac{1}{j+1} - \sum_{k=1}^{j+1} k x^{(k)} c^{(j+1-k)} +& = & \frac{1}{j+1} + \sum_{k=1}^{j+1} k x^{(k)} c^{(j+1-k)} \end{array} -\] $$ +\] $$ Using $latex s$$ for the Taylor coefficients of $latex \sin[ X(t) ]$$ the order $latex j+1$$ coefficient can be generated using the lower order coefficients for $latex \sin[ X(t) ]$$ and $latex \cos[ X(t) ]$$ by the following formula: $latex \[ -s^{(j+1)} = \frac{1}{j+1} - \sum_{k=1}^{j+1} k x^{(k)} c^{(j+1-k)} +s^{(j+1)} = \frac{1}{j+1} + \sum_{k=1}^{j+1} k x^{(k)} c^{(j+1-k)} \] $$ $end diff -Nru cppad-2015.00.00.9/omh/sparse_hes_fun.omh cppad-2016.00.00.1/omh/sparse_hes_fun.omh --- cppad-2015.00.00.9/omh/sparse_hes_fun.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/sparse_hes_fun.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: sparse_hes_fun.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: sparse_hes_fun.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: sparse_hes_fun$$ +$mindex source$$ -$index sparse_hes_fun, source$$ -$index source, sparse_hes_fun$$ $code -# ifndef CPPAD_SPARSE_HES_FUN_INCLUDED +# ifndef CPPAD_SPARSE_HES_FUN_HPP $pre $$ -# define CPPAD_SPARSE_HES_FUN_INCLUDED +# define CPPAD_SPARSE_HES_FUN_HPP $verbatim%cppad/speed/sparse_hes_fun.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/sparse_jac_fun.omh cppad-2016.00.00.1/omh/sparse_jac_fun.omh --- cppad-2015.00.00.9/omh/sparse_jac_fun.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/sparse_jac_fun.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: sparse_jac_fun.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: sparse_jac_fun.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: sparse_jac_fun$$ +$mindex source$$ -$index sparse_jac_fun, source$$ -$index source, sparse_jac_fun$$ $code -# ifndef CPPAD_SPARSE_JAC_FUN_INCLUDED +# ifndef CPPAD_SPARSE_JAC_FUN_HPP $pre $$ -# define CPPAD_SPARSE_JAC_FUN_INCLUDED +# define CPPAD_SPARSE_JAC_FUN_HPP $verbatim%cppad/speed/sparse_jac_fun.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/speed/speed_adolc.omh cppad-2016.00.00.1/omh/speed/speed_adolc.omh --- cppad-2015.00.00.9/omh/speed/speed_adolc.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/speed/speed_adolc.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: speed_adolc.omh 3308 2014-05-26 14:29:01Z bradbell $ +$Id: speed_adolc.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ Cygwin $$ -$index speed, test adolc$$ -$index test, adolc speed$$ -$index adolc, speed test$$ $section Speed Test of Derivatives Using Adolc$$ @@ -31,8 +28,8 @@ (any suggestions to make the Adolc results faster are welcome). $head adolc_prefix$$ -To run these tests, -you must include the $cref adolc_prefix$$ +To run these tests, +you must include the $cref adolc_prefix$$ in you $cref/cmake command/cmake/CMake Command/$$. @@ -44,7 +41,7 @@ cd speed/adolc make check_speed_adolc VERBOSE=1 %$$ -You can then run the corresponding speed tests +You can then run the corresponding speed tests with the following command $codei% ./speed_adolc speed %seed% diff -Nru cppad-2015.00.00.9/omh/speed/speed_cppad.omh cppad-2016.00.00.1/omh/speed/speed_cppad.omh --- cppad-2015.00.00.9/omh/speed/speed_cppad.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/speed/speed_cppad.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: speed_cppad.omh 3308 2014-05-26 14:29:01Z bradbell $ +$Id: speed_cppad.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,14 +24,11 @@ sln $$ -$index speed, test cppad$$ -$index test, cppad speed$$ -$index cppad, speed test$$ $section Speed Test Derivatives Using CppAD$$ $head Purpose$$ -CppAD has a set of speed tests that are used to determine if +CppAD has a set of speed tests that are used to determine if certain changes improve its execution speed (and to compare CppAD with other AD packages). This section links to the source code the CppAD speed tests @@ -46,7 +43,7 @@ cd speed/cppad make check_speed_cppad VERBOSE=1 %$$ -You can then run the corresponding speed tests +You can then run the corresponding speed tests with the following command $codei% ./speed_cppad speed %seed% diff -Nru cppad-2015.00.00.9/omh/speed/speed_double.omh cppad-2016.00.00.1/omh/speed/speed_double.omh --- cppad-2015.00.00.9/omh/speed/speed_double.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/speed/speed_double.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: speed_double.omh 3308 2014-05-26 14:29:01Z bradbell $ +$Id: speed_double.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,9 +24,6 @@ sln $$ -$index speed, test double$$ -$index test, double speed$$ -$index double, speed test$$ $section Speed Test of Functions in Double$$ @@ -43,7 +40,7 @@ cd speed/double make check_speed_double VERBOSE=1 %$$ -You can then run the corresponding speed tests +You can then run the corresponding speed tests with the following command $codei% ./speed_double speed %seed% diff -Nru cppad-2015.00.00.9/omh/speed/speed_fadbad.omh cppad-2016.00.00.1/omh/speed/speed_fadbad.omh --- cppad-2015.00.00.9/omh/speed/speed_fadbad.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/speed/speed_fadbad.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: speed_fadbad.omh 3308 2014-05-26 14:29:01Z bradbell $ +$Id: speed_fadbad.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ Cygwin $$ -$index speed, test fadbad$$ -$index test, fadbad speed$$ -$index fadbad, speed test$$ $section Speed Test Derivatives Using Fadbad$$ @@ -31,8 +28,8 @@ (any suggestions to make the Fadbad results faster are welcome). $head fadbad_prefix$$ -To run these tests, -you must include the $cref fadbad_prefix$$ +To run these tests, +you must include the $cref fadbad_prefix$$ in you $cref/cmake command/cmake/CMake Command/$$. @@ -44,7 +41,7 @@ cd speed/fadbad make check_speed_fadbad VERBOSE=1 %$$ -You can then run the corresponding speed tests +You can then run the corresponding speed tests with the following command $codei% ./speed_fadbad speed %seed% diff -Nru cppad-2015.00.00.9/omh/speed/speed.omh cppad-2016.00.00.1/omh/speed/speed.omh --- cppad-2015.00.00.9/omh/speed/speed.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/speed/speed.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: speed.omh 3311 2014-05-28 16:21:08Z bradbell $ +$Id: speed.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,13 +23,11 @@ sln $$ -$index speed, test$$ -$index test, speed$$ $section Speed Test an Operator Overloading AD Package$$ $head Purpose$$ -CppAD has a set of speed tests that are used to determine if +CppAD has a set of speed tests that are used to determine if certain changes improve its execution speed. These tests can also be used to compare the AD packages $href% @@ -41,7 +39,7 @@ CppAD %$$, $href% - http://www.imm.dtu.dk/fadbad.html/% + http://www.fadbad.com/% Fadbad %$$ and $href% diff -Nru cppad-2015.00.00.9/omh/speed/speed_sacado.omh cppad-2016.00.00.1/omh/speed/speed_sacado.omh --- cppad-2015.00.00.9/omh/speed/speed_sacado.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/speed/speed_sacado.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: speed_sacado.omh 3308 2014-05-26 14:29:01Z bradbell $ +$Id: speed_sacado.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,6 @@ Cygwin $$ -$index speed, test sacado$$ -$index test, sacado speed$$ -$index sacado, speed test$$ $section Speed Test Derivatives Using Sacado$$ @@ -31,8 +28,8 @@ (any suggestions to make the Sacado results faster are welcome). $head sacado_prefix$$ -To run these tests, -you must include the $cref sacado_prefix$$ +To run these tests, +you must include the $cref sacado_prefix$$ in you $cref/cmake command/cmake/CMake Command/$$. @@ -44,7 +41,7 @@ cd speed/sacado make check_speed_sacado VERBOSE=1 %$$ -You can then run the corresponding speed tests +You can then run the corresponding speed tests with the following command $codei% ./speed_sacado speed %seed% diff -Nru cppad-2015.00.00.9/omh/speed/speed_utility.omh cppad-2016.00.00.1/omh/speed/speed_utility.omh --- cppad-2015.00.00.9/omh/speed/speed_utility.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/speed/speed_utility.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: speed_utility.omh 3123 2014-02-26 21:40:18Z bradbell $ +$Id: speed_utility.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,8 +14,6 @@ $section Speed Testing Utilities$$ -$index speed, utility$$ -$index utility, speed$$ $children% cppad/speed/det_by_lu.hpp% @@ -47,7 +45,7 @@ $rref sparse_jac_fun$$ $rref sparse_hes_fun$$ $rref uniform_01$$ -$tend +$tend $head Library Routines$$ $table diff -Nru cppad-2015.00.00.9/omh/subversion.omh cppad-2016.00.00.1/omh/subversion.omh --- cppad-2015.00.00.9/omh/subversion.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/subversion.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: subversion.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: subversion.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -33,21 +33,19 @@ dir hpp $$ -$index download, subversion$$ -$index subversion, download$$ $section Using Subversion To Download Source Code$$ $head File Format$$ The files corresponding to this download -procedure are in Unix format; i.e., +procedure are in Unix format; i.e., each line ends with just a line feed. $head Subversion$$ You must have $href%http://subversion.tigris.org/%subversion%$$ installed to use this download procedure. -In Unix, you can check if subversion +In Unix, you can check if subversion is already installed in your path by entering the command $codep which svn @@ -57,14 +55,14 @@ $head OMhelp$$ The documentation for CppAD is built from the source code files using $href%http://www.seanet.com/~bradbell/omhelp/%OMhelp%$$. -In Unix, you can check if OMhelp +In Unix, you can check if OMhelp is already installed in your path by entering the command $codep which omhelp $$ $head Current Version$$ -The following command will download the +The following command will download the current version of the CppAD source code: $codei% svn co https://projects.coin-or.org/svn/CppAD/%dir% %dir% @@ -79,12 +77,12 @@ Subversion downloads are available for a set of stable versions (after the specified date, only bug fixes get applied). The following link will list the available $icode dir$$ values -corresponding to +corresponding to $href% https://projects.coin-or.org/CppAD/browser/stable% - stable versions + stable versions %$$. -The following command will download a +The following command will download a stable version of the CppAD source code: $codei% svn co https://projects.coin-or.org/svn/CppAD/stable/%dir% %dir% @@ -93,19 +91,19 @@ $codei% %dir%/cppad/cppad.hpp %$$ -Note that it will correspond to the most recent release for this stable +Note that it will correspond to the most recent release for this stable version. $head Release Versions$$ Subversion downloads are available for a set of release versions (no changes are applied). The following link will list the available $icode dir$$ values -corresponding to +corresponding to $href% https://projects.coin-or.org/CppAD/browser/releases% - release versions + release versions %$$. -The following command will download a +The following command will download a release version of the CppAD source code: $codei% svn co https://projects.coin-or.org/svn/CppAD/releases/%dir% %dir% @@ -124,13 +122,13 @@ $head Continue with Installation$$ Once the steps above are completed, -you can proceed with the install instructions in +you can proceed with the install instructions in the documentation you just built. Start by opening the file $codei% %dir%/doc/index.xml -%$$ -in a web browser and proceeding to the +%$$ +in a web browser and proceeding to the install instructions in that documentation, skipping the Download section and starting with the Configure command. diff -Nru cppad-2015.00.00.9/omh/theory/acos_forward.omh cppad-2016.00.00.1/omh/theory/acos_forward.omh --- cppad-2015.00.00.9/omh/theory/acos_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/acos_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: acos_forward.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: acos_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,67 +12,71 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin AcosForward$$ +$begin acos_forward$$ $spell acos + acosh Arccosine Taylor $$ -$index acos, forward theory$$ -$index theory, acos forward$$ -$index forward, acos theory$$ +$section Inverse Cosine and Hyperbolic Cosine Forward Mode Theory$$ +$mindex acos acosh$$ -$section Arccosine Function Forward Taylor Polynomial Theory$$ - -If $latex F(x) = \arccos(x) $$ it follows that +$head Derivatives$$ +$latex \[ +\begin{array}{rcl} +\R{acos}^{(1)} (x) & = & - 1 / \sqrt{ 1 - x * x } +\\ +\R{acosh}^{(1)} (x) & = & + 1 / \sqrt{ x * x - 1} +\end{array} +\] $$ +If $latex F(x)$$ is $latex \R{acos} (x)$$ or $latex \R{acosh} (x)$$ +the corresponding derivative satisfies the equation $latex \[ - \sqrt{ 1 - x * x } * F^{(1)} (x) - 0 * F (u) = -1 + \sqrt{ \mp ( x * x - 1 ) } * F^{(1)} (x) - 0 * F (u) = \mp 1 \] $$ and in the -$xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation /$$, $latex A(x) = 0$$, -$latex B(x) = \sqrt{1 - x * x }$$, -and $latex D(x) = -1$$. -We use $latex a$$, $latex b$$, $latex d$$ and $latex z$$ to denote the +$latex B(x) = \sqrt{ \mp( x * x - 1 ) }$$, +and $latex D(x) = \mp 1$$. +We use $latex a$$, $latex b$$, $latex d$$ and $latex z$$ to denote the Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, and $latex F [ X(t) ] $$ respectively. -$pre -$$ -We define $latex Q(x) = 1 - x * x$$ -and let $latex q$$ be the corresponding Taylor coefficients for +$head Taylor Coefficients Recursion$$ +We define $latex Q(x) = \mp ( x * x - 1 )$$ +and let $latex q$$ be the corresponding Taylor coefficients for $latex Q[ X(t) ]$$. It follows that $latex \[ q^{(j)} = \left\{ \begin{array}{ll} - 1 - x^{(0)} * x^{(0)} & {\rm if} \; j = 0 \\ - - \sum_{k=0}^j x^{(k)} x^{(j-k)} & {\rm otherwise} + \mp ( x^{(0)} * x^{(0)} - 1 ) & {\rm if} \; j = 0 \\ + \mp \sum_{k=0}^j x^{(k)} x^{(j-k)} & {\rm otherwise} \end{array} \right. \] $$ -It follows that +It follows that $latex B[ X(t) ] = \sqrt{ Q[ X(t) ] }$$ and from the equations for the -$cref/square root/SqrtForward/$$ +$cref/square root/sqrt_forward/$$ that for $latex j = 0 , 1, \ldots$$, $latex \[ \begin{array}{rcl} b^{(0)} & = & \sqrt{ q^{(0)} } \\ b^{(j+1)} & = & - \frac{1}{j+1} \frac{1}{ b^{(0)} } + \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( \frac{j+1}{2} q^{(j+1) } - - \sum_{k=1}^j k b^{(k)} b^{(j+1-k)} + - \sum_{k=1}^j k b^{(k)} b^{(j+1-k)} \right) \end{array} \] $$ @@ -87,29 +91,29 @@ that for $latex j = 0 , 1, \ldots$$, $latex \[ \begin{array}{rcl} -z^{(0)} & = & \arccos ( x^{(0)} ) +z^{(0)} & = & F ( x^{(0)} ) \\ -e^{(j)} +e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & \left\{ \begin{array}{ll} - -1 & {\rm if} \; j = 0 \\ + \mp 1 & {\rm if} \; j = 0 \\ 0 & {\rm otherwise} \end{array} \right. \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=0}^j e^{(k)} (j+1-k) x^{(j+1-k)} - - \sum_{k=1}^j b^{(k)} (j+1-k) z^{(j+1-k)} + \sum_{k=0}^j e^{(k)} (j+1-k) x^{(j+1-k)} + - \sum_{k=1}^j b^{(k)} (j+1-k) z^{(j+1-k)} \right) \\ -z^{(j+1)} & = & - \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - (j+1) x^{(j+1)} - + \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + \mp (j+1) x^{(j+1)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \end{array} -\] $$ +\] $$ -$end +$end diff -Nru cppad-2015.00.00.9/omh/theory/acos_reverse.omh cppad-2016.00.00.1/omh/theory/acos_reverse.omh --- cppad-2015.00.00.9/omh/theory/acos_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/acos_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: acos_reverse.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: acos_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,153 +12,150 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin AcosReverse$$ +$begin acos_reverse$$ $spell + acosh acos Taylor - Arccosine $$ -$index acos, reverse theory$$ -$index theory, acos reverse$$ -$index reverse, acos theory$$ - -$section Arccosine Function Reverse Mode Theory$$ +$section Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory$$ +$mindex acos acosh$$ We use the reverse theory -$xref% - ReverseTheory% - Standard Math Functions% - standard math function +$cref%standard math function + %ReverseTheory + %Standard Math Functions %$$ definition for the functions $latex H$$ and $latex G$$. -In addition, - -we use $latex q$$ and $latex b$$ -for the $th p$$ order Taylor coefficient -row vectors corresponding to functions +In addition, we use the forward mode notation in +$cref acos_forward$$ for $latex \[ \begin{array}{rcl} - Q(t) & = & 1 - X(t) * X(t) \\ + Q(t) & = & \mp ( X(t) * X(t) - 1 ) \\ B(t) & = & \sqrt{ Q(t) } \end{array} -\] $$ +\] $$ +We use $latex q$$ and $latex b$$ +for the $th p$$ order Taylor coefficient +row vectors corresponding to these functions and replace $latex z^{(j)}$$ by $latex \[ ( z^{(j)} , b^{(j)} ) -\] $$ +\] $$ in the definition for $latex G$$ and $latex H$$. -The forward mode formulas for the -$cref/acos/AcosForward/$$ +The zero order forward mode formulas for the +$cref/acos/acos_forward/$$ function are $latex \[ \begin{array}{rcl} - q^{(0)} & = & 1 - x^{(0)} x^{(0)} \\ - b^{(j)} & = & \sqrt{ q^{(0)} } \\ - z^{(j)} & = & \arccos ( x^{(0)} ) + q^{(0)} & = & \mp ( x^{(0)} x^{(0)} - 1) \\ + b^{(0)} & = & \sqrt{ q^{(0)} } \\ + z^{(0)} & = & F ( x^{(0)} ) \end{array} \] $$ - -for the case $latex j = 0$$, and for $latex j > 0$$, - +where $latex F(x) = \R{acos} (x)$$ for $latex -$$ +and $latex F(x) = \R{acosh} (x) $$ for $latex +$$. +For orders $latex j$$ greater than zero we have $latex \[ \begin{array}{rcl} -q^{(j)} & = & - - \sum_{k=0}^j x^{(k)} x^{(j-k)} +q^{(j)} & = & + \mp \sum_{k=0}^j x^{(k)} x^{(j-k)} \\ b^{(j)} & = & - \frac{1}{j} \frac{1}{ b^{(0)} } + \frac{1}{j} \frac{1}{ b^{(0)} } \left( \frac{j}{2} q^{(j)} - - \sum_{k=1}^{j-1} k b^{(k)} b^{(j-k)} + - \sum_{k=1}^{j-1} k b^{(k)} b^{(j-k)} \right) \\ -z^{(j)} & = & - \frac{1}{j} \frac{1}{ b^{(0)} } +z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } \left( - j x^{(j)} - + \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} + \mp j x^{(j)} + - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} \right) \end{array} -\] $$ +\] $$ -If $latex j = 0$$, we have the relation +If $latex j = 0$$, we note that +$latex F^{(1)} ( x^{(0)} ) = \mp 1 / b^{(0)}$$ and hence $latex \[ \begin{array}{rcl} -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(0)} } +\D{H}{ x^{(j)} } & = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(0)} } \D{ q^{(0)} }{ x^{(0)} } \\ & = & -\D{G}{ x^{(j)} } -- \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } -- \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } +\D{G}{ x^{(j)} } +\mp \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } \end{array} -\] $$ +\] $$ If $latex j > 0$$, then for $latex k = 1, \ldots , j-1$$ $latex \[ \begin{array}{rcl} -\D{H}{ b^{(0)} } & = & -\D{G}{ b^{(0)} } +\D{H}{ b^{(0)} } & = & +\D{G}{ b^{(0)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(0)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ b^{(0)} } \\ & = & -\D{G}{ b^{(0)} } -- \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} } +\D{G}{ b^{(0)} } +- \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} } - \D{G}{ b^{(j)} } \frac{ b^{(j)} }{ b^{(0)} } \\ -\D{H}{ x^{(0)} } & = & -\D{G}{ x^{(0)} } +\D{H}{ x^{(0)} } & = & +\D{G}{ x^{(0)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(j)} } \D{ q^{(j)} }{ x^{(0)} } \\ -& = & -\D{G}{ x^{(0)} } -- \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} } +& = & +\D{G}{ x^{(0)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} } \\ -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(j)} } +\D{H}{ x^{(j)} } & = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(j)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(j)} } \D{ q^{(j)} }{ x^{(j)} } \\ -& = & -\D{G}{ x^{(j)} } -- \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } -- \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } +& = & +\D{G}{ x^{(j)} } +\mp \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } \\ -\D{H}{ b^{(j - k)} } & = & -\D{G}{ b^{(j - k)} } +\D{H}{ b^{(j - k)} } & = & +\D{G}{ b^{(j - k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(j - k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ b^{(j - k)} } \\ & = & -\D{G}{ b^{(j - k)} } +\D{G}{ b^{(j - k)} } - \D{G}{ z^{(j)} } \frac{k z^{(k)} }{j b^{(0)} } - \D{G}{ b^{(j)} } \frac{ b^{(k)} }{ b^{(0)} } \\ -\D{H}{ x^{(k)} } & = & -\D{G}{ x^{(k)} } +\D{H}{ x^{(k)} } & = & +\D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(j)} } \D{ q^{(j)} }{ x^{(k)} } \\ -& = & -\D{G}{ x^{(k)} } -- \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} } +& = & +\D{G}{ x^{(k)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} } \\ -\D{H}{ z^{(k)} } & = & -\D{G}{ z^{(k)} } +\D{H}{ z^{(k)} } & = & +\D{G}{ z^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ z^{(k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ z^{(k)} } \\ & = & -\D{G}{ z^{(k)} } -- \D{G}{ z^{(j)} } \frac{k b^{(j-k)} }{ j b^{(0)} } +\D{G}{ z^{(k)} } +- \D{G}{ z^{(j)} } \frac{k b^{(j-k)} }{ j b^{(0)} } \end{array} -\] $$ +\] $$ $end diff -Nru cppad-2015.00.00.9/omh/theory/asin_forward.omh cppad-2016.00.00.1/omh/theory/asin_forward.omh --- cppad-2015.00.00.9/omh/theory/asin_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/asin_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: asin_forward.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: asin_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,67 +12,70 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin AsinForward$$ +$begin asin_forward$$ $spell + asinh asin - Arcsine Taylor $$ -$index asin, forward theory$$ -$index theory, asin forward$$ -$index forward, asin theory$$ +$section Inverse Sine and Hyperbolic Sine Forward Mode Theory$$ +$mindex asin asinh$$ -$section Arcsine Function Forward Taylor Polynomial Theory$$ - -If $latex F(x) = \arcsin(x) $$ it follows that +$head Derivatives$$ +$latex \[ +\begin{array}{rcl} +\R{asin}^{(1)} (x) & = & 1 / \sqrt{ 1 - x * x } +\\ +\R{asinh}^{(1)} (x) & = & 1 / \sqrt{ 1 + x * x } +\end{array} +\] $$ +If $latex F(x)$$ is $latex \R{asin} (x) $$ or $latex \R{asinh} (x)$$ +the corresponding derivative satisfies the equation $latex \[ - \sqrt{ 1 - x * x } * F^{(1)} (x) - 0 * F (u) = 1 + \sqrt{ 1 \mp x * x } * F^{(1)} (x) - 0 * F (u) = 1 \] $$ and in the -$xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation /$$, $latex A(x) = 0$$, -$latex B(x) = \sqrt{1 - x * x }$$, +$latex B(x) = \sqrt{1 \mp x * x }$$, and $latex D(x) = 1$$. -We use $latex a$$, $latex b$$, $latex d$$ and $latex z$$ to denote the +We use $latex a$$, $latex b$$, $latex d$$ and $latex z$$ to denote the Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, and $latex F [ X(t) ] $$ respectively. -$pre -$$ -We define $latex Q(x) = 1 - x * x$$ -and let $latex q$$ be the corresponding Taylor coefficients for +$head Taylor Coefficients Recursion$$ +We define $latex Q(x) = 1 \mp x * x$$ +and let $latex q$$ be the corresponding Taylor coefficients for $latex Q[ X(t) ]$$. It follows that $latex \[ q^{(j)} = \left\{ \begin{array}{ll} - 1 - x^{(0)} * x^{(0)} & {\rm if} \; j = 0 \\ - - \sum_{k=0}^j x^{(k)} x^{(j-k)} & {\rm otherwise} + 1 \mp x^{(0)} * x^{(0)} & {\rm if} \; j = 0 \\ + \mp \sum_{k=0}^j x^{(k)} x^{(j-k)} & {\rm otherwise} \end{array} \right. \] $$ -It follows that +It follows that $latex B[ X(t) ] = \sqrt{ Q[ X(t) ] }$$ and from the equations for the -$cref/square root/SqrtForward/$$ +$cref/square root/sqrt_forward/$$ that for $latex j = 0 , 1, \ldots$$, $latex \[ \begin{array}{rcl} b^{(0)} & = & \sqrt{ q^{(0)} } \\ b^{(j+1)} & = & - \frac{1}{j+1} \frac{1}{ b^{(0)} } + \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( \frac{j+1}{2} q^{(j+1) } - - \sum_{k=1}^j k b^{(k)} b^{(j+1-k)} + - \sum_{k=1}^j k b^{(k)} b^{(j+1-k)} \right) \end{array} \] $$ @@ -87,9 +90,9 @@ that for $latex j = 0 , 1, \ldots$$, $latex \[ \begin{array}{rcl} -z^{(0)} & = & \arcsin ( x^{(0)} ) +z^{(0)} & = & F ( x^{(0)} ) \\ -e^{(j)} +e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & \left\{ \begin{array}{ll} @@ -97,19 +100,19 @@ 0 & {\rm otherwise} \end{array} \right. \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=0}^j e^{(k)} (j+1-k) x^{(j+1-k)} - - \sum_{k=1}^j b^{(k)} (j+1-k) z^{(j+1-k)} + \sum_{k=0}^j e^{(k)} (j+1-k) x^{(j+1-k)} + - \sum_{k=1}^j b^{(k)} (j+1-k) z^{(j+1-k)} \right) \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( (j+1) x^{(j+1)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \end{array} -\] $$ +\] $$ -$end +$end diff -Nru cppad-2015.00.00.9/omh/theory/asin_reverse.omh cppad-2016.00.00.1/omh/theory/asin_reverse.omh --- cppad-2015.00.00.9/omh/theory/asin_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/asin_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: asin_reverse.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: asin_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,153 +12,149 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin AsinReverse$$ +$begin asin_reverse$$ $spell + asinh asin Taylor - Arcsine $$ -$index asin, reverse theory$$ -$index theory, asin reverse$$ -$index reverse, asin theory$$ - -$section Arcsine Function Reverse Mode Theory$$ +$section Inverse Sine and Hyperbolic Sine Reverse Mode Theory$$ +$mindex asin asinh$$ We use the reverse theory -$xref% - ReverseTheory% - Standard Math Functions% - standard math function +$cref%standard math function + %ReverseTheory + %Standard Math Functions %$$ definition for the functions $latex H$$ and $latex G$$. -In addition, - -we use $latex q$$ and $latex b$$ -for the $th p$$ order Taylor coefficient -row vectors corresponding to functions +In addition, we use the forward mode notation in +$cref asin_forward$$ for $latex \[ \begin{array}{rcl} - Q(t) & = & 1 - X(t) * X(t) \\ + Q(t) & = & 1 \mp X(t) * X(t) \\ B(t) & = & \sqrt{ Q(t) } \end{array} -\] $$ +\] $$ +We use $latex q$$ and $latex b$$ +for the $th p$$ order Taylor coefficient +row vectors corresponding to these functions and replace $latex z^{(j)}$$ by $latex \[ ( z^{(j)} , b^{(j)} ) -\] $$ +\] $$ in the definition for $latex G$$ and $latex H$$. -The forward mode formulas for the -$cref/asin/AsinForward/$$ +The zero order forward mode formulas for the +$cref/asin/asin_forward/$$ function are $latex \[ \begin{array}{rcl} - q^{(0)} & = & 1 - x^{(0)} x^{(0)} \\ - b^{(j)} & = & \sqrt{ q^{(0)} } \\ - z^{(j)} & = & \arcsin ( x^{(0)} ) + q^{(0)} & = & 1 \mp x^{(0)} x^{(0)} \\ + b^{(0)} & = & \sqrt{ q^{(0)} } \\ + z^{(0)} & = & F( x^{(0)} ) \end{array} \] $$ - -for the case $latex j = 0$$, and for $latex j > 0$$, - +where $latex F(x) = \R{asin} (x)$$ for $latex -$$ +and $latex F(x) = \R{asinh} (x) $$ for $latex +$$. +For the orders $latex j$$ greater than zero we have $latex \[ \begin{array}{rcl} -q^{(j)} & = & - - \sum_{k=0}^j x^{(k)} x^{(j-k)} +q^{(j)} & = & + \mp \sum_{k=0}^j x^{(k)} x^{(j-k)} \\ b^{(j)} & = & - \frac{1}{j} \frac{1}{ b^{(0)} } + \frac{1}{j} \frac{1}{ b^{(0)} } \left( \frac{j}{2} q^{(j)} - - \sum_{k=1}^{j-1} k b^{(k)} b^{(j-k)} + - \sum_{k=1}^{j-1} k b^{(k)} b^{(j-k)} \right) \\ -z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } +z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } \left( j x^{(j)} - - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} + - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} \right) \end{array} -\] $$ - -If $latex j = 0$$, we have the relation +\] $$ +If $latex j = 0$$, we note that +$latex F^{(1)} ( x^{(0)} ) = 1 / b^{(0)}$$ and hence $latex \[ \begin{array}{rcl} -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(0)} } +\D{H}{ x^{(j)} } & = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(0)} } \D{ q^{(0)} }{ x^{(0)} } \\ & = & -\D{G}{ x^{(j)} } +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } -- \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } \end{array} -\] $$ +\] $$ If $latex j > 0$$, then for $latex k = 1, \ldots , j-1$$ $latex \[ \begin{array}{rcl} -\D{H}{ b^{(0)} } & = & -\D{G}{ b^{(0)} } +\D{H}{ b^{(0)} } & = & +\D{G}{ b^{(0)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(0)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ b^{(0)} } \\ & = & -\D{G}{ b^{(0)} } -- \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} } +\D{G}{ b^{(0)} } +- \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} } - \D{G}{ b^{(j)} } \frac{ b^{(j)} }{ b^{(0)} } \\ -\D{H}{ x^{(0)} } & = & -\D{G}{ x^{(0)} } +\D{H}{ x^{(0)} } & = & +\D{G}{ x^{(0)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(j)} } \D{ q^{(j)} }{ x^{(0)} } \\ -& = & -\D{G}{ x^{(0)} } -- \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} } +& = & +\D{G}{ x^{(0)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} } \\ -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(j)} } +\D{H}{ x^{(j)} } & = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(j)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(j)} } \D{ q^{(j)} }{ x^{(j)} } \\ -& = & -\D{G}{ x^{(j)} } -+ \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } -- \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } +& = & +\D{G}{ x^{(j)} } ++ \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } \\ -\D{H}{ b^{(j - k)} } & = & -\D{G}{ b^{(j - k)} } +\D{H}{ b^{(j - k)} } & = & +\D{G}{ b^{(j - k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(j - k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ b^{(j - k)} } \\ & = & -\D{G}{ b^{(j - k)} } +\D{G}{ b^{(j - k)} } - \D{G}{ z^{(j)} } \frac{k z^{(k)} }{j b^{(0)} } - \D{G}{ b^{(j)} } \frac{ b^{(k)} }{ b^{(0)} } \\ -\D{H}{ x^{(k)} } & = & -\D{G}{ x^{(k)} } +\D{H}{ x^{(k)} } & = & +\D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(j)} } \D{ q^{(j)} }{ x^{(k)} } \\ -& = & -\D{G}{ x^{(k)} } -- \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} } +& = & +\D{G}{ x^{(k)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} } \\ -\D{H}{ z^{(k)} } & = & -\D{G}{ z^{(k)} } +\D{H}{ z^{(k)} } & = & +\D{G}{ z^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ z^{(k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ z^{(k)} } \\ & = & -\D{G}{ z^{(k)} } -- \D{G}{ z^{(j)} } \frac{k b^{(j-k)} }{ j b^{(0)} } +\D{G}{ z^{(k)} } +- \D{G}{ z^{(j)} } \frac{k b^{(j-k)} }{ j b^{(0)} } \end{array} -\] $$ +\] $$ $end diff -Nru cppad-2015.00.00.9/omh/theory/atan_forward.omh cppad-2016.00.00.1/omh/theory/atan_forward.omh --- cppad-2015.00.00.9/omh/theory/atan_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/atan_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: atan_forward.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: atan_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,60 +12,58 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin AtanForward$$ +$begin atan_forward$$ $spell atan - Arctangent + atanh Taylor $$ -$index atan, forward theory$$ -$index theory, atan forward$$ -$index forward, atan theory$$ +$section Inverse Tangent and Hyperbolic Tangent Forward Mode Theory$$ +$mindex atan atanh$$ -$section Arctangent Function Forward Taylor Polynomial Theory$$ - -If $latex F(x) = \arctan(x) $$ +$head Derivatives$$ +$latex \[ +\begin{array}{rcl} +\R{atan}^{(1)} (x) & = & 1 / ( 1 + x * x ) +\\ +\R{atanh}^{(1)} (x) & = & 1 / ( 1 - x * x ) +\end{array} +\] $$ +If $latex F(x)$$ is $latex \R{atan} (x)$$ or $latex \R{atanh} (x)$$, +the corresponding derivative satisfies the equation $latex \[ - (1 + x * x ) * F^{(1)} (x) - 0 * F (x) = 1 + (1 \pm x * x ) * F^{(1)} (x) - 0 * F (x) = 1 \] $$ and in the -$xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation /$$, $latex A(x) = 0$$, -$latex B(x) = 1 + x * x $$, +$latex B(x) = 1 \pm x * x $$, and $latex D(x) = 1$$. -We use $latex a$$, $latex b$$, $latex d$$ and $latex z$$ to denote the +We use $latex a$$, $latex b$$, $latex d$$ and $latex z$$ to denote the Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, and $latex F [ X(t) ] $$ respectively. -It now follows from the general -$xref/ - ForwardTheory/ - Standard Math Functions/ - Taylor Coefficients Recursion Formula/ - Taylor coefficients recursion formula/ - 1 -/$$ -that for $latex j = 0 , 1, \ldots$$, + +$head Taylor Coefficients Recursion$$ +For $latex j = 0 , 1, \ldots$$, $latex \[ \begin{array}{rcl} -z^{(0)} & = & \arctan ( x^{(0)} ) +z^{(0)} & = & F( x^{(0)} ) \\ b^{(j)} & = & \left\{ \begin{array}{ll} - 1 + x^{(0)} * x^{(0)} & {\rm if} \; j = 0 \\ - \sum_{k=0}^j x^{(k)} x^{(j-k)} & {\rm otherwise} + 1 \pm x^{(0)} * x^{(0)} & {\rm if} \; j = 0 \\ + \pm \sum_{k=0}^j x^{(k)} x^{(j-k)} & {\rm otherwise} \end{array} \right. \\ -e^{(j)} +e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & \left\{ \begin{array}{ll} @@ -73,18 +71,18 @@ 0 & {\rm otherwise} \end{array} \right. \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=0}^j e^{(k)} (j+1-k) x^{(j+1-k)} - - \sum_{k=1}^j b^{(k)} (j+1-k) z^{(j+1-k)} + \sum_{k=0}^j e^{(k)} (j+1-k) x^{(j+1-k)} + - \sum_{k=1}^j b^{(k)} (j+1-k) z^{(j+1-k)} \right) \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( (j+1) x^{(j+1)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \end{array} -\] $$ +\] $$ $end diff -Nru cppad-2015.00.00.9/omh/theory/atan_reverse.omh cppad-2016.00.00.1/omh/theory/atan_reverse.omh --- cppad-2015.00.00.9/omh/theory/atan_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/atan_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: atan_reverse.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: atan_reverse.omh 3682 2015-05-08 21:59:05Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,137 +12,134 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin AtanReverse$$ +$begin atan_reverse$$ $spell - Arctangent atan + atanh Taylor $$ -$index atan, reverse theory$$ -$index theory, atan reverse$$ -$index reverse, atan theory$$ - -$section Arctangent Function Reverse Mode Theory$$ +$section Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory$$ We use the reverse theory -$xref% - ReverseTheory% - Standard Math Functions% - standard math function +$cref%standard math function + %ReverseTheory + %Standard Math Functions %$$ definition for the functions $latex H$$ and $latex G$$. -In addition, - -we use $latex b$$ -for the $th p$$ order Taylor coefficient -row vectors corresponding to -$latex 1 + X(t) * X(t)$$ +In addition, we use the forward mode notation in +$cref atan_forward$$ for +$latex \[ + B(t) = 1 \pm X(t) * X(t) +\] $$ +We use $latex b$$ +for the $th p$$ order Taylor coefficient +row vectors corresponding to $latex B(t)$$ and replace $latex z^{(j)}$$ by $latex \[ ( z^{(j)} , b^{(j)} ) -\] $$ +\] $$ in the definition for $latex G$$ and $latex H$$. -The forward mode formulas for the -$cref/arctangent/AtanForward/$$ +The zero order forward mode formulas for the +$cref/atan/atan_forward/$$ function are $latex \[ \begin{array}{rcl} - z^{(j)} & = & \arctan ( x^{(0)} ) \\ - b^{(j)} & = & 1 + x^{(0)} x^{(0)} + z^{(0)} & = & F ( x^{(0)} ) \\ + b^{(0)} & = & 1 \pm x^{(0)} x^{(0)} \end{array} \] $$ - -for the case $latex j = 0$$, and for $latex j > 0$$, - +where $latex F(x) = \R{atan} (x)$$ for $latex +$$ +and $latex F(x) = \R{atanh} (x)$$ for $latex -$$. +For orders $latex j$$ greater than zero we have $latex \[ \begin{array}{rcl} -b^{(j)} & = & - \sum_{k=0}^j x^{(k)} x^{(j-k)} +b^{(j)} & = & + \pm \sum_{k=0}^j x^{(k)} x^{(j-k)} \\ -z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } +z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } \left( j x^{(j)} - - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} + - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} \right) \end{array} -\] $$ +\] $$ -If $latex j = 0$$, we have the relation +If $latex j = 0$$, we note that +$latex F^{(1)} ( x^{(0)} ) = 1 / b^{(0)}$$ and hence $latex \[ \begin{array}{rcl} -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(j)} } +\D{H}{ x^{(j)} } & = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(0)} } \\ & = & -\D{G}{ x^{(j)} } +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } -+ \D{G}{ b^{(j)} } 2 x^{(0)} +\pm \D{G}{ b^{(j)} } 2 x^{(0)} \end{array} -\] $$ +\] $$ If $latex j > 0$$, then for $latex k = 1, \ldots , j-1$$ - $latex \[ \begin{array}{rcl} -\D{H}{ b^{(0)} } & = & -\D{G}{ b^{(0)} } -- \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(0)} } +\D{H}{ b^{(0)} } & = & +\D{G}{ b^{(0)} } ++ \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(0)} } \\ & = & -\D{G}{ b^{(0)} } -- \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} } +\D{G}{ b^{(0)} } +- \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} } \\ -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(j)} } +\D{H}{ x^{(j)} } & = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(j)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(j)} } \\ & = & -\D{G}{ x^{(j)} } +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} } -+ \D{G}{ b^{(j)} } 2 x^{(0)} +\pm \D{G}{ b^{(j)} } 2 x^{(0)} \\ -\D{H}{ x^{(0)} } & = & -\D{G}{ x^{(0)} } +\D{H}{ x^{(0)} } & = & +\D{G}{ x^{(0)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(0)} } \\ -& = & -\D{G}{ x^{(0)} } + -\D{G}{ b^{(j)} } 2 x^{(j)} +& = & +\D{G}{ x^{(0)} } +\pm \D{G}{ b^{(j)} } 2 x^{(j)} \\ -\D{H}{ x^{(k)} } & = & -\D{G}{ x^{(k)} } +\D{H}{ x^{(k)} } & = & +\D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(k)} } \\ -& = & -\D{G}{ x^{(k)} } -+ \D{G}{ b^{(j)} } 2 x^{(j-k)} +& = & +\D{G}{ x^{(k)} } +\pm \D{G}{ b^{(j)} } 2 x^{(j-k)} \\ -\D{H}{ z^{(k)} } & = & -\D{G}{ z^{(k)} } +\D{H}{ z^{(k)} } & = & +\D{G}{ z^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ z^{(k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ z^{(k)} } \\ -& = & -\D{G}{ z^{(k)} } +& = & +\D{G}{ z^{(k)} } - \D{G}{ z^{(j)} } \frac{k b^{(j-k)} }{ j b^{(0)} } \\ -\D{H}{ b^{(j-k)} } & = & -\D{G}{ b^{(j-k)} } +\D{H}{ b^{(j-k)} } & = & +\D{G}{ b^{(j-k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ b^{(j-k)} } + \D{G}{ b^{(j)} } \D{ b^{(j)} }{ b^{(j-k)} } \\ -& = & -\D{G}{ b^{(j-k)} } -- \D{G}{ z^{(j)} } \frac{k z^{(k)} }{ j b^{(0)} } +& = & +\D{G}{ b^{(j-k)} } +- \D{G}{ z^{(j)} } \frac{k z^{(k)} }{ j b^{(0)} } \end{array} -\] $$ +\] $$ $end diff -Nru cppad-2015.00.00.9/omh/theory/erf_forward.omh cppad-2016.00.00.1/omh/theory/erf_forward.omh --- cppad-2015.00.00.9/omh/theory/erf_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/erf_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ $Id:$ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,14 +16,12 @@ Taylor $$ -$index erf, forward theory$$ -$index theory, erf forward$$ -$index forward, erf theory$$ $section Error Function Forward Taylor Polynomial Theory$$ +$mindex erf$$ $head Derivatives$$ -Given $latex X(t)$$, we define the function +Given $latex X(t)$$, we define the function $latex \[ Z(t) = \R{erf}[ X(t) ] \]$$ @@ -35,13 +33,13 @@ Z^{(1)} (t) & = & \R{erf}^{(1)} [ X(t) ] X^{(1)} (t) = Y(t) X^{(1)} (t) \end{array} \] $$ -where we define the function +where we define the function $latex \[ Y(t) = \frac{2}{ \sqrt{\pi} } \exp \left[ - X(t)^2 \right] \] $$ $head Taylor Coefficients Recursion$$ -Suppose that we are given the Taylor coefficients +Suppose that we are given the Taylor coefficients up to order $latex j$$ for the function $latex X(t)$$ and $latex Y(t)$$. We need a formula that computes the coefficient of order $latex j$$ for $latex Z(t)$$. @@ -59,14 +57,14 @@ Setting the coefficients of $latex t^{j-1}$$ equal, we have $latex \[ \begin{array}{rcl} -j z^{(j)} +j z^{(j)} = \sum_{k=1}^j k x^{(k)} y^{(j-k)} \\ -z^{(j)} +z^{(j)} = \frac{1}{j} \sum_{k=1}^j k x^{(k)} y^{(j-k)} \end{array} -\] $$ +\] $$ $end diff -Nru cppad-2015.00.00.9/omh/theory/erf_reverse.omh cppad-2016.00.00.1/omh/theory/erf_reverse.omh --- cppad-2015.00.00.9/omh/theory/erf_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/erf_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ $Id:$ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,11 +16,9 @@ Taylor $$ -$index erf, reverse theory$$ -$index theory, erf reverse$$ -$index reverse, erf theory$$ $section Error Function Reverse Mode Theory$$ +$mindex erf$$ $head Notation$$ We use the reverse theory @@ -39,31 +37,31 @@ the partial of $latex H$$ with respect to $latex x^{(k)}$$ is given by $latex \[ \D{H}{ x^{(k)} } -= += \D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(k)} } = -\D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \frac{k}{j} y^{(j-k)} -\] $$ -For $latex k = 1 , \ldots , j$$ +\D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \frac{k}{j} y^{(j-k)} +\] $$ +For $latex k = 1 , \ldots , j$$ The partial of $latex H$$ with respect to $latex y^{j-k}$$, is given by $latex \[ \D{H}{ y^{(j-k)} } -= += \D{G}{ y^{(j-k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ y^{(j-k)} } = \D{G}{ y^{(j-k)} } + \D{G}{ z^{(j)} } \frac{k}{j} x^{k} -\] $$ +\] $$ $head Order Zero Z(t)$$ -The $latex z^{(0)}$$ coefficient +The $latex z^{(0)}$$ coefficient is expressed as a function of the Taylor coefficients for $latex X(t)$$ and $latex Y(t)$$ as follows: In this case, $latex \[ -\D{H}{ x^{(0)} } -= +\D{H}{ x^{(0)} } += \D{G}{ x^{(0)} } + \D{G}{ z^{(0)} } \D{ z^{(0)} }{ x^{(0)} } = \D{G}{ x^{(0)} } + \D{G}{ z^{(0)} } y^{(0)} diff -Nru cppad-2015.00.00.9/omh/theory/exp_forward.omh cppad-2016.00.00.1/omh/theory/exp_forward.omh --- cppad-2015.00.00.9/omh/theory/exp_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/exp_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: exp_forward.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: exp_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,67 +12,70 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin ExpForward$$ +$begin exp_forward$$ $spell exp + expm1 Taylor $$ -$index exp, forward theory$$ -$index theory, exp forward$$ -$index forward, exp theory$$ +$section Exponential Function Forward Mode Theory$$ +$mindex exp expm1$$ -$section Exponential Function Forward Taylor Polynomial Theory$$ - -If $latex F(x) = \exp(x) $$ +$head Derivatives$$ +If $latex F(x)$$ is $latex \R{exp} (x)$$ or $latex \R{expm1} (x)$$ +the corresponding derivative satisfies the equation $latex \[ - 1 * F^{(1)} (x) - 1 * F (x) = 0 +1 * F^{(1)} (x) - 1 * F (x) += +d^{(0)} += +\left\{ \begin{array}{ll} + 0 & \R{if} \; F(x) = \R{exp}(x) + \\ + 1 & \R{if} \; F(x) = \R{expm1}(x) +\end{array} \right. \] $$ -and in the -$xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 +where the equation above defines $latex d^{(0)}$$. +In the +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation /$$, $latex A(x) = 1$$, $latex B(x) = 1$$, -and $latex D(x) = 0$$. -We use $latex a$$, $latex b$$, $latex d$$, -and $latex z$$ to denote the +and $latex D(x) = d^{(0)}$$. +We use $latex a$$, $latex b$$, $latex d$$, +and $latex z$$ to denote the Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, and $latex F [ X(t) ] $$ respectively. -It now follows from the general -$xref/ - ForwardTheory/ - Standard Math Functions/ - Taylor Coefficients Recursion Formula/ - Taylor coefficients recursion formula/ - 1 -/$$ -that for $latex j = 0 , 1, \ldots$$, + +$head Taylor Coefficients Recursion$$ +For orders $latex j = 0 , 1, \ldots$$, $latex \[ \begin{array}{rcl} -z^{(0)} & = & \exp ( x^{(0)} ) +z^{(0)} & = & F ( x^{(0)} ) \\ -e^{(j)} -& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} +e^{(0)} & = & d^{(0)} + z^{(0)} \\ -& = & z^{(j)} +e^{(j+1)} +& = & d^{(j+1)} + \sum_{k=0}^{j+1} a^{(j+1-k)} * z^{(k)} \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +& = & z^{(j+1)} +\\ +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \\ -& = & \frac{1}{j+1} - \sum_{k=1}^{j+1} k x^{(k)} z^{(j+1-k)} +& = & x^{(j+1)} d^{(0)} + + \frac{1}{j+1} \sum_{k=1}^{j+1} k x^{(k)} z^{(j+1-k)} \end{array} -\] $$ +\] $$ $end diff -Nru cppad-2015.00.00.9/omh/theory/exp_reverse.omh cppad-2016.00.00.1/omh/theory/exp_reverse.omh --- cppad-2015.00.00.9/omh/theory/exp_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/exp_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: exp_reverse.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: exp_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,55 +12,57 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin ExpReverse$$ +$begin exp_reverse$$ $spell Taylor exp + expm $$ -$index exp, reverse theory$$ -$index theory, exp reverse$$ -$index reverse, exp theory$$ - $section Exponential Function Reverse Mode Theory$$ +$mindex exp expm1$$ We use the reverse theory -$xref% - ReverseTheory% - Standard Math Functions% - standard math function +$cref%standard math function + %ReverseTheory + %Standard Math Functions %$$ definition for the functions $latex H$$ and $latex G$$. - -The forward mode formulas for the -$cref/exponential/ExpForward/$$ -function are +The zero order forward mode formula for the +$cref/exponential/exp_forward/$$ is $latex \[ - z^{(j)} = \exp ( x^{(0)} ) + z^{(0)} = F ( x^{(0)} ) \] $$ -if $latex j = 0$$, and +and for $latex j > 0$$, $latex \[ - z^{(j)} = \frac{1}{j} - \sum_{k=1}^{j} k x^{(k)} z^{(j-k)} -\] $$ - -for the case $latex j = 0$$, and for $latex j > 0$$, - + z^{(j)} = x^{(j)} d^{(0)} + + \frac{1}{j} \sum_{k=1}^{j} k x^{(k)} z^{(j-k)} +\] $$ +where +$latex \[ +d^{(0)} = \left\{ \begin{array}{ll} + 0 & \R{if} \; F(x) = \R{exp}(x) + \\ + 1 & \R{if} \; F(x) = \R{expm1}(x) +\end{array} \right. +\] $$ +For order $latex j = 0, 1, \ldots$$ we note that $latex \[ \begin{array}{rcl} -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } z^{(j)} +\D{H}{ x^{(j)} } +& = & \D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(j)} } +\\ +& = & \D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } ( d^{(0)} + z^{(0)} ) \end{array} \] $$ If $latex j > 0$$, then for $latex k = 1 , \ldots , j$$ - $latex \[ \begin{array}{rcl} -\D{H}{ x^{(k)} } & = & +\D{H}{ x^{(k)} } & = & \D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \frac{1}{j} k z^{(j-k)} \\ -\D{H}{ z^{(j-k)} } & = & +\D{H}{ z^{(j-k)} } & = & \D{G}{ z^{(j-k)} } + \D{G}{ z^{(j)} } \frac{1}{j} k x^{(k)} \end{array} \] $$ diff -Nru cppad-2015.00.00.9/omh/theory/forward_theory.omh cppad-2016.00.00.1/omh/theory/forward_theory.omh --- cppad-2015.00.00.9/omh/theory/forward_theory.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/forward_theory.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: forward_theory.omh 3495 2014-12-24 01:16:15Z bradbell $ +$Id: forward_theory.omh 3686 2015-05-11 16:14:25Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,19 +18,19 @@ $section The Theory of Forward Mode$$ $head Taylor Notation$$ -In Taylor notation, each variable corresponds to +In Taylor notation, each variable corresponds to a function of a single argument which we denote by $icode t$$ -(see Section 10.2 of +(see Section 10.2 of $cref/Evaluating Derivatives/Bib/Evaluating Derivatives/$$). Here and below -$latex X(t)$$, $latex Y(t)$$, and $icode Z(t)$$ are scalar valued functions +$latex X(t)$$, $latex Y(t)$$, and $icode Z(t)$$ are scalar valued functions and the corresponding $th p$$ order Taylor coefficients row vectors are $latex x$$, $latex y$$ and $latex z$$; i.e., $latex \[ \begin{array}{lcr} X(t) & = & x^{(0)} + x^{(1)} * t + \cdots + x^{(p)} * t^p + o( t^p ) \\ Y(t) & = & y^{(0)} + y^{(1)} * t + \cdots + y^{(p)} * t^p + o( t^p ) \\ -Z(t) & = & z^{(0)} + z^{(1)} * t + \cdots + z^{(p)} * t^p + o( t^p ) +Z(t) & = & z^{(0)} + z^{(1)} * t + \cdots + z^{(p)} * t^p + o( t^p ) \end{array} \] $$ For the purposes of this section, we are given $latex x$$ and $latex y$$ @@ -41,59 +41,59 @@ $subhead Addition$$ $latex \[ \begin{array}{rcl} -Z(t) -& = & X(t) + Y(t) +Z(t) +& = & X(t) + Y(t) \\ -\sum_{j=0}^p z^{(j)} * t^j +\sum_{j=0}^p z^{(j)} * t^j & = & \sum_{j=0}^p x^{(j)} * t^j + \sum_{j=0}^p y^{(j)} * t^j + o( t^p ) \\ z^{(j)} & = & x^{(j)} + y^{(j)} -\end{array} +\end{array} \] $$ $subhead Subtraction$$ $latex \[ \begin{array}{rcl} -Z(t) -& = & X(t) - Y(t) +Z(t) +& = & X(t) - Y(t) \\ -\sum_{j=0}^p z^{(j)} * t^j +\sum_{j=0}^p z^{(j)} * t^j & = & \sum_{j=0}^p x^{(j)} * t^j - \sum_{j=0}^p y^{(j)} * t^j + o( t^p ) \\ z^{(j)} & = & x^{(j)} - y^{(j)} -\end{array} +\end{array} \] $$ $subhead Multiplication$$ $latex \[ \begin{array}{rcl} -Z(t) -& = & X(t) * Y(t) +Z(t) +& = & X(t) * Y(t) \\ -\sum_{j=0}^p z^{(j)} * t^j +\sum_{j=0}^p z^{(j)} * t^j & = & \left( \sum_{j=0}^p x^{(j)} * t^j \right) -* +* \left( \sum_{j=0}^p y^{(j)} * t^j \right) + o( t^p ) \\ z^{(j)} & = & \sum_{k=0}^j x^{(j-k)} * y^{(k)} -\end{array} +\end{array} \] $$ $subhead Division$$ $latex \[ \begin{array}{rcl} -Z(t) -& = & X(t) / Y(t) +Z(t) +& = & X(t) / Y(t) \\ -x +x & = & z * y \\ -\sum_{j=0}^p x^{(j)} * t^j -& = & +\sum_{j=0}^p x^{(j)} * t^j +& = & \left( \sum_{j=0}^p z^{(j)} * t^j \right) -* -\left( \sum_{j=0}^p y^{(j)} * t^j \right) -+ +* +\left( \sum_{j=0}^p y^{(j)} * t^j \right) ++ o( t^p ) \\ x^{(j)} & = & \sum_{k=0}^j z^{(j-k)} y^{(k)} @@ -115,24 +115,24 @@ $latex \[ B(u) * F^{(1)} (u) - A(u) * F (u) = D(u) \] $$ -We use $latex a$$, $latex b$$ and $latex d$$ to denote the +We use $latex a$$, $latex b$$ and $latex d$$ to denote the $th p$$ order Taylor coefficient row vectors for $latex A [ X (t) ] $$, $latex B [ X (t) ]$$ and $latex D [ X (t) ] $$ respectively. -We assume that these coefficients are known functions of $latex x$$, +We assume that these coefficients are known functions of $latex x$$, the $th p$$ order Taylor coefficients for $latex X(t)$$. $subhead Taylor Coefficients Recursion Formula$$ -Our problem here is to express $latex z$$, +Our problem here is to express $latex z$$, the $th p$$ order Taylor coefficient row vector for $latex Z(t)$$, in terms of these other known coefficients. It follows from the formulas above that $latex \[ \begin{array}{rcl} -Z^{(1)} (t) -& = & F^{(1)} [ X(t) ] * X^{(1)} (t) +Z^{(1)} (t) +& = & F^{(1)} [ X(t) ] * X^{(1)} (t) \\ -B[ X(t) ] * Z^{(1)} (t) +B[ X(t) ] * Z^{(1)} (t) & = & \{ D[ X(t) ] + A[ X(t) ] * Z(t) \} * X^{(1)} (t) \\ B[ X(t) ] * Z^{(1)} (t) & = & E(t) * X^{(1)} (t) @@ -140,48 +140,48 @@ \] $$ where we define $latex \[ -E(t) = D[X(t)] + A[X(t)] * Z(t) -\] $$ +E(t) = D[X(t)] + A[X(t)] * Z(t) +\] $$ We can compute the value of $latex z^{(0)}$$ using the formula $latex \[ z^{(0)} = F ( x^{(0)} ) \]$$ -Suppose by induction (on $latex j$$) that we are given the +Suppose by induction (on $latex j$$) that we are given the Taylor coefficients of $latex E(t)$$ up to order $latex j-1$$; i.e., $latex e^{(k)}$$ for $latex k = 0 , \ldots , j-1$$ -and the coefficients +and the coefficients $latex z^{(k)}$$ for $latex k = 0 , \ldots , j$$. -We can compute $latex e^{(j)}$$ using the formula +We can compute $latex e^{(j)}$$ using the formula $latex \[ e^{(j)} = d^{(j)} + \sum_{k=0}^j a^{(j-k)} * z^{(k)} \] $$ -We need to complete the induction by finding formulas for $latex z^{(j+1)}$$. -It follows for the formula for the -$cref/multiplication/ForwardTheory/Binary Operators/Multiplication/$$ +We need to complete the induction by finding formulas for $latex z^{(j+1)}$$. +It follows for the formula for the +$cref/multiplication/ForwardTheory/Binary Operators/Multiplication/$$ operator that $latex \[ \begin{array}{rcl} \left( \sum_{k=0}^j b^{(k)} t^k \right) * \left( \sum_{k=1}^{j+1} k z^{(k)} * t^{k-1} \right) -& = & -\left( \sum_{k=0}^j e^{(k)} * t^k \right) +& = & +\left( \sum_{k=0}^j e^{(k)} * t^k \right) * \left( \sum_{k=1}^{j+1} k x^{(k)} * t^{k-1} \right) + o( t^p ) \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=0}^j e^{(k)} (j+1-k) x^{(j+1-k)} - - \sum_{k=1}^j b^{(k)} (j+1-k) z^{(j+1-k)} + \sum_{k=0}^j e^{(k)} (j+1-k) x^{(j+1-k)} + - \sum_{k=1}^j b^{(k)} (j+1-k) z^{(j+1-k)} \right) \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \end{array} \] $$ @@ -205,13 +205,13 @@ $subhead Cases that Apply Recursion Above$$ $table -$rref ExpForward$$ -$rref LogForward$$ -$rref SqrtForward$$ -$rref SinCosForward$$ -$rref AtanForward$$ -$rref AsinForward$$ -$rref AcosForward$$ +$rref exp_forward$$ +$rref log_forward$$ +$rref sqrt_forward$$ +$rref sin_cos_forward$$ +$rref atan_forward$$ +$rref asin_forward$$ +$rref acos_forward$$ $tend $subhead Special Cases$$ diff -Nru cppad-2015.00.00.9/omh/theory/log_forward.omh cppad-2016.00.00.1/omh/theory/log_forward.omh --- cppad-2015.00.00.9/omh/theory/log_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/log_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: log_forward.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: log_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,53 +12,54 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin LogForward$$ +$begin log_forward$$ $spell Taylor $$ -$index log, forward theory$$ -$index theory, log forward$$ -$index forward, log theory$$ +$section Logarithm Function Forward Mode Theory$$ +$mindex log1p$$ -$section Logarithm Function Forward Taylor Polynomial Theory$$ - -If $latex F(x) = \log(x) $$ +$head Derivatives$$ +If $latex F(x)$$ is $latex \R{log} (x)$$ or $latex \R{log1p} (x)$$ +the corresponding derivative satisfies the equation +$latex \[ + ( \bar{b} + x ) * F^{(1)} (x) - 0 * F (x) = 1 +\] $$ +where $latex \[ - x * F^{(1)} (x) - 0 * F (x) = 1 +\bar{b} += +\left\{ \begin{array}{ll} + 0 & \R{if} \; F(x) = \R{log}(x) + \\ + 1 & \R{if} \; F(x) = \R{log1p}(x) +\end{array} \right. \] $$ -and in the -$xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 +In the +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation /$$, $latex A(x) = 0$$, -$latex B(x) = x$$, +$latex B(x) = \bar{b} + x$$, and $latex D(x) = 1$$. -We use $latex a$$, $latex b$$, $latex d$$, -and $latex z$$ to denote the +We use $latex a$$, $latex b$$, $latex d$$, +and $latex z$$ to denote the Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, and $latex F [ X(t) ] $$ respectively. -It now follows from the general -$xref/ - ForwardTheory/ - Standard Math Functions/ - Taylor Coefficients Recursion Formula/ - Taylor coefficients recursion formula/ - 1 -/$$ -that for $latex j = 0 , 1, \ldots$$, + +$head Taylor Coefficients Recursion$$ +For orders $latex j = 0 , 1, \ldots$$, $latex \[ \begin{array}{rcl} -z^{(0)} & = & \log ( x^{(0)} ) +z^{(0)} & = & F ( x^{(0)} ) \\ -e^{(j)} +e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & \left\{ \begin{array}{ll} @@ -66,18 +67,18 @@ 0 & {\rm otherwise} \end{array} \right. \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \\ -& = & \frac{1}{j+1} \frac{1}{ x^{(0)} } +& = & \frac{1}{j+1} \frac{1}{ \bar{b} + x^{(0)} } \left( (j+1) x^{(j+1) } - - \sum_{k=1}^j k z^{(k)} x^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} x^{(j+1-k)} \right) \end{array} -\] $$ +\] $$ $end diff -Nru cppad-2015.00.00.9/omh/theory/log_reverse.omh cppad-2016.00.00.1/omh/theory/log_reverse.omh --- cppad-2015.00.00.9/omh/theory/log_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/log_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: log_reverse.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: log_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,75 +12,98 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin LogReverse$$ +$begin log_reverse$$ $spell Taylor $$ -$index log, reverse theory$$ -$index theory, log reverse$$ -$index reverse, log theory$$ - $section Logarithm Function Reverse Mode Theory$$ - +$mindex log1p$$ We use the reverse theory -$xref% - ReverseTheory% - Standard Math Functions% - standard math function +$cref%standard math function + %ReverseTheory + %Standard Math Functions %$$ definition for the functions $latex H$$ and $latex G$$. -The forward mode formulas for the -$cref/logarithm/LogForward/$$ -function are +The zero order forward mode formula for the +$cref/logarithm/log_forward/$$ is $latex \[ - z^{(j)} = \log ( x^{(0)} ) + z^{(0)} = F( x^{(0)} ) \] $$ - -for the case $latex j = 0$$, and for $latex j > 0$$, - +and for $latex j > 0$$, $latex \[ -z^{(j)} -= \frac{1}{ x^{(0)} } \frac{1}{j} +z^{(j)} += \frac{1}{ \bar{b} + x^{(0)} } \frac{1}{j} \left( j x^{(j)} - - \sum_{k=1}^{j-1} k z^{(k)} x^{(j-k)} + - \sum_{k=1}^{j-1} k z^{(k)} x^{(j-k)} \right) -\] $$ -otherwise. -If $latex j = 0$$, we have the relation +\] $$ +where $latex \[ -\D{H}{ x^{(j)} } = -\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{ x^{(0)} } +\bar{b} += +\left\{ \begin{array}{ll} + 0 & \R{if} \; F(x) = \R{log}(x) + \\ + 1 & \R{if} \; F(x) = \R{log1p}(x) +\end{array} \right. \] $$ - -If $latex j > 0$$, then for $latex k = 1 , \ldots , j-1$$ - +We note that for $latex j > 0$$ $latex \[ \begin{array}{rcl} -\D{H}{ x^{(0)} } & = & -\D{G}{ x^{(0)} } - \D{G}{ z^{(j)} } \frac{1}{ x^{(0)} } -\frac{1}{ x^{(0)} } \frac{1}{j} +\D{ z^{(j)} } { x^{(0)} } +& = & +- +\frac{1}{ \bar{b} + x^{(0)} } +\frac{1}{ \bar{b} + x^{(0)} } +\frac{1}{j} \left( j x^{(j)} - - \sum_{m=1}^{j-1} m z^{(m)} x^{(j-m)} + - \sum_{k=1}^{j-1} k z^{(k)} x^{(j-k)} \right) \\ & = & -\D{G}{ x^{(0)} } - \D{G}{ z^{(j)} } \frac{1}{ x^{(0)} } z^{(j)} +- +\frac{z^{(j)}}{ \bar{b} + x^{(0)} } +\end{array} +\] $$ +Removing the zero order partials are given by +$latex \[ +\begin{array}{rcl} +\D{H}{ x^{(0)} } & = & +\D{G}{ x^{(0)} } + \D{G}{ z^{(0)} } \D{ z^{(0)} }{ x^{(0)} } +\\ +& = & +\D{G}{ x^{(0)} } + \D{G}{ z^{(0)} } \frac{1}{ \bar{b} + x^{(0)} } +\end{array} +\] $$ +For orders $latex j > 0$$ and for $latex k = 1 , \ldots , j-1$$ +$latex \[ +\begin{array}{rcl} +\D{H}{ x^{(0)} } +& = & +\D{G}{ x^{(0)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } +\\ +& = & +\D{G}{ x^{(0)} } - \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ \bar{b} + x^{(0)} } +\\ +\D{H}{ x^{(j)} } +& = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(j)} } +\\ +& = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{ \bar{b} + x^{(0)} } \\ -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{ x^{(0)} } +\D{H}{ x^{(j-k)} } & = & +\D{G}{ x^{(j-k)} } - + \D{G}{ z^{(j)} } \frac{1}{ \bar{b} + x^{(0)} } \frac{k}{j} z^{(k)} \\ -\D{H}{ x^{(j-k)} } & = & -\D{G}{ x^{(j-k)} } - - \D{G}{ z^{(j)} } \frac{1}{ x^{(0)} } \frac{1}{j} k z^{(k)} -\\ -\D{H}{ z^{(k)} } & = & -\D{G}{ z^{(k)} } - - \D{G}{ z^{(j)} } \frac{1}{ x^{(0)} } \frac{1}{j} k x^{(j-k)} +\D{H}{ z^{(k)} } & = & +\D{G}{ z^{(k)} } - + \D{G}{ z^{(j)} } \frac{1}{ \bar{b} + x^{(0)} } \frac{k}{j} x^{(j-k)} \end{array} \] $$ diff -Nru cppad-2015.00.00.9/omh/theory/reverse_identity.omh cppad-2016.00.00.1/omh/theory/reverse_identity.omh --- cppad-2015.00.00.9/omh/theory/reverse_identity.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/reverse_identity.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: reverse_identity.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: reverse_identity.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -51,7 +51,7 @@ where $latex x^{(j)}$$ is the $th j$$ column of $latex x \in B^{n \times p}$$. The theorem below implies that $latex \[ - \D{ W_j }{ x^{(i)} } (x) = \D{ W_{j-i} }{ x^{(0)} } (x) + \D{ W_j }{ x^{(i)} } (x) = \D{ W_{j-i} }{ x^{(0)} } (x) \] $$ A $cref/general reverse sweep/reverse_any/$$ calculates the values $latex \[ @@ -66,7 +66,7 @@ $head Theorem$$ Suppose that $latex F : B^n \rightarrow B^m$$ is a $latex p$$ times continuously differentiable function. -Define the functions +Define the functions $latex Z : B \times B^{n \times p} \rightarrow B^n$$, $latex Y : B \times B^{n \times p }\rightarrow B^m$$, and @@ -77,10 +77,10 @@ \\ Y(t, x) & = & F [ Z(t, x) ] \\ - y^{(j)} (x) & = & \frac{1}{j !} \Dpow{j}{t} Y(0, x) + y^{(j)} (x) & = & \frac{1}{j !} \Dpow{j}{t} Y(0, x) \end{array} \] $$ -where $latex x^{(j)}$$ denotes the $th j$$ column of +where $latex x^{(j)}$$ denotes the $th j$$ column of $latex x \in B^{n \times p}$$. It follows that for all $latex i, j$$ such that $latex i \leq j < p$$, @@ -96,35 +96,35 @@ $latex \[ \begin{array}{rclr} \D{ y^{(j)} }{ x^{(i)} } (x) -& = & -\frac{1}{j ! } \D{ }{ x^{(i)} } +& = & +\frac{1}{j ! } \D{ }{ x^{(i)} } \left[ \Dpow{j}{t} (F \circ Z) (t, x) \right]_{t=0} \\ & = & -\frac{1}{j ! } \left[ \Dpow{j}{t} - \D{ }{ x^{(i)} } (F \circ Z) (t, x) +\frac{1}{j ! } \left[ \Dpow{j}{t} + \D{ }{ x^{(i)} } (F \circ Z) (t, x) \right]_{t=0} \\ & = & -\frac{1}{j ! } \left\{ - \Dpow{j}{t} \left[ t^i ( F^{(1)} \circ Z ) (t, x) \right] +\frac{1}{j ! } \left\{ + \Dpow{j}{t} \left[ t^i ( F^{(1)} \circ Z ) (t, x) \right] \right\}_{t=0} \end{array} \] $$ -For $latex k > i$$, the $th k$$ +For $latex k > i$$, the $th k$$ partial of $latex t^i$$ with respect to $latex t$$ is zero. Thus, the partial with respect to $latex t$$ is given by $latex \[ \begin{array}{rcl} -\Dpow{j}{t} \left[ t^i ( F^{(1)} \circ Z ) (t, x) \right] +\Dpow{j}{t} \left[ t^i ( F^{(1)} \circ Z ) (t, x) \right] & = & -\sum_{k=0}^i +\sum_{k=0}^i \left( \begin{array}{c} j \\ k \end{array} \right) -\frac{ i ! }{ (i - k) ! } t^{i-k} \; +\frac{ i ! }{ (i - k) ! } t^{i-k} \; \Dpow{j-k}{t} ( F^{(1)} \circ Z ) (t, x) \\ -\left\{ - \Dpow{j}{t} \left[ t^i ( F^{(1)} \circ Z ) (t, x) \right] +\left\{ + \Dpow{j}{t} \left[ t^i ( F^{(1)} \circ Z ) (t, x) \right] \right\}_{t=0} & = & \left( \begin{array}{c} j \\ i \end{array} \right) @@ -135,7 +135,7 @@ \Dpow{j-i}{t} ( F^{(1)} \circ Z ) (t, x) \\ \D{ y^{(j)} }{ x^{(i)} } (x) -& = & +& = & \frac{ 1 }{ (j - i) ! } \Dpow{j-i}{t} ( F^{(1)} \circ Z ) (t, x) \end{array} diff -Nru cppad-2015.00.00.9/omh/theory/reverse_theory.omh cppad-2016.00.00.1/omh/theory/reverse_theory.omh --- cppad-2015.00.00.9/omh/theory/reverse_theory.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/reverse_theory.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: reverse_theory.omh 3495 2014-12-24 01:16:15Z bradbell $ +$Id: reverse_theory.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,34 +19,34 @@ $section The Theory of Reverse Mode$$ $head Taylor Notation$$ -In Taylor notation, each variable corresponds to +In Taylor notation, each variable corresponds to a function of a single argument which we denote by $icode t$$ (see Section 10.2 of $cref/Evaluating Derivatives/Bib/Evaluating Derivatives/$$). Here and below -$latex X(t)$$, $latex Y(t)$$, and $icode Z(t)$$ are scalar valued functions +$latex X(t)$$, $latex Y(t)$$, and $icode Z(t)$$ are scalar valued functions and the corresponding $th p$$ order Taylor coefficients row vectors are $latex x$$, $latex y$$ and $latex z$$; i.e., $latex \[ \begin{array}{lcr} X(t) & = & x^{(0)} + x^{(1)} * t + \cdots + x^{(p)} * t^p + O( t^{p+1} ) \\ Y(t) & = & y^{(0)} + y^{(1)} * t + \cdots + y^{(p)} * t^p + O( t^{p+1} ) \\ -Z(t) & = & z^{(0)} + z^{(1)} * t + \cdots + z^{(p)} * t^p + O( t^{p+1} ) +Z(t) & = & z^{(0)} + z^{(1)} * t + \cdots + z^{(p)} * t^p + O( t^{p+1} ) \end{array} \] $$ For the purposes of this discussion, we are given the $th p$$ order Taylor coefficient row vectors $latex x$$, $latex y$$, and $latex z$$. -In addition, we are given the partial derivatives of a scalar valued function +In addition, we are given the partial derivatives of a scalar valued function $latex \[ G ( z^{(j)} , \ldots , z^{(0)}, x, y) \] $$ We need to compute the partial derivatives of the scalar valued function $latex \[ - H ( z^{(j-1)} , \ldots , z^{(0)}, x, y) = + H ( z^{(j-1)} , \ldots , z^{(0)}, x, y) = G ( z^{(j)}, z^{(j-1)} , \ldots , z^{(0)}, x , y ) \] $$ -where $latex z^{(j)}$$ is expressed as a function of the +where $latex z^{(j)}$$ is expressed as a function of the $th j-1$$ order Taylor coefficient row vector for $latex Z$$ and the vectors $latex x$$, $latex y$$; i.e., $latex z^{(j)}$$ above is a shorthand for @@ -73,10 +73,10 @@ \D{G}{ x^{(k)} } + \D{G}{ z^{(k)} } \\ \\ \D{H}{ y^{(k)} } & = & -\D{G}{ y^{(k)} } + \D{G}{ z^{(k)} } +\D{G}{ y^{(k)} } + \D{G}{ z^{(k)} } \\ -\D{H}{ z^{(l)} } & = & \D{G}{ z^{(l)} } -\end{array} +\D{H}{ z^{(l)} } & = & \D{G}{ z^{(l)} } +\end{array} \] $$ $subhead Subtraction$$ @@ -92,8 +92,8 @@ \D{G}{ x^{(k)} } - \D{G}{ z^{(k)} } \\ \\ \D{H}{ y^{(k)} } & = & -\D{G}{ y^{(k)} } - \D{G}{ z^{(k)} } -\end{array} +\D{G}{ y^{(k)} } - \D{G}{ z^{(k)} } +\end{array} \] $$ $subhead Multiplication$$ @@ -108,29 +108,29 @@ \begin{array}{rcl} \D{H}{ x^{(j-k)} } & = & \D{G}{ x^{(j-k)} } + -\sum_{k=0}^j \D{G}{ z^{(j)} } y^{(k)} +\sum_{k=0}^j \D{G}{ z^{(j)} } y^{(k)} \\ \D{H}{ y^{(k)} } & = & \D{G}{ y^{(k)} } + -\sum_{k=0}^j \D{G}{ z^{(j)} } x^{(j-k)} -\end{array} +\sum_{k=0}^j \D{G}{ z^{(j)} } x^{(j-k)} +\end{array} \] $$ $subhead Division$$ The forward mode formula for $cref/division/ForwardTheory/Binary Operators/Division/$$ is $latex \[ -z^{(j)} = -\frac{1}{y^{(0)}} -\left( - x^{(j)} - \sum_{k=1}^j z^{(j-k)} y^{(k)} +z^{(j)} = +\frac{1}{y^{(0)}} +\left( + x^{(j)} - \sum_{k=1}^j z^{(j-k)} y^{(k)} \right) \] $$ If follows that for $latex k = 1 , \ldots , j$$ $latex \[ \begin{array}{rcl} \D{H}{ x^{(j)} } & = & -\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} \\ \D{H}{ z^{(j-k)} } & = & \D{G}{ z^{(j-k)} } - \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} y^{(k)} @@ -139,9 +139,9 @@ \D{G}{ y^{(k)} } - \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} z^{(j-k)} \\ \D{H}{ y^{(0)} } & = & -\D{G}{ y^{(0)} } - \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} \frac{1}{y^{(0)}} -\left( - x^{(j)} - \sum_{k=1}^j z^{(j-k)} y^{(k)} +\D{G}{ y^{(0)} } - \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} \frac{1}{y^{(0)}} +\left( + x^{(j)} - \sum_{k=1}^j z^{(j-k)} y^{(k)} \right) \\ & = & @@ -151,16 +151,16 @@ $head Standard Math Functions$$ The standard math functions have only one argument. -Hence we are given the partial derivatives of a scalar valued function +Hence we are given the partial derivatives of a scalar valued function $latex \[ G ( z^{(j)} , \ldots , z^{(0)}, x) \] $$ We need to compute the partial derivatives of the scalar valued function $latex \[ - H ( z^{(j-1)} , \ldots , z^{(0)}, x) = + H ( z^{(j-1)} , \ldots , z^{(0)}, x) = G ( z^{(j)}, z^{(j-1)} , \ldots , z^{(0)}, x) \] $$ -where $latex z^{(j)}$$ is expressed as a function of the +where $latex z^{(j)}$$ is expressed as a function of the $th j-1$$ order Taylor coefficient row vector for $latex Z$$ and the vector $latex x$$; i.e., $latex z^{(j)}$$ above is a shorthand for diff -Nru cppad-2015.00.00.9/omh/theory/sin_cos_forward.omh cppad-2016.00.00.1/omh/theory/sin_cos_forward.omh --- cppad-2015.00.00.9/omh/theory/sin_cos_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/sin_cos_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: sin_cos_forward.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: sin_cos_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,7 +12,7 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin SinCosForward$$ +$begin sin_cos_forward$$ $spell sin cos @@ -22,31 +22,15 @@ $$ -$index sin, forward$$ -$index sinh, forward$$ -$index cos, forward$$ -$index cosh, forward$$ - -$index theory, sin$$ -$index theory, sinh$$ -$index theory, cos$$ -$index theory, cosh$$ - -$index forward, sin$$ -$index forward, sinh$$ -$index forward, cos$$ -$index forward, cosh$$ - $section Trigonometric and Hyperbolic Sine and Cosine Forward Theory$$ +$mindex sin sinh cos cosh$$ $head Differential Equation$$ The -$xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation /$$ is $latex \[ @@ -55,8 +39,8 @@ In this sections we consider forward mode for the following choices: $table -$pre $$ - $cnext $cnext $latex F(u)$$ +$pre $$ + $cnext $cnext $latex F(u)$$ $cnext $cnext $latex \sin(u)$$ $cnext $cnext $latex \cos(u)$$ $cnext $cnext $latex \sinh(u)$$ @@ -68,7 +52,7 @@ $cnext $cnext $latex 0$$ $cnext $cnext $latex 0$$ $rnext - $cnext $cnext $latex B(u)$$ + $cnext $cnext $latex B(u)$$ $cnext $cnext $latex 1$$ $cnext $cnext $latex 1$$ $cnext $cnext $latex 1$$ @@ -83,8 +67,8 @@ We use $latex a$$, $latex b$$, $latex d$$ and $latex f$$ for the Taylor coefficients of -$latex A [ X (t) ]$$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ]$$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, and $latex F [ X(t) ] $$ respectively. It now follows from the general @@ -100,22 +84,22 @@ \begin{array}{rcl} f^{(0)} & = & D ( x^{(0)} ) \\ -e^{(j)} +e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * f^{(k)} \\ & = & d^{(j)} \\ -f^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +f^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} - - \sum_{k=1}^j k f^{(k)} b^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} + - \sum_{k=1}^j k f^{(k)} b^{(j+1-k)} \right) \\ -& = & \frac{1}{j+1} - \sum_{k=1}^{j+1} k x^{(k)} d^{(j+1-k)} +& = & \frac{1}{j+1} + \sum_{k=1}^{j+1} k x^{(k)} d^{(j+1-k)} \end{array} -\] $$ -The formula above generates the +\] $$ +The formula above generates the order $latex j+1$$ coefficient of $latex F[ X(t) ]$$ from the lower order coefficients for $latex X(t)$$ and $latex D[ X(t) ]$$. diff -Nru cppad-2015.00.00.9/omh/theory/sin_cos_reverse.omh cppad-2016.00.00.1/omh/theory/sin_cos_reverse.omh --- cppad-2015.00.00.9/omh/theory/sin_cos_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/sin_cos_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: sin_cos_reverse.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: sin_cos_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,72 +12,56 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin SinCosReverse$$ +$begin sin_cos_reverse$$ $spell Taylor cos $$ -$index sin, reverse$$ -$index sinh, reverse$$ -$index cos, reverse$$ -$index cosh, reverse$$ - -$index theory, sin$$ -$index theory, sinh$$ -$index theory, cos$$ -$index theory, cosh$$ - -$index reverse, sin$$ -$index reverse, sinh$$ -$index reverse, cos$$ -$index reverse, cosh$$ - - $section Trigonometric and Hyperbolic Sine and Cosine Reverse Theory$$ +$mindex sin sinh cos cosh$$ We use the reverse theory -$xref% - ReverseTheory% - Standard Math Functions% - standard math function +$cref%standard math function + %ReverseTheory + %Standard Math Functions %$$ definition for the functions $latex H$$ and $latex G$$. -In addition, +In addition, we use the following definitions for $latex s$$ and $latex c$$ and the integer $latex \ell$$ $table -Coefficients - $cnext $cnext $latex s$$ - $cnext $cnext $latex c$$ +Coefficients + $cnext $cnext $latex s$$ + $cnext $cnext $latex c$$ $cnext $cnext $latex \ell$$ $rnext -Trigonometric Case +Trigonometric Case $cnext $cnext $latex \sin [ X(t) ]$$ $cnext $cnext $latex \cos [ X(t) ]$$ $cnext $cnext 1 $rnext -Hyperbolic Case - $cnext $cnext $latex \sinh [ X(t) ]$$ - $cnext $cnext $latex \cosh [ X(t) ]$$ +Hyperbolic Case + $cnext $cnext $latex \sinh [ X(t) ]$$ + $cnext $cnext $latex \cosh [ X(t) ]$$ $cnext $cnext -1 $tend We use the value $latex \[ z^{(j)} = ( s^{(j)} , c^{(j)} ) -\] $$ +\] $$ in the definition for $latex G$$ and $latex H$$. The forward mode formulas for the -$cref/sine and cosine/SinCosForward/$$ functions are +$cref/sine and cosine/sin_cos_forward/$$ functions are $latex \[ \begin{array}{rcl} -s^{(j)} & = & \frac{1 + \ell}{2} \sin ( x^{(0)} ) - + \frac{1 - \ell}{2} \sinh ( x^{(0)} ) +s^{(j)} & = & \frac{1 + \ell}{2} \sin ( x^{(0)} ) + + \frac{1 - \ell}{2} \sinh ( x^{(0)} ) \\ -c^{(j)} & = & \frac{1 + \ell}{2} \cos ( x^{(0)} ) - + \frac{1 - \ell}{2} \cosh ( x^{(0)} ) +c^{(j)} & = & \frac{1 + \ell}{2} \cos ( x^{(0)} ) + + \frac{1 - \ell}{2} \cosh ( x^{(0)} ) \end{array} \] $$ @@ -85,37 +69,37 @@ $latex \[ \begin{array}{rcl} -s^{(j)} & = & \frac{1}{j} +s^{(j)} & = & \frac{1}{j} \sum_{k=1}^{j} k x^{(k)} c^{(j-k)} \\ -c^{(j)} & = & \ell \frac{1}{j} - \sum_{k=1}^{j} k x^{(k)} s^{(j-k)} +c^{(j)} & = & \ell \frac{1}{j} + \sum_{k=1}^{j} k x^{(k)} s^{(j-k)} \end{array} -\] $$ +\] $$ If $latex j = 0$$, we have the relation $latex \[ \begin{array}{rcl} -\D{H}{ x^{(j)} } & = & -\D{G}{ x^{(j)} } +\D{H}{ x^{(j)} } & = & +\D{G}{ x^{(j)} } + \D{G}{ s^{(j)} } c^{(0)} + \ell \D{G}{ c^{(j)} } s^{(0)} \end{array} -\] $$ +\] $$ If $latex j > 0$$, then for $latex k = 1, \ldots , j-1$$ $latex \[ \begin{array}{rcl} -\D{H}{ x^{(k)} } & = & -\D{G}{ x^{(k)} } +\D{H}{ x^{(k)} } & = & +\D{G}{ x^{(k)} } + \D{G}{ s^{(j)} } \frac{1}{j} k c^{(j-k)} + \ell \D{G}{ c^{(j)} } \frac{1}{j} k s^{(j-k)} \\ -\D{H}{ s^{(j-k)} } & = & +\D{H}{ s^{(j-k)} } & = & \D{G}{ s^{(j-k)} } + \ell \D{G}{ c^{(j)} } k x^{(k)} \\ -\D{H}{ c^{(j-k)} } & = & +\D{H}{ c^{(j-k)} } & = & \D{G}{ c^{(j-k)} } + \D{G}{ s^{(j)} } k x^{(k)} \end{array} \] $$ diff -Nru cppad-2015.00.00.9/omh/theory/sqrt_forward.omh cppad-2016.00.00.1/omh/theory/sqrt_forward.omh --- cppad-2015.00.00.9/omh/theory/sqrt_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/sqrt_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,10 +1,10 @@ -$Id: sqrt_forward.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: sqrt_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ // BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,55 +12,48 @@ -------------------------------------------------------------------------- */ // END SHORT COPYRIGHT -$begin SqrtForward$$ +$begin sqrt_forward$$ $spell sqrt Arctangent Taylor $$ -$index sqrt, forward theory$$ -$index theory, sqrt forward$$ -$index forward, sqrt theory$$ +$section Square Root Function Forward Mode Theory$$ +$mindex sqrt$$ -$section Square Root Function Forward Taylor Polynomial Theory$$ - -If $latex F(x) = \sqrt{x} $$ +If $latex F(x) = \sqrt{x} $$ $latex \[ F(x) * F^{(1)} (x) - 0 * F (x) = 1/2 \] $$ and in the -$xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation /$$, $latex A(x) = 0$$, $latex B(x) = F(x)$$, and $latex D(x) = 1/2$$. -We use $latex a$$, $latex b$$, $latex d$$, -and $latex z$$ to denote the +We use $latex a$$, $latex b$$, $latex d$$, +and $latex z$$ to denote the Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, $latex D [ X (t) ] $$, and $latex F [ X(t) ] $$ respectively. It now follows from the general -$xref/ - ForwardTheory/ - Standard Math Functions/ - Taylor Coefficients Recursion Formula/ - Taylor coefficients recursion formula/ - 1 +$cref/Taylor coefficients recursion formula + /ForwardTheory + /Standard Math Functions + /Taylor Coefficients Recursion Formula /$$ that for $latex j = 0 , 1, \ldots$$, $latex \[ \begin{array}{rcl} z^{(0)} & = & \sqrt { x^{(0)} } \\ -e^{(j)} +e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & \left\{ \begin{array}{ll} @@ -68,18 +61,18 @@ 0 & {\rm otherwise} \end{array} \right. \\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \left( - \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} e^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} \right) \\ -& = & \frac{1}{j+1} \frac{1}{ z^{(0)} } +& = & \frac{1}{j+1} \frac{1}{ z^{(0)} } \left( \frac{j+1}{2} x^{(j+1) } - - \sum_{k=1}^j k z^{(k)} z^{(j+1-k)} + - \sum_{k=1}^j k z^{(k)} z^{(j+1-k)} \right) \end{array} -\] $$ +\] $$ $end diff -Nru cppad-2015.00.00.9/omh/theory/sqrt_reverse.omh cppad-2016.00.00.1/omh/theory/sqrt_reverse.omh --- cppad-2015.00.00.9/omh/theory/sqrt_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/sqrt_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,58 +1,54 @@ -$Id: sqrt_reverse.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: sqrt_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -$begin SqrtReverse$$ +$begin sqrt_reverse$$ $spell sqrt Taylor $$ -$index sqrt, reverse theory$$ -$index theory, sqrt reverse$$ -$index reverse, sqrt theory$$ - $section Square Root Function Reverse Mode Theory$$ +$mindex sqrt$$ We use the reverse theory -$xref% - ReverseTheory% - Standard Math Functions% - standard math function +$cref%standard math function + %ReverseTheory + %Standard Math Functions %$$ definition for the functions $latex H$$ and $latex G$$. The forward mode formulas for the -$cref/square root/SqrtForward/$$ +$cref/square root/sqrt_forward/$$ function are $latex \[ - z^{(j)} = \sqrt { x^{(0)} } + z^{(j)} = \sqrt { x^{(0)} } \] $$ for the case $latex j = 0$$, and for $latex j > 0$$, $latex \[ -z^{(j)} = \frac{1}{j} \frac{1}{ z^{(0)} } +z^{(j)} = \frac{1}{j} \frac{1}{ z^{(0)} } \left( \frac{j}{2} x^{(j) } - - \sum_{\ell=1}^{j-1} \ell z^{(\ell)} z^{(j-\ell)} + - \sum_{\ell=1}^{j-1} \ell z^{(\ell)} z^{(j-\ell)} \right) -\] $$ +\] $$ If $latex j = 0$$, we have the relation $latex \[ \begin{array}{rcl} -\D{H}{ x^{(j)} } & = & +\D{H}{ x^{(j)} } & = & \D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } \\ & = & @@ -64,20 +60,20 @@ $latex \[ \begin{array}{rcl} -\D{H}{ z^{(0)} } & = & -\D{G}{ z^{(0)} } + \D{G} { z^{(j)} } \D{ z^{(j)} }{ z^{(0)} } +\D{H}{ z^{(0)} } & = & +\D{G}{ z^{(0)} } + \D{G} { z^{(j)} } \D{ z^{(j)} }{ z^{(0)} } \\ & = & -\D{G}{ z^{(0)} } - +\D{G}{ z^{(0)} } - \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ z^{(0)} } \\ -\D{H}{ x^{(j)} } & = & +\D{H}{ x^{(j)} } & = & \D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(j)} } \\ & = & -\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{ 2 z^{(0)} } +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{ 2 z^{(0)} } \\ -\D{H}{ z^{(k)} } & = & +\D{H}{ z^{(k)} } & = & \D{G}{ z^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ z^{(k)} } \\ & = & diff -Nru cppad-2015.00.00.9/omh/theory/tan_forward.omh cppad-2016.00.00.1/omh/theory/tan_forward.omh --- cppad-2015.00.00.9/omh/theory/tan_forward.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/tan_forward.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: tan_forward.omh 3272 2014-05-20 13:50:52Z bradbell $ +$Id: tan_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,26 +15,24 @@ Taylor $$ -$index tan, forward theory$$ -$index theory, tan forward$$ -$index forward, tan theory$$ $section Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory$$ +$mindex tan$$ $head Derivatives$$ $latex \[ \begin{array}{rcl} -\tan^{(1)} ( u ) & = & [ \cos (u)^2 + \sin (u)^2 ] / \cos (u)^2 -\\ -& = & 1 + \tan (u)^2 +\tan^{(1)} ( u ) & = & [ \cos (u)^2 + \sin (u)^2 ] / \cos (u)^2 \\ -\tanh^{(1)} ( u ) & = & [ \cosh (u)^2 - \sinh (u)^2 ] / \cosh (u)^2 -\\ -& = & 1 - \tanh (u)^2 +& = & 1 + \tan (u)^2 +\\ +\tanh^{(1)} ( u ) & = & [ \cosh (u)^2 - \sinh (u)^2 ] / \cosh (u)^2 +\\ +& = & 1 - \tanh (u)^2 \end{array} \] $$ If $latex F(u)$$ is $latex \tan (u)$$ or $latex \tanh (u)$$ -the corresponding derivative is given by +the corresponding derivative is given by $latex \[ F^{(1)} (u) = 1 \pm F(u)^2 \]$$ @@ -46,8 +44,8 @@ where we define the function $latex Y(t) = Z(t)^2$$. $head Taylor Coefficients Recursion$$ -Suppose that we are given the Taylor coefficients -up to order $latex j$$ for the function $latex X(t)$$ and +Suppose that we are given the Taylor coefficients +up to order $latex j$$ for the function $latex X(t)$$ and up to order $latex j-1$$ for the functions $latex Y(t)$$ and $latex Z(t)$$. We need a formula that computes the coefficient of order $latex j$$ for $latex Y(t)$$ and $latex Z(t)$$. @@ -67,17 +65,17 @@ Setting the coefficients of $latex t^{j-1}$$ equal, we have $latex \[ \begin{array}{rcl} -j z^{(j)} +j z^{(j)} = -j x^{(j)} +j x^{(j)} \pm \sum_{k=1}^j k x^{(k)} y^{(j-k)} \\ -z^{(j)} +z^{(j)} = x^{(j)} \pm \frac{1}{j} \sum_{k=1}^j k x^{(k)} y^{(j-k)} \end{array} -\] $$ +\] $$ Once we have computed $latex z^{(j)}$$, we can compute $latex y^{(j)}$$ as follows: $latex \[ diff -Nru cppad-2015.00.00.9/omh/theory/tan_reverse.omh cppad-2016.00.00.1/omh/theory/tan_reverse.omh --- cppad-2015.00.00.9/omh/theory/tan_reverse.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/tan_reverse.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: tan_reverse.omh 3495 2014-12-24 01:16:15Z bradbell $ +$Id: tan_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,11 +15,9 @@ Taylor $$ -$index tan, reverse theory$$ -$index theory, tan reverse$$ -$index reverse, tan theory$$ $section Tangent and Hyperbolic Tangent Reverse Mode Theory$$ +$mindex tan$$ $head Notation$$ We use the reverse theory @@ -33,17 +31,17 @@ $latex \[ y^{(j-1)} = \sum_{k=0}^{j-1} z^{(k)} z^{(j-k-1)} \] $$ -Fix $latex j > 0$$ and suppose that $latex H$$ is the same as $latex G$$ -except that $latex y^{(j-1)}$$ is replaced as a function of the Taylor +Fix $latex j > 0$$ and suppose that $latex H$$ is the same as $latex G$$ +except that $latex y^{(j-1)}$$ is replaced as a function of the Taylor coefficients for $latex Z(t)$$. To be specific, for $latex k = 0 , \ldots , j-1$$, $latex \[ \begin{array}{rcl} -\D{H}{ z^{(k)} } -& = & +\D{H}{ z^{(k)} } +& = & \D{G}{ z^{(k)} } + \D{G}{ y^{(j-1)} } \D{ y^{(j-1)} }{ z^{(k)} } \\ -& = & +& = & \D{G}{ z^{(k)} } + \D{G}{ y^{(j-1)} } 2 z^{(j-k-1)} \end{array} \] $$ @@ -52,7 +50,7 @@ $head Positive Orders Z(t)$$ For order $latex j > 0$$, suppose that $latex H$$ is the same as $latex G$$ except that -$latex z^{(j)}$$ is expressed as a function of +$latex z^{(j)}$$ is expressed as a function of the coefficients for $latex X(t)$$, and the lower order Taylor coefficients for $latex Y(t)$$, $latex Z(t)$$. $latex \[ @@ -64,29 +62,29 @@ the partial of $latex H$$ with respect to $latex x^{(k)}$$ is given by $latex \[ \begin{array}{rcl} -\D{H}{ x^{(k)} } & = & +\D{H}{ x^{(k)} } & = & \D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(k)} } \\ & = & -\D{G}{ x^{(k)} } + +\D{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \left[ \delta ( j - k ) \pm \frac{k}{j} y^{(j-k)} \right] \end{array} -\] $$ +\] $$ where $latex \delta ( j - k )$$ is one if $latex j = k$$ and zero otherwise. -For $latex k = 1 , \ldots , j$$ +For $latex k = 1 , \ldots , j$$ The partial of $latex H$$ with respect to $latex y^{j-k}$$, is given by $latex \[ \begin{array}{rcl} -\D{H}{ y^{(j-k)} } & = & +\D{H}{ y^{(j-k)} } & = & \D{G}{ y^{(j-k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ y^{(j-k)} } \\ & = & \D{G}{ y^{(j-k)} } \pm \D{G}{ z^{(j)} }\frac{k}{j} x^{k} \end{array} -\] $$ +\] $$ $head Order Zero Z(t)$$ @@ -104,8 +102,8 @@ In this case, $latex \[ \begin{array}{rcl} -\D{H}{ x^{(0)} } -& = & +\D{H}{ x^{(0)} } +& = & \D{G}{ x^{(0)} } + \D{G}{ z^{(0)} } \D{ z^{(0)} }{ x^{(0)} } \\ diff -Nru cppad-2015.00.00.9/omh/theory/theory.omh cppad-2016.00.00.1/omh/theory/theory.omh --- cppad-2015.00.00.9/omh/theory/theory.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/theory/theory.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: theory.omh 3169 2014-03-09 13:37:59Z bradbell $ +$Id: theory.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/omh/thread_alloc.omh cppad-2016.00.00.1/omh/thread_alloc.omh --- cppad-2015.00.00.9/omh/thread_alloc.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/thread_alloc.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: thread_alloc.omh 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: thread_alloc.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,15 +12,14 @@ $begin thread_alloc$$ $spell openmp - cppad/thread_alloc.hpp + cppad/utility/thread_alloc.hpp CppAD $$ $section A Fast Multi-Threading Memory Allocator$$ +$mindex allocation$$ + -$index multi-threading, memory allocation$$ -$index memory, multi-threading allocation$$ -$index allocation, multi-threading$$ $head Syntax$$ $code # include $$ @@ -31,7 +30,7 @@ Once memory is obtained for a thread, the $code thread_alloc$$ memory allocator keeps that memory $cref/available/ta_available/$$ for the thread so that it can be re-used without waiting for a lock. -All the CppAD memory allocations use this utility. +All the CppAD memory allocations use this utility. The $cref/free_available/ta_free_available/$$ function should be used to return memory to the system (once it is no longer required by a thread). @@ -43,7 +42,7 @@ $childtable% example/thread_alloc.cpp% - cppad/thread_alloc.hpp + cppad/utility/thread_alloc.hpp %$$ $end diff -Nru cppad-2015.00.00.9/omh/uniform_01_hpp.omh cppad-2016.00.00.1/omh/uniform_01_hpp.omh --- cppad-2015.00.00.9/omh/uniform_01_hpp.omh 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/omh/uniform_01_hpp.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: uniform_01_hpp.omh 2506 2012-10-24 19:36:49Z bradbell $ +$Id: uniform_01_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,15 +18,14 @@ $$ $section Source: uniform_01$$ +$mindex source$$ -$index uniform_01, source$$ -$index source, uniform_01$$ $code -# ifndef CPPAD_UNIFORM_01_INCLUDED +# ifndef CPPAD_UNIFORM_01_HPP $pre $$ -# define CPPAD_UNIFORM_01_INCLUDED +# define CPPAD_UNIFORM_01_HPP $verbatim%cppad/speed/uniform_01.hpp%0%// BEGIN C++%// END C++%$$ diff -Nru cppad-2015.00.00.9/omh/utility.omh cppad-2016.00.00.1/omh/utility.omh --- cppad-2015.00.00.9/omh/utility.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/utility.omh 2016-02-09 08:31:48.000000000 +0000 @@ -0,0 +1,138 @@ +$Id: utility.omh 3769 2015-12-29 16:13:16Z bradbell $ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +$begin utility$$ +$spell + CppAD + namespace + alloc + cppad.hpp +$$ + + +$section Some General Purpose Utilities$$ +These routines can be include individually; for example, +$codep + # include +$$ +only includes the definitions necessary for the $code CppAD::vector$$ class. +They can also be included as a group, separate from the rest of CppAD, using +$codep + # include +$$ +They will also be included, along with the rest of CppAD, using +$codep + # include +$$ + +$children% + cppad/utility/error_handler.hpp% + + cppad/utility/near_equal.hpp% + cppad/utility/speed_test.hpp% + cppad/utility/time_test.hpp% + + omh/numeric_type.omh% + cppad/utility/check_numeric_type.hpp% + omh/simple_vector.omh% + cppad/utility/check_simple_vector.hpp% + + cppad/utility/nan.hpp% + cppad/utility/pow_int.hpp% + cppad/utility/poly.hpp% + omh/lu_det_and_solve.omh% + cppad/utility/romberg_one.hpp% + cppad/utility/romberg_mul.hpp% + cppad/utility/runge_45.hpp% + cppad/utility/rosen_34.hpp% + cppad/utility/ode_err_control.hpp% + cppad/utility/ode_gear.hpp% + cppad/utility/ode_gear_control.hpp% + + cppad/utility/vector.hpp% + omh/thread_alloc.omh% + cppad/utility/index_sort.hpp% + cppad/utility/to_string.hpp +%$$ + +$head Testing$$ +The routines listed below support numerical correctness and speed testing: +$table +$rref NearEqual$$ +$rref time_test$$ +$rref speed_test$$ +$rref SpeedTest$$ +$tend + +$head C++ Concepts$$ +We refer to a the set of classes that satisfy certain conditions +as a C++ concept. +The following concepts are used by the CppAD Template library: +$table +$rref NumericType$$ +$rref CheckNumericType$$ +$rref SimpleVector$$ +$rref CheckSimpleVector$$ +$tend + + +$head General Numerical Routines$$ +The routines listed below are general purpose numerical routines +written with the floating point type a C++ template parameter. +This enables them to be used with algorithmic differentiation types, +as well as for other purposes. +$table +$rref nan$$ +$rref pow_int$$ +$rref Poly$$ +$rref LuDetAndSolve$$ +$rref RombergOne$$ +$rref RombergMul$$ +$rref Runge45$$ +$rref Rosen34$$ +$rref OdeErrControl$$ +$rref OdeGear$$ +$rref OdeGearControl$$ +$tend + +$head Miscellaneous$$ + +$subhead Error Handler$$ +All of the routines in the CppAD namespace use the following +general purpose error handler: +$table +$rref ErrorHandler$$ +$tend + +$subhead Simple Vector Template Class$$ +A simple implementation of a template vector class +(that is easy to view in a C++ debugger): +$table +$rref CppAD_vector$$ +$tend + +$subhead Multi-Threading Memory Allocation$$ +$table +$rref thread_alloc$$ +$tend + +$subhead Sorting Indices$$ +$table +$rref index_sort$$ +$tend + +$subhead to_string$$ +$table +$rref to_string$$ +$tend + +$end diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_03.omh cppad-2016.00.00.1/omh/whats_new/whats_new_03.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_03.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_03.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_03.omh 2691 2012-12-30 23:39:57Z bradbell $ +$Id: whats_new_03.omh 3686 2015-05-11 16:14:25Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -45,7 +45,7 @@ $section Changes and Additions to CppAD During 2003$$ $head Introduction$$ -This section contains a list of the changes plus for +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. @@ -54,16 +54,16 @@ Some references to $code double$$ should have been references to the $cref/base type/glossary/Base Type/$$ (in reverse mode and in the $code Grad/$$ and $code Hess$$ functions). -This has been fixed. +This has been fixed. $head 12-22$$ The preprocessor symbol $code WIN32$$ was being used to determine if one was using Microsoft's C++ compiler. -This symbol is predefined by the +This symbol is predefined by the $href%http://www.mingw.org%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 -$code _MSC_VER$$ to determine if +$code _MSC_VER$$ to determine if one is using the Microsoft C++ compiler. @@ -91,7 +91,7 @@ size_t %TapeName%.Erase(void) TapeState %TapeName%.State(void) const size_t %TapeName%.Order(void) const - size_t %TapeName%.Required(void) const + size_t %TapeName%.Required(void) const bool Parameter(CppADvector< AD<%Base%> > &%u%) %TapeName%.Forward(%indvar%) %TapeName%.Reverse(%var%) @@ -107,7 +107,7 @@ if one does not directly access $code CppADCreateTape$$. The $cref/examples/example/$$ were changed to not use -$icode TapeName$$. +$icode TapeName$$. The following examples were skipped because they document the functions that access $icode TapeName$$: $code DefFun.cpp$$, @@ -117,9 +117,9 @@ $code rev_two.cpp$$. $head 12-05$$ -There was a bug in -$icode%f%.Rev%$$ and -$icode%f%.RevTwo%$$ and +There was a bug in +$icode%f%.Rev%$$ and +$icode%f%.RevTwo%$$ and when two dependent variables were always equal and shared the same location in the tape. This has been fixed. @@ -127,7 +127,7 @@ $$ The ODE Example was changed to tape the solution -(and not use $code OdeOne$$ or $code OdeTwo$$). +(and not use $code OdeOne$$ or $code OdeTwo$$). This is simpler to use and the resulting speed tests gave much faster results. @@ -137,7 +137,7 @@ void Independent(const CppADvector<%Base%> &%x%) %$$ which will declare the independent variables and begin recording -$codei%AD<%Base%>%$$ operations +$codei%AD<%Base%>%$$ operations (see $cref Independent$$). The $cref ADFun$$ constructor was modified so that it stops the recording and erases that tape as well as creates the @@ -150,13 +150,13 @@ $head 11-20$$ -The $code AbsGeq$$ and $code LeqZero$$ in +The $code AbsGeq$$ and $code LeqZero$$ in $cref LuSolve$$ were changed to template functions so they could have default definitions in the case where the $code <=$$ and $code >=$$ operators are defined. This made the $code double$$ and $code AD$$ use of $code LuSolve$$ simpler because the user need not worry about these functions. -On the other hand, it made the $code std::complex$$ +On the other hand, it made the $code std::complex$$ and $code AD$$ use of $code LuSolve$$ more complex. $pre @@ -164,15 +164,15 @@ $$ The member function names for the $icode fun$$ argument to ODE were changed from -$icode%fun%.f%$$ to -$icode%fun%.Ode%$$ +$icode%fun%.f%$$ to +$icode%fun%.Ode%$$ and from -$icode%fun%.g%$$ to -$icode%fun%.Ode_ini%$$. +$icode%fun%.g%$$ to +$icode%fun%.Ode_ini%$$. -$head 11-16$$ -The +$head 11-16$$ +The $cref/table of contents/_contents/$$ was reorganized to provide a better grouping of the documentation. $pre @@ -180,12 +180,12 @@ $$ The $cref LuSolve$$ utility is now part of the distribution and not just an example; i.e., -it is automatically included by +it is automatically included by $code cppad.hpp$$. $head 11-15$$ -The +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. @@ -194,15 +194,15 @@ $pre $$ -The template argument $icode Type$$ was changed to -$icode Base$$ where ever it was the +The template argument $icode Type$$ was changed to +$icode Base$$ where ever it was the $cref/base type/glossary/Base Type/$$ of an AD class. $head 11-14$$ -An +An $code speed_cppad/OdeSpeed.cpp/$$ test was added -and some changes were made to the +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 $icode fun$$. @@ -221,7 +221,7 @@ $cref Install$$ procedure. $head 11-06$$ -The documentation for +The documentation for $cref/taping derivative calculations/mul_level/$$ was improved as well as the corresponding example. In order to make this simpler, @@ -230,7 +230,7 @@ $head 11-04$$ The ODE utility was changed from an example to -part of the distribution. +part of the distribution. In addition, it was extended so that it now supports taping the solution of the differential equations (case $icode order$$ equal zero) or solving the extended set of differential equations @@ -242,7 +242,7 @@ $head 11-02$$ -It is now legal to differentiate a +It is now legal to differentiate a $cref/parameter/glossary/Parameter/$$ with respect to an $cref/independent variable/glossary/Tape/Independent Variable/$$ @@ -252,7 +252,7 @@ $code Partial$$, $code ReverseTwo$$, and $code PartialTwo$$ -functions. +functions. $head 10-21$$ All the $code CppAD$$ include files, @@ -263,13 +263,13 @@ $head 10-16$$ The $cref ADFun$$ template class was added so that one can save a tape recording and use it as a differentiable function. -The $code ADFun$$ functions supports directional derivatives in both -$cref Forward$$ and $cref Reverse$$ mode where as the +The $code ADFun$$ functions supports directional derivatives in both +$cref Forward$$ and $cref Reverse$$ mode where as the tape only supports partial derivatives. $head 10-14$$ -The $code sqrt$$ function was added to the -$cref/AD standard math unary functions/std_math_ad/$$. +The $code sqrt$$ function was added to the +$cref unary_standard_math$$ functions. In addition, a definition of the power function for the types $code float$$ and $code double$$ was automatically included in the $code CppAD$$ namespace. @@ -280,8 +280,8 @@ be called when the tape is in the Empty state. $head 10-10$$ -The $code atan$$ function was added to the -$cref/AD standard math unary functions/std_math_ad/$$. +The $code atan$$ function was added to the +$cref unary_standard_math$$ functions. $head 10-06$$ In the notation below, $icode zero$$ and $icode one$$ @@ -295,15 +295,15 @@ %z% = %zero% + %x% %z% = %one% * %x% %z% = %x% - %zero% %z% = %x% / %one% %$$ -Furthermore, in the following cases, the result +Furthermore, in the following cases, the result $icode z$$ is a parameter (equal to zero) and need not be recorded in the tape: $codei% %z% = %x% * %zero% %z% = %zero% / %x% %z% = %zero% * %x% %$$ -The -$cref/arithmetic operators/Arithmetic/$$ were +The +$cref/arithmetic operators/Arithmetic/$$ 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 @@ -323,15 +323,15 @@ $$ The function $icode%TapeName%.Total%$$ was added -to make it easy to track how many tape records are used by +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. $pre $$ -There was a bug +There was a bug (found by $href%mailto:magister@u.washington.edu%Mike Dodds%$$) -in the error checking of the +in the error checking of the $icode/TapeName/.Erase/$$ function. If $code Erase$$ was called twice in a row, and $code NDEBUG$$ was false during compilation, @@ -340,14 +340,14 @@ $head 09-30$$ -A process of changing the tape from storing partial derivatives to -storing operators has been started. +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 +of higher derivatives with out having to tape the tape (see $cref 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. +so this process has not yet been completed. $pre $$ @@ -358,12 +358,12 @@ 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 +This has been fixed and the $code Eq.cpp$$ example has been changed to test for this case. $pre $$ -The following tape functions were changed to be declared +The following tape functions were changed to be declared $code const$$ because they do not modify the tape in any way: $code State$$, $code Order$$, @@ -378,20 +378,20 @@ $head 09-19$$ -The higher order constructors (in standard valarray) were removed from the +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 +In addition, the function objects in the ODE examples were changed to be $code const$$. $head 09-18$$ -An ordinary differential equation solver was added. +An ordinary differential equation solver was added. In addition, the extended system to differentiate the solution was included. $head 09-15$$ The linked list of AD variables was not being maintained correctly -by the AD destructor. +by the AD destructor. This was fixed by have the destructor use $code RemoveFromVarList$$ to remove variables from the list. ($code RemoveFromVarList$$ is a private AD member function @@ -399,27 +399,27 @@ $head 09-14$$ There is a new Faq question about evaluating derivatives at multiple -values for the +values for the $cref/independent variables/Faq/Independent Variables/$$. $head 09-13$$ An example that uses -$code AD< AD >$$ +$code AD< AD >$$ to compute higher derivatives was added. $pre $$ -The name $code GaussEliminate$$ was changed to +The name $code GaussEliminate$$ was changed to $cref LuSolve$$ to better reflect the solution method. $head 09-06$$ -Changed the +Changed the $cref get_started.cpp$$ and $cref 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.) +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.) $head 09-05$$ -A $cref/getting started/get_started.cpp/$$ +A $cref/getting started/get_started.cpp/$$ example was added and the organization of the $cref/Examples/example/$$ was changed. @@ -431,9 +431,9 @@ $$ The 03-09-03 distribution did not have the proper date -attached to it. +attached to it. The distribution script has been changed so that attaching -the proper date is automated +the proper date is automated (i.e., this should not happen again). $pre @@ -441,9 +441,9 @@ A $tref faq$$ section was started. $head 09-03$$ -Added the +Added the $cref Value$$ function which returns -the $cref/base type/glossary/Base Type/$$ value +the $cref/base type/glossary/Base Type/$$ value corresponding to an AD object. $head 08-23$$ @@ -455,14 +455,14 @@ The following results correspond to the speed test of DetLu on a 9 by 9 matrix: $table -$bold Version$$ +$bold Version$$ $cnext $bold double Rate$$ $cnext $bold AD Rate$$ - $cnext $bold Gradient Rate$$ + $cnext $bold Gradient Rate$$ $cnext $bold Hessian Rate$$ - $cnext $bold Tape Length$$ + $cnext $bold Tape Length$$ $rnext -03-08-20 +03-08-20 $cnext 8,524 $cnext 5,278 $cnext 4,260 @@ -478,7 +478,7 @@ $tend $head 08-22$$ -The +The $cref/unary minus/UnaryMinus/$$ operator was added to the AD operations. @@ -488,9 +488,9 @@ $pre $$ -The +The $cref LuSolve$$ -routine what changed to use +routine what changed to use $codei%std::vector<%Base%> &%$$ arguments in place of $icode%Base% *%$$ arguments. This removes the need to use $code new$$ and $code delete$$ @@ -508,14 +508,14 @@ The following results correspond to the speed test of DetLu on a 9 by 9 matrix: $table -$bold Version$$ +$bold Version$$ $cnext $bold double Rate$$ $cnext $bold AD Rate$$ - $cnext $bold Gradient Rate$$ + $cnext $bold Gradient Rate$$ $cnext $bold Hessian Rate$$ - $cnext $bold Tape Length$$ + $cnext $bold Tape Length$$ $rnext -03-08-16 +03-08-16 $cnext 9,509 $cnext 5,565 $cnext 3,587 @@ -538,41 +538,41 @@ even in the $code NDEBUG$$ preprocessor flag is defined. $head 08-16$$ -The -$cref LuSolve$$ routine was extended to +The +$cref LuSolve$$ routine was extended to handle complex arguments. Because the complex absolute value function is nowhere differentiable, -this required the allowing for user defined +this required the allowing for user defined $cref/boolean valued functions with AD arguments/BoolFun/$$. The examples $cref lu_solve.cpp$$ -and +and $code GradLu.cpp$$ were converted to a complex case. $head 08-11$$ -The routine $cref LuSolve$$ was made more efficient -so that it is more useful as a tool for +The routine $cref 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: $table -$bold Version$$ +$bold Version$$ $cnext $bold double Rate$$ $cnext $bold AD Rate$$ - $cnext $bold Gradient Rate$$ + $cnext $bold Gradient Rate$$ $cnext $bold Hessian Rate$$ - $cnext $bold Tape Length$$ + $cnext $bold Tape Length$$ $rnext -03-08-10 +03-08-10 $cnext 49,201 $cnext 7,787 $cnext 2,655 $cnext 1,809 $cnext 824 $rnext -03-08-11 +03-08-11 $cnext 35,178 $cnext 12,681 $cnext 4,521 @@ -608,17 +608,17 @@ in the tape (where possible). $head 08-06$$ -During Lu factorization, certain elements of the matrix +During Lu factorization, certain elements of the matrix are know to be zero or one and do not depend on the variables. -The $cref/multiplication/ad_binary/$$ operator was modified to take +The $cref/multiplication/ad_binary/$$ 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 +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: $table -$bold Version$$ - $cnext $bold Tape Length$$ - $cnext $bold Gradient Rate$$ +$bold Version$$ + $cnext $bold Tape Length$$ + $cnext $bold Gradient Rate$$ $cnext $bold Hessian Rate$$ $rnext 03-08-05 $cnext 176 $cnext 11,362 $cnext 1,149 $rnext @@ -643,7 +643,7 @@ $head 08-03$$ The $code Grad$$ and $code Hess$$ functions were modified -to handel the case where the function does not depend on +to handel the case where the function does not depend on the independent variables. $pre @@ -651,14 +651,14 @@ The $cref LuSolve$$ example was added to show how on can differentiate linear algebra calculations. -In addition, it was used to add another set of +In addition, it was used to add another set of $cref/speed tests/speed_cppad/$$. $pre $$ The standard Math functions were added both as examples of defining atomic operations and to support -mathematical operations for the $code AD$$ case. +mathematical operations for the $code AD$$ case. $pre $$ @@ -667,7 +667,7 @@ $head 08-01$$ -The +The $cref/computed assignment/Arithmetic/$$ operators were added to the $code AD$$ template class. $pre @@ -691,31 +691,31 @@ i.e., multiple assignments. $head 07-29$$ -If the -$cref/AD copy constructor/ad_ctor/$$ constructor or +If the +$cref/AD copy constructor/ad_ctor/$$ constructor or $cref/assignment/ad_assign/$$ operator used an $cref/independent variable/glossary/Tape/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. +a dependent variable in these cases. $head 07-26$$ The $codei%AD<%Base%>%$$ data structure was changed to include a doubly linked list of variables. This enabled the -$cref/AD copy constructor/ad_ctor/$$ constructor and +$cref/AD copy constructor/ad_ctor/$$ constructor and $cref/assignment/ad_assign/$$ 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 +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: $table -$bold Version$$ - $cnext $bold Tape Length$$ - $cnext $bold Gradient Rate$$ +$bold Version$$ + $cnext $bold Tape Length$$ + $cnext $bold Gradient Rate$$ $cnext $bold Hessian Rate$$ $rnext 03-07-22 $cnext 1668 $cnext 1,363 $cnext 53 $rnext @@ -724,11 +724,11 @@ $head 07-22$$ -The facility was added so that the user can define +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.) +binary functions using AD variables.) $pre $$ @@ -739,14 +739,14 @@ $head 07-20$$ -The facility was added so that the user can define +The facility was added so that the user can define unary functions, together with their derivatives. For example, the standard math functions such as $cref/exp/exp.cpp/$$ 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 $cref AD$$.) +are now part of the AD types, see $cref AD$$.) $pre $$ @@ -756,7 +756,7 @@ $head 07-18$$ Computing the determinant of a minor of a matrix $cref det_of_minor$$ -was documented as a realistic example using CppAD. +was documented as a realistic example using CppAD. $head 07-16$$ @@ -765,7 +765,7 @@ $pre $$ -Compiled and ran the tests under Microsoft Windows. +Compiled and ran the tests under Microsoft Windows. (The Windows release should not take much more work.) $head 07-14$$ @@ -773,6 +773,6 @@ and is being released under the $cref/Gnu Public License/License/$$. It is intended for use by a Unix system. -A Microsoft release is intended in the near future. +A Microsoft release is intended in the near future. $end diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_04.omh cppad-2016.00.00.1/omh/whats_new/whats_new_04.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_04.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_04.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_04.omh 3170 2014-03-09 14:33:53Z bradbell $ +$Id: whats_new_04.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -59,7 +59,7 @@ $section Changes and Additions to CppAD During 2004$$ $head Introduction$$ -This section contains a list of the changes plus future plans for +This section contains a list of the changes plus future plans for CppAD during 2004 (in reverse order by date). The purpose of this section is to @@ -69,8 +69,8 @@ $head 12-11$$ The documentation for the CppAD error macros was improved. The package title in $cref cppad$$ was changed. -The documentation for $cref/CppAD::vector/CppAD_vector/$$ -was improved and the corresponding source code +The documentation for $cref/CppAD::vector/CppAD_vector/$$ +was improved and the corresponding source code $code cppad/vector.hpp$$ was included. $head 12-09$$ @@ -89,13 +89,13 @@ $head 11-17$$ Changing to Autoconf and Automake on -$cref/08-24/whats_new_04/08-24/$$ mistakenly forgot +$cref/08-24/whats_new_04/08-24/$$ mistakenly forgot the $code -Wall$$ compiler switch (all warnings). This has been added and the corresponding warnings have been fixed. $head 11-16$$ -The 11-15 Debug version would not compile under Visual C++ version 7.0 +The 11-15 Debug version would not compile under Visual C++ version 7.0 because a declaration of $code LessThanOrZero$$ was missing. This has been fixed. @@ -115,18 +115,18 @@ $head 11-12$$ If $code NDEBUG$$ is not defined during compile time, -all $codei%AD<%Base%>%$$ +all $codei%AD<%Base%>%$$ $cref/comparison/Compare/$$ operations are checked during $cref/zero order/forward_zero/$$ forward mode calculations. -The +The $cref CompareChange$$ function returns the number of comparison operations that have changed. $head 11-10$$ -The $cref get_started.cpp$$ example was changed to use the +The $cref get_started.cpp$$ example was changed to use the $cref Jacobian$$ driver. In addition, more $cref/index/_index/$$ entries, -that point to the $cref/easy to use drivers/Drivers/$$, +that point to the $cref/easy to use drivers/Drivers/$$, were added. $head 11-04$$ @@ -137,12 +137,12 @@ This has been fixed. $head 11-02$$ -The $cref/unix installation/InstallUnix/$$ required the user +The $cref/unix installation/auto_tools/$$ required the user to touch the files to get the dates in proper order. This is no longer necessary. $head 11-01$$ -Some of the dependency directories and files, for example +Some of the dependency directories and files, for example $code PrintFor/.deps$$ and $code PrintFor/.deps/PrintFor.Po$$ had an extra $code ?$$ at the end of their names. @@ -150,22 +150,22 @@ and automake tools. $head 10-29$$ -Add the example and test $cref simple_vector.cpp$$ +Add the example and test $cref simple_vector.cpp$$ to the $cref SimpleVector$$ documentation. $pre $$ -The specifications for +The specifications for $cref/preprocessor symbols/preprocessor/$$ state that all the CppAD preprocessor symbols -begin with $code CppAD$$ +begin with $code CppAD$$ (so they do not conflict with other packages). Some preprocessor symbols in the file $code cppad/config.h$$ did began with $code WITH_$$. This has been fixed. $head 10-28$$ -The examples +The examples $cref hes_lu_det.cpp$$, $cref hes_minor_det.cpp$$, $cref jac_lu_det.cpp$$, @@ -189,7 +189,7 @@ One declaration (for the $cref Value$$ function) was missing from the file $code cppad/local/Declare.h$$. This has been added and CppAD should now compile and run -under both Microsoft VC 6.0 and 7.0. +under both Microsoft VC 6.0 and 7.0. $head 10-19$$ The current version of CppAD has a problem compiling under Microsoft @@ -210,20 +210,20 @@ $code int$$ operands. $head 10-06$$ -The test +The test $code TapeDetLu$$ was added to $code speed_cppad/DetLuSpeed.cpp$$ -and +and $code TapeDetMinor$$ was added to $code speed_cppad/DetMinorSpeed.cpp$$. These tests just tape the calculations without computing any derivatives. -Using this, and the other tests, one can to separate the taping time +Using this, and the other tests, one can to separate the taping time from the derivative calculation time. $pre $$ -The +The windows installation steps do not build a $code config.h$$ file. -Hence a default $code config.h$$ file was added to the +Hence a default $code config.h$$ file was added to the distribution for use with Microsoft Visual Studio. $pre @@ -234,11 +234,11 @@ $$ Links to the ADOLC and FADBAD download pages were added -to the $cref/unix installation/InstallUnix/$$ instructions. +to the $cref/unix installation/auto_tools/$$ instructions. $head 09-29$$ -The include files for the $cref library$$ are now included -by the root file $code cppad/cppad.hpp$$. +The include files for the $cref/utilities/utility/$$ are now included +by the root file $code cppad/cppad.hpp$$. They can still be included individually with out the rest of the CppAD package. @@ -253,13 +253,13 @@ $$ The changes on $cref/09-21/whats_new_04/09-21/$$ did not fix all the file date and time problems; i.e., automake was still running -in response to the $cref/unix installation/InstallUnix/$$ +in response to the $cref/unix installation/auto_tools/$$ $code make$$ command. $head 09-23$$ There was a reference to $icode B$$ that should have been $icode X$$ -in the description of the +in the description of the $cref/X/LuSolve/X/$$ argument of $code LuSolve$$. This has been fixed. @@ -272,8 +272,8 @@ $$ The date of the files $code aclocal.m4$$ and $code config.h.in$$ were later than the date of top level $code Makefile.am$$. -This caused the $code make$$ command during the -$cref/unix installation/InstallUnix/$$ +This caused the $code make$$ command during the +$cref/unix installation/auto_tools/$$ to try to run $code autoconf$$ and this did not work on systems with very old versions of $code autoconf$$. This has been fixed. @@ -283,11 +283,11 @@ The examples that are specific to an operation were moved to be below that operation in the documentation tree. For example -$cref add.cpp$$ is below $cref ad_binary$$ +$cref add.cpp$$ is below $cref ad_binary$$ in the documentation tree. $head 09-10$$ -The version released on 04-09-09 did not have the +The version released on 04-09-09 did not have the new file $code PrintFor.h$$ in $code cppad/local$$. This has been fixed. $pre @@ -297,7 +297,7 @@ $pre $$ -The $cref/Unix installation/InstallUnix/$$ instructions +The $cref/Unix installation/auto_tools/$$ instructions were modified so just one make command was executed at the top level. This was necessary because the order of the makes is now important (as previously suggested, the makes did not work properly). @@ -308,7 +308,7 @@ at arguments that are different from those used when taping. $head 09-07$$ -In the $cref/Unix installation/InstallUnix/$$ instructions +In the $cref/Unix installation/auto_tools/$$ instructions place $code ./$$ in front of current directory program names; for example, $code ./GetStarted$$ instead of $code GetStarted$$ (because some unix systems do not have the current directory @@ -316,23 +316,23 @@ $head 09-04$$ -A library containing the +A library containing the $cref SpeedTest$$ and $cref NearEqual$$ object files was added to the distribution. $pre $$ -All of the include files of the form +All of the include files of the form $codei%%$$ were moved to -$codei%%$$. +$codei%%$$. $head 09-02$$ Some more messages were added to the output of $code configure$$ -during the $cref/Unix installation/InstallUnix/$$. +during the $cref/Unix installation/auto_tools/$$. $pre $$ -The suggested compression program during +The suggested compression program during Windows installation was changed from $href% @@ -347,8 +347,8 @@ $head 08-27$$ -The error messages printed by the default version of -the CppAD error macros had $code YY-MM-DD$$ in place of the +The error messages printed by the default version of +the CppAD error macros had $code YY-MM-DD$$ in place of the date for the current version. This has been fixed. $pre @@ -360,12 +360,12 @@ $pre $$ -The $cref/installation instructions/Install/$$ for +The $cref/installation instructions/Install/$$ for Unix and Windows were split into separate pages. $head 08-25$$ The $cref/installation/Install/$$ now automates the replacement -of $cref/CppAD::vector/CppAD_vector/$$ by +of $cref/CppAD::vector/CppAD_vector/$$ by either the $code std::vector$$ or $code boost::numeric::ublas::vector$$. @@ -376,7 +376,7 @@ $cref/installation/Install/$$ and is the standard way to distribute open source software. This caused some organizational changes, -for example, the $cref/GetStarted/get_started.cpp/$$ example now +for example, the $cref/GetStarted/get_started.cpp/$$ example now has its own directory and the distribution directory is named $codei% @@ -402,12 +402,12 @@ $head 07-08$$ The file $code cppad/example/NearEqual.h$$ has been moved to $code cppad/example/NearEqualExt.h$$ because it contains -extensions of the $cref NearEqual$$ routine to $code AD$$ types. +extensions of the $cref NearEqual$$ routine to $code AD$$ types. $head 07-07$$ The $code double$$ and $code std::complex$$ cases for the $cref NearEqual$$ routine arguments -has been moved to the general purpose $cref library$$. +has been moved to the general purpose $cref/utilities/utility/$$. $head 07-03$$ The CppAD error macros names @@ -423,16 +423,16 @@ the number of digits in the size changed. $head 06-29$$ -Added code to trap and report memory allocation errors during +Added code to trap and report memory allocation errors during $code new$$ operations. $head 06-25$$ A discussion of the order dependence of the $cref/assignment/ad_assign/$$ operator -and the +and the $cref/independent function/Independent/$$ was added to the -$cref/Faq/Faq/Assignment and Independent/$$. +$cref/Faq/Faq/Assignment and Independent/$$. In addition, a similar discussion was added to the documentation for the @@ -440,22 +440,22 @@ $pre $$ -The definition of a +The definition of a $cref/parameter/glossary/Parameter/$$ -and +and $cref/variable/glossary/Variable/$$ -were changed to reflect that fact that +were changed to reflect that fact that these are time dependent (current) properties of an $codei%AD<%Base%>%$$ object. $head 06-12$$ -All of the -$cref/arithmetic operators/Arithmetic/$$ +All of the +$cref/arithmetic operators/Arithmetic/$$ (except for the unary operators) can now accept $code int$$ arguments. The documentation for these arguments has been changed to reflect this. -In addition, +In addition, the corresponding test cases have been changed to test this and to test high order derivative cases. The old versions of these tests were moved into the @@ -466,13 +466,13 @@ The $cref/atan2/atan2/$$ function was added. $head 06-03$$ -The $code asin$$ and $code acos$$ -$cref/AD standard math unary functions/std_math_ad/$$ were added. +The $code asin$$ and $code acos$$ +$cref unary_standard_math$$ functions were added. $pre $$ -There was a bug the reverse mode theory and calculation of -derivatives of $cref/sqrt/std_math_ad/$$ for fourth and higher orders. +There was a bug the reverse mode theory and calculation of +derivatives of $cref sqrt$$ for fourth and higher orders. This has been fixed. In addition, the following examples have been changed @@ -487,7 +487,7 @@ $head 06-01$$ -There was a bug in the $cref/atan/std_math_ad/$$ function +There was a bug in the $cref atan$$ function $cref/forward mode/Forward/$$ calculations for Taylor coefficient orders greater than two. This has been fixed. @@ -498,7 +498,7 @@ $head 05-29$$ -The forward mode recursion formulas for each of the +The forward mode recursion formulas for each of the $xref/ ForwardTheory/ Standard Math Functions/ @@ -511,7 +511,7 @@ $$ A roman (instead of italic) font was used for the name of -for the name of each of the standard math functions +for the name of each of the standard math functions in the assumption statements below the section for the standard math functions. For example, $latex \sin(x)$$ instead of $latex sin(x)$$. @@ -519,13 +519,13 @@ $head 05-26$$ In the documentation for $cref Poly$$, -the reference to $code example/Poly.h$$ +the reference to $code example/Poly.h$$ was corrected to $code cppad/library/Poly.h$$. $pre $$ In the documentation for $cref SpeedTest$$, -the reference to $code Lib/SpeedTest.h$$ +the reference to $code Lib/SpeedTest.h$$ was corrected to $code cppad/library/SpeedTest.h$$. In addition, the example case was corrected. $pre @@ -555,21 +555,21 @@ $pre $$ -The user documentation was moved from the directory +The user documentation was moved from the directory $code cppad/User$$ to the directory $code cppad/Doc$$. $pre $$ The directory $code cppad/Lib$$ was moved to $code cppad/library$$ -to reflect that fact that it is not what one expects in a standard +to reflect that fact that it is not what one expects in a standard $code lib$$ directory or a standard $code include$$ directory. $head 05-12$$ -The string $code YY-MM-DD$$ in the preprocessor symbol $code CppADVersion$$ +The string $code YY-MM-DD$$ in the preprocessor symbol $code CppADVersion$$ was not being replaced by the current date during distribution. -This resulted in the $code CppADExternalAssert$$ macro printing -$code YY-MM-DD$$ where is should have printed the date of distribution. +This resulted in the $code CppADExternalAssert$$ macro printing +$code YY-MM-DD$$ where is should have printed the date of distribution. This has been fixed. $pre @@ -586,17 +586,17 @@ %$$ This will avoid mistakenly loading a file from another package that is in the set of directories being searched by the compiler. -It is therefore necessary to specify that the directory above the +It is therefore necessary to specify that the directory above the $code CppAD$$ directory be searched by the compiler. For example, if $code CppAD$$ is in $code /usr/local/cppad$$, you must specify that $code /usr/local$$ be searched by the compiler. Note that if $code /usr/local/cppad/$$ is no longer searched, -you will have to change +you will have to change $codep # include "cppad.hpp" $$ -to +to $codep # include "cppad/cppad.hpp" $$. @@ -630,12 +630,12 @@ respectively. $head 05-03$$ -The $cref Reverse$$ mode calculations for +The $cref Reverse$$ mode calculations for $cref/conditional expressions/CondExp/$$ were mistakenly left out. This has been fixed. $head 04-29$$ -The unary functions, such as $cref/sin/std_math_ad/$$ and $cref/cos/std_math_ad/$$, +The unary functions, such as $cref sin$$ and $cref cos$$, were not defined for elements of an $cref VecAD$$ vector. This has been fixed. @@ -666,7 +666,7 @@ $pre $$ -The $cref/log10/std_math_ad/$$ function was added. +The $cref log10$$ function was added. $head 04-22$$ @@ -680,8 +680,8 @@ $pre $$ -The value $icode n$$ for -$code OdeExplicit$$ and $code OdeImplicit$$ +The value $icode n$$ for +$code OdeExplicit$$ and $code OdeImplicit$$ is deduced from the argument $icode x0$$ and is not passed as a separate argument. This documentation has been fixed to this effect. @@ -690,7 +690,7 @@ $head 04-19$$ The $cref/+=/compute_assign/$$ operator did not function correctly -when the left hand operand was a +when the left hand operand was a $cref/parameter/glossary/Parameter/$$ and the right hand operand was a variable (found by $href%mailto:magister@u.washington.edu%Mike Dodds%$$). @@ -699,28 +699,28 @@ $head 04-09$$ Adding special operators for using parameters to index $code VecAD$$ objects -increased the speed and reduced the memory requirements (by about 20%) for +increased the speed and reduced the memory requirements (by about 20%) for the $cref VecAD$$ case in the $code speed_cppad/LuSolveSpeed.cpp/$$ test. $pre $$ -The $cref VecAD$$ objects are not being handled correctly by the +The $cref VecAD$$ objects are not being handled correctly by the $cref Reverse$$ function. The $code VecAD$$ test was extended to demonstrate the problem and the problem was fixed (it is now part of $code TestMore/VecAD$$). $head 04-08$$ -The example $cref lu_vec_ad_ok.cpp$$ -uses $cref VecAD$$ to executes different pivoting operations +The example $cref lu_vec_ad_ok.cpp$$ +uses $cref VecAD$$ to executes different pivoting operations during the solution of linear equations with out having to retape. $pre $$ The speed test $code speed_cppad/LuSolveSpeed.cpp/$$ has been added. It shows that the initial implementation of $cref VecAD$$ is slow -(and uses a lot of memory.) -In fact, +(and uses a lot of memory.) +In fact, it is faster to use $cref LuSolve$$ and retape for each set of equations than it is to use $cref lu_vec_ad.cpp$$ and not have to retape. This test will help us improve the speed of $cref lu_vec_ad.cpp$$. @@ -742,12 +742,12 @@ $head 04-02$$ Some memory savings is done with regard to equal parameter values being stored in the tape. There was a bug in this logic when parameter -in an $codei%AD< AD<%Base%> >%$$ class had values that were variables in the +in an $codei%AD< AD<%Base%> >%$$ class had values that were variables in the $codei%AD<%Base%>%$$ class. This has been fixed. $head 04-01$$ -The name of the class that tapes indexing operations +The name of the class that tapes indexing operations was changed from $code ADVec$$ to $cref VecAD$$. This class was extended so that the value of elements in these vectors can be variables @@ -759,18 +759,18 @@ $head 03-28$$ -The version $cref/ADVec/VecAD/$$, +The version $cref/ADVec/VecAD/$$, a vector class that tapes indexing operations, is now available. It is currently restricted by the fact that all the -values in the vector must be +values in the vector must be $cref/parameters/Glossary/Parameter/$$. $head 03-25$$ The internal taping structure has been changed to have variable length -instructions. +instructions. This is to save memory on the tape. In addition, it may help in the implementation of the vector class that tracks indexing. @@ -797,16 +797,16 @@ This has been fixed. $head 03-12$$ -The user defined unary functions were removed and +The user defined unary functions were removed and the user defined $cref/discrete functions/Discrete/$$ were -added. -These discrete functions add the capability of conditional expressions +added. +These discrete functions add the capability of conditional expressions (alternate calculations) being included in an $cref ADFun$$ object. $head 03-11$$ The classes $cref det_by_minor$$ and $cref det_by_lu$$ were added -and used these to simplify the +and used these to simplify the examples that compute determinants. $head 03-09$$ @@ -837,7 +837,7 @@ $head 03-05$$ The $code Grad$$ routine, which only computed first derivatives of scalar valued functions, -has been replaced by the $cref Jacobian$$ routine which +has been replaced by the $cref Jacobian$$ routine which computes the derivative of vector valued functions. $head 03-04$$ @@ -849,11 +849,11 @@ $$ The $cref/f.Parameter()/seq_property/Parameter/$$ function was added so that one can count how many components of the range space depend -on the value of the domain space components. +on the value of the domain space components. This helps when deciding whether to use forward or reverse mode. $head 03-03$$ -Special operators were added to distinguish the cases where +Special operators were added to distinguish the cases where one of the operands is a $cref/parameter/glossary/Parameter/$$. This reduced the amount of branching that is necessary @@ -870,16 +870,16 @@ comparison tests. $head 02-29$$ -Under certain optimization flag values, +Under certain optimization flag values, and on certain systems, an error was reported by the ADOLC correctness comparison. -It turned out that CppAD was not initializing a particular index +It turned out that CppAD was not initializing a particular index when debugging was turned off. This has been fixed. $head 02-28$$ -A set of routines for comparing CppAD with +A set of routines for comparing CppAD with ADOLC has been added to the distribution. In addition, documentation for compiling and linking the $cref/Examples/example/$$ and $cref/Speed Tests/speed_cppad/$$ @@ -894,13 +894,13 @@ (These unary functions were removed on $cref/03-12/whats_new_04/03-12/$$.) $head 02-20$$ -A user interface to arbitrary order +A user interface to arbitrary order $cref/reverse mode/Reverse/$$ calculations was implemented. In addition, the $cref ADFun$$ member functions $code Rev$$ and $code RevTwo$$ were removed because it is easier to use the uniform syntax below: $table -$bold Old Syntax$$ $cnext $bold Uniform Syntax$$ +$bold Old Syntax$$ $cnext $bold Uniform Syntax$$ $rnext $icode%r1% = %f%.Rev(%v%)%$$ $cnext $icode%r1% = %f%.Reverse(1, %v%)%$$ $rnext @@ -911,20 +911,20 @@ $pre $$ -The $cref Theory$$ section has been completely changed so that +The $cref Theory$$ section has been completely changed so that it corresponds to the arbitrary order calculations. (Some of this change was made when the arbitrary forward mode -interface was added on +interface was added on $cref/04-02-15/whats_new_04/02-15/$$. $pre $$ -The directory $code cppad/Test$$ has been added. +The directory $code cppad/Test$$ has been added. It contains tests cases that are not intended as examples. $head 02-17$$ There was a bug in the way CppAD handled the parameters zero and one -when they were variables on a lower level tape; i.e. x might be a +when they were variables on a lower level tape; i.e. x might be a parameter on an $codei%AD< AD<%Base%> >%$$ tape and a its value might be a variable on the $codei%AD<%Base%>%$$ tape. @@ -940,7 +940,7 @@ A bug in $cref Forward$$ prevented the calculation of derivatives with higher order than two. In addition, this checking for user errors in the use of $code Forward$$ -was also faulty. +was also faulty. This has been fixed. $pre @@ -951,18 +951,18 @@ $$ The example that $cref/tapes derivative calculations/mul_level/$$ -has been changed to an application of +has been changed to an application of $cref/Taylor's method/mul_level_ode.cpp/$$ for solving ordinary differential equations. $head 02-15$$ -A user interface to arbitrary order +A user interface to arbitrary order $cref/ forward mode/Forward/$$ calculations was implemented. In addition, the $cref ADFun$$ member functions $code Arg$$, $code For$$ and $code ForTwo$$ were removed because it is easier to use the uniform syntax below: $table -$bold Old Syntax$$ $cnext $bold Uniform Syntax$$ +$bold Old Syntax$$ $cnext $bold Uniform Syntax$$ $rnext $icode%v0% = %f%.Arg(%u0%)%$$ $cnext $icode%v0% = %f%.Forward(0, %u0%)%$$ $rnext @@ -980,10 +980,10 @@ $head 02-01$$ -The definition of a +The definition of a $cref/Taylor coefficient/glossary/Taylor Coefficient/$$ was changed to include the factorial factor. -This change was also made to the output specifications for the +This change was also made to the output specifications for the $code FunForTwo$$ routine. $head 01-29$$ @@ -991,7 +991,7 @@ that were fixed. $list number$$ If one of the dependent variables was a -$cref/parameter/glossary/Parameter/$$ +$cref/parameter/glossary/Parameter/$$ $code FunArg$$ did not set it's value properly. (All its derivatives are zero and this was handled properly.) $lnext @@ -1005,12 +1005,12 @@ $head 01-28$$ Some corrections and improvements were made to the documentation including: $code CppADvector$$ was placed before its use, -a reference to $code Ode_ind$$ and $code Ode_dep$$ was fixed in +a reference to $code Ode_ind$$ and $code Ode_dep$$ was fixed in $code OdeImplicit$$. $head 01-22$$ -The specifications for the routine $code FunForTwo$$ -was changed to use +The specifications for the routine $code FunForTwo$$ +was changed to use $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. This makes the interface to CppAD closer to the interface for $href%https://projects.coin-or.org/ADOL-C%ADOLC%$$. diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_05.omh cppad-2016.00.00.1/omh/whats_new/whats_new_05.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_05.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_05.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_05.omh 2579 2012-11-17 18:58:29Z bradbell $ +$Id: whats_new_05.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -67,29 +67,29 @@ $section Changes and Additions to CppAD During 2005$$ $head 12-24$$ -Fix a memory leak that could occur during the $cref ForSparseJac$$ +Fix a memory leak that could occur during the $cref ForSparseJac$$ calculations. $head 12-23$$ -The buffers that are used to do -$cref RevSparseJac$$ and $cref RevSparseHes$$ +The buffers that are used to do +$cref RevSparseJac$$ and $cref RevSparseHes$$ calculations are now freed directly after use. $pre $$ -The $cref TrackNewDel.cpp$$ example was missing from the Windows install +The $cref TrackNewDel.cpp$$ example was missing from the Windows install examples and testing -project file. +project file. This has been fixed. $head 12-22$$ -The buffer that is are used to do +The buffer that is are used to do $cref Reverse$$ mode calculations is now freed directly after use. This reduces the memory requirements attached to an $cref ADFun$$ object. $head 12-20$$ -Buffers that are used to store the tape information corresponding to +Buffers that are used to store the tape information corresponding to the $codei%AD<%Base%>%$$ type are now freed when the corresponding $cref ADFun$$ object is constructed. This reduces memory requirements and actually had better results @@ -120,15 +120,15 @@ $head 12-16$$ The $cref NearEqual$$ function documentation for the relative error case -was changed to +was changed to $codei% | %x% - %y% | <= %r% * ( |%x%| + |%y%| ) %$$ so that there is no problem with division by zero when $icode x$$ and $icode y$$ are zero (the code was changed to that form also). -The $code std::abs$$ function replaced the -direct computation of the complex norms +The $code std::abs$$ function replaced the +direct computation of the complex norms (for the complex case in $code NearEqual$$). In addition, more extensive testing was done in $cref near_equal.cpp$$. @@ -137,9 +137,9 @@ $head 12-15$$ Extend $cref NearEqual$$ and $cref NearEqualExt$$ to cover more cases while converting them from, -a library function in $code lib/CppADlib.a$$ +a library function in $code lib/CppADlib.a$$ and an utility in $code example/NearEqualExt.h$$, -to a template functions in +to a template functions in $code cppad/near_equal.hpp$$ and $code cppad/local/NearEqualExt.h$$. This is another step along the way of removing @@ -147,7 +147,7 @@ $pre $$ -The change on $cref/12-14/whats_new_05/12-14/$$ broke the +The change on $cref/12-14/whats_new_05/12-14/$$ broke the Microsoft project files $code example/Example.sln$$ and $code TestMore/TestMore.sln$$ used during CppAD installation on Windows. @@ -158,12 +158,12 @@ Move $code lib/SpeedTest.cpp$$ to $code cppad/speed_test.hpp$$. This was the last change necessary in order to remove the CppAD library, so remove all commands related to building and linking $code CppADlib.a$$. -The corresponding entry has been removed from the $cref WishList$$. +The corresponding entry has been removed from the $cref wish_list$$. $pre $$ -One of the entries in the $cref WishList$$ corresponded to the -$cref Integer$$ function. +One of the entries in the $cref wish_list$$ corresponded to the +$cref Integer$$ function. It has also been removed (because it is already implemented). @@ -189,13 +189,13 @@ Split out $cref LuFactor$$ with the $icode ratio$$ argument to a separate function called $cref LuRatio$$. This needed to be done because $cref LuRatio$$ is more restrictive -and should not be part of the general template $cref library$$. +and should not be part of the general template $cref/utilities/utility/$$. $head 12-07$$ Improve $cref CheckSimpleVector$$ so that it tests element assignment. Change $cref check_simple_vector.cpp$$ so that it provides and example and test of a case where a simple vector returns a type -different from the element type and the element assignment returns +different from the element type and the element assignment returns $code void$$. @@ -234,9 +234,9 @@ $pre $$ -The dates in this file used to correspond to +The dates in this file used to correspond to local time for when the change was checked -into the +into the $href% http://projects.coin-or.org/CppAD/browser% subversion repository @@ -248,23 +248,23 @@ $head 12-03$$ -There was a bug in the $cref RevSparseJac$$ +There was a bug in the $cref RevSparseJac$$ reverse mode sparsity patterns when used with $cref VecAD$$ calculations. -This bug was fixed and the calculations were made more efficient +This bug was fixed and the calculations were made more efficient (fewer true entries). $head 12-02$$ -There was a bug in the $cref ForSparseJac$$ +There was a bug in the $cref ForSparseJac$$ forward mode sparsity patterns when used with $cref VecAD$$ calculations. -This bug was fixed and the calculations were made more efficient +This bug was fixed and the calculations were made more efficient (fewer true entries). $head 12-01$$ The speed test of $cref lu_vec_ad.cpp$$ has been reinstated. It appears that there is some sort of bug in the gcc compiler with -the -O2 option whereby the following member function +the -O2 option whereby the following member function $codep static ADTape *Tape(void) { static ADTape tape; @@ -273,8 +273,8 @@ $$ (in $code cppad/local/AD.h$$) would sometimes return a null value (during $cref VecAD$$ operations). -A speed improvement in -$code cppad/local/ExtendBuffer.h$$ seems to prevent +A speed improvement in +$code cppad/local/ExtendBuffer.h$$ seems to prevent this problem. This fix is not well understood; i.e., we should watch to see if this problem reoccurs. @@ -309,15 +309,15 @@ A much better $cref/example/vec_ad.cpp/$$ for using $cref VecAD$$ vectors has been provided. In addition, a bug in the computation of derivatives using $code VecAD$$ vectors -has been fixed. +has been fixed. $pre $$ CppAD now checks that the domain dimension during -$cref Independent$$ and +$cref Independent$$ and the range dimension during $cref ADFun$$ (provided that $code -DNDEBUG$$ is not defined). -If either of these is zero, +If either of these is zero, the $code CppADUsageError$$ macro is invoked. @@ -326,7 +326,7 @@ $cref ForSparseJac$$ and $cref RevSparseJac$$ have been modified so that they are relative to the Jacobian at a single argument value. -This enables us to return more efficient +This enables us to return more efficient $cref/sparsity patterns/glossary/Sparsity Pattern/$$. $pre @@ -336,13 +336,13 @@ This makes $code VecAD$$ some what more efficient. $head 11-19$$ -Improve the output messages generated during execution of the -$cref/configure/InstallUnix/Configure/$$ command. +Improve the output messages generated during execution of the +$cref/configure/auto_tools/Configure/$$ command. $pre $$ Put a try and catch block around all of the uses of -$code new$$ so that if a memory allocation error occurs, +$code new$$ so that if a memory allocation error occurs, it will generate a $code CppADUsageError/$$ message. $pre @@ -358,7 +358,7 @@ Add reverse mode $cref/Jacobian sparsity/RevSparseJac/$$ calculation. $head 11-09$$ -Add prototype documentation for $cref/logdet/LuSolve/logdet/$$ in +Add prototype documentation for $cref/logdet/LuSolve/logdet/$$ in the $cref LuSolve$$ function. $pre @@ -375,7 +375,7 @@ was added. $head 11-06$$ -The cases of $code std::vector$$, $code std::valarray$$, and +The cases of $code std::vector$$, $code std::valarray$$, and $code CppAD::vector$$ were folded into the standard example and tests format for the following cases: $cref rev_two.cpp$$, @@ -388,18 +388,18 @@ $cref for_one.cpp$$, $code Fun.cpp$$ ($code Fun.cpp$$ has since been replaced by $cref independent.cpp$$, -$code Reverse.cpp$$ has since been replaced by +$code Reverse.cpp$$ has since been replaced by $cref reverse_one.cpp$$ and $code reverse_any.cpp$$). $head 11-01$$ Add forward mode $cref/Jacobian sparsity/ForSparseJac/$$ calculation. $head 10-20$$ -Add $cref/sparsity patterns/glossary/Sparsity Pattern/$$ to +Add $cref/sparsity patterns/glossary/Sparsity Pattern/$$ to the whish list. $head 10-18$$ -The Unix install $cref/configure/InstallUnix/Configure/$$ command +The Unix install $cref/configure/auto_tools/Configure/$$ command was missing the $code --$$ before of the $code prefix$$ command line argument. @@ -407,20 +407,20 @@ The template class $cref CppAD_vector$$ uses a try/catch block during the allocation of memory (for error reporting). This may be slow down memory allocation and hence it -is now replaced by simple memory allocation when +is now replaced by simple memory allocation when the preprocessor variable $code NDEBUG$$ is defined. $pre $$ The specialization of $code CppAD::vector$$ was moved to $cref/vectorBool/CppAD_vector/vectorBool/$$ -so that $code CppAD::vector$$ does not pack one bit per value +so that $code CppAD::vector$$ does not pack one bit per value (which can be slow to access). $head 10-12$$ -Change the -$cref/configure/InstallUnix/Configure/$$ script so that compilation of the +Change the +$cref/configure/auto_tools/Configure/$$ script so that compilation of the $cref get_started.cpp$$ and $cref print_for_cout.cpp$$ examples are optional. $pre @@ -434,16 +434,16 @@ $head 10-06$$ Change the Unix install $code configure$$ script so that is reports information using the same order and notation as its -$cref/documentation/InstallUnix/Configure/$$. +$cref/documentation/auto_tools/Configure/$$. $pre $$ -Some compiler errors in the $cref ode_gear_control.cpp$$ and +Some compiler errors in the $cref ode_gear_control.cpp$$ and $cref ode_stiff.cpp$$ examples were fixed. $head 09-29$$ -Add a specialization to $cref CppAD_vector$$ for the +Add a specialization to $cref CppAD_vector$$ for the $code CppAD::vector$$ case. A test for the $code push_back$$ member function as well as a $cref CheckSimpleVector$$ test has been added to $cref cppad_vector.cpp$$. @@ -453,35 +453,35 @@ $head 09-27$$ -Add the -$cref/prefix_dir/InstallUnix/prefix_dir/$$ and -$icode postfix_dir$$ ($icode postfix_dir$$ has since been removed) +Add the +$cref/prefix_dir/auto_tools/prefix_dir/$$ and +$icode postfix_dir$$ ($icode postfix_dir$$ has since been removed) options to the $code configure$$ command line. This gives the user more control over the location where CppAD is installed. $head 09-24$$ The stiff Ode routines, $cref OdeGear$$ and $cref OdeGearControl$$, -were added to the $cref library$$. +were added to the $cref/utilities/utility/$$. A comparison various Ode solvers on a stiff problem $cref ode_stiff.cpp$$ was added. In addition, $code OdeGear$$ and $code OdeGearControl$$ -were added to the $cref library$$ and the library was +were added to the $cref/utilities/utility/$$ and the library was reorganized. $head 09-20$$ -The Microsoft compiler project files -$code example/Example.vcproj$$ and $code TestMore/TestMore.vcproj$$ +The Microsoft compiler project files +$code example/Example.vcproj$$ and $code TestMore/TestMore.vcproj$$ were not up to date. This has been fixed. In addition, the example $cref numeric_type.cpp$$ has been added. $pre $$ -Make the building of the +Make the building of the $code Example$$, $code TestMore$$, and $code Speed$$, directories -optional during the $cref/configure/InstallUnix/Configure/$$ command. -The $cref/Unix installation instructions/InstallUnix/$$ were +optional during the $cref/configure/auto_tools/Configure/$$ command. +The $cref/Unix installation instructions/auto_tools/$$ were overhauled to make the larger set of options easy to understand. $head 09-14$$ @@ -490,26 +490,26 @@ concept for their floating point template parameter type: $cref LuSolve$$, $cref LuFactor$$, -$cref RombergOne$$, +$cref RombergOne$$, $cref RombergMul$$, $cref Runge45$$, $cref Rosen34$$, and $cref OdeErrControl$$. This is more restrictive than the previous requirements -for these routines but it +for these routines but it enables future changes to the implementation of these routines (for optimization purposes) with out affecting their specifications. $head 09-09$$ Add the $cref UnaryPlus$$ operator and move the $code Neg$$ -examples and tests to $cref UnaryMinus$$. +examples and tests to $cref UnaryMinus$$. $head 09-07$$ -Change name of distribution files from -$code CppAD.unix.tar.gz$$ and $code CppAD.dos.tar.gz$$ -to -$codei%CppAD-%yy%-%mm%-%dd%.tar.gz%$$ and $codei%CppAD-%yy%-%mm%-%dd%.zip%$$ +Change name of distribution files from +$code CppAD.unix.tar.gz$$ and $code CppAD.dos.tar.gz$$ +to +$codei%CppAD-%yy%-%mm%-%dd%.tar.gz%$$ and $codei%CppAD-%yy%-%mm%-%dd%.zip%$$ (the $icode%*%.zip%$$ file uses pkzip compression). @@ -524,14 +524,14 @@ $pre $$ -The documentation for +The documentation for replacing defaults in CppAD error macros has been improved. $head 08-24$$ Changed $code Romberg$$ to $cref RombergOne$$ and added $cref RombergMul$$. In addition, added missing entries to $cref ListAllExamples$$ -and reorganized $cref library$$. +and reorganized $cref/utilities/utility/$$. $head 08-20$$ Backed out addition of $code Romberg$$ integration routine @@ -539,15 +539,15 @@ the context of AD.) $head 08-19$$ -Added a $code Romberg$$ integration routine for +Added a $code Romberg$$ integration routine for where the argument types are template parameters (for use with AD types). $head 08-15$$ -The Microsoft project files $code example/Example.vcproj$$ and +The Microsoft project files $code example/Example.vcproj$$ and $code TestMore/TestMore.vcproj$$ were missing some necessary routines. In addition, $code Speed/Speed.vcproj$$ was generating a warning. -This has been fixed. +This has been fixed. $head 08-14$$ An $cref Integer$$ conversion function as been added. @@ -558,9 +558,9 @@ has been moved into the $code TestMore$$ directory. $head 08-13$$ -The $cref/AD standard math unary functions/std_math_ad/$$ -$code sinh$$, and $code cosh$$ have been added. -In addition, more correctness testing +The $cref unary_standard_math$$ functions +$code sinh$$, and $code cosh$$ have been added. +In addition, more correctness testing has been added for the $code sin$$ and $code cos$$ functions. $pre @@ -582,8 +582,8 @@ The old $code CondExp$$ function has been deprecated. $head 07-21$$ -Remove unnecessary no-op that was left in tape for the -$cref/AD standard math unary functions/std_math_ad/$$ +Remove unnecessary no-op that was left in tape for the +$cref unary_standard_math$$ functions $code acos$$, $code asin$$, $code atan$$, $code cos$$. $pre @@ -592,21 +592,23 @@ to the $code cppad/local$$ directory source code. $head 07-19$$ -The $cref WishList$$ and $cref Bugs$$ information -were moved out of this section and into their own separate sections. +The $cref wish_list$$ and $code Bugs$$ information +were moved out of this section and into their own separate sections +(the Bugs section has been removed; see the $code bug$$ subdirectory +instead). $pre $$ -A discussion of +A discussion of $cref/VecAD speed and memory/VecAD/Speed and Memory/$$ was added -as well as an entry in the -$cref WishList$$ to make it more efficient. +as well as an entry in the +$cref wish_list$$ to make it more efficient. $head 07-15$$ The $code BOOST_DIR$$ and $code CPP_ERROR_WARN$$ -$cref/configure/InstallUnix/Configure/$$ options -were not properly implemented for compiling the +$cref/configure/auto_tools/Configure/$$ options +were not properly implemented for compiling the $code lib$$ sub-directory. This has been fixed. $pre @@ -617,30 +619,30 @@ have been fixed. $head 07-11$$ -The $cref/push_back/CppAD_vector/push_back/$$ function has +The $cref/push_back/CppAD_vector/push_back/$$ function has been added to the $code CppAD::vector$$ template class. $pre $$ -It appears that the $code TestMore/Runge45.cpp$$ file was missing +It appears that the $code TestMore/Runge45.cpp$$ file was missing an include of $code example/NearEqualExt.h$$. This has been fixed. $head 07-08$$ -The documentation for $cref Forward$$ and $cref Reverse$$ has been +The documentation for $cref Forward$$ and $cref Reverse$$ has been improved. $head 07-05$$ -The $cref rosen_34.cpp$$ example mixed the -$cref/CppAD::vector/CppAD_vector/$$ and +The $cref rosen_34.cpp$$ example mixed the +$cref/CppAD::vector/CppAD_vector/$$ and $code CppADvector$$ vector types. -This caused the compilation of the examples to fail when -$code CppADvector$$ was defined as something other than +This caused the compilation of the examples to fail when +$code CppADvector$$ was defined as something other than $code CppAD::vector$$ (found by Jon Pearce). This has been fixed. $pre $$ -The $cref CheckSimpleVector$$ run time code has been improved so that it is +The $cref CheckSimpleVector$$ run time code has been improved so that it is only run once per case that is being checked. $pre @@ -670,10 +672,10 @@ $pre $$ -The previous version of the -routine $cref OdeErrControl$$ was mistakenly in the global namespace. -It has been moved to the $code CppAD$$ namespace -(where all the other $cref library$$ routines are). +The previous version of the +routine $cref OdeErrControl$$ was mistakenly in the global namespace. +It has been moved to the $code CppAD$$ namespace +(where all the other $cref/utilities/utility/$$ routines are). $pre $$ @@ -689,23 +691,23 @@ $head 07-02$$ Version 7 of Microsoft's C++ compiler supports the standard declaration for a friend template function. -Version 6 did not and +Version 6 did not and CppAD used macros to substitute the empty string for $code $$, $code < AD >$$, and $code < VecAD >$$ in these declarations. -These macro substitutions have been removed +These macro substitutions have been removed because Version 6 of Microsoft's C++ compiler is no longer supported by CppAD. $pre $$ The copy base section was split into the default -constructor and the +constructor and the construction for the base type. The construction from base type has been extended to include any type that is convertible to the base type. As a special case, this provides the previous wish list item of -a constructor from an arbitrary $icode Base$$ to a +a constructor from an arbitrary $icode Base$$ to a $codei%AD< AD<%Base%> >%$$, $codei%AD< AD< AD<%Base%> > >%$$ etc. @@ -715,7 +717,7 @@ This has been fixed. $head 06-25$$ -Some improvements were made to the +Some improvements were made to the README, AUTHORS, COPYING, and INSTALL files. In addition, the file $code UWCopy040507.html$$ @@ -723,20 +725,20 @@ policy (see Section 2) was added to the distribution. $head 06-24$$ -The $code List2Vector$$ +The $code List2Vector$$ $cref/example utility/ExampleUtility/$$ is no longer used and has been removed. $head 06-18$$ CppAD is now supported by Microsoft Visual C++ version 7 or higher. The version 6 project files -$icode%*%.dsw%$$ and $icode%*%.dsp%$$ +$icode%*%.dsw%$$ and $icode%*%.dsp%$$ have been replaced by the version 7 project files $icode%*%.sln%$$ and $icode%*%.vcproj%$$. $head 06-14$$ A new $cref/CondExp example/cond_exp.cpp/$$ has been added and -the old $cref CondExp$$ example has been moved to the +the old $cref CondExp$$ example has been moved to the $code TestMore$$ directory (it is now only a test). @@ -763,9 +765,9 @@ $head 05-19$$ A significant improvement in speed was obtained by moving -the buffer extension to a separate function and then +the buffer extension to a separate function and then inline the rest of putting operators in the tape. -For example, +For example, here is part of the speed test output before this change: $codep Tape of Expansion by Minors Determinant: Length = 350, Memory = 6792 @@ -792,7 +794,7 @@ $pre $$ -Correct the syntax for the $cref/Parameter and Variable/ParVar/$$ +Correct the syntax for the $cref/Parameter and Variable/ParVar/$$ functions. @@ -807,18 +809,18 @@ $head 05-12$$ -Using profiling, the +Using profiling, the $cref/multiplication operator/ad_binary/$$ was show to take a significant amount of time. It was reorganized in order to make it faster. -The profiling indicated an improvement so that same change was made +The profiling indicated an improvement so that same change was made to the $cref ad_binary$$ and $cref compute_assign$$ operators. $head 05-06$$ -The documentation for +The documentation for $cref SimpleVector$$ and $cref NearEqual$$ were changed to use more syntax (what the user enters) -and simpler prototypes +and simpler prototypes (the compiler oriented description of the arguments). In addition, exercises were added at the end of the $cref SimpleVector$$, $cref CppAD_vector$$, and $cref NearEqual$$ @@ -826,13 +828,13 @@ $pre $$ -There was a undesired divide by zero case in the file +There was a undesired divide by zero case in the file $code TestMore/VecUnary.cpp$$ that just happened to work in corresponding $cref NearEqual$$ check. The $code NearEqual$$ routine has been changed to return false if either of the values being compared is infinite or not a number. -In addition, the divide by zero has been removed from +In addition, the divide by zero has been removed from the $code TestMore/VecUnary.cpp$$ test. @@ -843,7 +845,7 @@ and it makes it more like the rest of CppAD. $head 04-21$$ -The profiling indicated that the destructor for an AD object was using a +The profiling indicated that the destructor for an AD object was using a significant amount of time. The internal data structure of an AD object had a doubly linked list that pointed to the current variables and this was modified when @@ -858,11 +860,11 @@ $head 04-20$$ -Add $cref/profiling/InstallUnix/Profiling CppAD/$$ +Add $cref/profiling/auto_tools/Profiling CppAD/$$ to the speed tests. $head 04-19$$ -Remove an extra (not necessary) +Remove an extra (not necessary) semi-colon from the file $code cppad/local/Operator.h$$. $head 03-26$$ @@ -896,18 +898,18 @@ An new multiple level of AD example $cref mul_level$$ was added. $head 03-01$$ -An option that specifies error and warning -$cref/flags/InstallUnix/cxx_flags/$$ +An option that specifies error and warning +$cref/flags/auto_tools/cxx_flags/$$ for all the C++ compile commands, was added to the -$cref/Unix installation instructions/InstallUnix/$$. +$cref/Unix installation instructions/auto_tools/$$. $head 02-24$$ The routine $cref LuSolve$$ was split into $cref LuFactor$$ and $cref LuInvert$$. This enables one to efficiently solve equations where the matrix does not change -and the right hand side for one equation depends on the +and the right hand side for one equation depends on the left hand side for a previous equation. $pre @@ -922,16 +924,16 @@ Under Mandrake Linux 10.1, some template friend declarations were failing because the corresponding operations were not declared before being indicated as friends -(found by +(found by $href%mailto:Jean-Pierre.Dussault@Usherbrooke.ca%Jean-Pierre Dussault%$$). This has been fixed. $head 01-08$$ -The $cref erf$$ function was added. +The $cref erf$$ function was added. The implementation of this function used conditional expressions ($cref CondExp$$) and some times the expression that was not valid in a region caused division by zero. -For this reason, the check and abort on division by zero +For this reason, the check and abort on division by zero has been removed. diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_06.omh cppad-2016.00.00.1/omh/whats_new/whats_new_06.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_06.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_06.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_06.omh 3214 2014-03-18 20:50:38Z bradbell $ +$Id: whats_new_06.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -64,6 +64,7 @@ $$ $section Changes and Additions to CppAD During 2006$$ +$mindex aclocal$$ $head Introduction$$ @@ -88,7 +89,7 @@ $head 12-23$$ Add exercises to the following sections: $cref get_started.cpp$$, -$cref exp_eps$$, +$cref exp_eps$$, $cref exp_eps_for0$$, and $cref exp_eps_for1$$. @@ -99,7 +100,7 @@ $$ Move the exponential example to the subdirectory $code introduction/exp_apx$$ and change the -$code --with-Introduction$$ +$code --with-Introduction$$ unix configure option to build both the $cref get_started.cpp$$ and $cref exp_apx_main.cpp$$ example programs. @@ -112,7 +113,7 @@ $$ The $cref get_started.cpp$$ section has been moved -into the $cref Introduction$$ and +into the $cref Introduction$$ and $cref/exercises/get_started.cpp/Exercises/$$ were added to that section. In addition some sections has switched position between the top level $cref CppAD$$ and the $cref Appendix$$. @@ -120,7 +121,7 @@ $head 12-19$$ Reorganize so that the source code is below the corresponding routine -in the documentation tree (instead of at the same level) for the +in the documentation tree (instead of at the same level) for the following routines: $cref det_by_minor$$, $cref det_grad_33$$, @@ -162,7 +163,7 @@ $pre $$ -Add to the specifications that each repeated test corresponds to a +Add to the specifications that each repeated test corresponds to a different matrix in $cref/det_lu/link_det_lu/$$ and $cref/det_minor/link_det_minor/$$. @@ -170,13 +171,13 @@ $pre $$ -Change some references from the deprecated name $code CppAD.h$$ to +Change some references from the deprecated name $code CppAD.h$$ to new name $code cppad.hpp$$. $pre $$ Change $cref adolc_det_minor.cpp$$ and $cref cppad_det_minor.cpp$$ -to tape once and reuse operation sequence for each repeated +to tape once and reuse operation sequence for each repeated matrix in the test. $pre @@ -199,8 +200,8 @@ $cnext CppAD drivers for the template functions $rnext $cref|speed/fadbad|speed_fadbad|$$ $cnext Fadbad drivers for the template functions $rnext -$cref|speed/profile|InstallUnix|Profiling CppAD|$$ - $cnext profiling version of CppAD drivers +$cref|speed/profile|auto_tools|Profiling CppAD|$$ + $cnext profiling version of CppAD drivers $tend @@ -211,19 +212,19 @@ test routines. $head 12-12$$ -Started the speed wish list item by +Started the speed wish list item by move the $code adolc$$ director to $code speed/adolc$$ and $code fadbad$$ to $code speed/fadbad$$. $head 12-11$$ -Started the speed wish list item by +Started the speed wish list item by creating the $code speed/example$$ directory and moving the relevant -examples from -$codei%example/%*%.cpp%$$ and +examples from +$codei%example/%*%.cpp%$$ and $codei%speed_example/%*%.cpp%$$ to $codei%speed/example/%*%.cpp%$$. In addition, the relevant include files have been moved from -$codei%example/%*%.hpp%$$ to +$codei%example/%*%.hpp%$$ to $codei%speed/%*%.hpp%$$. $pre @@ -234,15 +235,15 @@ $head 12-10$$ The $cref pow$$ function was changed to be a an $codei%AD<%Base%>%$$ $cref/atomic/glossary/Operation/Atomic/$$ operation. -This function used to return a $code nan$$ if +This function used to return a $code nan$$ if $icode x$$ is negative because it was implemented as $codei% pow(%x%, %y%) = exp( log(%x%) * %y% ) %$$ This has been fixed so that the function and its derivatives are now -calculated properly when $icode x$$ is less than zero. +calculated properly when $icode x$$ is less than zero. The $cref pow$$ documentation was improved -and the $cref pow.cpp$$ example was changed to +and the $cref pow.cpp$$ example was changed to test more cases and to use the same variable names as in the documentation. @@ -258,34 +259,34 @@ (Later changed to $code double$$.) $head 12-07$$ -Fix bug in the -subversion installation instructions; see +Fix bug in the +subversion installation instructions; see $href%http://list.coin-or.org/pipermail/cppad/2006q4/000076.html%bug report%$$. $pre $$ -The some of the automatically generated $code makefile.in$$ files +The some of the automatically generated $code makefile.in$$ files had an improper license statement in the GPL license version. This has been fixed. $head 12-05$$ Add the unix installation -$cref/--with-Documentation/InstallUnix/--with-Documentation/$$ option -and remove the +$cref/--with-Documentation/auto_tools/--with-Documentation/$$ option +and remove the $icode postfix_dir$$ option. $pre $$ -Create a fixed +Create a fixed $cref whats_new$$ section above the section for each particular year. Also improve the CppAD distribution $code README$$ file. $head 12-03$$ -The include file directory $code CppAD$$ was changed to be all +The include file directory $code CppAD$$ was changed to be all lower case; i.e., $code cppad$$. If you are using a Unix system, see $cref include_deprecated$$. -This completes the following $cref WishList$$ items (which were removed): +This completes the following $cref wish_list$$ items (which were removed): $list number$$ File and directory names should only contain lowercase letters, @@ -296,10 +297,10 @@ C++ header files should have the $code .hpp$$ extension. $lend - + $head 12-02$$ -Put explanation of version numbering in the +Put explanation of version numbering in the download instructions. $pre @@ -330,10 +331,10 @@ rpm file naming convention %$$ $italic -The only restriction placed on the version is that +The only restriction placed on the version is that it cannot contain a dash "-". $$ -As per the acceptable package naming conventions for cygwin, +As per the acceptable package naming conventions for cygwin, CppAD version numbering has be changed from $icode%yy%-%mm%-%dd%$$ format to $icode yyyymmdd$$; i.e. $code cppad-06-11-30$$ was changed to $code cppad-20061130$$. @@ -349,7 +350,7 @@ $head 11-23$$ A Version Numbering entry was added to the -$cref WishList$$ (this was completed on $cref/11-30/whats_new_06/11-30/$$). +$cref wish_list$$ (this was completed on $cref/11-30/whats_new_06/11-30/$$). $head 11-18$$ The example routine that computes determinants using expansion @@ -362,31 +363,31 @@ $head 11-12$$ -The -$cref example.cpp$$ and -$code test_more/test_more.cpp$$ +The +$cref example.cpp$$ and +$code test_more/test_more.cpp$$ programs were changed to print out the number of tests that passed or failed instead of just "All the tests passed" or "At least one of the tests failed". $pre $$ -The windows project files for +The windows project files for examples and testing should have been changes to use lower case file names on as part of the 11-08 change below. This has been fixed. $head 11-08$$ Move the $code Example$$ directory to $code example$$ -and change all its files to use lower case names. +and change all its files to use lower case names. $head 11-06$$ Move the $code TestMore$$ directory to $code test_more$$ -and change all its files to use lower case names. +and change all its files to use lower case names. $head 11-05$$ -Remove references in the $cref speed_cppad$$ tests to the +Remove references in the $cref speed_cppad$$ tests to the $code Memory$$ and $code Size$$ functions because they have been $cref/deprecated/FunDeprecated/$$. $pre @@ -397,18 +398,18 @@ $head 11-04$$ Put text written to standard output in the documentation for the -$cref/get_started.cpp/get_started.cpp/Output/$$ and +$cref/get_started.cpp/get_started.cpp/Output/$$ and $code print_for.cpp$$ examples. (Now documentation can be built from a subversion checkout with out needing to execute automake.) -The $code PrintFor.cpp$$ and +The $code PrintFor.cpp$$ and $code speedtest.cpp$$ examples were missing in $cref ListAllExamples$$ -(which has been fixed). +(which has been fixed). $pre $$ Move the $code Speed$$ directory to $code speed$$ -and change all its files to use lower case names. +and change all its files to use lower case names. $head 11-02$$ The $code print_for$$ directory was referenced as $code PrintFor$$ @@ -423,15 +424,15 @@ $$ Move the $code GetStarted$$ directory to $code get_started$$ -and change all its files to use lower case names. +and change all its files to use lower case names. $head 11-01$$ Move the $code PrintFor$$ directory to $code print_for$$ -and change all its files to use lower case names. +and change all its files to use lower case names. $head 10-31$$ Move the $code SpeedExample$$ directory to $code speed_cppad_example$$ -and change all its files to use lower case names. +and change all its files to use lower case names. $head 10-29$$ Move the $code Adolc$$ directory to $code adolc$$ @@ -439,7 +440,7 @@ $pre $$ -Change all the file in the $code omh$$ directory to +Change all the file in the $code omh$$ directory to use lower case names. $pre @@ -457,13 +458,13 @@ $head 10-27$$ -Change $cref hes_lagrangian.cpp$$ example so that it computes the +Change $cref hes_lagrangian.cpp$$ example so that it computes the Lagrangian two ways. One is simpler and the other can be used to avoid re-taping operation sequence. $head 10-26$$ Change $cref hes_lagrangian.cpp$$ example so that it modifies -the independent variable vector between the call to +the independent variable vector between the call to $cref Independent$$ and the $codei%ADFun<%Base%>%$$ $cref/constructor/FunConstruct/$$. @@ -474,17 +475,17 @@ $$ Fix definition of preprocessor symbol -$code PACKAGE_STRING$$ in $code Speed/Speed.cpp$$ +$code PACKAGE_STRING$$ in $code Speed/Speed.cpp$$ (broken by change on 10-18). $pre $$ -Added the example +Added the example $cref hes_lagrangian.cpp$$ which computes the Hessian of a Lagrangian. $head 10-18$$ -Document and fix possible conflicts for +Document and fix possible conflicts for $cref/preprocessor symbols/preprocessor/$$ that do not begin with $code CppAD$$ or $code CPPAD_$$. $pre @@ -504,11 +505,11 @@ Move the $code Discrete.cpp$$ example to $cref tape_index.cpp$$. Fix the Microsoft project file so that the Windows install examples and testing works properly -(it was missing the $cref stack_machine.cpp$$ example). +(it was missing the $cref stack_machine.cpp$$ example). -$head 09-30$$ +$head 09-30$$ These changes were grouped together because it took a while for Coin-Or -to review the dual licensing version and because it was not possible to +to review the dual licensing version and because it was not possible to get the nightly build changed: $list number$$ Change shell scripts to use *.sh extension. @@ -539,7 +540,7 @@ this conflict between CppAD and $href%http://valgrind.org/%valgrind%$$. $head 07-14$$ -Make some improvements were made to the $cref Introduction$$, +Make some improvements were made to the $cref Introduction$$, $cref exp_eps.hpp$$ and $cref exp_eps_rev1$$ sections. $head 07-12$$ @@ -547,7 +548,7 @@ for the navigation links, for each section in the documentation. $head 06-29$$ -Newer versions of the gcc compiler generated an error because +Newer versions of the gcc compiler generated an error because $cref erf$$ was using $cref CondExp$$ before it was defined. This was found by Kasper Kristensen and his fix has been included in the CppAD distribution. @@ -555,37 +556,37 @@ $head 06-22$$ The $cref ADFun$$ operation $icode%f%(%x%, %y%)%$$ no longer executes a zero order -$cref Forward$$ operation when a new operation sequence is stored in +$cref Forward$$ operation when a new operation sequence is stored in $icode f$$. In addition, the syntax for this operation was changed to $icode%f%.Dependent(%y%)%$$ (see $cref Dependent$$). $comment ----------------------------------------------------------- $$ $head 06-19$$ -The changes listed under 06-17 and 06-18 were made in the branches/ADFun branch +The changes listed under 06-17 and 06-18 were made in the branches/ADFun branch of the CppAD subversion repository. They did not get merged into the trunk -and become part of the distribution until 06-19. This accomplished the -following goal, which was removed from the $cref WishList$$: +and become part of the distribution until 06-19. This accomplished the +following goal, which was removed from the $cref wish_list$$: $pre $$ "We would like to be able to erase the function -values so that $cref ADFun$$ objects use less memory. +values so that $cref ADFun$$ objects use less memory. We may even want to erase the AD operation sequence so that -$cref ADFun$$ objects use even less memory and can be used +$cref ADFun$$ objects use even less memory and can be used for a subsequent AD operation sequence." $subhead 06-17$$ Added $cref capacity_order$$ which can be used to control the amount of memory used to store $cref Forward$$ results. -Also $cref/deprecated/FunDeprecated/$$ $code taylor_size$$, and defined +Also $cref/deprecated/FunDeprecated/$$ $code taylor_size$$, and defined $cref size_order$$ in its place. $subhead 06-18$$ Added the $cref/ADFun default constructor/FunConstruct/$$ and the ability to -$cref/store a new operation sequence/Dependent/$$ -in an $code ADFun$$ object with out having to use +$cref/store a new operation sequence/Dependent/$$ +in an $code ADFun$$ object with out having to use $code ADFun$$ pointers together with $code new$$ and $code delete$$. @@ -603,7 +604,7 @@ $pre $$ -The $cref Value$$ function has been extended to allow for +The $cref Value$$ function has been extended to allow for $cref/parameter/glossary/Parameter/$$ arguments even if the corresponding tape is in the Recording state. $pre @@ -615,13 +616,13 @@ $head 06-15$$ -Change $cref BenderQuad$$ to use $icode%Base%$$ instead of +Change $cref BenderQuad$$ to use $icode%Base%$$ instead of $codei%AD<%Base%>%$$ where every possible. This allows for more calculations to be done in the base type; i.e., is more efficient. $head 06-09$$ -Add a size check (size one) for the +Add a size check (size one) for the $cref/function value argument, g/BenderQuad/g/$$ in $code BenderQuad$$. $head 06-07$$ @@ -634,7 +635,7 @@ $latex exp_eps$$ was changed to $latex {\rm exp\_eps}$$. $head 06-05$$ -Change $cref BenderQuad$$ +Change $cref BenderQuad$$ $latex F_y (x, y)$$ to $latex H(x,y)$$ so applies in a more general setting. This was another change to the $code BenderQuad$$ interface, @@ -649,22 +650,22 @@ $head 05-31$$ The interface to $cref BenderQuad$$ has been changed. -Now all the function evaluation routines +Now all the function evaluation routines are member functions of one class object. This makes it easy for them to share common data. $head 05-29$$ -Change statement of command syntax to +Change statement of command syntax to be in the same browser frame as the command documentation -(for all the commands with a syntax statement). +(for all the commands with a syntax statement). Now when a user links to a specific heading in a command's documentation, the syntax for that command is automatically included. -Before the user needed to +Before the user needed to follow another link to see to the command syntax. $head 05-27$$ -Added $cref BenderQuad$$ for computing the Hessian of +Added $cref BenderQuad$$ for computing the Hessian of Bender's reduced objective function. $pre @@ -684,8 +685,8 @@ $pre $$ -Add more discussion and a reference for the -$cref/gcc 3.4.4 -O2/Bugs/gcc 3.4.4 -O2/$$ bug. +Add more discussion and a reference for a +$code gcc 3.4.4 -O2$$ bug (since been removed). $head 04-28$$ Improve the $cref get_started.cpp$$ example and move @@ -693,7 +694,7 @@ $head 04-26$$ The programs in $cref Introduction$$ have been converted to automated -test that return true or false with the driver program +test that return true or false with the driver program $cref/Introduction/exp_apx_main.cpp/$$. $head 04-25$$ @@ -707,10 +708,10 @@ $pre $$ -An operation sequence entry was added to the $cref WishList$$. +An operation sequence entry was added to the $cref wish_list$$. $head 04-18$$ -The new definitions for +The new definitions for $cref/AD of Base/glossary/AD of Base/$$ and $cref/operation sequence/glossary/Operation/Sequence/$$ @@ -719,7 +720,7 @@ $$ Add the $cref FunCheck$$ section for checking that a sequence of -operations is as intended. +operations is as intended. $head 04-17$$ @@ -738,7 +739,7 @@ $cref/Type operation sequence/glossary/Operation/Sequence/$$. $head 04-15$$ -The $cref mul_level$$ example was moved from +The $cref mul_level$$ example was moved from $cref ADFun$$ to $cref General$$. The documentation for $cref SpeedTest$$ was improved. @@ -752,7 +753,7 @@ $head 04-13$$ Documentation and examples were improved for the following routines: $cref Jacobian$$, -$cref ForOne$$, +$cref ForOne$$, $cref RevOne$$, and $cref Hessian$$. @@ -761,13 +762,13 @@ In the case where $cref/use_VecAD/FunDeprecated/use_VecAD/$$ is true, the $cref ForSparseJac$$ calculation in only for the current independent variable values. -In this case, the sparsity pattern can be (and has been) -made more efficient; i.e., fewer true values +In this case, the sparsity pattern can be (and has been) +made more efficient; i.e., fewer true values (because it only applies to the current $cref forward_zero$$). $pre $$ -The conversion from +The conversion from $cref/VecAD::reference/VecAD/VecAD::reference/$$ to $cref AD$$ gave a compile error (this has been fixed). Code example for this fix @@ -784,24 +785,24 @@ $head 04-06$$ The $cref ForSparseJac$$, $cref RevSparseJac$$, $cref RevSparseHes$$ -sparsity results are now valid for +sparsity results are now valid for all independent variable values -(if the AD operation sequence does no use any +(if the AD operation sequence does no use any $codei%VecAD<%Base%>%$$ operands). -In addition, the +In addition, the $code ForSparseJac$$, $cref RevSparseJac$$ and $cref RevSparseHes$$ documentation and examples were improved. $pre $$ -The $cref/useVecAD/FunDeprecated/use_VecAD/$$ +The $cref/useVecAD/FunDeprecated/use_VecAD/$$ member function was added to $cref ADFun$$ objects. $pre $$ -The $code var_size$$ member function was changed to -$cref/size_var/seq_property/size_var/$$ -(this is not backward compatible, but $code var_size$$ was just added on +The $code var_size$$ member function was changed to +$cref/size_var/seq_property/size_var/$$ +(this is not backward compatible, but $code var_size$$ was just added on $cref/04-03/whats_new_06/04-03/$$). @@ -810,11 +811,11 @@ improved and moved to be part of the $cref Forward$$ section. $head 04-04$$ -The documentation and examples for $cref Reverse$$ were +The documentation and examples for $cref Reverse$$ were improved and split into $cref reverse_one$$ and $cref reverse_any$$. $head 04-03$$ -Create separate sections for the +Create separate sections for the $cref/zero/forward_zero/$$ and $cref forward_one$$ first order case of $cref Forward$$ mode. $pre @@ -858,20 +859,20 @@ choices for the $cref SimpleVector$$ type. $head 04-01$$ -Move the $cref/ADFun Constructor/FunConstruct/$$ to its own separate -section, improve its documentation, and use $cref independent.cpp$$ +Move the $cref/ADFun Constructor/FunConstruct/$$ to its own separate +section, improve its documentation, and use $cref independent.cpp$$ for its example. $pre $$ -The following member functions of $cref ADFun$$ have been +The following member functions of $cref ADFun$$ have been $cref/deprecated/FunDeprecated/$$: $code Order$$, $code Memory$$. $pre $$ The wish list entry for Memory usage -was updated on 04-01. +was updated on 04-01. The request was implemented on $cref/06-19/whats_new_06/06-19/$$ and the entry was removed from the wish list. @@ -888,17 +889,17 @@ $$ In the examples for the $cref AD$$ sections, refer to the range space vector instead of the dependent variable vector -because some of the components may not be +because some of the components may not be $cref/variables/glossary/Variable/$$. $head 03-30$$ -Move the $cref LuRatio$$ section below $cref LuDetAndSolve$$. +Move the $cref LuRatio$$ section below $cref LuDetAndSolve$$. $pre $$ -Move the definition of an +Move the definition of an AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ from the glossary to the $cref AD$$ section. $pre @@ -907,7 +908,7 @@ $pre $$ -Add mention of taping to +Add mention of taping to $cref Erf$$, $cref BoolFun$$, $cref NearEqualExt$$,and $cref Pow$$. $pre @@ -918,7 +919,7 @@ $head 03-29$$ -Mention the $cref/VecAD::reference/VecAD/VecAD::reference/$$ case in +Mention the $cref/VecAD::reference/VecAD/VecAD::reference/$$ case in documentation and examples for $cref abs$$, $cref atan2$$, $cref erf$$, and $cref pow$$. $pre @@ -939,38 +940,38 @@ and $codei%VecAD<%Base%>::reference%$$. $head 03-28$$ -Mention the -$cref/VecAD::reference/VecAD/VecAD::reference/$$ case in +Mention the +$cref/VecAD::reference/VecAD/VecAD::reference/$$ case in documentation and examples for $cref UnaryPlus$$, $cref UnaryMinus$$, $cref ad_binary$$, $cref compute_assign$$, and -$cref std_math_ad$$ +$cref unary_standard_math$$ $head 03-27$$ -Extend and improve the +Extend and improve the $cref/VecAD exceptions/VecAD/VecAD::reference/Exceptions/$$. $pre $$ -Mention the $cref/VecAD::reference/VecAD/VecAD::reference/$$ case -and generally improve +Mention the $cref/VecAD::reference/VecAD/VecAD::reference/$$ case +and generally improve $cref/addition/ad_binary/$$ documentation and examples. $head 03-26$$ Improve documentation and examples for $cref VecAD$$ and change -its element type from -$codei%VecADelem<%Base%>%$$ to $codei%VecAD_reference<%Base%>%$$ +its element type from +$codei%VecADelem<%Base%>%$$ to $codei%VecAD_reference<%Base%>%$$ (so that it looks more like $cref/VecAD::reference/VecAD/VecAD::reference/$$). $pre $$ -Mention the $cref/VecAD::reference/VecAD/VecAD::reference/$$ case -and generally improve +Mention the $cref/VecAD::reference/VecAD/VecAD::reference/$$ case +and generally improve $cref Value$$, $cref ad_output$$ and $cref/assignment/ad_assign/$$ documentation and examples. $pre @@ -991,38 +992,38 @@ Move both of these sections from ExtendDomain to $cref ADValued$$. $head 03-22$$ -The documentation sections under $cref AD$$ +The documentation sections under $cref AD$$ have been organized into a new set of sub-groups. $head 03-18$$ The documentation and example for $cref PrintFor$$ have been improved. -The sections below $cref AD$$ +The sections below $cref AD$$ in the documentation have been organized into subgroups. $head 03-17$$ -The documentation and examples have been improved for the +The documentation and examples have been improved for the following functions: $cref BoolFun$$, and $cref NearEqualExt$$. $head 03-16$$ Improve the documentation and example for the $cref pow$$ function. -This includes splitting out and generalizing the integer case +This includes splitting out and generalizing the integer case $cref pow_int$$. $pre $$ The copies of the $code atan2$$ function were included -in the CppAD namespace for the +in the CppAD namespace for the $code float$$ and $code double$$ types. $head 03-15$$ -Improve the +Improve the $cref/introduction/cppad/Introduction/$$ to CppAD. $head 03-11$$ -The file $code cppad/local/MathOther.h$$ had a file name case error -that prevented the documentation from building and tests from running +The file $code cppad/local/MathOther.h$$ had a file name case error +that prevented the documentation from building and tests from running (except under Cygwin which is not really case sensitive). This has been fixed. $pre @@ -1030,27 +1031,27 @@ $$ The term AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ -has been defined. +has been defined. It will be used to improve the user's understanding of exactly how an $cref ADFun$$ object is related to the C++ algorithm. $head 03-10$$ -The math functions that are not under $cref std_math_ad$$ have -been grouped under $cref MathOther$$. +The math functions that are not under $cref unary_standard_math$$ have +been grouped under $code MathOther$$. $pre $$ -The documentation and examples have been improved for the +The documentation and examples have been improved for the following functions: $cref abs$$, $cref atan2$$. $head 03-09$$ -The examples -$cref cos.cpp$$, -$cref cosh.cpp$$, -$cref exp.cpp$$, -$cref log.cpp$$, +The examples +$cref cos.cpp$$, +$cref cosh.cpp$$, +$cref exp.cpp$$, +$cref log.cpp$$, $cref log10.cpp$$, $cref sin.cpp$$, $cref sinh.cpp$$, @@ -1062,31 +1063,31 @@ $pre $$ -The examples $cref Acos.cpp$$, $cref Asin.cpp$$ and +The examples $cref Acos.cpp$$, $cref Asin.cpp$$ and $cref atan.cpp$$ have been improved. $head 03-05$$ The AD standard math unary functions documentation has been grouped together with improved documentation -in $cref std_math_ad$$. +in $cref unary_standard_math$$. $head 02-28$$ The $cref ad_output$$ and $cref Abs$$ -documentation and example have been improved. +documentation and example have been improved. Minor improvements were also made to the $cref lu_vec_ad.cpp$$ documentation. $head 02-25$$ -The $cref Compare$$ documentation and example have been improved. +The $cref Compare$$ documentation and example have been improved. $head 02-24$$ The documentation and examples have been improved for the following sections: -$cref/division/ad_binary/$$, $cref/-=/compute_assign/$$, $cref/*=/compute_assign/$$, and $cref%/=%compute_assign%$$. +$cref/division/ad_binary/$$, $cref/-=/compute_assign/$$, $cref/*=/compute_assign/$$, and $cref%/=%compute_assign%$$. $head 02-23$$ -The $cref/multiplication/ad_binary/$$ documentation and example have been improved. +The $cref/multiplication/ad_binary/$$ documentation and example have been improved. $head 02-21$$ -The $cref/subtraction/ad_binary/$$ documentation and example have been improved. +The $cref/subtraction/ad_binary/$$ documentation and example have been improved. $pre $$ @@ -1101,10 +1102,10 @@ $head 02-15$$ -The $cref/+=/compute_assign/$$ documentation and example have been improved. +The $cref/+=/compute_assign/$$ documentation and example have been improved. $head 02-14$$ -The $cref/addition/ad_binary/$$ documentation and example have been improved. +The $cref/addition/ad_binary/$$ documentation and example have been improved. $head 02-13$$ @@ -1118,15 +1119,15 @@ $head 02-11$$ The documentation and examples have been improved for the following sections: -$cref ad_ctor$$, +$cref ad_ctor$$, $cref ad_ctor$$ and $cref ad_assign$$, and $cref Value$$. $head 02-10$$ -This is the beginning of a pass to improve the documentation: -The documentation sections -The CopyBase (formerly FromBase and now part of $cref ad_ctor$$ and $cref ad_assign$$) and -$cref/AD copy constructor/ad_ctor/$$ +This is the beginning of a pass to improve the documentation: +The documentation sections +The CopyBase (formerly FromBase and now part of $cref ad_ctor$$ and $cref ad_assign$$) and +$cref/AD copy constructor/ad_ctor/$$ (formerly Copy) documentation has been modified. $pre @@ -1138,7 +1139,7 @@ There was a read memory access past the end of an array in $cref/CppAD::vector::push_back/CppAD_vector/push_back/$$. This has been fixed and in addition -$cref TrackNewDel$$ is now used to do and check the allocation in +$cref TrackNewDel$$ is now used to do and check the allocation in $code CppAD::vector$$. $pre @@ -1149,19 +1150,18 @@ leak detection by $cref/TrackCount/TrackNewDel/TrackCount/$$. $head 01-20$$ -Add -$cref/software guidelines/WishList/Software Guidelines/$$ +Add +$cref/software guidelines/wish_list/Software Guidelines/$$ to the wish list. $head 01-18$$ -Improve the definition for +Improve the definition for $cref/parameters/glossary/Parameter/$$ and $cref/variables/glossary/Variable/$$. Remove unnecessary reference to parameter and variable in documentation for $cref Independent$$. $head 01-08$$ -$index aclocal$$ The aclocal program is part of the automake and autoconf system. It often generates warnings of the form: $codei% @@ -1174,15 +1174,15 @@ $head 01-07$$ Change CppAD error handler from using the macros defined in -$code cppad/CppADError.h$$ to using a class defined in -$cref%cppad/error_handler.hpp%ErrorHandler%$$. +$code cppad/CppADError.h$$ to using a class defined in +$cref%cppad/utility/error_handler.hpp%ErrorHandler%$$. The macros $code CppADUnknownError$$ and $code CppADUsageError$$ -have been depreciated (they are temporarily still available in the +have been deprecated (they are temporarily still available in the file $code cppad/local/CppADError.h$$). $head 01-02$$ Add the sed script $code Speed/gprof.sed$$ to aid in the display of the -$cref/profiling/InstallUnix/Profiling CppAD/$$ output. +$cref/profiling/auto_tools/Profiling CppAD/$$ output. $pre $$ diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_07.omh cppad-2016.00.00.1/omh/whats_new/whats_new_07.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_07.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_07.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_07.omh 3526 2014-12-29 21:56:45Z bradbell $ +$Id: whats_new_07.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -80,7 +80,7 @@ The $cref install$$ instructions have been improved. $head 12-21$$ -The $cref/--with-Documentation/InstallUnix/--with-Documentation/$$ +The $cref/--with-Documentation/auto_tools/--with-Documentation/$$ option on the $code configure$$ command line caused an error on some systems because it attempted to copy to many files. This has been fixed by copying the directory instead of the individual files. @@ -103,17 +103,17 @@ $code cppad.spec$$. $head 12-02$$ -Add the $codei%DESTDIR=%directory%$$ option on the -$cref/make install/InstallUnix/make install/$$ command line. +Add the $codei%DESTDIR=%directory%$$ option on the +$cref/make install/auto_tools/make install/$$ command line. $head 11-29$$ -The $cref std_math_ad$$ function $code sqrt$$ did not link properly +The $cref unary_standard_math$$ function $code sqrt$$ did not link properly when $icode Base$$ was $code AD$$. This has been fixed. $head 11-23$$ -The routines $code nan$$ and $code isnan$$ were failing -for some systems because they use $code nan$$ and or $code isnan$$ +The routines $code nan$$ and $code isnan$$ were failing +for some systems because they use $code nan$$ and or $code isnan$$ as preprocessor symbols. This has been fixed; see $cref/macros/nan/Include/Macros/$$. In addition, the example and test $cref nan.cpp$$ has been added. @@ -134,9 +134,9 @@ $$ The problem with newer C++ compilers requiring more definitions before use -also required the user to know about $code float$$ and $code double$$ -definitions for the standard math -functions in the CppAD namespace; +also required the user to know about $code float$$ and $code double$$ +definitions for the standard math +functions in the CppAD namespace; see $cref base_std_math$$. $pre @@ -160,7 +160,7 @@ $head 11-06$$ -Added the $code -DRAD_EQ_ALIAS$$ compiler flag to the +Added the $code -DRAD_EQ_ALIAS$$ compiler flag to the $cref/Sacado speed tests/speed_sacado/$$. In addition, compiler flag documentation was included for Sacado and all the other speed tests. @@ -168,18 +168,18 @@ $head 11-05$$ MS project files have been added for running the $cref/cppad/speed_cppad/$$ and -$cref/double/speed_double/$$ +$cref/double/speed_double/$$ speed tests. $head 11-04$$ -The $code cppad/config.h$$ file was not compatible with the -Windows install procedure and +The $code cppad/config.h$$ file was not compatible with the +Windows install procedure and the Windows project's could not find a certain include file. This has been fixed. $pre $$ -The $cref/unix install/InstallUnix/$$ procedure has been modified +The $cref/unix install/auto_tools/$$ procedure has been modified so that the one configure flag $code --with-Speed$$ builds all the possible executables related to the speed testing. @@ -190,12 +190,12 @@ $pre $$ -The subversion copy of the $cref/configure/InstallUnix/Configure/$$ script -was not executable. +The subversion copy of the $cref/configure/auto_tools/Configure/$$ script +was not executable. This has been fixed. $head 11-02$$ -The instructions for downloading the current version using +The instructions for downloading the current version using $cref/subversion/download/Subversion/$$ have changed. The user should now directly edit the file @@ -227,7 +227,7 @@ $$ Add the return status for all the correctness tests -to the documentation; see $code make test$$. +to the documentation; see $code make test$$. $head 10-30$$ The download instructions did not update current version number @@ -240,7 +240,7 @@ has been improved. The order of the elements in $cref det_of_minor$$ has been corrected (they were transposed but this did not really matter -because determinants of transposes are equal). +because determinants of transposes are equal). $pre $$ @@ -254,19 +254,19 @@ $$ The installation was broken on some systems because the -$cref/configure/InstallUnix/Configure/$$ command tried to run +$cref/configure/auto_tools/Configure/$$ command tried to run the $code autoconf$$ and $code automake$$ programs. This has been fixed by adding $code AM_MAINTAINER_MODE$$ to the $code autoconf$$ input file. $pre $$ -Extend the +Extend the $cref/subversion/download/Subversion/$$ methods to include a full installation and old versions. $head 10-23$$ -The $cref/cxx_flags/InstallUnix/cxx_flags/$$ environment variable +The $cref/cxx_flags/auto_tools/cxx_flags/$$ environment variable has been changed from $code CPP_ERROR_WARN$$ to $code CXX_FLAGS$$. $pre @@ -285,11 +285,11 @@ $head 10-22$$ -The correctness checks and speed test wrappers were moved +The correctness checks and speed test wrappers were moved from the individual package directories to $cref speed_main$$. This way they do not have to be reproduced for each package. This makes it easier to add a new package, -but it requires the prototype for +but it requires the prototype for $codei%compute_%test_name%$$ to be the same for all packages. $pre @@ -302,9 +302,9 @@ $$ The $icode postfix_dir$$ option -was removed on $cref/2006-12-05/whats_new_06/12-05/$$ but -it was not removed from the -$cref/configure/InstallUnix/Configure/$$ +was removed on $cref/2006-12-05/whats_new_06/12-05/$$ but +it was not removed from the +$cref/configure/auto_tools/Configure/$$ documentation. This has been fixed. $pre @@ -318,13 +318,13 @@ where $icode i$$ was $code 0$$ or $code 1$$. This does not work with when $icode Scalar$$ is $code Sacado::Tay::Taylor$$. -This requirement has been changed +This requirement has been changed (see $cref/restrictions/CheckSimpleVector/Restrictions/$$) to support of $codei% %x% = %i% %$$ -where $icode x$$ has type $icode Scalar$$ +where $icode x$$ has type $icode Scalar$$ and $icode i$$ has type $code int$$. $pre @@ -337,7 +337,7 @@ $$ Add $code ADOLC_DIR$$, $code FADBAD_DIR$$, $code SACADO_DIR$$, and $code BOOST_DIR$$ -to the $cref/configure/InstallUnix/Configure/$$ help string. +to the $cref/configure/auto_tools/Configure/$$ help string. $head 10-16$$ @@ -350,13 +350,13 @@ $cref speed_main$$. $head 10-05$$ -Added and example using complex calculations for a +Added and example using complex calculations for a function that is not complex differentiable $code not_complex_ad.cpp$$. (This example has been removed; see $cref/complex FAQ/Faq/Complex Types/$$.) -$head 10-02$$ +$head 10-02$$ Extend the $cref pow$$ function to work for any case where one argument -is $codei%AD<%Base%>%$$ and the other is $code double$$ +is $codei%AD<%Base%>%$$ and the other is $code double$$ (as do the binary operators). $head 09-06$$ @@ -373,25 +373,25 @@ $$ Use the $code ||$$ operation instead of $code |$$ -operator in the $code nan$$ function +operator in the $code nan$$ function (The Ginac library seems to use an alias for the type $code bool$$ and does not have $code |$$ defined for this alias). $pre $$ -The file $code test_more/ode_err_control.cpp$$ was using the -wrong include file name since the change on 08/07. +The file $code test_more/ode_err_control.cpp$$ was using the +wrong include file name since the change on 08/07. This has been fixed. $head 08-07$$ Sometimes an ODE solver takes to large a step and this results in invalid values for the variables being integrated. -The ODE solvers $cref Runge45$$ and $cref Rosen34$$ have been +The ODE solvers $cref Runge45$$ and $cref Rosen34$$ have been modified to abort and return $cref nan$$ when it is returned by the differential equation evaluation. -The solver $cref OdeErrControl$$ have been modified to try smaller steps -when this happens. +The solver $cref OdeErrControl$$ have been modified to try smaller steps +when this happens. $pre $$ @@ -409,28 +409,28 @@ $code CppADCreateBinaryBool$$ and $code CppADCreateUnaryBool$$ have been replaced by $code CPPAD_BOOL_BINARY$$ and $code CPPAD_BOOL_UNARY$$ respectively. -In addition, the $cref WishList$$ item for conversion +In addition, the $cref wish_list$$ item for conversion of all preprocessor macros to upper case been completed and removed. $head 07-29$$ -The preprocessor macros +The preprocessor macros $code CppADUsageError$$ and $code CppADUnknownError$$ have been replaced by $code CPPAD_ASSERT_KNOWN$$ and $code CPPAD_ASSERT_UNKNOWN$$ respectively. -The meaning for these macros +The meaning for these macros has been included in the $cref cppad_assert$$ section. In addition, the $icode known$$ argument to $cref ErrorHandler$$ was wrong for the unknown case. $pre $$ -The $cref WishList$$ item +The $cref wish_list$$ item for conversion of all preprocessor macros to upper case has been changes (to an item that was previous missing). $head 07-28$$ The preprocessor macro $code CPPAD_DISCRETE_FUNCTIOIN$$ was defined -as a replacement for $code CppADCreateDiscrete$$ +as a replacement for $code CppADCreateDiscrete$$ which has been deprecated. $head 07-26$$ @@ -446,7 +446,7 @@ deprecated items has been improved. $subhead 07-25$$ -Deprecate the preprocessor symbol $code CppADvector$$ +Deprecate the preprocessor symbol $code CppADvector$$ and start changing it to $small $cref/CPPAD_TEST_VECTOR/test_vector/$$ $$. $pre @@ -461,43 +461,42 @@ $code CppADTrackNewVec$$, $code CppADTrackDelVec$$, and $code CppADTrackExtend$$ have been deprecated. -The new macros names to use are +The new macros names to use are $code CPPAD_TRACK_NEW_VEC$$, $code CPPAD_TRACK_DEL_VEC$$, and $code CPPAD_TRACK_EXTEND$$ respectively. -This item has been removed from the -$cref/software guidelines/WishList/Software Guidelines/$$ +This item has been removed from the +$cref/software guidelines/wish_list/Software Guidelines/$$ section of the wish list. $pre $$ The member variable -$cref/software guideline/WishList/Software Guidelines/$$ +$cref/software guideline/wish_list/Software Guidelines/$$ wish list item has be brought up to date. $head 07-22$$ Minor improvements to the $cref mul_level_adolc_ode.cpp$$ example. $head 07-21$$ +$list number$$ The $code openmp/run.sh$$ example programs -$code example_a11c.cpp$$, -$code openmp_newton_example.cpp$$, and +$code example_a11c.cpp$$, +$code openmp_newton_example.cpp$$, and $code sum_i_inv.cpp$$ have been changed so that they run on more systems (are C++ standard compliant). -$pre - -$$ +$lnext +$cref base_require$$: The $code IdenticalEqual$$ function, in the $cref base_require$$ specification, was changed to $code IdenticalEqualPar$$ -(note the $cref/warning/base_require/Warning/$$ in the +(note the $cref/API warning/base_require/API Warning/$$ in the $icode Base$$ requirement specifications). -$pre - -$$ +$lnext Implementation of the $cref/base requirements/base_require/$$ for complex types were moved into the $cref base_complex.hpp$$ example. +$lend @@ -506,12 +505,12 @@ It turned out that the copyright message was missing from the file $cref base_adolc.hpp$$ and this stopped the creation of the download files. This has been fixed. -In addition, the automated testing procedure has been modified so +In addition, the automated testing procedure has been modified so that missing copyright messages and test program failures will be more obvious in the test log. $head 07-19$$ -The download for CppAD has been broken since the example +The download for CppAD has been broken since the example $code mul_level_adolc_ode.cpp$$ was added because the $code example/example$$ program was failing. This has been fixed. @@ -528,8 +527,8 @@ $head 07-13$$ Separate the include file -$cref base_adolc.hpp$$ -from the $cref mul_level_adolc.cpp$$ example +$cref base_adolc.hpp$$ +from the $cref mul_level_adolc.cpp$$ example so that it can be used by other examples. $head 06-22$$ @@ -538,11 +537,11 @@ $pre $$ -The $cref get_started.cpp$$ +The $cref get_started.cpp$$ example did not build when -the $code --with-Introduction$$ and -$code BOOST_DIR$$ options were included on the -$cref/configure/InstallUnix/Configure/$$ command line. +the $code --with-Introduction$$ and +$code BOOST_DIR$$ options were included on the +$cref/configure/auto_tools/Configure/$$ command line. In fact, some of the $cref speed$$ tests also had compilation errors when $code BOOST_DIR$$ was include in the configure command. This has been fixed. @@ -556,12 +555,12 @@ This has been fixed. $head 06-20$$ -The MS project +The MS project $code test_more/test_more.vcproj$$ would not build because the file $code test_more/fun_check.cpp$$ was missing; -this has been fixed. -In addition, -fix warnings generated by the MS compiler when compiling the +this has been fixed. +In addition, +fix warnings generated by the MS compiler when compiling the $code test_more/test_more.cpp$$ file. $pre @@ -573,8 +572,8 @@ $pre $$ -Fix the description of the $code tan$$ function in -$cref std_math_ad$$. +Fix the description of the $code tan$$ function in +$cref unary_standard_math$$. $head 06-14$$ @@ -582,7 +581,7 @@ of a $code size_t$$ ( $code int$$ ) by a $icode Scalar$$, where $icode Scalar$$ was any $cref NumericType$$. Such an operation may not be valid for a particular numeric type. -This has been fixed by explicitly converting the +This has been fixed by explicitly converting the $code size_t$$ to an $code int$$, then converting the $code int$$ to a $icode Scalar$$, and then preforming the division. @@ -602,7 +601,7 @@ $pre $$ -This slicing has also been fixed in the +This slicing has also been fixed in the $cref/assignment/ad_assign/$$ operation. In addition, the assignment and copy operations have been grouped together in the documentation; see $cref ad_ctor$$ and $cref ad_assign$$. @@ -617,9 +616,9 @@ $$ The documentation for all the $cref/computed assignment/compute_assign/$$ operators has been grouped together. -In addition, a +In addition, a computed assignment wish list item has been added -(it was completed and removed with the +(it was completed and removed with the $cref/05-26/whats_new_07/05-26/$$ update.) @@ -628,7 +627,7 @@ $codei% %left% %op% %right% %$$ -where one of the operands was $code AD< AD >$$ and +where one of the operands was $code AD< AD >$$ and the other operand was $code double$$. There was a bug in this case that caused the $code double$$ operand to be converted to $code int$$ before @@ -636,18 +635,18 @@ This has been fixed. $head 05-22$$ -The Microsoft +The Microsoft examples and testing -project file $code example/example.vcproj$$ +project file $code example/example.vcproj$$ was missing a reference to the source code file $code example/reverse_two.cpp$$. -This has been fixed. +This has been fixed. $head 05-08$$ -Reverse mode does not work with the +Reverse mode does not work with the $cref pow$$ function when the base is less than or equal zero and the exponent is an integer. -For this reason, the $cref pow_int$$ function +For this reason, the $cref pow_int$$ function is no longer deprecated (and is used by CppAD when the exponent has type $code int$$). @@ -660,22 +659,22 @@ $$ The return value descriptions were improved for the introduction examples: -$cref/exp_2_for1/exp_2_for1/Return Value/$$, -$cref/exp_2_for2/exp_2_for2/Return Value/$$, +$cref/exp_2_for1/exp_2_for1/Return Value/$$, +$cref/exp_2_for2/exp_2_for2/Return Value/$$, $cref/exp_eps_for1/exp_eps_for1/Return Value/$$, and $cref/exp_eps_for2/exp_eps_for2/Return Value/$$. $pre $$ -The summation index in $cref SqrtReverse$$ was changed from +The summation index in $cref sqrt_reverse$$ was changed from $latex k$$ to $latex \ell$$ to make partial differentiation with respect to $latex z^{(k)}$$ easier to understand. -In addition, a sign error was corrected near the end of -$cref SqrtReverse$$. +In addition, a sign error was corrected near the end of +$cref sqrt_reverse$$. $pre $$ -The dimension for the notation $latex X$$ in +The dimension for the notation $latex X$$ in $cref reverse_identity$$ was corrected. $pre @@ -689,9 +688,9 @@ $pre $$ -Improve the $code openmp/run.sh$$ script. +Improve the $code openmp/run.sh$$ script. It now runs all the test cases at once in addition -to including multiple number of thread cases for each test. +to including multiple number of thread cases for each test. $pre $$ @@ -699,7 +698,7 @@ $pre $$ -There was a typo in the +There was a typo in the $cref/second order/forward_order/Second Order/$$ discussion (found by Kipp Martin). It has been fixed. @@ -708,13 +707,13 @@ $head 04-17$$ Add a paragraph to $cref reverse_identity$$ explaining how it relates to $cref reverse_any$$ calculations. -Add description of +Add description of $cref/first/reverse_any/First Order/$$ and -$cref/second order/reverse_any/Second Order/$$ +$cref/second order/reverse_any/Second Order/$$ results in $cref reverse_any$$. $head 04-14$$ -Simplify the $cref Reverse$$ mode documentation by creating +Simplify the $cref Reverse$$ mode documentation by creating a separate $cref reverse_two$$ section for second order reverse, making major changes to the description in $cref reverse_any$$, and creating a third order example $cref reverse_any.cpp$$ for @@ -728,7 +727,7 @@ Merge in changes made in $code branches/intro$$. $subhead 04-11$$ -Add $cref exp_eps_rev2$$ and its verification routine +Add $cref exp_eps_rev2$$ and its verification routine $cref exp_eps_rev2.cpp$$. $subhead 04-10$$ @@ -743,10 +742,10 @@ (does not yet have verification or exercises). $subhead 04-06$$ -Fixed a problem with the Microsoft Visual Studio project file +Fixed a problem with the Microsoft Visual Studio project file $code introduction/exp_apx/exp_apx.vcproj$$ -(it did not track the file name changes of the form -$code exp_apx/exp_2_for$$ to $code exp_apx/exp_2_for1$$ +(it did not track the file name changes of the form +$code exp_apx/exp_2_for$$ to $code exp_apx/exp_2_for1$$ on 04-05). $pre @@ -755,7 +754,7 @@ $subhead 04-05$$ Use order expansions in introduction; e.g., the -$cref/second order expansion/exp_2_for2/Second Order Expansion/$$ +$cref/second order expansion/exp_2_for2/Second Order Expansion/$$ for the $cref exp_2$$ example. $head 03-31$$ @@ -764,14 +763,14 @@ $subhead 03-31$$ Create the a simpler exponential approximation in the $cref introduction$$ -called $cref exp_2$$ which has a different program +called $cref exp_2$$ which has a different program variable for each variable in the operation sequence. $pre $$ Simplify the $cref exp_eps$$ approximation using the $latex v_1 , \ldots , v_7$$ notation so that variables directly -correspond to index in operation sequence (as with the $cref exp_2$$ +correspond to index in operation sequence (as with the $cref exp_2$$ example). $subhead 03-30$$ @@ -793,8 +792,8 @@ $pre $$ -Added an Introduction and -$cref/Tracing/WishList/Tracing/$$ entry to the wish list. +Added an Introduction and +$cref/Tracing/wish_list/Tracing/$$ entry to the wish list. (The Introduction item was completed on $cref/03-31/whats_new_07/03-31/$$.) $head 03-20$$ @@ -809,17 +808,17 @@ $subhead 03-15$$ Add command line arguments to $code openmp_newton_example.cpp$$, and -modified $code openmp/run.sh$$ to allow for more flexible testing. +modified $code openmp/run.sh$$ to allow for more flexible testing. $subhead 03-14$$ -Fixed some Microsoft compiler warnings by explicitly converting from +Fixed some Microsoft compiler warnings by explicitly converting from $code size_t$$ to $code int$$. $pre $$ -In the Microsoft compiler case, the $code cppad/config.h$$ file had +In the Microsoft compiler case, the $code cppad/config.h$$ file had the wrong setting of $code GETTIMEOFDAY$$. -The setting is now overridden (and always false) when the +The setting is now overridden (and always false) when the $code _MSC_VER$$ preprocessor symbol is defined. $pre @@ -827,7 +826,7 @@ Some minor changes were made in an effort to speed up the multi-threading case. $subhead 03-13$$ -Started a new openmp branch and created a version of CppAD +Started a new openmp branch and created a version of CppAD that does not use the OpenMP $code threadprivate$$ command (not supported on some systems). @@ -841,11 +840,11 @@ $subhead 03-28$$ -The conditional include commands were missing on some include files; +The conditional include commands were missing on some include files; for example $codep - # ifndef CPPAD_BENDER_QUAD_INCLUDED - # define CPPAD_BENDER_QUAD_INCLUDED + # ifndef CPPAD_BENDER_QUAD_HPP + # define CPPAD_BENDER_QUAD_HPP $$ was missing at the beginning of the $cref BenderQuad$$ include file. This has been fixed. @@ -854,13 +853,13 @@ $$ The $code speed_test$$ routines $cref/timing/speed_test/Timing/$$ was changed to use $code gettimeofday$$ if it is available. -($code gettimeofday$$ measures wall clock time +($code gettimeofday$$ measures wall clock time which is better in a multi-threading environment). $pre $$ Added the user multi-threading interface -$cref omp_max_thread$$ along with its examples +$cref omp_max_thread$$ along with its examples which are distributed in the directory $code openmp$$. $pre @@ -870,15 +869,15 @@ item has been removed. $pre -$$ -The multiple tapes with the same base type wish list item +$$ +The multiple tapes with the same base type wish list item have been removed (it's purpose was multi-threading which has been implemented). $subhead 02-27$$ The $cref speed$$ include files are currently being distributed -above the $code cppad$$ include directory. +above the $code cppad$$ include directory. A fix this wish list item has been added. $pre @@ -900,12 +899,13 @@ This has been fixed. $subhead 02-17$$ -An entry about $cref/optimizing/WishList/Optimization/$$ the operation -sequence in an $cref/ADFun/FunConstruct/$$ object was added. +An entry about optimizing the operation +sequence in an $cref/ADFun/FunConstruct/$$ object was added to the +$cref wish_list$$. $pre $$ -Change the argument syntax for $cref Dependent$$ and deprecate the +Change the argument syntax for $cref Dependent$$ and deprecate the $cref/old Dependent syntax/FunDeprecated/Dependent/$$. @@ -918,7 +918,7 @@ $subhead 02-15$$ -Fixed the $code example/test_one.sh$$ script +Fixed the $code example/test_one.sh$$ script (it was using its old name $code one_test$$). $head 02-06$$ @@ -935,9 +935,9 @@ $head 02-03$$ The change on $cref/02-01/whats_new_07/02-01/$$ had a new, saved as a static -pointer, with no corresponding delete. +pointer, with no corresponding delete. This was not a bug, but it has been changed to avoid -an error message when using CppAD with +an error message when using CppAD with $href%http://valgrind.org/%valgrind%$$. $pre @@ -949,19 +949,19 @@ $head 02-02$$ Fix minor errors and improve -$cref/profiling/InstallUnix/Profiling CppAD/$$ documentation. +$cref/profiling/auto_tools/Profiling CppAD/$$ documentation. Also change the problem sizes used for the $cref speed$$ tests. $head 02-01$$ There seems to be a bug in the cygwin version of g++ version 3.4.4 -with the -O2 flag whereby some static variables in static member functions +with the -O2 flag whereby some static variables in static member functions sometimes do not get constructed before being used. This has been avoided by using a static pointer and the new operator in cppad/local/ad.hpp. $head 01-29$$ The copyright message was missing from some of the distribution files for some new files added on $cref%06-12-15%whats_new_06%12-15%$$. -This resulted in the +This resulted in the tarballs $icode%*%.tgz%$$ and $icode%*%.zip%$$ not existing for a period of time. The automated tests have been extended so that this should not happen again. diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_08.omh cppad-2016.00.00.1/omh/whats_new/whats_new_08.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_08.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_08.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_08.omh 3301 2014-05-24 05:20:21Z bradbell $ +$Id: whats_new_08.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -43,6 +43,7 @@ $$ $section Changes and Additions to CppAD During 2008$$ +$mindex erf ipopt_cppad_nlp$$ $head Introduction$$ @@ -54,12 +55,12 @@ $head 12-19$$ In the documentation for $cref pow_int$$ change the integer exponent from $codei%int %y%$$ to $codei%const int &%y%$$. -In the implementation for $cref pow$$ make the integer base case +In the implementation for $cref pow$$ make the integer base case agree with the documentation; i.e., change from $codei%int %x%$$ to $codei%const int &%x%$$. $head 12-14$$ -Added another test of $cref mul_level$$ calculations (in the +Added another test of $cref mul_level$$ calculations (in the $code test_more$$ directory). $head 12-04$$ @@ -69,12 +70,12 @@ $head 11-22$$ The CppAD interface to the Ipopt nonlinear programming solver $cref cppad_ipopt_nlp$$ -has been moved from $code example/ipopt_cppad_nlp$$ to +has been moved from $code example/ipopt_cppad_nlp$$ to $code ipopt_cppad/ipopt_cppad_nlp$$. $head 11-21$$ The Microsoft's Visual C++ Version 9.0 generates a warning of the form -$codei warning C4396:%...%$$ +$codei warning C4396:%...%$$ for every template function that is declared as a both a friend and inline (it thinks it is only doing this for specializations of template functions). The warnings are no longer generated because @@ -83,9 +84,8 @@ $head 11-20$$ -$index erf$$ -The function $codei%tanh(%x%)%$$ was added to the -$cref std_math_ad$$ functions. +The function $codei%tanh(%x%)%$$ was added to the +$cref unary_standard_math$$ functions. The $code abs$$ and $code erf$$ functions were removed from the $cref/Base requirements/base_require/$$. The restrictions about the Base class were removed from @@ -96,10 +96,10 @@ Visual Studio Version 9.0 could not handle the large number of static constants in the CppAD $cref erf$$ function. This function was changed to a simpler representation -that is much faster and that +that is much faster and that is differentiable at all points (not defined differently on subregions). -The down side to this is that the new version -is not as accurate (see $cref/method/erf/Method/$$). +The down side to this is that the new version +is not as accurate. $head 10-27$$ Change prototypes for $code ipopt_cppad/ipopt_cppad_ode$$ helper routines @@ -109,7 +109,7 @@ Major improvements to the $code ipopt_cppad/ipopt_cppad_ode$$ example. $head 10-16$$ -Minor improvement to description of optimization argument in +Minor improvement to description of optimization argument in $code ipopt_cppad/ipopt_cppad_ode$$. $head 09-30$$ @@ -117,7 +117,7 @@ $code cppad_ipopt_nlp$$ (since removed), multiple argument forward (completed with $cref forward_dir$$), and sparsity patterns -($cref/sparsity patterns/glossary/Sparsity Pattern/$$ has been fulfilled). +($cref/sparsity patterns/glossary/Sparsity Pattern/$$ has been fulfilled). $head 09-26$$ @@ -161,10 +161,10 @@ $$ In $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$, -combined $icode%fg_info%->domain_index()%$$ and +combined $icode%fg_info%->domain_index()%$$ and $icode%fg_info%->range_index()%$$ into a single function called $icode%fg_info%->index()%$$. -Also added more error checking (if $code NDEBUG$$ is not defined). +Also added more error checking (if $code NDEBUG$$ is not defined). $head 09-09$$ Fixed an indexing bug in $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$. @@ -179,13 +179,13 @@ $head 09-06$$ Checked in a major change to $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ whereby the object and constraints can be expressed as the -sum of simpler functions. +sum of simpler functions. This is the first step in what will eventually be a more versatile representation. $head 09-05$$ Fix bug in $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ (not recording the function -at the proper location. Here is the difference that occurred +at the proper location. Here is the difference that occurred multiple places in the $code ipopt_cppad/ipopt_cppad_nlp.cpp$$ source: $codep for(j = 0; j < n_; j++) @@ -216,20 +216,19 @@ $head 08-29$$ The $code push_vector$$ member function was missing from the -$cref/vectorBool/Cppad_vector/vectorBool/$$ class. +$cref/vectorBool/Cppad_vector/vectorBool/$$ class. This has been fixed. In addition, it seems that for some cases (or compilers) the assignment $codei% %x%[%i%] = %y%[%j%] %$$ -did not work properly when both $icode x$$ and $icode y$$ +did not work properly when both $icode x$$ and $icode y$$ had type $code vectorBool$$. This has been fixed. $pre $$ -$index ipopt_cppad_nlp$$ The $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ example has been extended so that it allows for both scalar and vector evaluation of the objective and constraints; see the argument $icode fg_vector$$ in @@ -244,20 +243,20 @@ $cref/simple vectors/SimpleVector/$$ into one large $code CppAD::vector$$. $head 08-08$$ -There was an indexing bug in the +There was an indexing bug in the $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ example that affected the $icode retape$$ equal to $code false$$ case. This has been fixed. -In addition, the missing +In addition, the missing $icode retape$$ documentation was added. $head 07-02$$ -Extend $cref/configure/InstallUnix/Configure/$$ command to check for +Extend $cref/configure/auto_tools/Configure/$$ command to check for extras libraries that are necessary for linking the ipopt example. $head 06-18$$ Add specifications for the Ipopt class $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$. -This is only an example class it may change with future +This is only an example class it may change with future versions of CppAD. $head 06-15$$ @@ -296,7 +295,7 @@ pass this flag along to the speed test implementations (because the corresponding tests have a fixed operation sequence). If this flag is false, a test implementation is allowed to just tape -the operation sequence once and reuse it. +the operation sequence once and reuse it. The following tests use this flag: $cref adolc_det_minor.cpp$$, $cref cppad_det_minor.cpp$$, @@ -313,11 +312,11 @@ $head 04-20$$ -Added the $cref ode_evaluate$$ speed test utility in +Added the $cref ode_evaluate$$ speed test utility in preparation for having ode speed tests. -Created ode speed test for the $code cppad$$ and $code double$$ +Created ode speed test for the $code cppad$$ and $code double$$ cases; see $cref speed_main$$. -In addition, +In addition, added the examples $cref ode_evaluate.cpp$$ and $cref sparse_hessian.cpp$$. $pre @@ -325,31 +324,31 @@ Changed the $cref speed_main$$ routines defined for each package from $codei%compute_%name%$$ to $codei%link_%name%$$. For example, in $code speed/cppad/det_minor.cpp$$, -the function name +the function name $code compute_det_minor$$ was changed to $code link_det_minor$$. $head 04-18$$ Fix a problem in the $cref link_poly$$ correctness test. -Also add $cref double_sparse_hessian.cpp$$ to the set +Also add $cref double_sparse_hessian.cpp$$ to the set speed and correctness tests (now available). $head 04-10$$ -Change all the +Change all the $cref/Adolc speed/speed_adolc/$$ examples to use $cref TrackNewDel$$ instead of using $code new$$ and $code delete$$ directly. This makes it easy to check for memory allocation errors and leaks (when $code NDEBUG$$ is not defined). -Also include in documentation sub functions that indicate +Also include in documentation sub functions that indicate the $code sparse_hessian$$ speed test is not available for $cref double_sparse_hessian.cpp$$, $cref fadbad_sparse_hessian.cpp$$, and $cref sacado_sparse_hessian.cpp$$. $head 04-06$$ -The following $cref/wish list/WishList/$$ +The following $cref/wish list/wish_list/$$ entry has been completed and removed from the list: "Change private member variables names (not part of the user interface) @@ -361,11 +360,11 @@ $head 03-27$$ Corrected $cref cppad_sparse_hessian.cpp$$ -so that it uses the sparse case when +so that it uses the sparse case when $code USE_CPPAD_SPARSE_HESSIAN$$ is $code 1$$. Also added a wish list sparsity pattern entry (the $cref/sparsity pattern/glossary/Sparsity Pattern/$$ entry -has been fulfilled). +has been fulfilled). $pre $$ @@ -373,7 +372,7 @@ $head 02-05$$ -Change windows install instructions +Change windows install instructions to use Unix formatted files (so only two instead of four tarballs are necessary for each version). The Microsoft project files for @@ -381,7 +380,7 @@ were missing. This has also been fixed. $head 02-03$$ -There was an ambiguity problem +There was an ambiguity problem (detected by g++ 4.3) with the following operations $codei% %x% %op% %y% @@ -389,25 +388,24 @@ where $icode x$$ and $icode y$$ were $code AD$$ and $icode op$$ was a member operator of that class. This has been fixed by making all such member functions friends -instead of members of $code AD$$. +instead of members of $code AD$$. $pre $$ Remove computed assignment entry from wish list (it was fixed on $cref/2007-05-26/whats_new_07/05-26/$$). -Add -$cref/expression hashing/WishList/Optimization/Expression Hashing/$$ -to the wish list. +Add an expression hashing entry to the $cref wish_list$$ +(it has since been removed). Add Library and Scripting Languages to the wish list (this has since been fulfilled by the example $cref ad_in_c.cpp$$). $head 01-26$$ -The $cref LuFactor$$ routine gave a misleading error message +The $cref LuFactor$$ routine gave a misleading error message when the input matrix had not a number or infinity in it. This has been fixed. $head 01-24$$ -The $cref/postfix_dir/InstallUnix/postfix_dir/$$ +The $cref/postfix_dir/auto_tools/postfix_dir/$$ has been added to the $code configure$$ command line options. $head 01-21$$ @@ -415,7 +413,7 @@ $cref/sparse_hessian/link_sparse_hessian/$$. $head 01-20$$ -CppAD can now be installed using $code yum$$ on +CppAD can now be installed using $code yum$$ on $code Fedora$$ operating systems. diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_09.omh cppad-2016.00.00.1/omh/whats_new/whats_new_09.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_09.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_09.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_09.omh 3542 2014-12-31 18:37:57Z bradbell $ +$Id: whats_new_09.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -62,7 +62,7 @@ trying to read and understand the CppAD source code.) $head 12-23$$ -The +The $code ADFun$$ $cref/assignment operator/FunConstruct/Assignment Operator/$$ was changed so that it now copies forward mode Taylor coefficients and sparsity pattern information. @@ -76,8 +76,8 @@ $cref/size_forward_set/ForSparseJac/f/size_forward_set/$$. $head 12-22$$ -Convert the optimization of a sequence of additions from multiple operators -to one operator with a varying number of arguments. This improved the speed +Convert the optimization of a sequence of additions from multiple operators +to one operator with a varying number of arguments. This improved the speed for forward and reverse mode computations of an optimized tape. $head 12-18$$ @@ -99,17 +99,17 @@ $head 12-02$$ Fix minor grammatical error in the Purpose heading -for $cref/conditional expressions/CondExp/Purpose/$$. +for $cref/conditional expressions/CondExp/Purpose/$$. $pre $$ -Add the following functions: +Add the following functions: $cref/size_op/seq_property/size_op/$$, $cref/size_op_arg/seq_property/size_op_arg/$$, and $cref/size_op_seq/seq_property/size_op_seq/$$. -In addition, improve and extend the -$cref seq_property.cpp$$ example. +In addition, improve and extend the +$cref seq_property.cpp$$ example. $head 11-28$$ Fix bug in tape optimization with $cref VecAD$$ objects. @@ -129,7 +129,7 @@ Add the speed testing problem $code ipopt_cppad/ipopt_ode_speed.cpp$$. $head 10-29$$ -Split out the +Split out the $cref/ode inverse problem/ipopt_nlp_ode_problem/$$, $cref/its simple representation/ipopt_nlp_ode_simple/$$, and @@ -138,28 +138,28 @@ $cref ipopt_nlp_ode_problem.hpp$$, $cref ipopt_nlp_ode_simple.hpp$$, $cref ipopt_nlp_ode_fast.hpp$$, -and +and $cref ipopt_nlp_ode_check.cpp$$. $head 10-28$$ -Improve the documentation for $cref ipopt_nlp_ode_simple$$ and +Improve the documentation for $cref ipopt_nlp_ode_simple$$ and $cref ipopt_nlp_ode_fast$$. $head 10-27$$ Moved old $code ipopt_cppad_simple.cpp$$ to $cref ipopt_nlp_get_started.cpp$$, created the example $cref ipopt_nlp_ode_simple.hpp$$, -and split and $code ipopt_cppad_ode.cpp$$ +and split and $code ipopt_cppad_ode.cpp$$ into $cref ipopt_nlp_ode_fast.hpp$$ and $cref ipopt_nlp_ode_check.cpp$$. $head 10-24$$ Added the $cref/assignment operator/FunConstruct/Assignment Operator/$$ to the $code ADFun$$ object class. -This makes a copy of the entire operation sequence in another +This makes a copy of the entire operation sequence in another function object. The intention is that the two functions objects can do calculations in parallel. In addition, -CppAD now check for the $code ADFun$$ +CppAD now check for the $code ADFun$$ $cref/copy constructor/FunConstruct/Copy Constructor/$$ and generates an error message if it is used. @@ -192,7 +192,7 @@ (see $cref/sparsity patterns/glossary/Sparsity Pattern/$$). $head 10-03$$ -The Microsoft Visual Studio project files for +The Microsoft Visual Studio project files for examples and testing and for more correctness testing @@ -212,9 +212,9 @@ $head 09-28$$ Changed $cref RevSparseHes$$ so that it uses a sparse -representation when the corresponding call to +representation when the corresponding call to $cref ForSparseJac$$ used a sparse representation. -This should have been included with the change on 09-26 +This should have been included with the change on 09-26 because Hessian sparsity patters after $code ForSparseJac$$ with $icode packed$$ did not work. Thus, this could be considered a bug fix. @@ -223,7 +223,7 @@ Added the $code packed$$ parameter to $cref ForSparseJac$$ and $cref RevSparseJac$$. If $icode packed$$ is false, -a sparse instead of packed representation is used +a sparse instead of packed representation is used during the calculations of sparsity patterns. The sparse representation should be faster, and use less memory, for very large sparse Jacobians. @@ -237,8 +237,8 @@ that included use of $cref VecAD$$ objects. $head 09-19$$ -Some more memory allocation improvements (related to those -on 09-18) were made. +Some more memory allocation improvements (related to those +on 09-18) were made. $head 09-18$$ A bug was found in all the $cref/Sparsity/Sparse/$$ calculations. @@ -258,19 +258,19 @@ Add an option to $cref optimize$$ an operation sequence. $pre -$$ -$bold Begin Merge$$ +$$ +$bold Begin Merge$$ $pre $$ -of changes from the directory $code branches/optimize$$ +of changes from the directory $code branches/optimize$$ in the CppAD subversion repository. -The subheading dates below represent when the correspond change was made in +The subheading dates below represent when the correspond change was made in $code branches/optimize$$. $subhead 08-13$$ An automatic check of the $cref forward_zero$$ results was added after each call to $cref/f.optimize()/optimize/$$ -(this $cref/check/optimize/Checking Optimization/$$ +(this $cref/check/optimize/Checking Optimization/$$ is skipped when $code NDEBUG$$ is defined). In addition, all of the $codei%speed/cppad/%*%.cpp%$$ tests now check and use the speed test @@ -292,9 +292,9 @@ $pre $$ -The function +The function $cref/size_VecAD/seq_property/size_VecAD/$$ function was added -so that the user could see the $code VecAD$$ vectors +so that the user could see the $code VecAD$$ vectors and elements corresponding to an operation sequence. $subhead 08-09$$ @@ -310,7 +310,7 @@ $head 08-06$$ Add hash table coding to reduce the number of copies of the same parameter value necessary in a tape recording. -In addition, add the function +In addition, add the function $cref/size_par/seq_property/size_par/$$ was added so that the user could see the number of parameters corresponding to an operation sequence. @@ -321,18 +321,18 @@ $pre $$ -Fix bug in overnight build where HTML version and entire documentation +Fix bug in overnight build where HTML version and entire documentation as one page versions of documentation were not being built. $pre $$ -Fix missing new line under +Fix missing new line under $cref/Using Value/SimpleVector/Element Access/Using Value/$$ heading for simple vector documentation. $head 08-01$$ Fix bug in reverse mode Jacobian $cref/sparsity/RevSparseJac/$$ -for $cref VecAD$$ objects. +for $cref VecAD$$ objects. $head 07-31$$ The $cref/forward/ForSparseJac/$$ and $cref/reverse/RevSparseJac/$$ @@ -356,7 +356,7 @@ $pre $$ -Improve the $cref vec_ad.cpp$$ user example. +Improve the $cref vec_ad.cpp$$ user example. $subhead 07-06$$ Fixed a bug in second or higher order reverse mode calculations @@ -367,13 +367,13 @@ $$ Add developer documentation for tape evaluation of the -VecAD load operations +VecAD load operations (a load operation accesses an element of the vector but does not change it.) $pre $$ -Fix $code isnan$$ undefined in $code example/cond_exp.cpp$$ error +Fix $code isnan$$ undefined in $code example/cond_exp.cpp$$ error introduced on 07-04 change. $head 07-04$$ @@ -381,13 +381,13 @@ $cref CompareChange$$ operations during tape evaluation. $pre -$$ -$bold Begin Merge$$ +$$ +$bold Begin Merge$$ $pre $$ -of changes from the directory $code branches/sweep$$ +of changes from the directory $code branches/sweep$$ in the CppAD subversion repository. -The subheading dates below represent when the correspond change was made in +The subheading dates below represent when the correspond change was made in $code branches/sweep$$. $subhead 07-04$$ @@ -399,49 +399,49 @@ $$ A simpler and useful example was provided for -$cref/conditional expressions/CondExp/$$; +$cref/conditional expressions/CondExp/$$; see $cref cond_exp.cpp$$. $subhead 07-03$$ -Some minor improvements were made to the documentation for +Some minor improvements were made to the documentation for $cref CondExp$$. To be specific, a newer OMhelp option was used to change the formatting of the syntax, some of the argument names were changed to be more descriptive. $subhead 07-02$$ -Add developer doxygen documentation of +Add developer doxygen documentation of tape evaluation for power (exponentiation) operators. $subhead 07-01$$ -Fix an example indexing error in +Fix an example indexing error in $code introduction/exp_apx/exp_eps_for2.cpp$$ (found by valgrind). $pre $$ -Add developer doxygen documentation of +Add developer doxygen documentation of tape evaluation for multiplication and division operators. $subhead 06-30$$ -Add developer doxygen documentation of +Add developer doxygen documentation of tape evaluation for addition and subtraction operators. $subhead 06-29$$ -Add developer doxygen documentation of +Add developer doxygen documentation of tape evaluation for sin, sinh, cos, and cosh. $subhead 06-28$$ -Add developer doxygen documentation of +Add developer doxygen documentation of tape evaluation for atan, asin, acos, sqrt, log. $pre $$ $bold End Merge$$ $head 06-25$$ -The tarball for most recent release (of the subversion trunk for CppAD) -was not being placed in the -$href%http://www.coin-or.org/download/source/CppAD/%download%$$ -directory. +The tarball for most recent release (of the subversion trunk for CppAD) +was not being placed in the +$href%http://www.coin-or.org/download/source/CppAD/%download%$$ +directory. This has been fixed. $head 06-22$$ @@ -455,7 +455,7 @@ to be run without a lot of other demands on the system. $head 06-21$$ -The configure instructions for $cref/ipopt_dir/InstallUnix/ipopt_dir/$$ +The configure instructions for $cref/ipopt_dir/auto_tools/ipopt_dir/$$ had the wrong path for $code IpIpoptApplication.hpp$$. This has been fixed. @@ -466,16 +466,16 @@ $$ Fix conflict between CppAD's use of config.h preprocessor symbols -and other packages use of the same symbol names. +and other packages use of the same symbol names. $head 06-06$$ $list number$$ Using complex of an AD type (instead of AD of complex) was not working -correctly in $code not_complex_ad.cpp$$ because the +correctly in $code not_complex_ad.cpp$$ because the $cref/default constructor/ad_ctor/$$ for an AD object has an unspecified value. This has been fixed for the complex type by changing the default constructor -to use value zero. -(The $code not_complex_ad.cpp$$ example has been removed; +to use value zero. +(The $code not_complex_ad.cpp$$ example has been removed; see $cref/complex FAQ/Faq/Complex Types/$$.) $lnext Fixing the $code not_complex_ad.cpp$$ problem above also fixed a warning @@ -483,18 +483,18 @@ Now $code valgrind$$ runs the CppAD $code example/example$$ program with out any warning or error messages. In addition, a minor initialization error was fixed in the -$code test_more/jacobian.cpp$$ routine so now +$code test_more/jacobian.cpp$$ routine so now $code valgrind$$ also runs the CppAD $code test_more/test_more$$ program with out any warnings or error messages. $lend $head 05-20$$ A change was make to the trunk on 05-19 (svn revision 1361) that broke the -$cref/Unix install/InstallUnix/$$ procedure. +$cref/Unix install/auto_tools/$$ procedure. This was has been fixed (revision 1362). $head 03-24$$ -Added cross references in +Added cross references in the $cref/examples/ListAllExamples/$$ to occurrence of the following tokens: $cref AD$$, $cref/ADFun/FunConstruct/$$, @@ -529,7 +529,7 @@ $head 01-18$$ Sometimes an error occurs while taping AD operations. -The $cref abort_recording$$ function has been added +The $cref abort_recording$$ function has been added to make it easier to recover in such cases. $pre @@ -543,7 +543,7 @@ $pre $$ -A discussion has been added to the documentation for $cref Jacobian$$ +A discussion has been added to the documentation for $cref Jacobian$$ about its use of $cref/forward or reverse/Jacobian/Forward or Reverse/$$ mode depending on which it estimates is more efficient. @@ -552,7 +552,7 @@ $$ A minor typo has been fixed in the description of $code W(t, u)$$ in $cref reverse_any$$. -To be specific, +To be specific, $latex o ( t^{p-1} ) * t^{1-p} \rightarrow 0$$ has been replaced by $latex o ( t^{p-1} ) / t^{1-p} \rightarrow 0$$. diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_10.omh cppad-2016.00.00.1/omh/whats_new/whats_new_10.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_10.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_10.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_10.omh 2859 2013-05-28 06:03:21Z bradbell $ +$Id: whats_new_10.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -57,8 +57,8 @@ Move most all CppAD development shell scripts to the $code bin$$ subdirectory of the distribution directory. $lnext -Fix warnings generated by the $code g++$$ compiler option $code -Wshadow$$; -for example, +Fix warnings generated by the $code g++$$ compiler option $code -Wshadow$$; +for example, $code sparse_pack.hpp:101:2: warning: declaration of 'end' shadows a member of 'this' $$ @@ -72,7 +72,7 @@ after its assert. $head 09-26$$ -There was a bug +There was a bug (introduced on 09-22) in $code make test$$ when the $code configure$$ command was executed from a directory @@ -83,34 +83,34 @@ $head 09-22$$ Promote $cref cppad_ipopt_nlp$$ from an example to a library -that gets installed -(provided that the $cref/ipopt_dir/InstallUnix/ipopt_dir/$$ +that gets installed +(provided that the $cref/ipopt_dir/auto_tools/ipopt_dir/$$ is specified on the $code configure$$ command line). $head 08-21$$ Fix problems with linking of $cref cppad_ipopt_nlp$$ test with -both older and newer versions of $code ipopt$$. +both older and newer versions of $code ipopt$$. $head 07-14$$ The new versions of ipopt use $code pkg-config$$ to record the location where its necessary libraries are stored on the system. -The cppad $cref/configure/InstallUnix/Configure/$$ command has +The cppad $cref/configure/auto_tools/Configure/$$ command has been improved so that it can work both with versions of ipopt that use $code pkg-config$$ and ones that don't. $head 07-11$$ -Old versions of the ipopt library were located in +Old versions of the ipopt library were located in $icode%ipopt_dir%/lib/libipopt.%*%$$ -(see $cref/ipopt_dir/InstallUnix/ipopt_dir/$$), -but newer versions will be located in +(see $cref/ipopt_dir/auto_tools/ipopt_dir/$$), +but newer versions will be located in $icode%ipopt_dir%/lib/coin/libipopt.%*%$$. The directory $icode%ipopt_dir%/lib/coin%$$ has been added to the library -search path so that the +search path so that the $cref/cppad_ipopt_nlp examples/cppad_ipopt_nlp/Example/$$ work with both old and new versions of ipopt. $head 06-01$$ -In the case where the preprocessor symbol $code NDEBUG$$ was defined +In the case where the preprocessor symbol $code NDEBUG$$ was defined (see $cref/speed/Faq/Speed/$$), the function $codei% @@ -148,7 +148,7 @@ This was fixed in the trunk. It was also fixed in the release with version number $code 20100101.3$$ which can be downloaded from the CppAD -$href%http://www.coin-or.org/download/source/CppAD/%download directory%$$. +$href%http://www.coin-or.org/download/source/CppAD/%download directory%$$. $head 04-01$$ @@ -164,18 +164,18 @@ $head 03-10$$ The $cref optimize$$ routine would mistakenly remove some -expressions that depended on the independent variables and that +expressions that depended on the independent variables and that affected the result of certain $cref CondExp$$ operations. -This has been fixed. +This has been fixed. $head 03-09$$ -Extend $cref reverse_any$$ so that it can be used for +Extend $cref reverse_any$$ so that it can be used for $cref/checkpointing/checkpoint/$$; i.e., splitting reverse mode calculations at function composition points. $head 03-03$$ Fixed a bug in handling -$cref/vector of boolean/glossary/Sparsity Pattern/Vector of Boolean/$$ +$cref/vector of boolean/glossary/Sparsity Pattern/Vector of Boolean/$$ sparsity patterns. (when the number of elements per set was a multiple of $code sizeof(size_t))$$. @@ -191,11 +191,11 @@ A bug was introduced in the $cref/02-05/whats_new_10/02-05/$$ change whereby the $code make$$ command tried to build the $code libcppad_ipopt.a$$ library even if $code IPOPT_DIR$$ was -not specified on the $cref/configure/InstallUnix/Configure/$$ command line. +not specified on the $cref/configure/auto_tools/Configure/$$ command line. This has been fixed. $head 02-06$$ -The Microsoft project files for the speed tests were extended +The Microsoft project files for the speed tests were extended so that the worked properly for the Release (as well as the Debug) configuration. (This required conversion from Visual Studio Version 7 to Visual Studio 2008 @@ -203,8 +203,8 @@ $pre $$ -Add an automated check for $cref optimize$$ bug -fixed on $code 02-05$$. +Add an automated check for $cref optimize$$ bug +fixed on $code 02-05$$. (Automatic checking for $cref PrintFor$$ bug was added on $code 02-05$$.) $head 02-05$$ @@ -212,7 +212,7 @@ Simplify running all the tests by adding the $code make test$$ command. $lnext -Simplify the $cref/configure/InstallUnix/Configure/$$ command by removing +Simplify the $cref/configure/auto_tools/Configure/$$ command by removing need for: $code --with-Speed$$, $code --with-Introduction$$, @@ -229,7 +229,7 @@ $head 02-03$$ Fix a mistakes in the test $cref bender_quad.cpp$$. -In addition, the $cref optimize$$ routine was used to reduce the +In addition, the $cref optimize$$ routine was used to reduce the tape before doing the calculations. $pre @@ -245,7 +245,7 @@ $head 01-24$$ It appears that in $cref cppad_ipopt_nlp$$, when $code retape[k]$$ was true, and $code L[k] > 1$$, it was possible to use the wrong operation sequence -in the calculations (though a test case that demonstrated this could not be +in the calculations (though a test case that demonstrated this could not be produced). This is because the argument value to $latex r_k (u)$$ depends on the value of $latex \ell$$ in the expression $latex \[ @@ -267,7 +267,7 @@ $head 01-20$$ -We plan to split up the +We plan to split up the $code ipopt_cppad/src/ipopt_cppad_nlp.hpp$$ include file. In preparation, the example $code ipopt_cppad$$ has been changed to $code cppad_ipopt$$. @@ -286,10 +286,10 @@ $head 01-04$$ The following items have been fulfilled and -hence were removed for the $cref WishList$$: +hence were removed for the $cref wish_list$$: $list number$$ If an exception occurs before the call to the corresponding -$cref ADFun$$ constructor or $cref Dependent$$, +$cref ADFun$$ constructor or $cref Dependent$$, the tape recording can be stopped using $cref abort_recording$$. $lnext @@ -309,7 +309,7 @@ CppAD to an arbitrary scripting language. $lnext -The vector of sets option has been added to sparsity calculations; +The vector of sets option has been added to sparsity calculations; see $cref/sparsity pattern/glossary/Sparsity Pattern/$$. $lend diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_11.omh cppad-2016.00.00.1/omh/whats_new/whats_new_11.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_11.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_11.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_11.omh 3542 2014-12-31 18:37:57Z bradbell $ +$Id: whats_new_11.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,6 +12,7 @@ $begin whats_new_11$$ $spell + eps cxx namespace boostvector @@ -80,15 +81,14 @@ $list number$$ There was a bug when using $cref abs$$ with an $code AD< AD >$$ argument, whereby the corresponding $code AD$$ operation sequence -depended on the value of the argument to the $code abs$$ function. +depended on the value of the argument to the $code abs$$ function. $lnext Change the specifications for the derivative of the $cref abs$$ -function to be the $cref sign$$ function; see to -$cref%old derivative%abs%Old Derivative%$$ specifications. +function to be the $cref sign$$ function instead of a directional derivative. $lnext Add the $cref sign$$ function to the $codei%AD<%Base%>%$$ list of -available functions. -In addition, add the +available functions. +In addition, add the $cref%sign%base_std_math%sign%$$ function to the list of $cref%base type requirements%base_require%$$. $lend @@ -99,14 +99,14 @@ This has been fixed. $head 12-21$$ -The types +The types $code SizeVector$$, $code NumberVector$$, $code ADNumber$$, and $code ADVector$$, -were in the global namespace and this was causing warnings -about the shadowing of these declarations. -The +were in the global namespace and this was causing warnings +about the shadowing of these declarations. +The $cref/cppad_ipopt namespace/cppad_ipopt_nlp/cppad_ipopt namespace/$$ was created to avoid these problems. The simplest way to make old $cref cppad_ipopt_nlp$$ code work with this @@ -120,14 +120,14 @@ Change $code team_start$$ to $cref/team_create/team_thread.hpp/team_create/$$ and $code team_stop$$ to $cref/team_destroy/team_thread.hpp/team_destroy/$$. $lnext -Change $code NDEBUG$$ mentions to include link to +Change $code NDEBUG$$ mentions to include link to $cref/NDEBUG/Faq/Speed/NDEBUG/$$. $lnext Improve $cref memory_leak$$ documentation. $lend $head 11-29$$ -THe $cref time_test$$ routine was still executing the +THe $cref time_test$$ routine was still executing the test at least twice, even if that was not necessary for the specified minimum time. This has been fixed. @@ -140,16 +140,16 @@ preprocessor symbols that are in the CppAD API. $head 11-21$$ -Separate $cref/--with-boostvector/InstallUnix/--with-testvector/$$ -for $cref/boost_dir/InstallUnix/boost_dir/$$. -This enables one to specify $icode boost_dir$$ for +Separate $cref/--with-boostvector/auto_tools/--with-testvector/$$ +for $cref/boost_dir/auto_tools/boost_dir/$$. +This enables one to specify $icode boost_dir$$ for $cref team_bthread.cpp$$ with out using boost vectors. $head 11-20$$ $list number$$ Move $code sum_i_inv.cpp$$ to $cref harmonic.cpp$$. $lnext -Include the date, time, CppAD version, and +Include the date, time, CppAD version, and $cref/team_name/team_thread.hpp/team_name/$$ in the $cref thread_test.cpp$$ output. $lend @@ -172,13 +172,13 @@ test so that an extra call is not necessary (to make the tests run faster when only a few repetitions are necessary). $lend - + $head 11-17$$ $list number$$ Create another speed testing routine $cref time_test$$ which is like $cref speed_test$$ but it returns the time instead of rate -and as a $code double$$ instead of a $code size_t$$. +and as a $code double$$ instead of a $code size_t$$. The use it for the timing tests in $code sum_i_inv_time.cpp$$ and $cref multi_newton_time.cpp$$. $lnext @@ -241,7 +241,7 @@ $lnext Remove the $code bug/optimize.sh$$ file (no longer a bug). $lnext -Make $code arc_tan.cpp$$ +Make $code arc_tan.cpp$$ utility that can be used by multiple multi-threading tests. $lnext Create $cref team_thread.hpp$$ specifications, @@ -273,18 +273,18 @@ This has been fixed by not compiling the $code pthread$$ examples unless $code pthread_barrier_wait$$ is present. $lnext -The $cref cppad_ipopt_nlp$$ routine has been changed to +The $cref cppad_ipopt_nlp$$ routine has been changed to $cref optimize$$ the functions $latex r_k (u)$$ such that $codei%retape(%k%)%$$ is false. $lend $head 09-06$$ $list number$$ -Add the +Add the $href% http://www.boost.org/doc/libs/1_47_0/doc/html/thread.html% boost multi-threading -%$$ +%$$ examples $cref a11c_bthread.cpp$$ and $code bthread_simple_ad.cpp$$. $lnext Improve documentation for @@ -300,25 +300,25 @@ $head 09-02$$ $list number$$ -The OpenMP speed test program $code openmp/run.cpp$$ was not setting +The OpenMP speed test program $code openmp/run.cpp$$ was not setting the number of threads for the one thread case (so dynamic thread adjustment was used). This has been fixed. $lnext -The $cref thread_alloc.cpp$$ example was missing from the +The $cref thread_alloc.cpp$$ example was missing from the Microsoft $code example/example.vcproj$$ file and a attempt was made to link to missing OpenMP routines (this has been fixed). In addition, some Microsoft compiler warning have been fixed; see the examples and tests in the Windows install instructions. $lnext -There was an oversight, +There was an oversight, and $code CPPAD_MAX_NUM_THREAD$$ was being set to 2 when $code _OPENMP$$ was not defined. -This has been fixed and -$cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ +This has been fixed and +$cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ has been documented and is now part of the CppAD API. $lnext -The $code pthread_simple_ad.cpp$$ test failed under cygwin. +The $code pthread_simple_ad.cpp$$ test failed under cygwin. This was because the previous test $code openmp_ad.cpp$$ was set up calls to OpenMP routines that were still in effect when $code pthread/simple_ad$$ ran. @@ -335,7 +335,7 @@ https://projects.coin-or.org/svn/CppAD/branches/pthread $$ These changes are described below under the headings -$cref/08-21/whats_new_11/09-01/08-21/$$ through +$cref/08-21/whats_new_11/09-01/08-21/$$ through $cref/08-31/whats_new_11/09-01/08-31/$$. $lnext There was a bug in the $cref old_atomic$$ functions @@ -345,7 +345,7 @@ In addition, $cref old_tan.cpp$$ generated an assert for this case and this has also been fixed (in addition to including an example for this case). -$lend +$lend $subhead 08-31$$ $list number$$ @@ -353,30 +353,30 @@ $code openmp/run.sh$$ to $code openmp/run.cpp$$. $lnext Change $code --with-openmp$$ to -$cref/OPENMP_FLAGS=openmp_flags/InstallUnix/openmp_flags/$$ configure +$cref/OPENMP_FLAGS=openmp_flags/auto_tools/openmp_flags/$$ configure command line argument. $lend $subhead 08-30$$ $list number$$ -Create the $code openmp/run.cpp$$ program +Create the $code openmp/run.cpp$$ program and move the $code openmp_multi_newton.cpp$$ test from $code openmp/run.sh$$ to $code openmp/run.cpp$$. -This uses $cref/configure/InstallUnix/Configure/$$ +This uses $cref/configure/auto_tools/Configure/$$ information for building the tests. $lnext Document the $code --with-openmp$$ configure command line argument. $lnext -Move $code openmp/multi_newton.hpp$$ to +Move $code openmp/multi_newton.hpp$$ to $code openmp/newton_method.hpp$$ and -$code openmp/multi_newton.cpp$$ to +$code openmp/multi_newton.cpp$$ to $code openmp/newton_example.cpp$$. $lend $subhead 08-25$$ $list number$$ -Replace $cref omp_alloc$$ by $cref thread_alloc$$ in +Replace $cref omp_alloc$$ by $cref thread_alloc$$ in $cref multi_thread$$, the section on how to use CppAD in parallel. $lnext Implement $cref omp_alloc$$ as links to corresponding $cref thread_alloc$$ @@ -386,10 +386,10 @@ pthread library. In addition, fix some problems in $code openmp_simple_ad.cpp$$ $lnext -Move $code openmp/example_a11c.cpp$$ to +Move $code openmp/example_a11c.cpp$$ to $cref|example/a11c_openmp.cpp|a11c_openmp.cpp|$$. $lnext -Move $code openmp/parallel_ad.cpp$$ to +Move $code openmp/parallel_ad.cpp$$ to $code openmp_simple_ad.cpp$$. $lend @@ -397,7 +397,7 @@ Beginning steps in replacing $cref omp_alloc$$ by $cref thread_alloc$$: $list number$$ Replace $cref omp_alloc$$ by $cref thread_alloc$$ -in the $cref library$$. +in the $cref/utilities/utility/$$. $lnext move $cref omp_alloc$$ to the deprecated section of the documentation. @@ -427,7 +427,7 @@ https://projects.coin-or.org/svn/CppAD/branches/base_require $$ These changes are described below under the headings -$cref/08-04/whats_new_11/08-11/08-04/$$ through +$cref/08-04/whats_new_11/08-11/08-04/$$ through $cref/08-10/whats_new_11/08-11/08-10/$$. $subhead 08-10$$ @@ -444,8 +444,8 @@ $subhead 08-09$$ $list number$$ -$cref/Warning:/base_require/Warning/$$ -Add $cref/epsilon/base_std_math/limits/$$ to the +$cref base_require$$: +Add $cref/epsilon/numeric_limits/epsilon/$$ to the $icode Base$$ type requirements. $lnext Extend $code epsilon$$ to AD types. @@ -455,10 +455,10 @@ $list number$$ Improve the $cref base_require$$ documentation for $cref/standard math functions/base_std_math/$$. -$lnext -$cref/Warning:/base_require/Warning/$$ +$lnext +$cref base_require$$: Add $code abs_geq$$ to the $cref/requirements/base_require/$$ -for a user defined $icode Base$$ type. +for a user defined $icode Base$$ type. $lnext Check that zero order forward mode results are approximately equal, instead of exactly equal, @@ -469,23 +469,23 @@ $lend $subhead 08-07$$ -Improve the $cref base_require$$ documentation for +Improve the $cref base_require$$ documentation for $cref/EqualOpSeq/base_identical/EqualOpSeq/$$, -$cref/Identical/base_identical/Identical/$$ -$cref/Integer/base_require/Integer/$$, and +$cref/Identical/base_identical/Identical/$$ +$cref/Integer/base_require/Integer/$$, and $cref/Ordered/base_ordered/$$ operations. $subhead 08-06$$ -Add the $cref/CondExpRel/base_cond_exp/CondExpRel/$$ paragraph to the -base requirements documentation. +Add the $cref/CondExpRel/base_cond_exp/CondExpRel/$$ paragraph to the +base requirements documentation. This was missing and are required for $cref CondExp$$ to work with $codei%AD<%Base%>%$$ arguments and a non-standard $icode Base$$ type. $subhead 08-04$$ $list number$$ -$cref/Warning:/base_require/Warning/$$ +$cref base_require$$: Change the $cref/include/base_require/Include Order/$$ file name to $cref/base_require.hpp/base_require/$$. $lnext @@ -495,7 +495,7 @@ $lend $head 08-03$$ -Change $cref PrintFor$$ condition from less than or equal zero +Change $cref PrintFor$$ condition from less than or equal zero to not greater than zero;i.e., not positive. This makes $code nan$$ print because it results in false for all comparisons. @@ -519,13 +519,13 @@ $head 07-29$$ $list number$$ -The routines $cref/set_max_num_threads/omp_max_num_threads/$$ and +The routines $cref/set_max_num_threads/omp_max_num_threads/$$ and $code get_max_num_threads$$ were created. -User's will need to replace calls to -$cref/max_num_threads/old_max_num_threads/$$ +User's will need to replace calls to +$cref/max_num_threads/old_max_num_threads/$$ by calls to $code set_max_num_threads$$. $lnext -The functions $cref omp_efficient$$ was deprecated because it +The functions $cref omp_efficient$$ was deprecated because it has not been shown to be useful. $lend @@ -552,7 +552,7 @@ to make $code tan$$ and $code tanh$$ CppAD atomic operations. $head 07-18$$ -The reverse mode formulas for $latex Z(t)$$ need to involve +The reverse mode formulas for $latex Z(t)$$ need to involve the lower order Taylor coefficients for $latex Y(t)$$. This has been fixed in $cref tan_reverse$$. @@ -561,24 +561,24 @@ Fix bug in $cref old_atomic$$ functions. To be specific, the Taylor coefficients for $latex y$$, of order less than $icode k$$, -were not passed into the $code old_atomic$$ +were not passed into the $code old_atomic$$ $cref/forward/old_atomic/forward/$$ callback function. $lnext Derive the theory for including the tangent and hyperbolic tangent -as CppAD atomic operations $cref tan_forward$$ and $cref tan_reverse$$; +as CppAD atomic operations $cref tan_forward$$ and $cref tan_reverse$$; see the wish list item $code Tan and Tanh$$. $lnext Implement and test forward mode calculation of derivative for -the tangent and hyperbolic tangent functions; +the tangent and hyperbolic tangent functions; see the new $cref old_atomic$$ example $cref old_tan.cpp$$. $lend $head 07-14$$ $list number$$ -The $cref InstallUnix$$ instructions for running the individual -correctness and speed tests were out of date. -This has been fixed; see -$cref/example and tests/InstallUnix/make/Examples and Tests/$$. +The $cref auto_tools$$ instructions for running the individual +correctness and speed tests were out of date. +This has been fixed; see +$cref/example and tests/auto_tools/make/Examples and Tests/$$. $lnext Move $code parallel_ad.cpp$$ from $code example$$ directory to $code openmp$$ directory (and convert it from a function to a program). @@ -592,7 +592,7 @@ $head 07-13$$ $list number$$ static hash code data that was begin used by multiple threads -when recording $codei%AD<%Base%>%$$ operations +when recording $codei%AD<%Base%>%$$ operations $cref omp_in_parallel$$ execution mode. This has been fixed. $lnext Make the $cref/sparsity/Sparse/$$ calculations safe @@ -606,7 +606,7 @@ $head 07-11$$ $list number$$ -Change the upper limit for +Change the upper limit for $cref omp_max_num_threads$$ from 32 to 48. $lnext Add $cref/parallel/ta_in_parallel/$$ documentation for, @@ -627,7 +627,7 @@ maximum number of threads instead of specifying the entire set of values to be tested. $lnext -Change settings for +Change settings for $code newton_example$$ so that $code n_gird$$ is a multiple of the maximum number of threads. $lnext @@ -640,18 +640,18 @@ The documentation for $code openmp/run.sh$$ was moved to the $code multi_thread$$ section. $lend - + $head 07-10$$ $list number$$ Add link to $tref Discrete$$ in $cref multi_thread$$. $lnext Make use of the $cref TrackNewDel$$ routines -$cref omp_in_parallel$$ execution mode an error (it never worked properly); +$cref omp_in_parallel$$ execution mode an error (it never worked properly); see $cref/TrackNewDel multi-threading/TrackNewDel/Multi-Threading/$$. $lnext Change $cref memory_leak$$ so that it checks for a leak in all threads. -This is what $code openmp_newton_example.cpp$$ and +This is what $code openmp_newton_example.cpp$$ and $code sum_i_inv_time.cpp$$ assumed was being done. $lend @@ -675,7 +675,7 @@ %$$ sometimes occurred. $lnext -The routine $cref omp_max_thread$$ was deprecated, +The routine $cref omp_max_thread$$ was deprecated, use the routine $cref omp_max_num_threads$$ instead. $lnext The deprecated routines have been grouped together in the @@ -688,12 +688,12 @@ instead of $code automatic$$, for automatic choice of $code openmp/run.sh$$ number of repeats -and +and maximum number of threads. $lnext The output of each of the OpenMP examples / speed tests -(run by $code openmp/run.sh$$) +(run by $code openmp/run.sh$$) was changed to be valid matlab / octave assignment statements. $lnext @@ -705,11 +705,11 @@ $head 06-18$$ $list number$$ -The $cref/tape_addr_type/InstallUnix/tape_addr_type/$$ option was added -to the $cref/configure/InstallUnix/Configure/$$ command line. +The $cref/tape_addr_type/auto_tools/tape_addr_type/$$ option was added +to the $cref/configure/auto_tools/Configure/$$ command line. $lnext The function $cref/size_op_seq/seq_property/size_op_seq/$$ results uses -$code sizeof(CppAD_TAPE_ADDR_TYPE)$$ +$code sizeof(CppAD_TAPE_ADDR_TYPE)$$ where it used to use $code sizeof(size_t)$$. $lnext Remove $code cppad/config.h$$ from CppAD distribution, @@ -717,7 +717,7 @@ This removes the need to undefine symbols that were defined by $code cppad/config.h$$ and that did not begin with $code CPPAD_$$. $lnext -Change $cref/adolc/InstallUnix/adolc_dir/$$ library linkage so it +Change $cref/adolc/auto_tools/adolc_dir/$$ library linkage so it works with version $code ADOL-C-2.2.0$$. $lend @@ -735,11 +735,11 @@ $lend $head 05-26$$ -Fix Visual Studio project files that were broken during the change on 05-22. +Fix Visual Studio project files that were broken during the change on 05-22. In addition, in the file $code cppad/omp_alloc.hpp$$, suppress the following Microsoft Visual Studio warning $codep - warning C4345: behavior change: an object of POD type constructed with + warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized $$ @@ -748,7 +748,7 @@ $list number$$ The old memory tracking routines $cref TrackNewDel$$ have been deprecated. Their use should be replaced using the $cref omp_alloc$$ -a memory allocator which is designed to work well in a multi-threading OpenMP +a memory allocator which is designed to work well in a multi-threading OpenMP environment; see $cref/purpose/omp_alloc/Purpose/$$. $lnext The replacement of $code TrackNewDel$$ by $code omp_alloc$$ @@ -771,7 +771,7 @@ The $cref/capacity/CppAD_vector/capacity/$$ function has been added to the CppAD vector class. $lnext -The simple vector +The simple vector $cref/ element constructor and destructor/ SimpleVector/ @@ -786,10 +786,10 @@ $head 05-11$$ $list number$$ -Avoid ambiguity in the definition of the +Avoid ambiguity in the definition of the $cref/complex isnan/base_complex.hpp/isnan/$$ function. $lnext -Errors during $code make test$$ were not +Errors during $code make test$$ were not being detected. This has been fixed. $lend @@ -797,24 +797,24 @@ $head 05-03$$ $list number$$ If $code NDEBUG$$ is not defined, -the $cref/hasnan/nan/$$ function is used to make sure that the -results of any $cref Forward$$ operation does not contain a +the $cref/hasnan/nan/$$ function is used to make sure that the +results of any $cref Forward$$ operation does not contain a nan (not a number). If so, an error message is generated and the program terminates. This error message and termination can be caught; see $cref ErrorHandler$$. $lnext -In the event that the +In the event that the $cref cppad_ipopt_nlp$$ objective function, the constraints, -or their derivatives are infinite, +or their derivatives are infinite, an error message is generated and the program terminates -(proved that $code NDEBUG$$ is not defined and the default error +(proved that $code NDEBUG$$ is not defined and the default error handler has not been replaced). $lend $head 04-29$$ $list number$$ -The Microsoft Visual Studio 2003 project files +The Microsoft Visual Studio 2003 project files for the Windows examples and tests no longer worked because the current version of CppAD uses local types in template instantiation; see $href% @@ -839,17 +839,17 @@ Also improve the openmp test program output formatting. $head 04-19$$ -The $icode use_ad$$ option was added to the +The $icode use_ad$$ option was added to the $code openmp_newton_example.cpp$$ test case. $head 03-19$$ -The subversion write protected directory +The subversion write protected directory $code bin/.svn$$ was mistakenly part of the $cref/compressed tar file/download/Compressed Archives/$$. It has been removed. $head 03-11$$ -The vector of sets argument +The vector of sets argument $cref/r/old_atomic/rev_hes_sparse/r/$$ to the $code old_atomic$$ function $icode rev_hes_sparse$$ must have size greater than or equal to $icode n$$. @@ -860,8 +860,8 @@ Add the $cref/conjugate gradient/conj_grad.cpp/$$ example. $head 02-22$$ -Add the $cref/atomic/speed_main/option_list/atomic/$$ option to the -speed test program and use +Add the $cref/atomic/speed_main/option_list/atomic/$$ option to the +speed test program and use $cref old_mat_mul.hpp$$ during the $cref cppad_mat_mul.cpp$$ speed test when the atomic option is specified. @@ -870,13 +870,13 @@ There was a bug when $cref omp_max_thread$$ was set to one, and $code NDEBUG$$ was not defined, the thread corresponding to parameters was one, but the only valid thread -number was zero (only one thread) +number was zero (only one thread) and an CPPAD stopped with an assertion error. This has been fixed. $head 02-17$$ There was a mistake in $code openmp/run.sh$$ where it attempted -to remove a non-existent file in the case where +to remove a non-existent file in the case where $code openmp/run.sh$$ openmp_flag was not $code ""$$. This has been fixed. @@ -896,9 +896,9 @@ $pre $$ -The $cref old_mat_mul.hpp$$ example has been improved by +The $cref old_mat_mul.hpp$$ example has been improved by caching the $latex x$$ variable information and using it during -$cref/reverse Hessian sparsity/old_atomic/rev_hes_sparse/$$ calculations. +$cref/reverse Hessian sparsity/old_atomic/rev_hes_sparse/$$ calculations. $pre $$ @@ -909,7 +909,7 @@ The use can now define complex $cref/atomic/old_atomic/$$ operations and store them in a CppAD $cref ADFun$$ object. This item has been remove from the -$cref/wish list/WishList/$$. +$cref/wish list/wish_list/$$. $pre $$ @@ -919,7 +919,7 @@ $$ A faster set operations item was added to the wish list. -This has since been satisfied by +This has since been satisfied by $cref/cppad_sparse_list/cmake/cppad_sparse_list/$$ choice during the install process. @@ -928,7 +928,7 @@ The errors have been fix and the documentation has been improved. $head 02-01$$ -The subversion +The subversion install instructions were brought up to date. They have since been replaced by just separate $cref/subversion download/download/Subversion/$$ @@ -936,9 +936,9 @@ $head 01-19$$ -The directory where the $cref pkgconfig$$ file $code cppad.pc$$ -is stored has been moved from -$icode%prefixdir%/lib/pkgconfig/cppad.pc%$$ +The directory where the $cref pkgconfig$$ file $code cppad.pc$$ +is stored has been moved from +$icode%prefixdir%/lib/pkgconfig/cppad.pc%$$ to $icode%prefixdir%/share/pkgconfig/cppad.pc%$$; see @@ -951,18 +951,18 @@ The install of the documentation failed when it was done from a directory other than the top source directory. $lnext -The GPL distribution had the output of the -$cref/configure/InstallUnix/Configure/$$ command in it. +The GPL distribution had the output of the +$cref/configure/auto_tools/Configure/$$ command in it. $lnext -Since the change on 01-09, the file -$code omh/whats_new_11.omh$$ has been required to build the +Since the change on 01-09, the file +$code omh/whats_new_11.omh$$ has been required to build the documentation (and it has been missing from the distribution). $lnext Fadbad was generating warnings due to the $code -Wshadow$$ flag with the $code g++$$ compiler. The Fadbad $cref/speed/speed_fadbad/$$ tests have a special flag with this warning removed from the -$cref/cxx_flags/InstallUnix/cxx_flags/$$. +$cref/cxx_flags/auto_tools/cxx_flags/$$. $lend $head 01-09$$ @@ -975,15 +975,15 @@ The version of automake used to build the corresponding $code makefile.in$$ files did not define $code abs_top_builddir$$. $lnext -The include file $code cppad_ipopt_nlp.hpp$$ was always installed, even if -$cref/ipopt_dir/InstallUnix/ipopt_dir/$$ was not defined on the +The include file $code cppad_ipopt_nlp.hpp$$ was always installed, even if +$cref/ipopt_dir/auto_tools/ipopt_dir/$$ was not defined on the $code configure$$ command line. $lnext The speed test library $code libspeed.a$$ was being installed (it is only intended for testing). $lend -These problems are fixed in the trunk -and these fixes will be copied to the corresponding stable and +These problems are fixed in the trunk +and these fixes will be copied to the corresponding stable and release versions; i.e., $codei% http://www.coin-or.org/download/source/CppAD/cppad-20110101.1.%license%.tgz diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_12.omh cppad-2016.00.00.1/omh/whats_new/whats_new_12.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_12.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_12.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_12.omh 3542 2014-12-31 18:37:57Z bradbell $ +$Id: whats_new_12.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -80,7 +80,7 @@ $head 12-30$$ $list number$$ Merge changes in $code branches/ipopt_solve$$ to $code trunk$$, -delete that branch, and +delete that branch, and advance version number to $code cppad-20121230$$. $lnext Remove $code cppad/configure.hpp$$ from repository because @@ -98,10 +98,10 @@ sparse Jacobians. $lnext The $cref ipopt_solve$$ routine seems to be faster and simpler -than $cref cppad_ipopt_nlp$$. +than $cref cppad_ipopt_nlp$$. More speed comparisons would be good to have. $lnext -All of the $cref/ADFun Drivers/Drivers/$$ +All of the $cref/ADFun Drivers/Drivers/$$ have added specifications for the zero order Taylor coefficients after the routine is called. For example, see @@ -131,10 +131,10 @@ In $code branches/ipopt_solve$$: $list number$$ Convert documentation most all documentation references from -the deprecated $cref InstallUnix$$ instructions to the new $cref cmake$$ +the deprecated $cref auto_tools$$ instructions to the new $cref cmake$$ instructions. $lnext -Include the $cref Introduction$$ programs in the +Include the $cref Introduction$$ programs in the $cref cmake_check$$ built using $cref cmake$$. $lnext Deprecate $cref cppad_ipopt_nlp$$ and replace it by $cref ipopt_solve$$ @@ -151,7 +151,7 @@ $head 12-20$$ $list number$$ -The $cref/install instructions/install/Instructions/$$ +The $cref/install instructions/install/Instructions/$$ were installing $code cppad/CMakeLists.txt$$ and $code cppad/configure.hpp.in$$ in the $code cppad$$ include directory. This has been fixed so that only $icode%*%.h%$$ and $icode%*%.hpp%$$ files @@ -161,7 +161,7 @@ $lend $head 12-19$$ -The files $code $$ and $code $$ +The files $code $$ and $code $$ do not exist for all C compilers, and this caused a problem when using the Windows compiler. This has been fixed by defining the type bool inside the @@ -172,27 +172,27 @@ file $code hash_code.hpp$$. This mistake could generate a C++ assertion with an unknown error source. It has been fixed. - + $head 12-15$$ $list number$$ Advance version number from $code 20121120$$ to $code 20121215$$. -Note that the CppAD version number no longer automatically advances with the +Note that the CppAD version number no longer automatically advances with the date and is rather chosen to advance to the current date. $lnext The $cref cmake$$ installation was putting the $code cppad.pc$$ -$cref pkgconfig$$ file in +$cref pkgconfig$$ file in $codei% - cmake_install_prefix%/cmake_install_datadir%/cppad.pc + cppad_prefix%/cmake_install_datadir%/cppad.pc %$$ This has been fixed and is now $codei% - cmake_install_prefix%/cmake_install_datadir%/pkgconfig/cppad.pc + cppad_prefix%/cmake_install_datadir%/pkgconfig/cppad.pc %$$ $lnext The $cref pkgconfig$$ documentation has been improved. $lnext -The command for running the +The command for running the $cref/adolc examples/adolc_prefix/Examples/$$ and $cref/eigen examples/eigen_prefix/Examples/$$ was fixed @@ -202,11 +202,11 @@ $head 12-14$$ $list number$$ -Fix the old $cref InstallUnix$$ so that it works with the +Fix the old $cref auto_tools$$ so that it works with the new $code cppad.pc$$. $lnext -Fix the old installation -$cref/--with-Documentation/InstallUnix/--with-Documentation/$$ option +Fix the old installation +$cref/--with-Documentation/auto_tools/--with-Documentation/$$ option (it was attempting to copy from the wrong directory). $lend @@ -223,7 +223,7 @@ $head 11-28$$ -Update the $cref WishList$$: +Update the $cref wish_list$$: $list number$$ Remove Microsoft compiler warning item that has been fixed. $lnext @@ -232,7 +232,7 @@ $lnext Remove $cref cmake$$ items that have been completed. $lnext -Remove $cref CondExp$$ items related to using +Remove $cref CondExp$$ items related to using $code AD< std::complex >$$ types because it is better to use $code std::complex< AD >$$. $lnext @@ -240,20 +240,20 @@ $lnext Remove $cref VecAD$$ item about slicing from floating point type to $code int$$ (not important). -$lnext +$lnext Change an Ipopt item to a $cref cppad_ipopt_nlp$$ (which was removed because $code cppad_ipopt_nlp$$ is now deprecated). Add new $code cppad_ipopt_sum$$ item to the wish list. -(This has been removed because $cref/checkpointing/checkpoint/$$ +(This has been removed because $cref/checkpointing/checkpoint/$$ can now be used for this purpose.) $lnext -Add new $code old_atomic$$ $cref WishList$$ item (since removed). +Add new $code old_atomic$$ $cref wish_list$$ item (since removed). $lend $head 11-21$$ $list number$$ -Fix the version number in link to the +Fix the version number in link to the $cref/current download files/download/Compressed Archives/Current Version/$$. $lnext Change the @@ -265,8 +265,8 @@ $head 11-20$$ $list number$$ The $code cmake$$ variables -$code cmake_install_includedir$$ and -$code cmake_install_libdir$$ +$code cmake_install_includedir$$ and +$code cmake_install_libdir$$ were changed to $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$ and $cref/cmake_install_libdirs/cmake/cmake_install_libdirs/$$ @@ -278,7 +278,7 @@ $head 11-17$$ $list number$$ Finish documenting the new $cref cmake$$ configuration instructions -and deprecate the old $cref/unix/InstallUnix/$$ instructions. +and deprecate the old $cref/unix/auto_tools/$$ instructions. $lnext Change the specifications for $cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ @@ -297,16 +297,16 @@ Advanced the CppAD version to $code cppad-20121114$$. $list number$$ -Started documenting the +Started documenting the $cref cmake$$ configuration procedure during installation. -This included factoring out the +This included factoring out the $cref download$$ procedure as a separate section -so that the same download instruction also apply to the -$cref/unix/InstallUnix/$$ install procedure. +so that the same download instruction also apply to the +$cref/unix/auto_tools/$$ install procedure. $lnext -Changed -$cref%example/compare_change.cpp%compare_change.cpp%$$ +Changed +$cref%example/compare_change.cpp%compare_change.cpp%$$ to just return true when $code NDEBUG$$ is defined. This enabled all the tests in the $code example$$ directory to be compiled @@ -314,14 +314,14 @@ $lnext In the case where $code NDEBUG$$ is defined, -removed detection of $code nan$$ during forward mode from +removed detection of $code nan$$ during forward mode from $code test_more/forward.cpp%$$. -This enables all the tests in the +This enables all the tests in the $code test_more$$ directory to be compiled with $code NDEBUG$$ is defined and to pass. $lnext -Started a wish list for CppAD's use of $cref cmake$$. +Started a wish list for CppAD's use of $cref cmake$$. The wish list items were completed and removed. $lend @@ -352,19 +352,19 @@ This has been fixed and the comments for this example have been improved. $head 10-31$$ -The CppAD $cref/profiling/InstallUnix/Profiling CppAD/$$ was not compiling +The CppAD $cref/profiling/auto_tools/Profiling CppAD/$$ was not compiling the $code speed/src/*.cpp$$ files with the profiling flag. -This has been changes +This has been changes (only for the profiling speed test). $head 10-30$$ -The $cref/fadbad_dir/InstallUnix/fadbad_dir/$$ directory install instructions +The $cref/fadbad_dir/auto_tools/fadbad_dir/$$ directory install instructions were changed. To be specific, $code FADBAD++$$ was changed to $code include/FADBAD++$$. This makes it more like the other optional packages. $head 10-25$$ -The test $cref runge45_1.cpp$$ was failing when using gcc-4.5.2. +The test $cref runge45_1.cpp$$ was failing when using gcc-4.5.2. This has been fixed by properly defining $codei%fabs(%x%)%$$ where $icode x$$ is a double (without the $code std$$ in front). @@ -374,9 +374,9 @@ $head 10-12$$ $list number$$ -Change all the multiple levels of AD examples to +Change all the multiple levels of AD examples to start with $cref mul_level$$. -To be specific, move +To be specific, move $code ode_taylor.cpp$$ to $cref mul_level_ode.cpp$$ and $code ode_taylor_adolc.cpp$$ to $cref mul_level_adolc_ode.cpp$$. $lnext @@ -408,9 +408,9 @@ $code multi_thread/test.sh$$; see $cref/03-17/whats_new_12/03-17/$$ $head 09-24$$ -Improve documentation for the -$cref old_atomic$$ -$cref/rev_hes_sparse/old_atomic/rev_hes_sparse/$$ +Improve documentation for the +$cref old_atomic$$ +$cref/rev_hes_sparse/old_atomic/rev_hes_sparse/$$ argument $cref/v/old_atomic/rev_hes_sparse/v/$$. In addition, @@ -425,7 +425,7 @@ A new type was added for the internal representation of $cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$ sparsity patterns; see the configure -$cref/--with-sparse_option/InstallUnix/--with-sparse_option/$$. +$cref/--with-sparse_option/auto_tools/--with-sparse_option/$$. $lnext A new speed test, $cref compare_c$$, compares the speed of the same source code compiled with C and C++. @@ -433,7 +433,7 @@ $head 07-30$$ $list number$$ -The $cref/clear/CppAD_vector/clear/$$ function was added to +The $cref/clear/CppAD_vector/clear/$$ function was added to $code CppAD::vector$$. $lnext Warning !!: @@ -442,7 +442,7 @@ the corresponding memory (use $icode%x%.clear()%$$ instead). $lnext Fix a bug in error checking during $cref optimize$$ procedure -had the following $code valgrind$$ symptom during the +had the following $code valgrind$$ symptom during the $cref optimize.cpp$$ example: $codep ==6344== Conditional jump or move depends on uninitialised value(s) @@ -452,7 +452,7 @@ was missing before the call $codep dw = F.Reverse(1, w); -$$ +$$ $lend $head 07-08$$ @@ -465,8 +465,8 @@ $lend $head 07-07$$ -Add the $code CPPAD_TAPE_ID_TYPE$$ argument to the -$cref/configure/InstallUnix/Configure/$$ command line. +Add the $code CPPAD_TAPE_ID_TYPE$$ argument to the +$cref/configure/auto_tools/Configure/$$ command line. $head 07-05$$ Deprecate $cref/CPPAD_TEST_VECTOR/test_vector/$$ and use @@ -476,11 +476,11 @@ $head 07-04$$ $list number$$ -Replace the requirement that the $cref SimpleVector$$ +Replace the requirement that the $cref SimpleVector$$ $cref/size/SimpleVector/Size/$$ function return a $code size_t$$ value to the requirement that it can be converted to a $code size_t$$ value. $lnext -The $cref/--with-eigenvector/InstallUnix/Configure/$$ option was +The $cref/--with-eigenvector/auto_tools/Configure/$$ option was added to the $code configure$$ command line. $lend @@ -494,14 +494,14 @@ $$ $head 07-02$$ -Add $cref eigen_plugin.hpp$$ so that +Add $cref eigen_plugin.hpp$$ so that an Eigen vector can be used as a $cref/SimpleVector/$$. $head 07-01$$ $list number$$ -Change $cref cppad_eigen.hpp$$ -to match new specifications and example in eigen help files on +Change $cref cppad_eigen.hpp$$ +to match new specifications and example in eigen help files on $href% http://eigen.tuxfamily.org/dox/TopicCustomizingEigen.html% customizing and extending eigen. @@ -519,43 +519,43 @@ $head 06-17$$ $list number$$ -Move $cref epsilon$$ to $cref/numeric_limits/limits/$$ +Move $cref epsilon$$ to $cref numeric_limits$$ and add the functions $code min$$ and $code max$$ in $icode%CppAD::numeric_limits<%Type%>%$$. $lnext Convert use of the deprecated $cref epsilon$$ in examples -to use of $cref/numeric_limits/limits/$$ $code epsilon$$. +to use of $code numeric_limits$$ $cref/epsilon/numeric_limits/epsilon/$$. $lnext -Complete $cref cppad_eigen.hpp$$ interface to +Complete $cref cppad_eigen.hpp$$ interface to $code lowest$$ and $code highest$$ functions for all non-complex AD types. $lend $head 06-16$$ -Add the example $cref eigen_det.cpp$$ that uses the +Add the example $cref eigen_det.cpp$$ that uses the $href%http://eigen.tuxfamily.org%Eigen%$$ linear algebra package. $head 06-15$$ Include the $cref base_adolc.hpp$$ as -$code $$ under the -$cref/prefix_dir/InstallUnix/prefix_dir/$$ directory. +$code $$ under the +$cref/prefix_dir/auto_tools/prefix_dir/$$ directory. $head 06-12$$ -Increase the size and of the +Increase the size and of the $cref/sparse Jacobian speed tests/link_sparse_jacobian/$$. $head 06-10$$ $list number$$ Add the $cref/hold_memory/speed_main/option_list/memory/$$ option to the speed test main program. -This was changed to just $code memory$$; see +This was changed to just $code memory$$; see $cref/10-03/whats_new_12/10-03/$$. $lnext In $cref cppad_sparse_jacobian.cpp$$, change $code USE_BOOL_SPARSITY$$ from true to false. -In addition, change the number of non-zeros per row from about approximately +In addition, change the number of non-zeros per row from about approximately three to approximately ten. $lend @@ -599,7 +599,7 @@ (and similarly for $code float$$). $lnext Add the $cref adolc_ode.cpp$$ and $cref fadbad_ode.cpp$$ speed tests -(and edit the $cref cppad_ode.cpp$$ test). +(and edit the $cref cppad_ode.cpp$$ test). $lend $head 06-03$$ @@ -615,13 +615,13 @@ $head 06-02$$ $list number$$ Remove the deprecated symbol -$cref/CppADvector/test_vector/Deprecated/$$ from the +$cref/CppADvector/test_vector/Deprecated 2012-07-03/$$ from the $cref det_by_lu$$ speed test source code $cref det_by_lu.hpp$$. $lnext -Include $cref memory_leak$$ in the list of +Include $cref memory_leak$$ in the list of $cref deprecated$$ features. $lnext -Change the $cref ode_evaluate$$ speed test utility so that its +Change the $cref ode_evaluate$$ speed test utility so that its $cref/operation sequence/glossary/Operation/Sequence/$$ does not depend on the repetition; see $cref/p == 0/ode_evaluate/p/p == 0/$$ in its documentation. @@ -632,44 +632,44 @@ Implement the $icode%retape% == false%$$ option in $cref cppad_ode.cpp$$. $lnext -Have -$cref cppad_det_lu.cpp$$, +Have +$cref cppad_det_lu.cpp$$, $cref cppad_det_minor.cpp$$, and $cref cppad_poly.cpp$$, return false when one of the specified options is not supported. Do the same for -$icode%package%_%test%.cpp%$$ for $icode package$$ equal to -$code adolc$$, $code fadbad$$, and $code sacado$$ and -for $icode test$$ equal to +$icode%package%_%test%.cpp%$$ for $icode package$$ equal to +$code adolc$$, $code fadbad$$, and $code sacado$$ and +for $icode test$$ equal to $code det_lu$$, $code det_minor$$, $code poly$$. $lend $head 06-01$$ -Change +Change $cref cppad_sparse_hessian.cpp$$ and -$cref cppad_sparse_jacobian.cpp$$ +$cref cppad_sparse_jacobian.cpp$$ to use the $icode row$$, $icode col$$ interface to $cref sparse_hessian$$. -In addition, implement the speed test +In addition, implement the speed test $code retape$$ speed test option for these tests. $head 05-31$$ Add the $code cppad_print_optimize$$ routine to so that the corresponding -code does not need to be reproduced for all the +code does not need to be reproduced for all the $cref speed_cppad$$ tests. -In addition, during CppAD speed tests, +In addition, during CppAD speed tests, print out the optimization results for each test size. $head 05-30$$ -Change specifications for -$cref link_sparse_hessian$$ so that the row and column indices are +Change specifications for +$cref link_sparse_hessian$$ so that the row and column indices are inputs (instead of being chosen randomly by the test for each repetition). -This enables use of the +This enables use of the $code retape$$ speed test option during sparse Hessian speed tests. $head 05-29$$ -Add $cref index_sort$$ to the general purpose template $cref library$$ +Add $cref index_sort$$ to the general purpose template $cref/utilities/utility/$$ so that it can be used by the implementations of $cref link_sparse_jacobian$$ and $cref link_sparse_hessian$$. @@ -691,17 +691,17 @@ $lnext The examples $cref sparse_jacobian.cpp$$ and -$cref sparse_hessian.cpp$$ were improved +$cref sparse_hessian.cpp$$ were improved and extended to include the new interface. $lnext -The definition of an +The definition of an $cref/AD function/glossary/AD Function/$$ was improved to include definition of the corresponding $icode n$$ and $icode m$$. $lend $head 04-19$$ -The $cref/BOOST_DIR/InstallUnix/boost_dir/$$ +The $cref/BOOST_DIR/auto_tools/boost_dir/$$ configure command line value has been changed to be the corresponding prefix during the installation of boost. To be specific, it used to be that @@ -714,29 +714,29 @@ $head 04-18$$ -Add documentation and testing for not using $cref/free_all/ta_free_all/$$ and +Add documentation and testing for not using $cref/free_all/ta_free_all/$$ and $cref/old_atomic clear/old_atomic/clear/$$ while in $cref/parallel/ta_in_parallel/$$ mode. $head 04-17$$ -Fix bug when using $cref old_atomic$$ functions with +Fix bug when using $cref old_atomic$$ functions with $cref/multi_threading/multi_thread/$$. $head 04-10$$ -Add control of the -$cref/max_num_threads/InstallUnix/max_num_threads/$$ argument -to the unix -$cref/configure/InstallUnix/Configure/$$ command. +Add control of the +$cref/max_num_threads/auto_tools/max_num_threads/$$ argument +to the unix +$cref/configure/auto_tools/Configure/$$ command. $head 04-06$$ $list number$$ -A change was made to the way that the tapes were managed to reduce +A change was made to the way that the tapes were managed to reduce false sharing during $cref/multi-threading/multi_thread/$$. -Because of this change, it is now suggest that the user call +Because of this change, it is now suggest that the user call $cref parallel_ad$$ after the multi-threading section of the program. $lnext -The routine $cref ta_free_all$$ was created to make it easier -to manage memory and the routine $cref memory_leak$$ +The routine $cref ta_free_all$$ was created to make it easier +to manage memory and the routine $cref memory_leak$$ was deprecated. $lnext Add the $code -lteuchos$$ flag to the link line for the @@ -751,11 +751,11 @@ This was necessary inorder to initialize some new statics in the tape. $head 04-01$$ -Fixed a race condition when using CppAD with -$cref/multi-threading/multi_thread/$$. +Fixed a race condition when using CppAD with +$cref/multi-threading/multi_thread/$$. This has been fixed and the error message below no longer occurs. -Suppose that you ran the CppAD -$cref/configure/InstallUnix/Configure/$$ command in the $code work$$ +Suppose that you ran the CppAD +$cref/configure/auto_tools/Configure/$$ command in the $code work$$ directory. If you then edited the file $code work/multi_thread/makefile$$ and changed @@ -804,10 +804,10 @@ This includes separating generic code that can be used for all applications from problem specific code. $lnext -Add initialization of statics in -$cref/CheckSimpleVector/parallel_ad/CheckSimpleVector/$$ +Add initialization of statics in +$cref/CheckSimpleVector/parallel_ad/CheckSimpleVector/$$ during $code parallel_ad$$ call. -These statics are required to use +These statics are required to use $cref/CppAD::vector/CppAD_vector/$$. $lnext Add a debugging check to make sure $cref CheckSimpleVector$$ @@ -816,8 +816,8 @@ $head 03-21$$ Fix an incorrect error check in $code thread_alloc$$ -that did not allow $cref ta_return_memory$$ -to return memory in sequential execution mode that was allocated by a +that did not allow $cref ta_return_memory$$ +to return memory in sequential execution mode that was allocated by a different thread during parallel execution. $head 03-17$$ @@ -825,7 +825,7 @@ $code /bin/sh$$ to $code dash$$ (which caused $code multi_thread/test.sh$$ to fail). This has been fixed. -In general, Debian's policy is that $code bin/sh$$ will be a +In general, Debian's policy is that $code bin/sh$$ will be a $href% http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html% Posix Shell @@ -834,28 +834,28 @@ $head 03-11$$ There was a bug in $cref thread_alloc$$ where extra memory was held onto even if $cref/hold_memory/ta_hold_memory/$$ was never called -and only one thread was used by the program. This caused +and only one thread was used by the program. This caused $codei% valgrind --leak-check=full --show-reachable=yes %$$ to generate an error message. If $cref/multiple threads/multi_thread/$$ are used, -one should free this +one should free this $cref/extra memory/ta_free_available/Purpose/Extra Memory/$$ for threads other than thread zero. If $code hold_memory$$ is used, -one should call $cref/free_available/ta_free_available/$$ for all threads. +one should call $cref/free_available/ta_free_available/$$ for all threads. $head 03-03$$ $list number$$ -Add the examples +Add the examples $cref simple_ad_openmp.cpp$$, $cref simple_ad_bthread.cpp$$ and $cref simple_ad_pthread.cpp$$. $lnext Fix bug in finding boost multi-threading library -(due to fact that $cref/boost_dir/InstallUnix/boost_dir/$$ +(due to fact that $cref/boost_dir/auto_tools/boost_dir/$$ is not the prefix during the boost installation). $lend @@ -863,7 +863,7 @@ $list number$$ Change the name $code simple_ad.cpp$$ to $cref team_example.cpp$$ $lnext -The multi-threading $code team_example.cpp$$ example was changed to use +The multi-threading $code team_example.cpp$$ example was changed to use $latex f(x) = \sqrt{ x^2 }$$ instead of the function $latex {\rm atan2} [ \sin(x) , \cos (x) ]$$ (both functions should behave like the identity function $latex f(x) = x$$). @@ -876,7 +876,7 @@ $head 02-11$$ $list number$$ -The requirements in +The requirements in $cref base_member$$ were missing from the $cref base_require$$ documentation. In addition, the $cref base_require.cpp$$ example has been added. @@ -884,8 +884,8 @@ The specifications for $cref memory_leak$$ where changes so that calling routine specifies the amount of static memory to add. In addition, -it is now possible to call -$code memory_leak$$ when $cref/num_threads/ta_num_threads/$$ +it is now possible to call +$code memory_leak$$ when $cref/num_threads/ta_num_threads/$$ is greater than one (still can't be in parallel mode). @@ -913,13 +913,13 @@ $head 01-30$$ Make another attempt to fix linking with boost threads where the wrong version of the library is in the system include directory; i.e., -to have $cref/boost_dir/InstallUnix/boost_dir/$$ override the default +to have $cref/boost_dir/auto_tools/boost_dir/$$ override the default library. $head 01-27$$ -There were some problems with -$cref/configure's/InstallUnix/Configure/$$ automatic detection of -the boost multi-threading library. +There were some problems with +$cref/configure's/auto_tools/Configure/$$ automatic detection of +the boost multi-threading library. These have been fixed. $head 01-24$$ @@ -929,7 +929,7 @@ Holding onto memory is now controlled by the separate routine $cref/hold_memory/ta_hold_memory/$$. This give the user more control over the memory allocator -and the ability to obtain a speed up even +and the ability to obtain a speed up even when there is only one thread. To convert old code to the new interface, after each call to $codei% @@ -946,10 +946,10 @@ $head 01-20$$ $list number$$ -Add the example $cref change_const.cpp$$ +Add the example $cref change_param.cpp$$ which shows how to compute derivatives of functions that have -parameters that can change (but derivatives are not computed - with respect to these parameters). +parameters that change, but derivatives are not computed +with respect to these parameters. $lnext The documentation for machine $cref epsilon$$ has been improved. @@ -969,23 +969,23 @@ $lend $head 01-16$$ -The test program $code multi_thread/test.sh$$ failed if the -$cref/openmp_flags/InstallUnix/openmp_flags/$$ not present in the +The test program $code multi_thread/test.sh$$ failed if the +$cref/openmp_flags/auto_tools/openmp_flags/$$ not present in the $code configure$$ command. This has been fixed. In addition, this $code test.sh$$ has been made faster by cycling through the available threading systems instead of doing every system for every -test. +test. $head 01-15$$ -Fix $code make test$$ so it works when -$cref/configure/InstallUnix/Configure/$$ is run in the distribution directory +Fix $code make test$$ so it works when +$cref/configure/auto_tools/Configure/$$ is run in the distribution directory $codei%cppad-%yyyymmdd%$$ (not just when it is run in a different directory). $head 01-12$$ -The $code -lpthread$$ library was missing from the +The $code -lpthread$$ library was missing from the $cref multi_thread$$ test program linker command. This has been fixed. @@ -1032,12 +1032,12 @@ There was a problem with the way that $cref/multi_newton_combine/multi_newton_work.cpp/multi_newton_combine/$$ joined two solutions into one. -It is possible that one of the solutions that needs to be joined is on +It is possible that one of the solutions that needs to be joined is on the boundary and very close to a solution in the next (or previous interval) that is not on the boundary. In this case, the one with the smaller function value is chosen. $lend -for the previous +for the previous $end diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_13.omh cppad-2016.00.00.1/omh/whats_new/whats_new_13.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_13.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_13.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_13.omh 3542 2014-12-31 18:37:57Z bradbell $ +$Id: whats_new_13.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -64,27 +64,28 @@ $head 12-29$$ $list number$$ -The include file +The include file $cref cppad_eigen.hpp$$ now automatically includes $code cppad.hpp$$. $lnext There was a problem with this automation when $code eigen$$ was used for the cppad $cref testvector$$. This has been fixed. $lnext -There was a problem with deprecated $cref InstallUnix$$ +There was a problem with deprecated $cref auto_tools$$ (created when optional implicit constructor from any type was added). This has been fixed by adding the -$cref/--with-implicit_ctor/InstallUnix/--with-implicit_ctor/$$ option. +$code --with-implicit_ctor$$ option +(later changed to $cref/--with-deprecated/auto_tools/--with-deprecated/$$). $lend $head 12-27$$ The constructor from an arbitrary type to $codei%AD<%Base%>%$$ was implicit, but there was no specification to this effect. -The caused problems when using CppAD with +The caused problems when using CppAD with $cref/eigen 3.2/eigen_prefix/$$ (scheduled to be fixed in 3.3). -The default for this constructor has been changed to be +The default for this constructor has been changed to be $cref/explicit/ad_ctor/x/explicit/$$. -In addition, other +In addition, other $cref/implicit/ad_ctor/x/implicit/$$ constructors are now listed in the documentation. $pre @@ -99,10 +100,7 @@ AD<%Base%>( %y% ) %$$ A deprecated alternative is to make this constructor implicit using the -$cref/cppad_implicit_ctor_from_any_type - /cmake - /cppad_implicit_ctor_from_any_type -/$$ +$cref/cppad_deprecated/cmake/cppad_deprecated/$$ option during the install procedure. $head 12-26$$ @@ -120,7 +118,7 @@ $head 11-27$$ $list number$$ -Fix bug when using $cref optimize$$ with an $cref ADFun$$ object containing +Fix bug when using $cref optimize$$ with an $cref ADFun$$ object containing the $cref sign$$ function. $lnext Add $cref atomic_norm_sq.cpp$$, an atomic function example @@ -131,7 +129,7 @@ It used to be that one had to define the $code std::set$$ version of $cref atomic_rev_sparse_jac$$ for each atomic function that was part of an $cref ADFun$$ object that was $cref/optimized/optimize/$$. -Now the current +Now the current $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ setting is used to determine if the $code bool$$ or $code std::set$$ version of $code rev_sparse_jac$$ is used by the optimization process. @@ -144,7 +142,7 @@ $cref/rev_sparse_jac/optimize/Atomic Functions/rev_sparse_jac/$$. $head 10-29$$ -The $cref/optimization/CondExp/Optimize/$$ +The $cref/optimization/CondExp/Optimize/$$ now handles nested conditional expressions. For example, give the code $codep @@ -155,20 +153,20 @@ only two of the conditional expressions will be evaluated (one will be skipped depending on the result of $code left_z == right_z$$). For more details, see -$cref/nesting conditional expressions/ -WishList/Conditional Expressions/Nesting/$$ +$cref/nesting conditional expressions + /wish_list + /Optimizing Nested Conditional Expressions +/$$. $head 10-23$$ $list number$$ Fix a bug in the optimization of calls to $cref atomic$$ functions. This bug existed before recent change to optimizing conditional expressions. -This required adding the -$cref/nz_compare/RevSparseJac/nz_compare/$$ argument to the +This required adding the +$cref/dependency/RevSparseJac/dependency/$$ argument to the reverse Jacobian sparsity pattern calculation. -For further details; see sparsity heading under conditional expressions in the -$cref/whish list/WishList/Conditional Expressions/Sparsity/$$. $lnext -Fix the deprecated autotools install (see $cref InstallUnix$$) +Fix the deprecated autotools install (see $cref auto_tools$$) which was broken by the changes on 10-22. To be specific, the example for $cref number_skip$$ was not being included. @@ -188,7 +186,7 @@ $lend $head 10-16$$ -Fix bug in $cref/Tracing/WishList/Tracing/$$ $cref atomic$$ functions. +Fix bug in $cref/Tracing/wish_list/Tracing/$$ $cref atomic$$ functions. $head 10-15$$ The documentation for the class @@ -197,7 +195,7 @@ $head 10-14$$ The script $cref get_adolc.sh$$ was added (for downloading and installing -$href%https://projects.coin-or.org/ADOL-C%ADOL-C%$$) in the +$href%https://projects.coin-or.org/ADOL-C%ADOL-C%$$) in the $code build$$ directory. Note that this local install of Adolc requires ColPack; see $cref get_colpack.sh$$. @@ -205,7 +203,7 @@ with the same prefix was added. $head 10-13$$ -Make sure that all of the +Make sure that all of the $cref/preprocessor symbols/cppad/Preprocessor Symbols/$$, that are not part of the CppAD API, are undefined when the $code $$ file concludes. @@ -221,7 +219,7 @@ $lnext Fix following $code g++$$ error on OSX system: $codep -error: no match for 'operator|=' (operand types are +error: no match for 'operator|=' (operand types are 'std::vector::reference {aka std::_Bit_reference}' and 'bool') Check[i * n + j] |= F2[i * n + k] & r[ k * n + j]; ^ @@ -234,7 +232,7 @@ to both the definition and use of each operation. This required adding sub-headings in the example usages corresponding to the function documentation sections. -For example; see +For example; see $cref/atomic forward examples/atomic_forward/Examples/$$. $lnext Improve the documentation for $cref atomic_base_clear$$ @@ -246,9 +244,9 @@ $head 09-19$$ Add links from the $cref atomic_base$$ functions documentation to the corresponding examples. -This required adding headings in the examples that -correspond to the function documentation sections. -For example; see +This required adding headings in the examples that +correspond to the function documentation sections. +For example; see $cref/atomic forward examples/atomic_forward/Examples/$$. $head 09-18$$ @@ -267,7 +265,7 @@ $cref/2012-07-30/whats_new_12/07-30/$$ $lnext There was a bug during the -$cref/checking for nan/check_for_nan/$$ during +$cref/checking for nan/check_for_nan/$$ during $cref reverse$$ mode. This has been fixed. $lnext @@ -287,7 +285,7 @@ (which is used by $cref optimize$$ ) for $cref Forward$$ orders greater than zero. This was detected by the $cref checkpoint$$ tests -when $code optimize$$ was used to make the +when $code optimize$$ was used to make the checkpoint functions faster. The bug has been fixed and the checkpoint functions now use optimize (and hence should be faster). @@ -298,11 +296,11 @@ $cref Forward$$ mode results has been added; see $cref check_for_nan$$. $lnext Use this option to remove the need to handel $code nan$$ as a special -case in $cref checkpoint$$ functions that +case in $cref checkpoint$$ functions that $cref/atomic functions/optimize/Atomic Functions/$$ in within another function is optimized. $lnext -Check $cref/reverse/reverse_any/$$ mode results when +Check $cref/reverse/reverse_any/$$ mode results when $cref check_for_nan$$ is true. (It used to be the case that only $cref/forward/forward_order/$$ results were checked for $code nan$$.) @@ -317,7 +315,7 @@ with $cref/atomic functions/optimize/Atomic Functions/$$ has been added. $head 08-06$$ -Fix a case where the test $code test_more/limits.cpp$$ failed because +Fix a case where the test $code test_more/num_limits.cpp$$ failed because $codep double inf = std::numeric_limits::infinity(); double check = std::complex(inf) / std::complex(1.) @@ -331,9 +329,9 @@ $head 05-28$$ Remove $icode ok$$ return flag from -$cref/checkpoint algo/checkpoint/algo/$$ +$cref/checkpoint algo/checkpoint/algo/$$ and -$cref/checkpoint afun/checkpoint/afun/$$. +$cref/checkpoint atom_fun/checkpoint/atom_fun/$$. $head 05-21$$ $list number$$ @@ -367,7 +365,7 @@ The old checkpointing example is now the $cref reverse_any.cpp$$ example. $lnext Fix bug in $cref RevSparseJac$$ for case when $cref/q/RevSparseJac/q/$$ -was not equal to $icode m$$ (range dimension) and sparsity pattern was a +was not equal to $icode m$$ (range dimension) and sparsity pattern was a vector of $code bool$$. $lnext Add the $cref/transpose/RevSparseJac/transpose/$$ option to @@ -379,11 +377,11 @@ being run. This has been fixed. $head 05-11$$ -The $cref/old_atomic examples/old_atomic/Example/$$ +The $cref/old_atomic examples/old_atomic/Example/$$ names were all changed to begin with $code user$$. $head 05-04$$ -The option to compute +The option to compute $cref/multiple orders/forward_order/xq/Multiple Orders/$$ was added. The $cref old_usead_2.cpp$$ example shows the need for this. The problem is that a new atomic function interface needs to be designed @@ -393,11 +391,11 @@ $head 04-28$$ $list number$$ The scripts $cref get_eigen.sh$$ and $cref get_sacado.sh$$ were added. -If you are using Unix, and you do not have +If you are using Unix, and you do not have $href%http://eigen.tuxfamily.org%Eigen%$$ or -$href%http://trilinos.sandia.gov/packages/sacado%Sacado%$$ -installed on your system, you can use the corresponding script -to download and install a local copy for use when testing CppAD. +$href%http://trilinos.sandia.gov/packages/sacado%Sacado%$$ +installed on your system, you can use the corresponding script +to download and install a local copy for use when testing CppAD. $lnext The code $codei%std::cout << %X%$$, would generate a compile error when $icode X$$ was an Eigen matrix @@ -414,22 +412,22 @@ template struct significant_decimals_default_impl $$ -because the original template requires definition of a implicit conversion +because the original template requires definition of a implicit conversion from the scalar type to an $code int$$ and this is dangerous for AD types (note that $cref Integer$$ is used for explicit conversions). $head 04-26$$ $list number$$ -The example $cref old_usead_2.cpp$$ was completed. +The example $cref old_usead_2.cpp$$ was completed. This is a more realistic, but also more complicated, example of using AD to computed derivatives inside an atomic function. $lnext The script $cref get_fadbad.sh$$ has been added. -If you are using Unix, and you do not have +If you are using Unix, and you do not have $href%http://www.fadbad.com%FADBAD%$$ -installed on your system, you can use this script -to download and install a local copy for use when testing CppAD. +installed on your system, you can use this script +to download and install a local copy for use when testing CppAD. $lend $end @@ -439,10 +437,10 @@ $head 04-16$$ The script $cref get_ipopt.sh$$ has been added. -If you are using Unix, and you do not have -$href%http://www.coin-or.org/projects/Ipopt.xml%Ipopt%$$ -installed on your system, you can use this script -to download and install a local copy for use when testing CppAD. +If you are using Unix, and you do not have +$href%http://www.coin-or.org/projects/Ipopt.xml%Ipopt%$$ +installed on your system, you can use this script +to download and install a local copy for use when testing CppAD. $head 04-14$$ The following program, @@ -456,7 +454,7 @@ return 0; } $$ -It now generates the following message, +It now generates the following message, (when compiled without $cref/NDEBUG/faq/Speed/NDEBUG/$$)" $codep get_memory(min_bytes, cap_bytes): min_bytes is too large @@ -476,11 +474,11 @@ multi-threading $cref/initialization/multi_thread/Initialization/$$ list. $head 03-01$$ -Remove the $cref cmake$$ $code cppad_c11_flag$$ and instead +Remove the $cref cmake$$ $code cppad_c11_flag$$ and instead automatically detect if the compiler supports specific c++11 features. $head 02-27$$ -The test $cref limits.cpp$$ was failing during testing of Fedora-19; see +The test $cref num_limits.cpp$$ was failing during testing of Fedora-19; see $href%https://bugzilla.redhat.com/show_bug.cgi?id=913929% Bug 913929%$$. This has been fixed. @@ -504,19 +502,19 @@ $list number$$ The $cref limits$$ documentation was corrected an improved. $lnext -The $cref limits.cpp$$ example was simplified and restricted to just testing -for $code AD$$. +The $cref num_limits.cpp$$ example was simplified and restricted to just testing +for $code AD$$. $lnext Testing for types other than $code AD$$ -was moved to $code test_more/limits.cpp$$. -In addition, $code test_more/limits.cpp$$ was modified to avoid the +was moved to $code test_more/num_limits.cpp$$. +In addition, $code test_more/num_limits.cpp$$ was modified to avoid the use of guard digits (and hence test failure) on more machines. $lend $head 01-05$$ $list number$$ -The $cref limits.cpp$$ example was failing on some machines -because they were using guard digits during calculations. +The $cref num_limits.cpp$$ example was failing on some machines +because they were using guard digits during calculations. This has been fixed by using vectors instead of scalars for storing values. $lnext @@ -529,7 +527,7 @@ $head 01-02$$ $list number$$ A new stable version of CppAD, for 2013, was created -and its first release $code cppad-20130000.0$$ is available +and its first release $code cppad-20130000.0$$ is available for download at $pre $$ @@ -543,7 +541,7 @@ the following warning could be generated: $codei% %...%rev_sparse_jac.hpp:315:9: warning: unused variable 'm' [-Wunused-variable] -%$$ +%$$ This has been fixed. diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_14.omh cppad-2016.00.00.1/omh/whats_new/whats_new_14.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_14.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_14.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new_14.omh 3529 2014-12-30 15:36:27Z bradbell $ +$Id: whats_new_14.omh 3760 2015-12-01 04:12:28Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -79,7 +79,7 @@ %$$ and was failing to compile with the $code clang$$ complier. This example has been removed because it is not consistent with the -C++ standard; see +C++ standard; see $cref/complex FAQ/faq/Complex Types/$$. @@ -89,10 +89,9 @@ that were not being used; e.g., sub-tests that were not being executed. $lnext Fix $code cmake$$ setting -$cref/cppad_implicit_ctor_from_any_type/ - cmake/cppad_implicit_ctor_from_any_type -/$$. -Note that this option is deprecated and may eventually be removed. +$code cppad_implicit_ctor_from_any_type$$ +Note that this cmake option has since been replaced by +$cref/cppad_deprecated/cmake/cppad_deprecated/$$. $lnext The $code clang++$$ compiler was optimizing out the calculations in the $cref time_test.cpp$$ and $cref speed_test.cpp$$ examples. @@ -102,9 +101,9 @@ $lend $head 12-27$$ -More work on the bug in -$cref/optimizing/CondExp/Optimize/$$ -conditional expressions. +More work on the bug in +$cref/optimizing/CondExp/Optimize/$$ +conditional expressions. $head 12-26$$ A minimal example for computing cross terms in atomic operation @@ -112,11 +111,11 @@ $head 12-25$$ More work on the bug in -$cref/optimizing/CondExp/Optimize/$$ -conditional expressions. +$cref/optimizing/CondExp/Optimize/$$ +conditional expressions. $head 12-23$$ -The c++11 standard includes the error function $cref erf$$ in +The c++11 standard includes the error function $cref erf$$ in $code cmath$$. If the c++ compiler has the error function defined in $code cmath$$, the complier version of the error function is used and it corresponds to an @@ -128,14 +127,14 @@ $cref/Positive Orders/tan_reverse/Positive Orders Z(t)/$$. $head 12-22$$ -There was a bug related to -$cref/optimizing/CondExp/Optimize/$$ -conditional expressions. +There was a bug related to +$cref/optimizing/CondExp/Optimize/$$ +conditional expressions. This has been fixed. $head 12-17$$ Fix some compiler warnings and $cref speed$$ program names -when using the deprecated $cref/auto-tools/InstallUnix/$$ install procedure. +when using the deprecated $cref/auto-tools/auto_tools/$$ install procedure. $head 12-16$$ If the $code c++11$$ include file $code $$ @@ -153,13 +152,13 @@ $head 11-27$$ $list number$$ -Add alignment to the +Add alignment to the $cref/get_memory/ta_get_memory/Alignment/$$ and $cref/create_array/ta_create_array/Alignment/$$ specifications -and +and $cref/thread_alloc example/thread_alloc.cpp/$$. $lnext -Advance the deprecated $cref/unix install/InstallUnix/$$ utilities to +Advance the deprecated $cref/unix install/auto_tools/$$ utilities to autoconf-2.69 and automake-1.13.4. $lend @@ -170,7 +169,7 @@ $lnext Not properly following dependence back through atomic operations. $lnext -Aborting during forward order zero, when skipping computation for a variable +Aborting during forward order zero, when skipping computation for a variable that was already completed (the skip is still useful for higher orders and for reverse mode). $lnext @@ -182,20 +181,20 @@ $lend $head 09-27$$ -Fix a bug that occurred when +Fix a bug that occurred when $cref/f.optimize/optimize/$$ was used with a function $icode f$$ that contained calls to user defined $cref atomic$$ operations and $cref/conditional expressions/CondExp/$$. $head 09-25$$ -Fix a bug that occurred when +Fix a bug that occurred when $cref/f.optimize/optimize/$$ was used with a function $icode f$$ that contained $cref discrete$$ functions. $head 09-21$$ -Fix a typo in documentation for +Fix a typo in documentation for $cref/any order reverse/reverse_any/$$. -To be specific, $latex x^{(k)}$$ was changed to be $latex u^{(k)}$$. +To be specific, $latex x^{(k)}$$ was changed to be $latex u^{(k)}$$. $head 05-28$$ $list number$$ @@ -210,20 +209,20 @@ $head 05-27$$ $list number$$ -The $cref/cppad_colpack.cpp/colpack_prefix/cppad_colpack.cpp/$$ +The $code cppad_colpack.cpp$$ file was not being copied to the specified directory. In addition, the specified directory was changed from an include -directory to data directory -($code cppad_colpack.cpp$$ is not an include file). +directory to data directory because +$code cppad_colpack.cpp$$ is not an include file. $lnext -If $cref colpack_prefix$$ was specified, the CppAD +If $cref colpack_prefix$$ was specified, the CppAD $cref pkgconfig$$ file was missing some information. This has been fixed. $lend $head 05-23$$ The $cref speed$$ test instructions were converted from using -the old auto-tools $cref/unix install/InstallUnix/$$ instructions +the old auto-tools $cref/unix install/auto_tools/$$ instructions to use the $cref cmake$$ install instructions. These instructions should work on any system, not just unix. @@ -243,9 +242,9 @@ cppad_sparse_jacobian_size = [ 100, 400, 900, 1600, 2500 ] cppad_sparse_jacobian_rate = [ 6389, 954.26, 314.04, 180.06, 56.95 ] $$ -Due to the success of this change, other -$cref/multiple direction/WishList/Multiple Directions/$$ items -were added to the wish list. +Due to the success of this change, +$code multiple direction$$ items were added to the wish list +(they were later removed). $lnext Improve the forward mode tracing of arguments to, and results from, user defined $cref atomic$$ operations. @@ -253,11 +252,11 @@ $head 05-20$$ $list number$$ -Move $code speed/adolc/alloc_mat.hpp$$ to +Move $code speed/adolc/alloc_mat.hpp$$ to $code speed/adolc/adolc_alloc_mat.hpp$$ so it has the same name is its $code # ifndef$$ command. $lnext -Fix $code # ifndef$$ command in +Fix $code # ifndef$$ command in $code cppad/ipopt/solve_callback.hpp$$. $lnext Add $code # ifndef$$ command to $code test_more/extern_value.hpp$$. @@ -265,7 +264,7 @@ $head 05-19$$ -In the files +In the files $code cppad/local/asin_op.hpp$$ and $code cppad/local/acos_op.hpp$$ there were assignments of the form $code uj = 0.$$ where $code u_j$$ has type $cref/Base/glossary/Base Type/$$. @@ -274,29 +273,29 @@ $head 05-16$$ -There was a mistake in printing the arguments for +There was a mistake in printing the arguments for $code CSumOp$$ and $code CSkipOp$$ when using the undocumented -$code TRACE$$ option during forward mode (available in files of the form +$code TRACE$$ option during forward mode (available in files of the form $codei%cppad/local/%*%sweep.hpp/%$$). This has been fixed. $head 05-14$$ $list number$$ -There were some global variables in the file +There were some global variables in the file $code cppad/local/op_code.hpp$$ that might have caused multiple definitions -during link time for CppAD applications. +during link time for CppAD applications. These variables have been changed to be local so that this cannot happen. $lnext -There was a mistaken assert that the number of arguments for the +There was a mistaken assert that the number of arguments for the $code BeginOp$$ was zero that caused an abort when using the undocumented -$code TRACE$$ option available in files of the form +$code TRACE$$ option available in files of the form $codei%cppad/local/%*%sweep.hpp/%$$. This has been fixed. $lend $head 03-18$$ $list number$$ -The +The $cref/size_taylor/FunDeprecated/size_taylor/$$ and $cref/capacity_taylor/FunDeprecated/capacity_taylor/$$ @@ -304,14 +303,14 @@ use $cref size_order$$ and $cref capacity_order$$ instead. $lnext The documentation for $cref forward$$ and the examples -$cref forward.cpp$$, $cref forward_order.cpp$$, have been improved. +$cref forward.cpp$$, $cref forward_order.cpp$$, have been improved. To be more specific, $cref forward_order$$ now references the special cases $cref forward_zero$$, $cref forward_one$$ and the new case $cref forward_two$$. $lend $head 03-17$$ -The +The $cref/move semantics/CppAD_vector/Assignment/Move Semantics/$$ version of the $code CppAD::vector$$ assignment statement was not checking vector sizes. @@ -324,24 +323,24 @@ The documentation links $code forwardzero$$, $code forwardone$$, and $code forwardany$$ have been changed to -$cref forward_zero$$, $cref forward_one$$, +$cref forward_zero$$, $cref forward_one$$, and $cref forward_order$$ respectively. This may affect links from other web pages to the CppAD documentation. $head 03-05$$ -The names $icode p$$ and $icode q$$ in the +The names $icode p$$ and $icode q$$ in the $cref/forward/forward_order/$$, $cref/reverse/reverse_any/$$, -$cref atomic_forward$$, and +$cref atomic_forward$$, and $cref atomic_reverse$$ functions -were reverse so that $icode%p% <= %q%$$. +were reverse so that $icode%p% <= %q%$$. This is only a notational change to make the arguments easier to remember. $head 03-02$$ $list number$$ In the output for the speed $cref/correct/speed_main/test/correct/$$ test, -mention which tests are not available. +mention which tests are not available. Note that the set of available tests can depend on the $cref/list of options/speed_main/option_list/$$. $lnext @@ -351,7 +350,7 @@ $cref/color_method/sparse_jacobian/work/color_method/$$. $lnext The $cref speed_cppad$$ tests were simplified by removing the printing -of auxillary information related to the +of auxillary information related to the $cref/optimize/speed_main/option_list/optimize/$$ option. Future auxillary information will be passed back in a manner similar to $cref/n_sweep/link_sparse_jacobian/n_sweep/$$ for the sparse jacobian test. @@ -362,7 +361,7 @@ $head 03-01$$ $list number$$ -Change the prototype for $icode row$$ and $icode col$$ in the +Change the prototype for $icode row$$ and $icode col$$ in the $cref link_sparse_jacobian$$ speed test to be $code const$$; i.e., they are not changed. $lnext @@ -377,13 +376,13 @@ $head 02-27$$ The CppAD developer documentation for the subdirectory -$code cppad/ipopt$$ was not being built by the command -$code bin/run_doxygen.sh$$. +$code cppad/ipopt$$ was not being built by the command +$code bin/run_doxygen.sh$$. This has been fixed. $head 02-26$$ $list number$$ -The +The $cref/adolc/speed_adolc/$$ and $cref/cppad/speed_cppad/$$ sparse jacobian speed tests now print out $cref/n_sweep/sparse_jacobian/n_sweep/$$. @@ -400,10 +399,10 @@ $head 02-23$$ The $cref/color_method/sparse_jacobian/work/color_method/$$ option was added to the sparse Jacobian calculations. -This enables one to use $cref/ColPack/colpack_prefix/$$ +This enables one to use $cref/ColPack/colpack_prefix/$$ do color the rows or columns. -The speed test $cref/colpack/speed_main/Sparsity Options/colpack/$$ option -was also added (but not yet implemented for +The speed test $cref/colpack/speed_main/Sparsity Options/colpack/$$ option +was also added (but not yet implemented for $cref/sparse_hessian/link_sparse_hessian/$$ speed tests). @@ -414,7 +413,7 @@ where $icode threading$$ is $code openmp$$, $code pthread$$ or $code bthread$$. $head 02-17$$ -Fix ambiguous call to $cref/isnan/nan/isnan/$$ +Fix ambiguous call to $cref/isnan/nan/isnan/$$ during MS Visual Studio 2012 compilation. $head 02-15$$ @@ -422,10 +421,10 @@ The $cref/boolsparsity/speed_main/Sparsity Options/boolsparsity/$$ option was added to the $cref speed_main$$ program. $lnext -The $code retape$$ option what changed to +The $code retape$$ option what changed to $cref/onetape/speed_main/option_list/onetape/$$ so that the default is to retape (option not present). -This was done because +This was done because $cref/fadbad/fadbad_prefix/$$ and $cref/sacado/sacado_prefix/$$ always retape. $lnext @@ -433,7 +432,7 @@ $cref/options/speed_main/option_list/$$ was improved (made clearer). $lnext -Improve the success rate for +Improve the success rate for $cref speed_test.cpp$$ and $cref time_test.cpp$$. $lend @@ -451,7 +450,7 @@ -D cppad_documentation=%yes_or_no% %$$ which has been removed. - + $head 01-21$$ The destination directory for the cppad documentation diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new_15.omh cppad-2016.00.00.1/omh/whats_new/whats_new_15.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new_15.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new_15.omh 2016-02-09 08:31:49.000000000 +0000 @@ -0,0 +1,926 @@ +$Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +$begin whats_new_15$$ +$dollar @$$ +$spell + addon + runge + lcppad + ind + const + enum + ctor + dimensioned + cskip_op + adolc + zdouble + expm1 + eigen + expm1 + atanh + acosh + asinh + src + op + onetape + CppAD + colpack + hes + cppad + Jacobian + gettimeofday + cmake + hpp + dir + includedirs + libdirs + datadir + docdir + std + cxx + erf + var + NumRes + chrono + aeps + CondExpGt + hasnan + Adolc + resize + bool + alloc + adouble + gmtime + asctime + ipopt + fadbad + sacado + unreferenced + azmul + retape +$$ + +$section CppAD Changes and Additions During 2015$$ + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2015 +(in reverse order by date). +The purpose of this section is to +assist you in learning about changes between various versions of CppAD. + +$head 12-29$$ +Separate $cref to_string$$ from $cref ad_to_string$$ so that it +can be used without the rest of CppAD; i.e., +by including +$codei% + # include +%$$ + + +$head 12-28$$ +$list number$$ +Add the $cref to_string$$ utility. +$lnext +Add $cref base_to_string$$ to the Base type requirements. +$lnext +A $cref/Base requirements/wish_list/Base Requirements/$$ item +was added to the wish list. +$lnext +The $cref wish_list$$ item to +reorganize the include directory has been removed. +It was completed when the utilities was moved to $code cppad/utility$$; see +$cref/11-30/whats_new_15/11-30/$$. +$lend + +$head 12-08$$ +$list number$$ +A convention was included for addon +$cref/library files/addon/Library Files/$$. +$lnext +Change new $cref utility$$ specifications to allow for individual file +includes; e.g., $code $$. +$lend + +$head 12-01$$ +Fix problem with $cref auto_tools$$ install handling of the +deprecated files. +This included changing the auto-tools +$code --with-implicit_ctor$$ option to +$cref/--with-deprecated/auto_tools/--with-deprecated/$$. + +$head 11-30$$ +$list number$$ +The $code library$$ section has been moved to the +$cref/utilities/utility/$$ section. +In addition, the corresponding source code files in $code cppad$$ +have been moved to $code cppad/utility$$. +$lnext +The individual $cref utility$$ include files have been deprecated; see +$cref include_deprecated$$. +For example, +$codep + # include +$$ +You should us the utility include instead; i.e., +$codep + # include +$$ +$lnext +The $cref numeric_ad$$ routines where moved from the $code library$$ +the a separate documentation section. +$lnext +Change $code cmake_install_prefix$$ to +$cref/cppad_prefix/cmake/cppad_prefix/$$ and +Change $code cmake_install_postfix$$ to +$cref/cppad_postfix/cmake/cppad_postfix/$$. +$lnext +Change $code cppad_implicit_ctor_from_any_type$$ to +$cref/cppad_deprecated/cmake/cppad_deprecated/$$ and +change its specifications to refer to all deprecated features. +$lend + +$head 11-25$$ +$list number$$ +CppAD now installs the object library +$codep + -lcppad_lib +$$ +to be included when linking. +Currently, it is only required when +$cref colpack_prefix$$ is specified on the +$cref/cmake command/cmake/CMake Command/$$. +$lnext +It is no longer necessary to compile and link the file +$codep + cppad_colpack.cpp +$$ +when $cref colpack_prefix$$ +is specified during the install process; see +$cref/cmake command/cmake/CMake Command/$$. +(It is included in $code cppad_lib$$). +$lend + +$head 11-24$$ +$list number$$ +The $code check_for_nan$$ output now includes the first dependent +variable +$cref/index/check_for_nan/Error Message/index/$$ +that is $code nan$$ in its error message. +$lnext +Change the +$cref/deprecated include/include_deprecated/$$ reference $code pow_int.h$$ +to $code pow_int.hpp$$ in $cref pow_int$$. +$lend + +$head 11-14$$ +There was a bug in the new +$cref/get_check_for_nan/check_for_nan/get_check_for_nan/$$ +feature that writes independent variable values to a temporary file; +see $cref/11-06/whats_new_15/11-06/$$ below. +This has been fixed. + + +$head 11-08$$ +$list number$$ +Fixed a bug in the $cref RevSparseJac$$ routine. +To be specific, the argument $cref/r/RevSparseJac/r/$$ +was transposed from what the documentation said. +(This has no effect in the usual case where $icode r$$ is the identity.) +$lnext +Added the $cref bool_sparsity.cpp$$ examples which show how +to conserve memory when computing sparsity patterns. +$lnext +Modified the $cref ipopt_solve$$ procedure to take +advantage of the memory conserving sparsity pattern calculations +when $cref/retape/ipopt_solve/options/Retape/$$ is false. +$lnext +Added the $cref/bit_per_unit/CppAD_vector/vectorBool/bit_per_unit/$$ +function to the $code vectorBool$$ class. +(This aids the memory conservation mentioned above.) +$lend + + +$head 11-06$$ +It is often difficult to determine what cause a $code nan$$ result +during an operation with an $cref ADFun$$ object. +The new feature +$cref/get_check_for_nan/check_for_nan/get_check_for_nan/$$ was +added to make this easier. + +$head 10-21$$ +There was a mistake in the documentation for $cref index_sort$$, +the argument $cref/ind/index_sort/ind/$$ is not $code const$$. + +$head 10-16$$ +Add a $cref/PrintFor optimization/wish_list/PrintFor Optimization/$$ +item to the wish list. + +$head 10-06$$ +$list number$$ +Add +$cref/CPPAD_USE_CPLUSPLUS_2011 + /preprocessor + /Documented Here + /CPPAD_USE_CPLUSPLUS_2011 +/$$, +$code CPPAD_NUMERIC_LIMITS$$, and +$code CPPAD_STANDARD_MATH_UNARY$$, to +the $cref preprocessor$$ section. +In addition, remove checking that all user API preprocessor symbols +are in this section form the $cref wish_list$$. +$lnext +Alphabetize and make some corrections to +$cref/list of examples/ListAllExamples/$$. +$lnext +The documentation for some of the $cref deprecated$$ features +was missing the date when they were deprecated. +This has been fixed; e.g., see +$cref/Deprecated 2012-12-26/auto_tools/Deprecated 2012-12-26/$$. +$lend + + +$head 10-04$$ +$list number$$ +$cref base_require$$: +Add the macro +$cref/CPPAD_NUMERIC_LIMITS/base_limits/CPPAD_NUMERIC_LIMITS/$$ +to aid in setting the numeric limits for a user defined $icode Base$$ class. +$lnext +$cref base_require$$: +The $cref/quiet_NaN/numeric_limits/quiet_NaN/$$ function has been added +to the CppAD $code numeric_limits$$. +Note the reason for not using +$cref/std::numeric_limits/numeric_limits/std::numeric_limits/$$. +$lnext +The $cref/nan(zero)/nan/nan(zero)/$$ function computes a $code nan$$ by +dividing zero by zero which results in a warning when using some compilers. +This function has been deprecated and the corresponding +$cref wish_list$$ item has been removed. +$lnext +Move documentation for $cref zdouble$$ to $cref deprecated$$ section +and documentation for $cref numeric_limits$$ to $cref ADValued$$. +$lnext +Remove all uses of, and references to, +$cref zdouble$$ from the $cref/examples/Example/$$. +$lend + +$head 10-03$$ +$cref base_require$$: +It is no longer necessary to define the specialization for +$codei%CppAD::epsilon<%Base>()%$$ for each $icode Base$$ type. + +$head 10-02$$ +There was a bug in $code test_more/azmul.cpp$$ whereby the vector +$code z$$ had the wrong dimension (in two places). This has been fixed. + +$head 09-28$$ +$list number$$ +Use the current $cref atomic_option$$ setting to determine +which type of sparsity patterns to use for +$cref/dependency/dependency.cpp/$$ calculations during +$cref optimize$$ procedure. +It used to be that the +$cref/bool_sparsity_enum/atomic_option/atomic_sparsity/bool_sparsity_enum/$$ +was used when +$cref/pack_sparsity_enum/atomic_option/atomic_sparsity/pack_sparsity_enum/$$ +was specified. +$lnext +It is not longer an error to take the derivative of the square root function, +because the result may be the part of a +$cref/conditional expression/CondExp/$$ that is not used. +$lnext +Update the $cref wish_list$$ section. +$lend + + +$head 09-27$$ +$list number$$ +It is no longer necessary to use the $cref zdouble$$ class when +computing with $cref/multiple levels of AD/mul_level/$$ +$cref/conditional expressions/CondExp/$$ and +$cref/reverse mode/reverse/$$. +$lnext +The $code zdouble$$ class has been deprecated. +Use the $cref azmul$$ function for absolute zero (when it is needed). +$lend + +$head 09-25$$ +$cref base_require$$: +$cref/absolute zero multiplication/base_require/Absolute Zero, azmul/$$ +is now required for user defined base types. +This makes it possible to combine +$cref/conditional expression/CondExp/$$, +$cref/multiple levels/mul_level/$$, +$cref/reverse/Reverse/$$, and +a base type that has standard ieee multiplication; e.g., $code double$$. +In other words, not all multiplications will need to have an +absolute zero (as is the case with the $cref zdouble$$ base class. + +$head 09-24$$ +Fix some Visual Studio 2013 C++ level four $code /W4$$ warnings +(previous warnings were are level 3). +In addition, disable warning +$code 4100$$ unreferenced formal parameter, +and warning +$code 4127$$ conditional expression is constant. + +$head 09-23$$ +CppAD can optionally test its use with the external packages +$cref/eigen/get_eigen.sh/$$, +$cref/ipopt/get_ipopt.sh/$$, and +$cref/colpack/get_colpack.sh/$$. +In addition, it can compare its $cref speed$$ with the external AD packages +$cref/adolc/get_adolc.sh/$$, +$cref/fadbad/get_fadbad.sh/$$, and +$cref/sacado/get_sacado.sh/$$. +The scripts that download and install a local copy of these external packages +have been modified to automatically skip installation +when it has already been done. + +$head 09-21$$ +Improve discussion of +$cref/windows download and testing + /download + /Compressed Archives + /Windows File Extraction and Testing +/$$. + +$head 09-20$$ +$list number$$ +Add the $cref/cppad_profile_flag/cmake/cppad_profile_flag/$$ +to the list of possible $code cmake$$ command arguments. +$lnext +More of the warnings generated by Visual Studio 2013 have been fixed. +One remaining warning is about $code asctime$$ and $code gmtime$$ not being +thread safe. +$lend + +$head 09-19$$ +$list number$$ +There was a bug in the $cref/numeric_limits/base_alloc.hpp/numeric_limits/$$ +section of the example user defined base type. +This has been fixed. +$lnext +There were some compile and link errors when +running the tests using Visual Studio 2013. +These have been fixed. +$lnext +Many of the warnings generated by Visual Studio 2013 have been fixed. +$lend + +$head 09-16$$ +The conditional expressions, $cref CondExp$$, were not working +for the type $code< CppAD::AD >$$ where $code adouble$$ +is the ADOL-C AD type. +This has been fixed by adding a call to +$cref/CPPAD_COND_EXP_REL/base_adolc.hpp/CondExpRel/$$ in +$code base_adolc.hpp$$. + +$head 09-03$$ +$list number$$ +There was a bug in the $cref/vectorBool/CppAD_vector/vectorBool/$$ +$cref/assignment/CppAD_vector/Assignment/$$. +To be specific, +it not allow a size zero vector to be assigned using a vector any other size. +This has been fixed. +$lnext +The addition of the +$cref/pack/atomic_option/atomic_sparsity/pack_sparsity_enum/$$ option +on 08-31 introduced a bug in the calculation of $cref RevSparseHes$$. +The $cref checkpoint.cpp$$ example was changed to demonstrate this +problem and the bug was fixed. +$lend + +$head 09-02$$ +The $cref/dependency pattern/dependency.cpp/Dependency Pattern/$$ +was not being computed correctly for the +$cref sign$$, $cref Discrete$$, and $cref VecAD$$ operations. +This has been fixed. +This could have caused problems using +$cref checkpoint$$ functions that used any of these operations. + +$head 08-31$$ +$list number$$ +Mention the fact that using checkpoint functions can make +$cref/recordings faster/checkpoint/Purpose/Faster Recording/$$. +$lnext +Add the +$cref/pack/atomic_option/atomic_sparsity/pack_sparsity_enum/$$ +sparsity option for $cref atomic_base$$ operations. +$lnext +Add the pack sparsity option to +$cref/checkpoint/checkpoint/sparsity/$$ functions. +$lnext +Added the $cref atomic_sparsity.cpp$$ example. +$lnext +Remove mention of OpenMP from $cref/thread_alloc::thread_num/ta_thread_num/$$ +($cref thread_alloc$$ never was OpenMP specific). +$lend + +$head 08-30$$ +$list number$$ +The $cref/sparsity/atomic_ctor/atomic_base/sparsity/$$ +argument was added to the $code atomic_base$$ constructor and the +$cref/checkpoint/checkpoint/sparsity/$$ constructor. +$lnext +Make $cref atomic_norm_sq.cpp$$ an example with no set sparsity +and $cref atomic_reciprocal.cpp$$ an example with no bool sparsity. +$lnext +Improve discussion of $code Independent$$ and +$cref/parallel mode/Independent/Parallel Mode/$$. +$lend + +$head 08-29$$ +Some asserts in the $cref checkpoint$$ implementation were not using +the CppAD $cref ErrorHandler$$. This has been fixed. + +$head 08-28$$ +Free $cref checkpoint$$ function sparsity patters during +$cref forward$$ operations that use its atomic operation. +(They kept between sparsity calculations because they do not change.) + +$head 08-26$$ +Fix a bug in $cref RevSparseJac$$ when used to compute sparsity pattern +for a subset of the rows in a $cref checkpoint$$ function. + +$head 08-25$$ +Reduce the amount of memory required for $cref checkpoint$$ functions +(since sparsity patterns are now being held so they do not need to be +recalculated). + +$head 08-20$$ +Added an example that computes the sparsity pattern for a subset +of the $cref/Jacobian/sparsity_sub.cpp/ForSparseJac/$$ and a subset +of the $cref/Hessian/sparsity_sub.cpp/RevSparseHes/$$. + +$head 08-17$$ +$list number$$ +Do some optimization of the +$cref checkpoint$$ feature so that sparsity patterns are +stored and not recalculated. +$lnext +Fix a warning (introduced on 08-11) where the $code CppAD::vector$$ +$cref/data/CppAD_vector/data/$$ function was being shadowed by +a local variable. +$lnext +The source code control for CppAD has a link to $code compile$$, +instead of real file. +This sometimes caused problems with the +deprecated $cref auto_tools$$ install procedure and has been fixed. +$lend + +$head 08-16$$ +$list number$$ +Improve the documentation for checkpoint functions. +To be specific, change the $cref/syntax/checkpoint/Syntax/$$ to use +the name $icode atom_fun$$. +In addition, include the fact that $icode atom_fun$$ must not +be destructed for as along as the corresponding atomic operations are used. +$lnext +Add the $cref/size_var/checkpoint/size_var/$$ function +to the checkpoint objects. +$lend + + +$head 08-09$$ +Add the preservation of data to the specifications of a $code CppAD::vector$$ +during a $cref/resize/CppAD_vector/resize/$$ when the +capacity of the vector does not change. +In addition, added and example of this to $cref cppad_vector.cpp$$. + +$head 08-06$$ +The $cref zdouble$$ +$cref/numeric_limits/base_limits/$$ +were not being computed properly. +This has been fixed. + +$head 07-31$$ +Added the $cref sparse_sub_hes.cpp$$ example, +a way to compute the sparsity for a subset of variables without +using $cref/multiple levels of AD/mul_level/$$. + +$head 06-16$$ +$list number$$ +There were some +$cref/unknown/cppad_assert/Unknown/$$ asserts +when the sparsity pattern $icode p$$ in +$cref/sparse_jacobian/sparse_jacobian/p/$$ and +$cref/sparse_hessian/sparse_hessian/p/$$ was not properly dimensioned. +These have been changed to +$cref/known/cppad_assert/Known/$$ asserts to give better +error reporting. +$lnext +In the special case where sparse Hessian $cref/work/sparse_hessian/work/$$ or +sparse Jacobian $cref/work/sparse_hessian/work/$$ was specified and the +set of elements to be computed was empty, the work vector is empty after +the call (and it appears to need to be calculated on subsequent calls). +This resulted in a bug when the sparsity pattern was not provided +on subsequent calls (and has been fixed). +$lend + +$head 06-11$$ +$list number$$ +Some C++11 features were not being taken advantage of after the change on +$cref/05-10/whats_new_15/05-10/$$. To be specific, move semantics, +the high resolution clock, and null pointers. +This has been fixed. +$lnext +In the example $cref zdouble.cpp$$, the vector $code a1z$$ was not +properly dimensioned. +This has been fixed and the dimensions of all the variables have been +clarified. +$lend + + +$head 06-09$$ +Add an $cref/abort_op_index/Independent/abort_op_index/$$ +item to the wish list. It has since been removed +(domain errors may not affect the results due to +$cref/conditional expressions/CondExp/$$). + + +$head 06-07$$ +Add a $cref/absolute zero/base_require/Absolute Zero, azmul/$$ item +and a $cref numeric_limits$$ item to the wish list. +The absolute zero item has been completed and the +numeric limit item was modified on implementation. +Remove the multiple directions with list item. + +$head 05-26$$ + +$subhead cond_exp_1$$ +There was a problem using +$cref/conditional expressions/CondExp/$$ +with $cref/multiple levels of AD/mul_level/$$ where +the result of the conditional expression might not be determined +during forward mode. +This would generate an assert of the form: +$codei% + Error detected by false result for + IdenticalPar(%side%) + at line %number% in the file + %...%/cppad/local/cskip_op.hpp +%$$ +where $icode side$$ was $code left$$ or $code right$$ +and $icode number$$ was the line number of an assert in $code cskip_op.hpp$$. +This has been fixed. + +$subhead cond_exp_2$$ +There was a problem with using +$cref/conditional expressions/CondExp/$$ and $cref/reverse mode/reverse/$$ +with $cref/multiple levels of AD/mul_level/$$. +This was problem was represented by the file $code bug/cond_exp_2.sh$$. + +$list number$$ +The problem above has been fixed by adding the base type $code zdouble$$, see +$cref/CppAD motivation/zdouble/Motivation/CppAD/$$ for this new type. +(It is no longer necessary to use $code zdouble$$ to get an absolute zero +because CppAD now uses $cref azmul$$ where an absolute zero is required.) +$lnext +The sections +$cref mul_level$$, +$cref change_param.cpp$$, +$cref mul_level.cpp$$, +and $cref mul_level_ode.cpp$$ were changed to use $cref zdouble$$. +$lnext +The $cref/adolc/adolc_prefix/$$ multi-level examples +$cref mul_level_adolc.cpp$$ and $cref mul_level_adolc_ode.cpp$$ +were changed to mention the limitations because Adolc does not have an +$cref/absolute zero/zdouble/Absolute Zero/$$. +$lnext +The example above were also changed so that AD variable names that +indicated the level of AD for the variable. +$lnext +$cref base_require$$: +The base type requirements were modified to include mention of +$cref/absolute zero/base_require/Absolute Zero, azmul/$$. +In addition, the base type requirements +$cref/API warning/base_require/API Warning/$$ is now more informative. +$lend + +$head 05-11$$ +Reorganize the $cref unary_standard_math$$ documentation. + +$head 05-10$$ +$list number$$ +Add the exponential minus one function $cref log1p$$. +$lnext +$cref base_require$$: +If you are defining your own base type, +note that $cref/log1p/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ +was added to the base type requirements. +$lnext +Use the single preprocessor flag +$code CPPAD_USE_CPLUSPLUS_2011$$ to signal that the functions +$cref/erf, asinh, acosh, atanh, expm1, log1p + /base_std_math + /erf, asinh, acosh, atanh, expm1, log1p +/$$ +are part of the base type requirements. +$lend + +$head 05-09$$ +$list number$$ +Add the exponential minus one function $cref expm1$$. +If you are defining your own base type, +note that $cref/expm1/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ +was added to the base type requirements. +$lnext +Fix some warnings about comparing signed and unsigned integers +when using $cref/eigen/cppad_testvector/eigen/$$ for the CppAD test vector. +(The eigen vector $code size()$$ function returns an $code int$$ instead of a +$code size_t$$.) +$lend + +$head 05-08$$ +$list number$$ +Add the inverse hyperbolic sine function $cref atanh$$. +If you are defining your own base type, +note that $cref/atanh/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ +was added to the base type requirements. +$lnext +Fix a bug in the implementation of the $code acosh$$ +multiple direction forward mode $cref forward_dir$$ +(when compiler has $cref/acosh/acosh/CPPAD_USE_CPLUSPLUS_2011/$$). +$lend + +$head 05-07$$ +Add the inverse hyperbolic sine function $cref acosh$$. +If you are defining your own base type, +note that $cref/acosh/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ +was added to the base type requirements. + +$head 05-05$$ +Add the inverse hyperbolic sine function $cref asinh$$. +If you are defining your own base type, +note that $cref/asinh/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ +was added to the base type requirements. + +$head 04-18$$ +In the sparse jacobian and sparse hessian calculations, +If $icode work$$ is present, and has already been computed, +the sparsity pattern $icode p$$ is not used. +This has been added to the documentation; see +$cref/sparse jacobian/sparse_jacobian/work/p/$$ and +$cref/sparse hessian/sparse_hessian/work/p/$$ documentation +for $icode work$$ and $icode p$$. + +$head 03-13$$ +Remove the syntax +$codei% + AD<%Base%> %y% = %x% +%$$ +for the $cref/AD constructor/ad_ctor/$$ documentation because it does not +work when the constructor is $cref/explicit/ad_ctor/x/explicit/$$. +Also document the restriction that the constructor in the +$cref/assignment/ad_assign/$$ must be implicit. + +$head 03-06$$ +The developers of the +$href%https://github.com/kaskr/adcomp%TMB%$$ package reported that +for large $cref ADFun$$ tapes, the $cref optimize$$ routine uses +a large amount of memory because it allocates a standard set for +each variable on the tape. These sets are only necessary for variables in +$cref/conditional expressions/condexp/$$ that can be skipped once +the independent variables have a set value. +The problem has been reduced by using a NULL pointer for the empty set +and similar changes. It still needs more work. + +$head 02-28$$ +It used to be the case that the +$cref/Reverse mode/reverse/$$ would propagate $cref nan$$ +through the $cref/conditional expression/condexp/$$ +case that is not used. +For example, if +$codep + Independent(ax); + AD aeps = 1e-10; + ay[0] = CondExpGt( ax[0], aeps, 1.0/ax[0], 1.0/aeps ); + ADFun f(ax, ay); +$$ +The corresponding reverse mode calculation, +at $code x[0] = 0.0$$, would result in +$codep + Error detected by false result for + ! ( hasnan(value) && check_for_nan_ ) +$$ +This has been fixed so that only the conditional expression case that is used +affects the reverse mode results. +The example $cref cond_exp.cpp$$ was changed to reflect this +(a check for $code nan$$ was changed to a check for zero). +Note that this fix only works when +$cref/IdenticalPar/base_identical/Identical/IdenticalPar/$$ is true for the +base type of the result in the conditional expression; e.g., +one can still get a $code nan$$ effect from the case that is not selected +when using $code AD< AD >$$ conditional expressions. + +$head 02-18$$ +If the compiler supports the c++11 feature +$code std::chrono:high_resolution_clock$$ then use it for +the $cref elapsed_seconds$$ function. + +$head 02-16$$ +The new example $cref sub_sparse_hes.cpp$$ shows one way to +compute a Hessian for a subset of variables without having to compute +the sparsity pattern for the entire functions. + +$head 02-14$$ +Fix another bug in the derivative calculations for the +c++11 version of the error function; see +$cref/CPPAD_USE_CPLUSPLUS_2011/erf/CPPAD_USE_CPLUSPLUS_2011/$$. + +$head 02-11$$ +Fix a bug in the optimization of conditional expressions. To be specific, +if $cref/NDEBUG/faq/Speed/NDEBUG/$$ is not defined, one could get +an assert with the message: +$codep + Error detected by false result for + var_index_ >= NumRes(op_) +$$ + +$head 02-10$$ +The change on $cref/2014-12-23/whats_new_14/12-23/$$ introduced a +bug when the c++11 version of the error function was used with +an $cref/optimized/optimize/$$ function. see +$cref/CPPAD_USE_CPLUSPLUS_2011/erf/CPPAD_USE_CPLUSPLUS_2011/$$. +There was also a bug in the sparsity calculations for when +this erf function was included. +These bugs have been fixed. + +$head 02-09$$ +The test $code test_more/optimize.cpp$$ was failing on some systems +because an exactly equality check should have been a near equal check. +This has been fixed. + +$head 02-07$$ +On some systems, the library +corresponding to $code speed/src$$ could not be found. +This library is only used for testing and so has been changed to always be +static (hence does not need to be found at run time). + +$head 02-06$$ +There was a bug in the coloring method change on +$cref/2015-01-07/whats_new_15/01-07/$$. +To be specific, $icode%work%.color_method%$$ was not being set +to $code "cppad.symmetric"$$ after $icode%work%.color_method.clear()%$$. +This has been fixed. + +$head 02-04$$ +$list number$$ +Enable the same install of CppAD to be used both with and without C++11 +features; e.g., with both $code g++ --std=c++11$$ and with +$code g++ --std=c++98$$. Previously if the +$cref/cppad_cxx_flags/cmake/cppad_cxx_flags/$$ specified C++11, +then it could only be used in that way. +$lnext +The $cref/cmake command/cmake/CMake Command/$$ now requires the version +of $code cmake$$ to be greater than or equal 2.8 +(due a bug in $code cmake$$ version 2.6). +$lend + +$head 02-03$$ +Improved the searching for the boost multi-threading library +which is used for by the $cref team_bthread.cpp$$ case of the +$cref thread_test.cpp$$ example and test. + +$head 02-02$$ +Improve the documentation for the +$cref/cmake command/cmake/CMake Command/$$ line options +$codei% + cmake_install_%dir% +%$$ +for $icode dir$$ equal to +$code prefix$$, $code postfix$$, $code includedirs$$, $code libdirs$$, +$code datadir$$, and $code docdir$$. + +$head 01-30$$ +Fix bug in $cref link_sparse_hessian$$ speed test introduced on +$cref/01-09/whats_new_15/01-09/$$ below. + +$head 01-29$$ +Fix some warnings generated by $code g++ 4.9.2$$. + +$head 01-26$$ +The change of global variables to local in +$code cppad/local/op_code.hpp$$ on $cref/2014-50-14/whats_new_14/05-14/$$ +created a bug in $cref parallel_ad$$ (some local statics needed to +be initialized). This has been fixed. + +$head 01-23$$ +There was a bug in the $cref cmake$$ install detection of compiler features. +One symptom of this bug was that on systems that had the $code gettimeofday$$ +function, the cmake install would sometimes report +$codei% + cppad_has_gettimeofday = 0 +%$$ +This has been fixed. + +$head 01-21$$ +The deprecated $cref auto_tools$$ procedure had a bug in the +detection of when the size of an $code unsigned int$$ +was the same as the size of a $code size_t$$. This has been fixed. + +$head 01-20$$ +$list number$$ +The new $cref compare_change$$ interface has been created +and the old $cref CompareChange$$ function has been deprecated; +see the $cref compare_change.cpp$$ example. +This enables one to determine the source code during taping +that corresponds to changes in the comparisons during +$cref/zero order forward/forward_zero/$$ operations; see +$cref/abort_op_index/Independent/abort_op_index/$$. + +$lnext +This new $cref compare_change$$ interface can detect comparison changes +even if $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined and +even if $cref/f.optimize()/optimize/$$ has been called. +The deprecated function $code CompareChange$$ used to always return zero after +$codei% + %f%.optimize() +%$$ +and was not even defined when $code NDEBUG$$ was defined. +There was a resulting speed effect for this; see the wish list +$cref/compare change/wish_list/Comparison Changes and Optimization/$$ entry. + +$lnext +The date when some features where deprecated has been added to the +documentation. For example, see +$cref/Deprecated 2006-12-17/include_deprecated/Deprecated 2006-12-17/$$. +$lend + +$head 01-09$$ +$list number$$ +The change 01-07 below included (but did not mention) using +a sparse, instead of full, structure for the Hessian in the test. +This has also been done for the +$cref/sparse Jacobian/link_sparse_jacobian/$$ test. +$lnext +For both the +$cref/sparse_jacobian/link_sparse_jacobian/$$ and +$cref/sparse_hessian/link_sparse_hessian/$$ tests, +the sparse function is only chosen once +(it used to be different for every repeat). +This reduced the amount of computation not connected what is being tested. +It also make the $cref/onetape/speed_main/option_list/onetape/$$ a valid +option for these tests. +$lnext +There was a bug in the +$cref/multiple direction forward/forward_dir/$$ routine. +Results for function values that are +$cref/parameter/parvar/$$ were not being computed properly +(all the derivatives are zero in this case). +This has been fixed. +$lend + + +$head 01-07$$ +The following changes were merged in from the $code color_hes$$ branch: +$list number$$ +Specify the type of +$cref/coloring/sparse_hessian/work/color_method/$$ +for the sparse hessian calculations. +To be specific, instead of $code "cppad"$$ and $code "colpack"$$, +the choices are $code "cppad.symmetric"$$, $code "cppad.general"$$, +and $code "colpack.star"$$. +This is not compatible with the change on +$cref/01-02/whats_new_15/01-02/$$, which was so recent +that this should not be a problem. +$lnext +The $cref/n_sweep/link_sparse_hessian/n_sweep/$$ values were +not being returned properly by +$cref cppad_sparse_hessian.cpp$$ and +$cref adolc_sparse_hessian.cpp$$. +The CppAD version has been fixed and the ADOL-C version +has been set to zero. +$lnext +The $cref link_sparse_hessian$$ example case was to sparse for good +testing (by mistake). +This has been fixed. +$lnext +Add $icode n_sweep$$ to +$cref/link_sparse_hessian/link_sparse_hessian/n_sweep/$$ and +$cref/speed_main/speed_main/Speed Results/n_sweep/$$. +$lnext +Change the $code cppad$$ sparse Hessian +$cref/color_method/sparse_hessian/work/color_method/$$ +to take advantage of the symmetry of the Hessian +(in a similar fashion to the $code colpack$$ coloring method). +$lend + +$head 01-02$$ +Added to option to uses +$cref/colpack/colpack_prefix/$$ for the sparse Hessian +$cref/coloring method/sparse_hessian/work/color_method/$$; +see the example $cref colpack_hes.cpp$$. + +$end diff -Nru cppad-2015.00.00.9/omh/whats_new/whats_new.omh cppad-2016.00.00.1/omh/whats_new/whats_new.omh --- cppad-2015.00.00.9/omh/whats_new/whats_new.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/whats_new/whats_new.omh 2016-02-09 08:31:49.000000000 +0000 @@ -1,9 +1,9 @@ -$Id: whats_new.omh 3083 2014-01-10 18:35:07Z bradbell $ +$Id: whats_new.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,12 +18,13 @@ $section Changes and Additions to CppAD$$ $head Introduction$$ -The sections listed below contain a list of the changes to CppAD +The sections listed below contain a list of the changes to CppAD in reverse order by date. The purpose of these sections is to assist you in learning about changes between various versions of CppAD. $children% + omh/whats_new/whats_new_15.omh% omh/whats_new/whats_new_14.omh% omh/whats_new/whats_new_13.omh% omh/whats_new/whats_new_12.omh% @@ -39,9 +40,10 @@ %$$ $head This Year$$ -$cref whats_new_14$$ +$cref whats_new_15$$ $head Previous Years$$ +$cref whats_new_14$$ $cref whats_new_13$$ $cref whats_new_12$$ $cref whats_new_11$$, diff -Nru cppad-2015.00.00.9/omh/wish_list.omh cppad-2016.00.00.1/omh/wish_list.omh --- cppad-2015.00.00.9/omh/wish_list.omh 2015-02-24 08:31:41.000000000 +0000 +++ cppad-2016.00.00.1/omh/wish_list.omh 2016-02-09 08:31:48.000000000 +0000 @@ -1,16 +1,18 @@ -$Id: wish_list.omh 3301 2014-05-24 05:20:21Z bradbell $ +$Id: wish_list.omh 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -$begin WishList$$ +$begin wish_list$$ $spell + op + Recomputation jacobian nz RevSparseJac @@ -22,56 +24,55 @@ Checkpointing grep recomputed - recomputation afun iterator std cos - Ipopt Adolc xml hpp - Cpp + CppAD Atan cppad + mul + div + instantiate + instantiation + Bool + runge $$ $section The CppAD Wish List$$ -$index wish list$$ -$index new, features$$ -$index features, new$$ + +$head Base Requirements$$ +Change the $cref/Base requirements/base_require/$$ to use template +specialization instead of functions so that there is a default value +for each function. The default would result in a +$cref/known/cppad_assert/Known/$$ assert when the operation is used and not +defined by the base class. +An example of this type of template specialization can be found in +the implementation of $cref to_string$$. + +$head PrintFor Optimization$$ +Do not remove $cref PrintFor$$ operations during $cref optimize$$ because +they are very useful when debugging expected calculations on the tape. +If not this, we at least need to disable optimization of $cref checkpoint$$ +functions. + +$head checkpoint$$ +There should be some examples and tests for both speed and memory use +that demonstrate that checkpointing is useful. + +$head Machine Epsilon in Examples$$ +Use a multiple of $code std::numeric_limits::epsilon()$$ instead +$code 1e-10$$ for a small number in correctness checks; e.g., +see $cref sqrt.cpp$$. $head Adolc$$ -$index adolc$$ Create a documentation page that shows how to convert Adolc commands to CppAD commands. -$head Atan2$$ -$index atan2$$ -The $cref/atan2/Atan2/$$ function could be made faster by adding -a special operator for it. - -$head BenderQuad$$ -See the $cref/problem/BenderQuad/Problem/$$ with the -current $code BenderQuad$$ specifications. - -$head Checkpointing$$ -$index checkpoint$$ -It would be more flexible to also have a -$cref/checkpoint constructor/checkpoint/constructor/$$ -that passed in an $cref ADFun$$ object instead of a algorithm. -Perhaps the syntax would be -$codei% - checkpoint %afun%(%name%, %ad_fun%, %copy%) -%$$ -where $icode copy$$ would determine if a separate copy of $icode ad_fun$$ -was made or if a pointer was used. -Note that if a pointer is used, it becomes invalid when the destructor -for $icode ad_fun$$ is called. - -$head Conditional Expressions$$ - -$subhead Nesting$$ +$head Optimizing Nested Conditional Expressions$$ If one $cref/optimizes/optimize/$$ the code $codep x = CondExpLt(left_x, right_x, true_x, false_x) @@ -79,42 +80,21 @@ z = CondExpEq(left_z, right_z, x, y) $$ only two of the expressions -$code true_x$$, $code false_x$$, $code true_y$$, $code false_y$$ -will be evaluated +$code true_x$$, $code false_x$$, $code true_y$$, $code false_y$$ +will be evaluated (two will be skipped depending on the result of $code left_z == right_z$$). Not all of the expressions corresponding to $code left_x$$, $code right_x$$, $code left_y$$, $code right_y$$ need to be evaluate, but they are. -The optimizer could be improved to skip two more expressions +The optimizer could be improved to skip two more expressions (depending on the result of $code left_z == right_z$$). -$subhead Sparsity$$ -The $cref/optimizer/optimize/$$ uses -$cref/atomic reverse jacobian sparsity/atomic_rev_sparse_jac/$$ -to determine which arguments affect the value of the results -for the atomic functions (which include $cref checkpoint$$ functions). -While the partials of -$codei% - %z% = CondExp%Rel%( %left%, %right%, %if_true%, %if_false% ) -%$$ -with respect to $icode left$$ and $icode right$$ always evaluates to zero, -the value of $icode z$$ does depend on the value of $icode left$$ and -$icode right$$. -The $cref checkpoint$$ functions use the value true for -$cref/nz_compare/RevSparseJac/nz_compare/$$ when computing -reverse jacobian sparsity patterns. -This enables the optimizer to properly track the dependencies. -An $cref atomic_option$$ should be added so this is only -done when the optimizer is using the sparsity pattern for this purpose. - $head Forward Mode Recomputation$$ -$index forward$$ If the results of $cref forward_order$$ have already been computed and are still -stored in the $cref ADFun$$ object (see $cref size_order$$), +stored in the $cref ADFun$$ object (see $cref size_order$$), then they do not need to be recomputed and the results can just be returned. $head Iterator Interface$$ -$index iterator$$ All of the CppAD simple vector interfaces should also have an iterator version for the following reasons: $list number$$ @@ -126,97 +106,47 @@ (because an iterator for the result container would be passed in). $lend -$head Library$$ -$index compile, speed AD$$ -$index speed, compile AD$$ -$index AD, compile speed$$ +$head Compilation Speed$$ One could build a CppAD library for use with the type $code AD$$. This would speed up compilation for the most common usage where the $icode Base$$ type is $code double$$. -$head Multiple Directions$$ -$index speed, forward$$ -$index forward, speed$$ -$list number$$ -Extend the $cref forward_dir$$ routine so they can do multiple orders -as well as multiple directions at the same time. -$lnext -Extend the $cref atomic$$ functions so they can use multiple directions -and multiple orders at the same time -(currently they compute one direction and one order at a time). -$lnext -Extend the $cref Reverse$$ routines so they can handle one reverse direction -for multiple forward directions, or multiple reverse directions for -one forward direction. -$lend - -$head Numeric Limits$$ -$index testing, machine epsilon$$ -$index machine epsilon, testing$$ -Use a multiple of $code std::numeric_limits::epsilon()$$ instead -$code 1e-10$$ for a small number in correctness checks; e.g., -see $cref tan.cpp$$. $head Operation Sequence$$ -$index sequence, operation$$ -$index operation, sequence$$ -It is possible to detect if the -AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$ +It is possible to detect if the +AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ does not depend on any of the $cref/independent variable/glossary/Tape/Independent Variable/$$ values. This could be returned as an extra $cref seq_property$$. -$head Optimization$$ -$index optimize, tape$$ -$index tape, optimize$$ - -$subhead Expression Hashing$$ -During expression sequence $cref/optimization/optimize/$$, -hash codes are used to detect expressions that have already -been computed. -Perhaps this should be done during the original forward mode recording. - -$subhead Variable Pairs$$ -Suppose that $icode x$$ is a variable -and $codei%sin(%x%)%$$ is used in an expression. -The extra expression $codei%cos(%x%)%$$ is also computed -during a $cref Forward$$ calculation. -This is because the derivative of the original expression -is expressed in terms of the values of the other expression. -In general, -the representation of the derivative of an expression to order $icode p$$ -may include the derivative of another expression to order $icode%p%-1%$$. -In our example, if only the value $codei%sin(%x%)%$$ -is requested, it is not necessary to compute $codei%cos(%x%)%$$. -We should remove the computation of extra expressions derivatives that are -not need to compute the requested derivative of the original expression. - -$head Preprocessor Symbols$$ -$index preprocessor$$ -Make sure all the user API preprocessor symbols are list in -the $cref preprocessor$$ section. +$head Comparison Changes and Optimization$$ +The comparison operators used to not be taped when +$cref/NDEBUG/Faq/Speed/NDEBUG/$$ was defined. +They are now taped so that the $cref compare_change$$ interface +works even for compiler optimize code. +This caused a significant slow down in the +$cref cppad_det_lu.cpp$$ speed test (with no options specified). +Perhaps there should be an option to skip the comparison taping. $head Software Guidelines$$ - -$subhead Boost$$ The following is a list of some software guidelines taken from $href%http://www.boost.org/development/requirements.html#Guidelines%boost%$$. These guidelines are not followed by the current CppAD source code, but perhaps they should be: $list number$$ -Names (except as noted below) +Names (except as noted below) should be all lowercase, with words separated by underscores. -For example, acronyms should be treated as ordinary names +For example, acronyms should be treated as ordinary names (xml_parser instead of XML_parser). $lnext Template parameter names should begin with an uppercase letter. $lnext -Use spaces rather than tabs. +Use spaces rather than tabs. Currently, CppAD uses a tabs stops at column multiples of 5. Five columns were chosen to avoid high levels of indenting and to allow for $codep @@ -225,20 +155,27 @@ else statement $$ with a tab after the else. -Automatic conversion to actual spaces should be easy. +Automatic conversion to actual spaces should be easy. $lend $head Tracing$$ -$index operation, sequence tracing$$ -$index sequence, operation tracing$$ -$index tracing, operation sequence$$ Add tracing the operation sequence to the user API and documentation. -Tracing the operation sequence is currently done by changing the CppAD +Tracing the operation sequence is currently done by changing the CppAD source code. Use the command $codep grep '^# *define *CPPAD_.*_TRACE' cppad/local/*.hpp $$ to find all the possible tracing flags. + +$head atan2$$ +The $cref/atan2/Atan2/$$ function could be made faster by adding +a special operator for it. + + +$head BenderQuad$$ +See the $cref/problem/BenderQuad/Problem/$$ with the +current $code BenderQuad$$ specifications. + $end diff -Nru cppad-2015.00.00.9/pkgconfig/CMakeLists.txt cppad-2016.00.00.1/pkgconfig/CMakeLists.txt --- cppad-2015.00.00.9/pkgconfig/CMakeLists.txt 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/pkgconfig/CMakeLists.txt 2016-02-09 08:31:57.000000000 +0000 @@ -1,6 +1,6 @@ -# $Id: CMakeLists.txt 3491 2014-12-21 13:15:12Z bradbell $ +# $Id: CMakeLists.txt 3608 2015-01-23 12:20:38Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the @@ -9,42 +9,44 @@ # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the cppad pkg-config information files. -# Inherit environment from ../CMakeLists.txt +# Construct cppad.pc from cppad.pc.in; see +# http://people.freedesktop.org/~dbn/pkg-config-guide.html # -SET(cppad_cflags "-I${cppad_abs_includedir}") -SET(cppad_libs "") -SET(cppad_requires "") +# Setting that are always included +SET(cppad_pkgconfig_cflags "-I${cppad_abs_includedir}") +SET(cppad_pkgconfig_libs "") +SET(cppad_pkgconfig_requires "") +# +# Settings that are only included if cppad is configured with ipopt. +# (Note that ipopt has a pkgconfig file.) IF( ipopt_prefix ) - SET(cppad_libs "-L${cppad_abs_libdir} -lcppad_ipopt") - SET(cppad_requires "ipopt") - FOREACH(dir ${cmake_install_includedirs}) - IF(IS_DIRECTORY ${ipopt_prefix}/${dir} ) - SET(cppad_cflags "${cppad_cflags} -I${ipopt_prefix}/${dir}" ) - ENDIF(IS_DIRECTORY ${ipopt_prefix}/${dir} ) - ENDFOREACH(dir) + SET(cppad_pkgconfig_requires "ipopt") + SET(cppad_pkgconfig_libs "-L${cppad_abs_libdir} -lcppad_ipopt") ENDIF( ipopt_prefix ) # +# Settings that are only included if cppad is configured with colpack +# (Note that colpack does not have a pkgconfig file.) IF( colpack_prefix ) - # Cannot use requires because colpack does not have a pkgconfig file. - # SET(cppad_requires "colpack") - SET(cppad_libs "${cppad_libs} -lColPack") + SET(cppad_pkgconfig_libs "${cppad_pkgconfig_libs} -lColPack") FOREACH(dir ${cmake_install_libdirs}) IF(IS_DIRECTORY ${colpack_prefix}/${dir} ) - SET(cppad_cflags "${cppad_cflags} -L${colpack_prefix}/${dir}" ) + SET(cppad_pkgconfig_libs + "${cppad_pkgconfig_libs} -L${colpack_prefix}/${dir}" + ) ENDIF(IS_DIRECTORY ${colpack_prefix}/${dir} ) ENDFOREACH(dir) FOREACH(dir ${cmake_install_includedirs}) - SET(check_dir ${colpack_prefix}/${dir} ) - IF(IS_DIRECTORY ${check_dir} ) - SET(cppad_cflags "${cppad_cflags} -I${check_dir}" ) - ENDIF(IS_DIRECTORY ${check_dir} ) + IF(IS_DIRECTORY ${colpack_prefix}/${dir} ) + SET(cppad_pkgconfig_cflags + "${cppad_pkgconfig_cflags} -I${colpack_prefix}/${dir}" + ) + ENDIF(IS_DIRECTORY ${colpack_prefix}/${dir} ) ENDFOREACH(dir) ENDIF( colpack_prefix ) # -MESSAGE(STATUS "cppad_cflags = ${cppad_cflags}") -MESSAGE(STATUS "cppad_libs = ${cppad_libs}") -MESSAGE(STATUS "cppad_requires = ${cppad_requires}") +MESSAGE(STATUS "cppad_pkgconfig_cflags = ${cppad_pkgconfig_cflags}") +MESSAGE(STATUS "cppad_pkgconfig_libs = ${cppad_pkgconfig_libs}") +MESSAGE(STATUS "cppad_pkgconfig_requires = ${cppad_pkgconfig_requires}") # # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) diff -Nru cppad-2015.00.00.9/pkgconfig/cppad.pc.in cppad-2016.00.00.1/pkgconfig/cppad.pc.in --- cppad-2015.00.00.9/pkgconfig/cppad.pc.in 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/pkgconfig/cppad.pc.in 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: cppad.pc.in 2600 2012-12-14 02:08:51Z bradbell $ +# $Id: cppad.pc.in 3760 2015-12-01 04:12:28Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -11,10 +11,19 @@ # ----------------------------------------------------------------------------- # This file is used with pkg-config to include CppAD after it is installed +# ------------------------------------------------------------------------- +# HACK: With no specifications as to what will work in the future, set the +# values 'includedir' and 'prefix' so cppad.pc works with the 2015-01-21 +# verison of https://build.opensuse.org/package/view_file/ +# windows:mingw:win32/mingw32-filesystem/mingw32-install-post.sh?expand=1 +prefix=@cppad_prefix@ +includedir=@cppad_abs_includedir@ +# ------------------------------------------------------------------------- + Name: cppad Description: @cppad_description@ Version: @cppad_version@ URL: @cppad_url@ -Cflags: @cppad_cflags@ -Libs: @cppad_libs@ -Requires: @cppad_requires@ +Cflags: @cppad_pkgconfig_cflags@ +Libs: @cppad_pkgconfig_libs@ +Requires: @cppad_pkgconfig_requires@ diff -Nru cppad-2015.00.00.9/pkgconfig/cppad-uninstalled.pc.in cppad-2016.00.00.1/pkgconfig/cppad-uninstalled.pc.in --- cppad-2015.00.00.9/pkgconfig/cppad-uninstalled.pc.in 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/pkgconfig/cppad-uninstalled.pc.in 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: cppad-uninstalled.pc.in 2601 2012-12-14 16:17:53Z bradbell $ +# $Id: cppad-uninstalled.pc.in 3754 2015-11-26 22:23:05Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -16,5 +16,5 @@ Version: @cppad_version@ URL: @cppad_url@ Cflags: -I@cppad_SOURCE_DIR@ -Libs: +Libs: -L@cppad_BINARY_DIR@/lib -lcppad_lib Requires: diff -Nru cppad-2015.00.00.9/print_for/makefile.am cppad-2016.00.00.1/print_for/makefile.am --- cppad-2015.00.00.9/print_for/makefile.am 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/print_for/makefile.am 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2541 2012-11-06 16:32:36Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -25,7 +25,7 @@ endif # # Microsoft project files -EXTRA_DIST = test.sh +EXTRA_DIST = test.sh # check_PROGRAMS = print_for # diff -Nru cppad-2015.00.00.9/print_for/makefile.in cppad-2016.00.00.1/print_for/makefile.in --- cppad-2015.00.00.9/print_for/makefile.in 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/print_for/makefile.in 2016-02-09 08:31:57.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = print_for$(EXEEXT) subdir = print_for -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -146,6 +155,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -176,12 +186,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -262,26 +272,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -329,7 +342,7 @@ # # Microsoft project files -EXTRA_DIST = test.sh +EXTRA_DIST = test.sh # AM_CPPFLAGS = -I. $(CPPAD_INCLUDE) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # @@ -352,7 +365,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu print_for/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu print_for/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -603,6 +615,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check $(srcdir)/test.sh diff -Nru cppad-2015.00.00.9/print_for/print_for.cpp cppad-2016.00.00.1/print_for/print_for.cpp --- cppad-2015.00.00.9/print_for/print_for.cpp 2015-02-24 08:31:44.000000000 +0000 +++ cppad-2016.00.00.1/print_for/print_for.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: print_for.cpp 3114 2014-02-22 16:20:39Z bradbell $ */ +// $Id: print_for.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -32,10 +32,8 @@ $$ $section Printing During Forward Mode: Example and Test$$ +$mindex mode print$$ -$index forward, mode print$$ -$index example, print forward mode$$ -$index print, example forward mode$$ $head Running$$ To build this program and run its correctness test see $cref cmake_check$$. @@ -44,7 +42,7 @@ $codep */ # include -namespace { +namespace { using std::cout; using std::endl; using CppAD::AD; @@ -59,7 +57,7 @@ PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); return log(y); - } + } } void print_for(void) @@ -75,11 +73,11 @@ CppAD::VecAD av(1); AD Zero(0); av[Zero] = 0.; - PrintFor("v[0] = ", av[Zero]); + PrintFor("v[0] = ", av[Zero]); // Print a newline to separate this from previous output, // then print an AD object that is a variable. - PrintFor("\nv[0] + x[0] = ", av[0] + ax[0]); + PrintFor("\nv[0] + x[0] = ", av[0] + ax[0]); // A conditional print that will not generate output when x[0] = 2. PrintFor(ax[0], "\n 2. + x[0] = ", 2. + ax[0], "\n"); @@ -91,25 +89,25 @@ AD var = 2. - ax[0]; AD log_var = check_log(var); - // dependent variable vector + // dependent variable vector size_t m = 2; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = av[Zero] + ax[0]; // define f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); - // zero order forward with x[0] = 2 + // zero order forward with x[0] = 2 CPPAD_TESTVECTOR(double) x(n); x[0] = 2.; - cout << "v[0] = 0" << endl; - cout << "v[0] + x[0] = 2" << endl; - cout << " 3. + x[0] = 5" << endl; + cout << "v[0] = 0" << endl; + cout << "v[0] + x[0] = 2" << endl; + cout << " 3. + x[0] = 5" << endl; cout << "check_log: y == 0 which is <= 0" << endl; // ./makefile.am expects "Test passes" at beginning of next output line cout << "Test passes if four lines above repeat below:" << endl; - f.Forward(0, x); + f.Forward(0, x); return; } diff -Nru cppad-2015.00.00.9/speed/adolc/adolc_alloc_mat.hpp cppad-2016.00.00.1/speed/adolc/adolc_alloc_mat.hpp --- cppad-2015.00.00.9/speed/adolc/adolc_alloc_mat.hpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/adolc_alloc_mat.hpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,18 +1,18 @@ -/* $Id: adolc_alloc_mat.hpp 3275 2014-05-20 17:35:11Z bradbell $ */ +// $Id: adolc_alloc_mat.hpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -# ifndef CPPAD_ADOLC_ALLOC_MAT_INCLUDED -# define CPPAD_ADOLC_ALLOC_MAT_INCLUDED +# ifndef CPPAD_ADOLC_ALLOC_MAT_HPP +# define CPPAD_ADOLC_ALLOC_MAT_HPP double** adolc_alloc_mat(size_t m, size_t n); void adolc_free_mat(double** mat); -# endif +# endif diff -Nru cppad-2015.00.00.9/speed/adolc/alloc_mat.cpp cppad-2016.00.00.1/speed/adolc/alloc_mat.cpp --- cppad-2015.00.00.9/speed/adolc/alloc_mat.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/alloc_mat.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: alloc_mat.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: alloc_mat.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,7 @@ $$ $section Adolc Test Utility: Allocate and Free Memory For a Matrix$$ -$index adolc_alloc_mat$$ -$index alloc, adolc$$ -$index matrix, adolc$$ +$mindex adolc_alloc_mat alloc$$ $head Syntax$$ $codei%mat% = adolc_alloc_mat(%m%, %n%) @@ -39,7 +37,7 @@ $head mat$$ Is the matrix. -To be specific, +To be specific, between a call to $code adolc_alloc_mat$$, and the corresponding call to $code adolc_free_mat$$, for $icode%i% = 0 , %...% , %m%-1%$$ @@ -49,7 +47,7 @@ $end */ -# include +# include double** adolc_alloc_mat(size_t m, size_t n) { using CppAD::thread_alloc; @@ -59,7 +57,7 @@ for(size_t i = 0; i < m; i++) mat[i] = vec + i * n; - + return mat; } void adolc_free_mat(double** mat) diff -Nru cppad-2015.00.00.9/speed/adolc/CMakeLists.txt cppad-2016.00.00.1/speed/adolc/CMakeLists.txt --- cppad-2015.00.00.9/speed/adolc/CMakeLists.txt 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/CMakeLists.txt 2016-02-09 08:31:52.000000000 +0000 @@ -1,29 +1,29 @@ -# $Id: CMakeLists.txt 3141 2014-03-02 23:24:45Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the speed/adolc directory tests +# Build the speed/adolc directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # assert adolc_prefix is defined IF ( NOT adolc_prefix ) - MESSAGE(FATAL_ERROR + MESSAGE(FATAL_ERROR "speed/adolc/CMakeLists.txt: adolc_prefix = ${adolc_prefix}" ) ENDIF ( NOT adolc_prefix ) -# Adds flags to the compiler command line for sources in the current directory -# and below. This command can be used to add any flags, but it was originally -# intended to add preprocessor definitions. +# Adds flags to the compiler command line for sources in the current directory +# and below. This command can be used to add any flags, but it was originally +# intended to add preprocessor definitions. ADD_DEFINITIONS("-DCPPAD_ADOLC_SPEED") # Local include directories to search (not in package_prefix/includdir) @@ -46,12 +46,17 @@ add_cppad_cxx_flags( speed_adolc ) # List of libraries to be linked into the specified target -TARGET_LINK_LIBRARIES(speed_adolc speed_src adolc ${colpack_libs} ) +TARGET_LINK_LIBRARIES(speed_adolc + speed_src + ${cppad_lib} + adolc + ${colpack_libs} +) # Add the check_speed_adolc target ADD_CUSTOM_TARGET( - check_speed_adolc + check_speed_adolc speed_adolc correct 54321 colpack - DEPENDS + DEPENDS speed_adolc speed_src ) diff -Nru cppad-2015.00.00.9/speed/adolc/det_lu.cpp cppad-2016.00.00.1/speed/adolc/det_lu.cpp --- cppad-2015.00.00.9/speed/adolc/det_lu.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/det_lu.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_lu.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,14 +30,8 @@ $$ $section Adolc Speed: Gradient of Determinant Using Lu Factorization$$ +$mindex link_det_lu speed matrix factor$$ -$index link_det_lu, adolc$$ -$index adolc, link_det_lu$$ -$index speed, adolc$$ -$index adolc, speed$$ -$index lu, speed adolc$$ -$index matrix, factor speed adolc$$ -$index factor, matrix speed adolc$$ $head Specifications$$ See $cref link_det_lu$$. @@ -48,14 +42,14 @@ # include # include -# include +# include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_lu( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { @@ -89,8 +83,8 @@ // AD version of matrix size_min = n; ADVector A = thread_alloc::create_array(size_min, size_out); - - // vectors of reverse mode weights + + // vectors of reverse mode weights size_min = m; double* u = thread_alloc::create_array(size_min, size_out); u[0] = 1.; diff -Nru cppad-2015.00.00.9/speed/adolc/det_minor.cpp cppad-2016.00.00.1/speed/adolc/det_minor.cpp --- cppad-2015.00.00.9/speed/adolc/det_minor.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/det_minor.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_minor.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -31,13 +31,8 @@ $$ $section Adolc Speed: Gradient of Determinant by Minor Expansion$$ +$mindex link_det_minor speed$$ -$index link_det_minor, adolc$$ -$index adolc, link_det_minor$$ -$index speed, adolc$$ -$index adolc, speed$$ -$index minor, speed adolc$$ -$index determinant, speed adolc$$ $head Specifications$$ See $cref link_det_minor$$. @@ -45,7 +40,7 @@ $head Implementation$$ $codep */ # include -# include +# include # include # include @@ -53,16 +48,16 @@ extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_minor( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_atomic ) - return false; + return false; if( global_memory || global_optimize ) - return false; + return false; // ----------------------------------------------------- // setup typedef adouble ADScalar; @@ -86,8 +81,8 @@ // AD version of matrix ADVector A = thread_alloc::create_array(size_t(n), capacity); - - // vectors of reverse mode weights + + // vectors of reverse mode weights double* u = thread_alloc::create_array(size_t(m), capacity); u[0] = 1.; @@ -103,7 +98,7 @@ CppAD::uniform_01(n, mat); // declare independent variables - int keep = 1; // keep forward mode results + int keep = 1; // keep forward mode results trace_on(tag, keep); for(j = 0; j < n; j++) A[j] <<= mat[j]; @@ -142,7 +137,7 @@ // evaluate the determinant at the new matrix value keep = 1; // keep this forward mode result - zos_forward(tag, m, n, keep, mat, &f); + zos_forward(tag, m, n, keep, mat, &f); // evaluate and return gradient using reverse mode fos_reverse(tag, m, n, u, grad); diff -Nru cppad-2015.00.00.9/speed/adolc/makefile.am cppad-2016.00.00.1/speed/adolc/makefile.am --- cppad-2015.00.00.9/speed/adolc/makefile.am 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/makefile.am 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3481 2014-12-17 23:39:47Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -19,7 +19,7 @@ # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -check_PROGRAMS = speed_adolc +check_PROGRAMS = speed_adolc # AM_CPPFLAGS = \ -I$(top_srcdir) \ diff -Nru cppad-2015.00.00.9/speed/adolc/makefile.in cppad-2016.00.00.1/speed/adolc/makefile.in --- cppad-2015.00.00.9/speed/adolc/makefile.in 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/makefile.in 2016-02-09 08:31:52.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = speed_adolc$(EXEEXT) subdir = speed/adolc -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -162,6 +171,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -266,26 +276,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -324,12 +337,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -386,7 +399,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu speed/adolc/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/adolc/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -648,6 +660,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + main.cpp: cp $(srcdir)/../main.cpp main.cpp diff -Nru cppad-2015.00.00.9/speed/adolc/mat_mul.cpp cppad-2016.00.00.1/speed/adolc/mat_mul.cpp --- cppad-2015.00.00.9/speed/adolc/mat_mul.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/mat_mul.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mat_mul.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,13 +28,8 @@ $$ $section Adolc Speed: Matrix Multiplication$$ +$mindex link_mat_mul speed multiply$$ -$index link_mat_mul, adolc$$ -$index adolc, link_mat_mul$$ -$index speed, adolc$$ -$index adolc, speed$$ -$index matrix, speed adolc$$ -$index multiply, speed adolc$$ $head Specifications$$ See $cref link_mat_mul$$. @@ -43,17 +38,17 @@ $codep */ # include -# include +# include # include # include -# include +# include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_mat_mul( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz ) @@ -139,7 +134,7 @@ // evaluate the determinant at the new matrix value keep = 1; // keep this forward mode result - zos_forward(tag, m, n, keep, mat, &f); + zos_forward(tag, m, n, keep, mat, &f); // evaluate and return gradient using reverse mode fos_reverse(tag, m, n, u, grad); diff -Nru cppad-2015.00.00.9/speed/adolc/ode.cpp cppad-2016.00.00.1/speed/adolc/ode.cpp --- cppad-2015.00.00.9/speed/adolc/ode.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/ode.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,12 +26,8 @@ $$ $section Adolc Speed: Ode$$ +$mindex link_ode speed$$ -$index link_ode, adolc$$ -$index adolc, link_ode$$ -$index speed, adolc$$ -$index adolc, speed$$ -$index ode, speed adolc$$ $head Specifications$$ See $cref link_ode$$. @@ -41,7 +37,7 @@ $codep */ # include -# include +# include # include # include @@ -94,7 +90,7 @@ // ------------------------------------------------------------- if( ! global_onetape ) while(repeat--) - { // choose next x value + { // choose next x value uniform_01(n, x); // declare independent variables @@ -116,7 +112,7 @@ jacobian(tag, m, n, x_raw, jac_ptr); } else - { // choose next x value + { // choose next x value uniform_01(n, x); // declare independent variables diff -Nru cppad-2015.00.00.9/speed/adolc/poly.cpp cppad-2016.00.00.1/speed/adolc/poly.cpp --- cppad-2015.00.00.9/speed/adolc/poly.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/poly.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: poly.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -35,12 +35,8 @@ $$ $section Adolc Speed: Second Derivative of a Polynomial$$ +$mindex link_poly speed$$ -$index link_poly, adolc$$ -$index adolc, link_poly$$ -$index speed, adolc$$ -$index adolc, speed$$ -$index polynomial, speed adolc$$ $head Specifications$$ See $cref link_poly$$. @@ -52,20 +48,20 @@ # include # include -# include -# include -# include +# include +# include +# include # include "adolc_alloc_mat.hpp" // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_poly( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &a , // coefficients of polynomial CppAD::vector &z , // polynomial argument value - CppAD::vector &ddp ) // second derivative w.r.t z + CppAD::vector &ddp ) // second derivative w.r.t z { if( global_atomic ) return false; @@ -78,7 +74,7 @@ int keep = 0; // do not keep forward mode results in buffer int m = 1; // number of dependent variables int n = 1; // number of independent variables - int d = 2; // highest derivative degree + int d = 2; // highest derivative degree double f; // function value // set up for thread_alloc memory allocator (fast and checks for leaks) @@ -113,9 +109,9 @@ // declare independent variables trace_on(tag, keep); - Z <<= z[0]; + Z <<= z[0]; - // AD computation of the function value + // AD computation of the function value P = CppAD::Poly(0, A, Z); // create function object f : Z -> P @@ -138,9 +134,9 @@ // declare independent variables trace_on(tag, keep); - Z <<= z[0]; + Z <<= z[0]; - // AD computation of the function value + // AD computation of the function value P = CppAD::Poly(0, A, Z); // create function object f : Z -> P diff -Nru cppad-2015.00.00.9/speed/adolc/sparse_hessian.cpp cppad-2016.00.00.1/speed/adolc/sparse_hessian.cpp --- cppad-2015.00.00.9/speed/adolc/sparse_hessian.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/sparse_hessian.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_hessian.cpp 3136 2014-03-02 11:54:07Z bradbell $ */ +// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,7 +16,7 @@ boolsparsity onetape hess - int int_n + int nnz cind const @@ -34,13 +34,8 @@ $$ $section Adolc Speed: Sparse Hessian$$ +$mindex link_sparse_hessian speed$$ -$index link_sparse_hessian, adolc$$ -$index adolc, link_sparse_hessian$$ -$index speed, adolc$$ -$index adolc, speed$$ -$index sparse, speed adolc$$ -$index hessian, speed adolc$$ $head Specifications$$ See $cref link_sparse_hessian$$. @@ -50,9 +45,9 @@ $codep */ # include # include -# include +# include # include -# include +# include # include // list of possible options @@ -60,15 +55,16 @@ extern bool global_colpack, global_boolsparsity; bool link_sparse_hessian( - size_t size , - size_t repeat , + size_t size , + size_t repeat , const CppAD::vector& row , const CppAD::vector& col , - CppAD::vector& x_return , - CppAD::vector& hessian ) + CppAD::vector& x_return , + CppAD::vector& hessian , + size_t& n_sweep ) { if( global_atomic || (! global_colpack) ) - return false; + return false; if( global_memory || global_optimize || global_boolsparsity ) return false; // ----------------------------------------------------- @@ -79,7 +75,7 @@ typedef ADScalar* ADVector; - size_t i, j; // temporary indices + size_t i, j, k; // temporary indices size_t order = 0; // derivative order corresponding to function size_t m = 1; // number of dependent variables size_t n = size; // number of independent variables @@ -94,9 +90,9 @@ ADVector a_x = thread_alloc::create_array(n, capacity); // AD range space vector ADVector a_y = thread_alloc::create_array(m, capacity); - // double argument value + // double argument value DblVector x = thread_alloc::create_array(n, capacity); - // double function value + // double function value double f; // options that control sparse_hess @@ -110,26 +106,21 @@ SizeVector cind = CPPAD_NULL; // column indices DblVector values = CPPAD_NULL; // Hessian values - // initialize all entries as zero - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - hessian[ i * n + j ] = 0.; - } // ---------------------------------------------------------------------- if( ! global_onetape ) while(repeat--) { // choose a value for x CppAD::uniform_01(n, x); // declare independent variables - int keep = 0; // keep forward mode results + int keep = 0; // keep forward mode results trace_on(tag, keep); for(j = 0; j < n; j++) a_x[j] <<= x[j]; - // AD computation of f (x) + // AD computation of f (x) CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); - // create function object f : x -> y + // create function object f : x -> y a_y[0] >>= f; trace_off(); @@ -140,13 +131,20 @@ rind = CPPAD_NULL; cind = CPPAD_NULL; values = CPPAD_NULL; - sparse_hess(tag, int(n), + sparse_hess(tag, int(n), same_pattern, x, &nnz, &rind, &cind, &values, options ); - int int_n = int(n); - for(int k = 0; k < nnz; k++) - { hessian[ rind[k] * int_n + cind[k] ] = values[k]; - hessian[ cind[k] * int_n + rind[k] ] = values[k]; + // only needed last time through loop + if( repeat == 0 ) + { size_t K = row.size(); + for(int ell = 0; ell < nnz; ell++) + { i = size_t(rind[ell]); + j = size_t(cind[ell]); + for(k = 0; k < K; k++) + { if( (row[k]==i && col[k]==j) || (row[k]==j && col[k]==i) ) + hessian[k] = values[ell]; + } + } } // free raw memory allocated by sparse_hess @@ -159,12 +157,12 @@ CppAD::uniform_01(n, x); // declare independent variables - int keep = 0; // keep forward mode results + int keep = 0; // keep forward mode results trace_on(tag, keep); for(j = 0; j < n; j++) a_x[j] <<= x[j]; - // AD computation of f (x) + // AD computation of f (x) CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); // create function object f : x -> y @@ -179,27 +177,33 @@ CppAD::uniform_01(n, x); // calculate the hessian at this x - sparse_hess(tag, int(n), + sparse_hess(tag, int(n), same_pattern, x, &nnz, &rind, &cind, &values, options ); same_pattern = 1; } - int int_n = int(n); - for(int k = 0; k < nnz; k++) - { hessian[ rind[k] * int_n + cind[k] ] = values[k]; - hessian[ cind[k] * int_n + rind[k] ] = values[k]; + size_t K = row.size(); + for(int ell = 0; ell < nnz; ell++) + { i = size_t(rind[ell]); + j = size_t(cind[ell]); + for(k = 0; k < K; k++) + { if( (row[k]==i && col[k]==j) || (row[k]==j && col[k]==i) ) + hessian[k] = values[ell]; + } } - // free raw memory allocated by sparse_hessian free(rind); free(cind); free(values); } // -------------------------------------------------------------------- - // return argument + // return argument for(j = 0; j < n; j++) x_return[j] = x[j]; + // do not know how to return number of sweeps used + n_sweep = 0; + // tear down thread_alloc::delete_array(a_x); thread_alloc::delete_array(a_y); diff -Nru cppad-2015.00.00.9/speed/adolc/sparse_jacobian.cpp cppad-2016.00.00.1/speed/adolc/sparse_jacobian.cpp --- cppad-2015.00.00.9/speed/adolc/sparse_jacobian.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/adolc/sparse_jacobian.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,16 +1,16 @@ -/* $Id: sparse_jacobian.cpp 3320 2014-09-11 23:06:21Z bradbell $ */ +// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include -# include +# include /* $begin adolc_sparse_jacobian.cpp$$ @@ -35,13 +35,8 @@ $$ $section adolc Speed: Sparse Jacobian$$ +$mindex link_sparse_jacobian speed$$ -$index link_sparse_jacobian, adolc$$ -$index adolc, link_sparse_jacobian$$ -$index speed, adolc$$ -$index adolc, speed$$ -$index sparse, speed adolc$$ -$index jacobian, speed adolc$$ $head Specifications$$ See $cref link_sparse_jacobian$$. @@ -51,7 +46,7 @@ $codep */ # include # include -# include +# include # include # include @@ -60,8 +55,8 @@ extern bool global_colpack, global_boolsparsity; bool link_sparse_jacobian( - size_t size , - size_t repeat , + size_t size , + size_t repeat , size_t m , const CppAD::vector& row , const CppAD::vector& col , @@ -70,9 +65,9 @@ size_t& n_sweep ) { if( global_atomic || (! global_colpack) ) - return false; + return false; if( global_memory || global_optimize ) - return false; + return false; // ----------------------------------------------------- // setup typedef unsigned int* SizeVector; @@ -80,8 +75,8 @@ typedef adouble ADScalar; typedef ADScalar* ADVector; - size_t i, j; // temporary indices - size_t n = size; // number of independent variables + size_t i, j, k; // temporary indices + size_t n = size; // number of independent variables size_t order = 0; // derivative order corresponding to function // set up for thread_alloc memory allocator (fast and checks for leaks) @@ -99,7 +94,7 @@ // function value in double DblVector y = thread_alloc::create_array(m, capacity); - + // options that control sparse_jac int options[4]; extern bool global_boolsparsity; @@ -117,22 +112,16 @@ SizeVector cind = CPPAD_NULL; // column indices DblVector values = CPPAD_NULL; // Jacobian values - // initialize all entries as zero - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - jacobian[ i * n + j ] = 0.; - } - // choose a value for x CppAD::uniform_01(n, x); // declare independent variables - int keep = 0; // keep forward mode results + int keep = 0; // keep forward mode results trace_on(tag, keep); for(j = 0; j < n; j++) a_x[j] <<= x[j]; - // AD computation of f (x) + // AD computation of f (x) CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); // create function object f : x -> y @@ -143,7 +132,7 @@ // Retrieve n_sweep using undocumented feature of sparsedrivers.cpp int same_pattern = 0; options[2] = -1; - n_sweep = sparse_jac(tag, int(m), int(n), + n_sweep = sparse_jac(tag, int(m), int(n), same_pattern, x, &nnz, &rind, &cind, &values, options ); options[2] = 0; @@ -157,10 +146,10 @@ for(j = 0; j < n; j++) a_x[j] <<= x[j]; - // AD computation of f (x) + // AD computation of f (x) CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); - // create function object f : x -> y + // create function object f : x -> y for(i = 0; i < m; i++) a_y[i] >>= y[i]; trace_off(); @@ -172,12 +161,21 @@ rind = CPPAD_NULL; cind = CPPAD_NULL; values = CPPAD_NULL; - sparse_jac(tag, int(m), int(n), + sparse_jac(tag, int(m), int(n), same_pattern, x, &nnz, &rind, &cind, &values, options ); - int int_n = int(n); - for(int k = 0; k < nnz; k++) - jacobian[ rind[k] * int_n + cind[k] ] = values[k]; + // only needed last time through loop + if( repeat == 0 ) + { size_t K = row.size(); + for(int ell = 0; ell < nnz; ell++) + { i = size_t(rind[ell]); + j = size_t(cind[ell]); + for(k = 0; k < K; k++) + { if( row[k]==i && col[k]==j ) + jacobian[k] = values[ell]; + } + } + } // free raw memory allocated by sparse_jac free(rind); @@ -190,14 +188,20 @@ CppAD::uniform_01(n, x); // calculate the jacobian at this x - sparse_jac(tag, int(m), int(n), + sparse_jac(tag, int(m), int(n), same_pattern, x, &nnz, &rind, &cind, &values, options ); same_pattern = 1; } - int int_n = int(n); - for(int k = 0; k < nnz; k++) - jacobian[ rind[k] * int_n + cind[k] ] = values[k]; + size_t K = row.size(); + for(int ell = 0; ell < nnz; ell++) + { i = size_t(rind[ell]); + j = size_t(cind[ell]); + for(k = 0; k < K; k++) + { if( row[k]==i && col[k]==j ) + jacobian[k] = values[ell]; + } + } // free raw memory allocated by sparse_jac free(rind); @@ -205,7 +209,7 @@ free(values); } // -------------------------------------------------------------------- - // return argument + // return argument for(j = 0; j < n; j++) x_return[j] = x[j]; diff -Nru cppad-2015.00.00.9/speed/CMakeLists.txt cppad-2016.00.00.1/speed/CMakeLists.txt --- cppad-2015.00.00.9/speed/CMakeLists.txt 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/CMakeLists.txt 2016-02-09 08:31:53.000000000 +0000 @@ -1,33 +1,28 @@ -# $Id: CMakeLists.txt 3301 2014-05-24 05:20:21Z bradbell $ +# $Id: CMakeLists.txt 3754 2015-11-26 22:23:05Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the speed/* directory tests +# Build the speed/* directory tests # Inherit environment from ../CMakeList.txt -# CppAD developers use MinSizeRel for profiling the speed tests -SET(CMAKE_CXX_FLAGS_MINSIZEREL "-O0 -DNDEBUG") -SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") +# CppAD developers use DEBUG for debugging speed tests. +# SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -DNDEBUG") -# Specify build type for this directory and all its subdirectories. +# Specify build type for this directory and all its subdirectories. # Possible values are DEBUG, RELEASE, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) -# colpack_prefix -SET(sources ../../cppad/local/cppad_colpack.cpp) -sources_libs_define(colpack "${sources}" ColPack COLPACK_SPEED) - # Initialize list of tests as empty SET(check_depends "") -# The CMakeLists.txt file in the specified source directory is processed +# The CMakeLists.txt file in the specified source directory is processed # before the current input file continues beyond this command. # add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) ADD_SUBDIRECTORY(src) @@ -41,8 +36,10 @@ ADD_SUBDIRECTORY(example) add_to_list(check_depends check_speed_example) # -ADD_SUBDIRECTORY(profile) -add_to_list(check_depends check_speed_profile) +IF ( cppad_profile_flag ) + ADD_SUBDIRECTORY(profile) + add_to_list(check_depends check_speed_profile) +ENDIF ( cppad_profile_flag ) # IF ( adolc_prefix ) ADD_SUBDIRECTORY(adolc) diff -Nru cppad-2015.00.00.9/speed/cppad/CMakeLists.txt cppad-2016.00.00.1/speed/cppad/CMakeLists.txt --- cppad-2015.00.00.9/speed/cppad/CMakeLists.txt 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/CMakeLists.txt 2016-02-09 08:31:52.000000000 +0000 @@ -1,21 +1,21 @@ -# $Id: CMakeLists.txt 3139 2014-03-02 21:12:00Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the speed/cppad directory tests +# Build the speed/cppad directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory -# Adds flags to the compiler command line for sources in the current directory -# and below. This command can be used to add any flags, but it was originally -# intended to add preprocessor definitions. +# Adds flags to the compiler command line for sources in the current directory +# and below. This command can be used to add any flags, but it was originally +# intended to add preprocessor definitions. ADD_DEFINITIONS("-DCPPAD_CPPAD_SPEED") # Local include directories to search (not in package_prefix/includdir) @@ -24,7 +24,7 @@ # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) -ADD_EXECUTABLE(speed_cppad EXCLUDE_FROM_ALL ../main.cpp +ADD_EXECUTABLE(speed_cppad EXCLUDE_FROM_ALL ../main.cpp det_lu.cpp det_minor.cpp mat_mul.cpp @@ -38,10 +38,14 @@ add_cppad_cxx_flags( speed_cppad ) # List of libraries to be linked into the specified target -TARGET_LINK_LIBRARIES(speed_cppad speed_src ${colpack_libs}) +TARGET_LINK_LIBRARIES(speed_cppad + speed_src + ${cppad_lib} + ${colpack_libs} +) # Add the check_speed_cppad target -ADD_CUSTOM_TARGET(check_speed_cppad +ADD_CUSTOM_TARGET(check_speed_cppad speed_cppad correct 54321 DEPENDS speed_cppad speed_src ) diff -Nru cppad-2015.00.00.9/speed/cppad/det_lu.cpp cppad-2016.00.00.1/speed/cppad/det_lu.cpp --- cppad-2015.00.00.9/speed/cppad/det_lu.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/det_lu.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_lu.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,21 +30,15 @@ $$ $section CppAD Speed: Gradient of Determinant Using Lu Factorization$$ +$mindex link_det_lu speed matrix factor$$ -$index link_det_lu, cppad$$ -$index cppad, link_det_lu$$ -$index speed, cppad$$ -$index cppad, speed$$ -$index lu, speed cppad$$ -$index matrix, factor speed cppad$$ -$index factor, matrix speed cppad$$ $head Specifications$$ See $cref link_det_lu$$. $head Implementation$$ $codep */ -# include +# include # include # include @@ -53,8 +47,8 @@ global_onetape, global_atomic, global_optimize; bool link_det_lu( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { @@ -64,8 +58,8 @@ // ----------------------------------------------------- // setup - typedef CppAD::AD ADScalar; - typedef CppAD::vector ADVector; + typedef CppAD::AD ADScalar; + typedef CppAD::vector ADVector; CppAD::det_by_lu Det(size); size_t i; // temporary index @@ -74,8 +68,8 @@ ADVector A(n); // AD domain space vector ADVector detA(m); // AD range space vector CppAD::ADFun f; // AD function object - - // vectors of reverse mode weights + + // vectors of reverse mode weights CppAD::vector w(1); w[0] = 1.; @@ -97,6 +91,9 @@ if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + // evaluate and return gradient using reverse mode f.Forward(0, matrix); gradient = f.Reverse(1, w); diff -Nru cppad-2015.00.00.9/speed/cppad/det_minor.cpp cppad-2016.00.00.1/speed/cppad/det_minor.cpp --- cppad-2015.00.00.9/speed/cppad/det_minor.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/det_minor.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_minor.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -31,20 +31,15 @@ $$ $section CppAD Speed: Gradient of Determinant by Minor Expansion$$ +$mindex link_det_minor speed$$ -$index link_det_minor, cppad$$ -$index cppad, link_det_minor$$ -$index speed, cppad$$ -$index cppad, speed$$ -$index minor, speed cppad$$ -$index determinant, speed cppad$$ $head Specifications$$ See $cref link_det_minor$$. $head Implementation$$ $codep */ -# include +# include # include # include @@ -53,8 +48,8 @@ global_onetape, global_atomic, global_optimize; bool link_det_minor( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { @@ -66,8 +61,8 @@ // setup // object for computing determinant - typedef CppAD::AD ADScalar; - typedef CppAD::vector ADVector; + typedef CppAD::AD ADScalar; + typedef CppAD::vector ADVector; CppAD::det_by_minor Det(size); size_t i; // temporary index @@ -75,8 +70,8 @@ size_t n = size * size; // number of independent variables ADVector A(n); // AD domain space vector ADVector detA(m); // AD range space vector - - // vectors of reverse mode weights + + // vectors of reverse mode weights CppAD::vector w(1); w[0] = 1.; @@ -90,22 +85,25 @@ CppAD::uniform_01(n, matrix); for( i = 0; i < size * size; i++) A[i] = matrix[i]; - + // declare independent variables Independent(A); - + // AD computation of the determinant detA[0] = Det(A); - + // create function object f : A -> detA f.Dependent(A, detA); if( global_optimize ) f.optimize(); - + + // skip comparison operators + f.compare_change_count(0); + // evaluate the determinant at the new matrix value f.Forward(0, matrix); - + // evaluate and return gradient using reverse mode gradient = f.Reverse(1, w); } @@ -115,27 +113,30 @@ CppAD::uniform_01(n, matrix); for( i = 0; i < size * size; i++) A[i] = matrix[i]; - + // declare independent variables Independent(A); - + // AD computation of the determinant detA[0] = Det(A); - + // create function object f : A -> detA f.Dependent(A, detA); if( global_optimize ) f.optimize(); - + + // skip comparison operators + f.compare_change_count(0); + // ------------------------------------------------------ while(repeat--) { // get the next matrix CppAD::uniform_01(n, matrix); - + // evaluate the determinant at the new matrix value f.Forward(0, matrix); - + // evaluate and return gradient using reverse mode gradient = f.Reverse(1, w); } diff -Nru cppad-2015.00.00.9/speed/cppad/makefile.am cppad-2016.00.00.1/speed/cppad/makefile.am --- cppad-2015.00.00.9/speed/cppad/makefile.am 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/makefile.am 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3481 2014-12-17 23:39:47Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -18,7 +18,7 @@ # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -check_PROGRAMS = speed_cppad +check_PROGRAMS = speed_cppad # AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # diff -Nru cppad-2015.00.00.9/speed/cppad/makefile.in cppad-2016.00.00.1/speed/cppad/makefile.in --- cppad-2015.00.00.9/speed/cppad/makefile.in 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/makefile.in 2016-02-09 08:31:53.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = speed_cppad$(EXEEXT) subdir = speed/cppad -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -150,6 +159,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -253,26 +263,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -311,12 +324,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -366,7 +379,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu speed/cppad/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/cppad/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -627,6 +639,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + main.cpp: cp $(srcdir)/../main.cpp main.cpp diff -Nru cppad-2015.00.00.9/speed/cppad/mat_mul.cpp cppad-2016.00.00.1/speed/cppad/mat_mul.cpp --- cppad-2015.00.00.9/speed/cppad/mat_mul.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/mat_mul.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mat_mul.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +/* $Id: mat_mul.cpp 3741 2015-10-07 14:51:10Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,16 +27,13 @@ CppAD dz typedef + boolsparsity + enum $$ -$section CppAD Speed: Matrix Multiplication$$ +$section CppAD Speed, Matrix Multiplication$$ +$mindex link_mat_mul multiply$$ -$index link_mat_mul, cppad$$ -$index cppad, link_mat_mul$$ -$index speed, cppad$$ -$index cppad, speed$$ -$index matrix, speed cppad$$ -$index multiply, speed cppad$$ $head Specifications$$ See $cref link_mat_mul$$. @@ -51,11 +48,11 @@ // Note that CppAD uses global_memory at the main program level extern bool - global_onetape, global_atomic, global_optimize; + global_onetape, global_atomic, global_optimize, global_boolsparsity; bool link_mat_mul( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz @@ -63,8 +60,8 @@ { // ----------------------------------------------------- // setup - typedef CppAD::AD ADScalar; - typedef CppAD::vector ADVector; + typedef CppAD::AD ADScalar; + typedef CppAD::vector ADVector; size_t j; // temporary index size_t m = 1; // number of dependent variables @@ -73,8 +70,8 @@ ADVector Y(n); // Store product matrix ADVector Z(m); // AD range space vector CppAD::ADFun f; // AD function object - - // vectors of reverse mode weights + + // vectors of reverse mode weights CppAD::vector w(1); w[0] = 1.; @@ -84,7 +81,11 @@ size_t n_middle = size; size_t nc_result = size; matrix_mul atom_mul(nr_result, n_middle, nc_result); - + // + if( global_boolsparsity ) + atom_mul.option( CppAD::atomic_base::pack_sparsity_enum ); + else + atom_mul.option( CppAD::atomic_base::set_sparsity_enum ); // ------------------------------------------------------ if( ! global_onetape ) while(repeat--) { // get the next matrix @@ -108,13 +109,16 @@ Z[0] = 0.; for(j = 0; j < n; j++) Z[0] += ay[j]; - } + } // create function object f : X -> Z f.Dependent(X, Z); if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + // evaluate and return gradient using reverse mode z = f.Forward(0, x); dz = f.Reverse(1, w); @@ -141,13 +145,17 @@ Z[0] = 0.; for(j = 0; j < n; j++) Z[0] += ay[j]; - } - + } + // create function object f : X -> Z f.Dependent(X, Z); if( global_optimize ) f.optimize(); + + // skip comparison operators + f.compare_change_count(0); + while(repeat--) { // get a next matrix CppAD::uniform_01(n, x); @@ -158,7 +166,7 @@ } } // -------------------------------------------------------------------- - // Free temporary work space. (If there are future calls to + // Free temporary work space. (If there are future calls to // mat_mul they would create new temporary work space.) CppAD::user_atomic::clear(); diff -Nru cppad-2015.00.00.9/speed/cppad/ode.cpp cppad-2016.00.00.1/speed/cppad/ode.cpp --- cppad-2015.00.00.9/speed/cppad/ode.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/ode.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -29,12 +29,8 @@ $$ $section CppAD Speed: Gradient of Ode Solution$$ +$mindex link_ode speed$$ -$index link_ode, cppad$$ -$index cppad, link_ode$$ -$index speed, cppad$$ -$index cppad, speed$$ -$index ode, speed cppad$$ $head Specifications$$ See $cref link_ode$$. @@ -79,7 +75,7 @@ // ------------------------------------------------------------- if( ! global_onetape ) while(repeat--) - { // choose next x value + { // choose next x value uniform_01(n, x); for(j = 0; j < n; j++) X[j] = x[j]; @@ -96,10 +92,13 @@ if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + jacobian = f.Jacobian(x); } else - { // an x value + { // an x value uniform_01(n, x); for(j = 0; j < n; j++) X[j] = x[j]; @@ -115,6 +114,10 @@ if( global_optimize ) f.optimize(); + + // skip comparison operators + f.compare_change_count(0); + while(repeat--) { // get next argument value uniform_01(n, x); diff -Nru cppad-2015.00.00.9/speed/cppad/poly.cpp cppad-2016.00.00.1/speed/cppad/poly.cpp --- cppad-2015.00.00.9/speed/cppad/poly.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/poly.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: poly.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,12 +36,8 @@ $$ $section CppAD Speed: Second Derivative of a Polynomial$$ +$mindex link_poly speed$$ -$index link_poly, cppad$$ -$index cppad, link_poly$$ -$index speed, cppad$$ -$index cppad, speed$$ -$index polynomial, speed cppad$$ $head Specifications$$ See $cref link_poly$$. @@ -57,11 +53,11 @@ global_onetape, global_atomic, global_optimize; bool link_poly( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &a , // coefficients of polynomial CppAD::vector &z , // polynomial argument value - CppAD::vector &ddp ) // second derivative w.r.t z + CppAD::vector &ddp ) // second derivative w.r.t z { // speed test global option values if( global_atomic ) @@ -69,8 +65,8 @@ // ----------------------------------------------------- // setup - typedef CppAD::AD ADScalar; - typedef CppAD::vector ADVector; + typedef CppAD::AD ADScalar; + typedef CppAD::vector ADVector; size_t i; // temporary index size_t m = 1; // number of dependent variables @@ -104,7 +100,7 @@ // declare independent variables Independent(Z); - // AD computation of the function value + // AD computation of the function value P[0] = CppAD::Poly(0, A, Z[0]); // create function object f : A -> detA @@ -113,10 +109,13 @@ if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + // pre-allocate memory for three forward mode calculations f.capacity_order(3); - // evaluate the polynomial + // evaluate the polynomial p = f.Forward(0, z); // evaluate first order Taylor coefficient @@ -135,7 +134,7 @@ // declare independent variables Independent(Z); - // AD computation of the function value + // AD computation of the function value P[0] = CppAD::Poly(0, A, Z[0]); // create function object f : A -> detA @@ -144,6 +143,9 @@ if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + while(repeat--) { // sufficient memory is allocated by second repetition diff -Nru cppad-2015.00.00.9/speed/cppad/sparse_hessian.cpp cppad-2016.00.00.1/speed/cppad/sparse_hessian.cpp --- cppad-2015.00.00.9/speed/cppad/sparse_hessian.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/sparse_hessian.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_hessian.cpp 3139 2014-03-02 21:12:00Z bradbell $ */ +// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,6 +12,8 @@ /* $begin cppad_sparse_hessian.cpp$$ $spell + ifdef + ifndef colpack boolsparsity namespace @@ -34,13 +36,8 @@ $$ $section CppAD Speed: Sparse Hessian$$ +$mindex link_sparse_hessian speed$$ -$index link_sparse_hessian, cppad$$ -$index cppad, link_sparse_hessian$$ -$index speed, cppad$$ -$index cppad, speed$$ -$index sparse, speed cppad$$ -$index hessian, speed cppad$$ $head Specifications$$ See $cref link_sparse_hessian$$. @@ -54,7 +51,7 @@ // Note that CppAD uses global_memory at the main program level extern bool - global_onetape, global_colpack, + global_onetape, global_colpack, global_atomic, global_optimize, global_boolsparsity; namespace { @@ -98,15 +95,20 @@ } bool link_sparse_hessian( - size_t size , - size_t repeat , + size_t size , + size_t repeat , const CppAD::vector& row , const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& hessian ) + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ) { - if( global_atomic || global_colpack ) + if( global_atomic ) return false; +# ifndef CPPAD_COLPACK_SPEED + if( global_colpack ) + return false; +# endif // ----------------------------------------------------- // setup typedef vector DblVector; @@ -114,15 +116,13 @@ typedef CppAD::AD ADScalar; typedef vector ADVector; - size_t i, j, k; + size_t j; size_t order = 0; // derivative order corresponding to function size_t m = 1; // number of dependent variables size_t n = size; // number of independent variables - size_t K = row.size(); // number of non-zeros in lower triangle ADVector a_x(n); // AD domain space vector ADVector a_y(m); // AD range space vector DblVector w(m); // double range space vector - DblVector hes(K); // non-zeros in lower triangle CppAD::ADFun f; // AD function object // weights for hessian calculation (only one component of f) @@ -132,20 +132,15 @@ SetVector set_sparsity(n); BoolVector bool_sparsity(n * n); - // initialize all entries as zero - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - hessian[ i * n + j] = 0.; - } // ------------------------------------------------------ if( ! global_onetape ) while(repeat--) - { // choose a value for x + { // choose a value for x CppAD::uniform_01(n, x); for(j = 0; j < n; j++) a_x[j] = x[j]; // declare independent variables - Independent(a_x); + Independent(a_x); // AD computation of f(x) CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); @@ -156,6 +151,9 @@ if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + // calculate the Hessian sparsity pattern for this function if( global_boolsparsity ) calc_sparsity(bool_sparsity, f); @@ -164,25 +162,26 @@ // structure that holds some of work done by SparseHessian CppAD::sparse_hessian_work work; - +# ifdef CPPAD_COLPACK_SPEED + if( global_colpack ) + work.color_method = "colpack.star"; +# endif // calculate this Hessian at this x - if( global_boolsparsity) - f.SparseHessian(x, w, bool_sparsity, row, col, hes, work); - else - f.SparseHessian(x, w, set_sparsity, row, col, hes, work); - for(k = 0; k < K; k++) - { hessian[ row[k] * n + col[k] ] = hes[k]; - hessian[ col[k] * n + row[k] ] = hes[k]; - } + if( global_boolsparsity) n_sweep = f.SparseHessian( + x, w, bool_sparsity, row, col, hessian, work + ); + else n_sweep = f.SparseHessian( + x, w, set_sparsity, row, col, hessian, work + ); } else - { // choose a value for x + { // choose a value for x CppAD::uniform_01(n, x); for(j = 0; j < n; j++) a_x[j] = x[j]; // declare independent variables - Independent(a_x); + Independent(a_x); // AD computation of f(x) CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); @@ -193,6 +192,9 @@ if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + // calculate the Hessian sparsity pattern for this function if( global_boolsparsity) calc_sparsity(bool_sparsity, f); @@ -201,21 +203,21 @@ // declare structure that holds some of work done by SparseHessian CppAD::sparse_hessian_work work; - +# ifdef CPPAD_COLPACK_SPEED + if( global_colpack ) + work.color_method = "colpack.star"; +# endif while(repeat--) { // choose a value for x CppAD::uniform_01(n, x); - // calculate sparsity at this x - if( global_boolsparsity ) - f.SparseHessian(x, w, bool_sparsity, row, col, hes, work); - else - f.SparseHessian(x, w, set_sparsity, row, col, hes, work); - - for(k = 0; k < K; k++) - { hessian[ row[k] * n + col[k] ] = hes[k]; - hessian[ col[k] * n + row[k] ] = hes[k]; - } + // calculate hessian at this x + if( global_boolsparsity ) n_sweep = f.SparseHessian( + x, w, bool_sparsity, row, col, hessian, work + ); + else n_sweep = f.SparseHessian( + x, w, set_sparsity, row, col, hessian, work + ); } } return true; diff -Nru cppad-2015.00.00.9/speed/cppad/sparse_jacobian.cpp cppad-2016.00.00.1/speed/cppad/sparse_jacobian.cpp --- cppad-2015.00.00.9/speed/cppad/sparse_jacobian.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/cppad/sparse_jacobian.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_jacobian.cpp 3139 2014-03-02 21:12:00Z bradbell $ */ +// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -37,13 +37,8 @@ $$ $section CppAD Speed: Sparse Jacobian$$ +$mindex link_sparse_jacobian speed$$ -$index link_sparse_jacobian, cppad$$ -$index cppad, link_sparse_jacobian$$ -$index speed, cppad$$ -$index cppad, speed$$ -$index sparse, speed cppad$$ -$index jacobian, speed cppad$$ $head Specifications$$ See $cref link_sparse_jacobian$$. @@ -87,8 +82,8 @@ } bool link_sparse_jacobian( - size_t size , - size_t repeat , + size_t size , + size_t repeat , size_t m , const CppAD::vector& row , const CppAD::vector& col , @@ -105,39 +100,31 @@ // ----------------------------------------------------- // setup typedef vector< std::set > SetVector; - typedef CppAD::vector DblVector; typedef CppAD::AD ADScalar; typedef CppAD::vector ADVector; - size_t i, j, k; - size_t order = 0; // derivative order corresponding to function - size_t K = row.size();// number of row and column indices + size_t j; + size_t order = 0; // derivative order corresponding to function size_t n = size; // number of independent variables ADVector a_x(n); // AD domain space vector ADVector a_y(m); // AD range space vector y = g(x) - DblVector jac(K); // non-zeros in Jacobian CppAD::ADFun f; // AD function object // declare sparsity pattern SetVector set_sparsity(m); BoolVector bool_sparsity(m * n); - // initialize all entries as zero - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - jacobian[ i * n + j ] = 0.; - } // ------------------------------------------------------ if( ! global_onetape ) while(repeat--) - { // choose a value for x + { // choose a value for x CppAD::uniform_01(n, x); - for(k = 0; k < n; k++) - a_x[k] = x[k]; + for(j = 0; j < n; j++) + a_x[j] = x[j]; // declare independent variables - Independent(a_x); + Independent(a_x); - // AD computation of f (x) + // AD computation of f (x) CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); // create function object f : X -> Y @@ -146,6 +133,9 @@ if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + // calculate the Jacobian sparsity pattern for this function if( global_boolsparsity ) calc_sparsity(bool_sparsity, f); @@ -161,24 +151,22 @@ // calculate the Jacobian at this x // (use forward mode because m > n ?) if( global_boolsparsity) n_sweep = f.SparseJacobianForward( - x, bool_sparsity, row, col, jac, work + x, bool_sparsity, row, col, jacobian, work ); else n_sweep = f.SparseJacobianForward( - x, set_sparsity, row, col, jac, work + x, set_sparsity, row, col, jacobian, work ); - for(k = 0; k < K; k++) - jacobian[ row[k] * n + col[k] ] = jac[k]; } else - { // choose a value for x + { // choose a value for x CppAD::uniform_01(n, x); - for(k = 0; k < n; k++) - a_x[k] = x[k]; + for(j = 0; j < n; j++) + a_x[j] = x[j]; // declare independent variables - Independent(a_x); + Independent(a_x); - // AD computation of f (x) + // AD computation of f (x) CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); // create function object f : X -> Y @@ -187,6 +175,9 @@ if( global_optimize ) f.optimize(); + // skip comparison operators + f.compare_change_count(0); + // calculate the Jacobian sparsity pattern for this function if( global_boolsparsity ) calc_sparsity(bool_sparsity, f); @@ -199,21 +190,18 @@ if( global_colpack ) work.color_method = "colpack"; # endif - while(repeat--) - { // choose a value for x + { // choose a value for x CppAD::uniform_01(n, x); // calculate the Jacobian at this x // (use forward mode because m > n ?) if( global_boolsparsity ) n_sweep = f.SparseJacobianForward( - x, bool_sparsity, row, col, jac, work + x, bool_sparsity, row, col, jacobian, work ); else n_sweep = f.SparseJacobianForward( - x, set_sparsity, row, col, jac, work + x, set_sparsity, row, col, jacobian, work ); - for(k = 0; k < K; k++) - jacobian[ row[k] * n + col[k] ] = jac[k]; } } return true; diff -Nru cppad-2015.00.00.9/speed/double/det_lu.cpp cppad-2016.00.00.1/speed/double/det_lu.cpp --- cppad-2015.00.00.9/speed/double/det_lu.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/det_lu.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_lu.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,21 +22,15 @@ $$ $section Double Speed: Determinant Using Lu Factorization$$ +$mindex link_det_lu speed matrix factor$$ -$index link_det_lu, double$$ -$index double, link_det_lu$$ -$index speed, double$$ -$index double, speed$$ -$index lu, speed double$$ -$index matrix, factor speed double$$ -$index factor, matrix speed double$$ $head Specifications$$ See $cref link_det_lu$$. $head Implementation$$ $codep */ -# include +# include # include # include @@ -45,8 +39,8 @@ global_onetape, global_atomic, global_optimize; bool link_det_lu( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &det ) { @@ -56,7 +50,7 @@ // setup CppAD::det_by_lu Det(size); size_t n = size * size; // number of independent variables - + // ------------------------------------------------------ while(repeat--) diff -Nru cppad-2015.00.00.9/speed/double/det_minor.cpp cppad-2016.00.00.1/speed/double/det_minor.cpp --- cppad-2015.00.00.9/speed/double/det_minor.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/det_minor.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_minor.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,13 +22,8 @@ $$ $section Double Speed: Determinant by Minor Expansion$$ +$mindex link_det_minor speed$$ -$index link_det_minor, double$$ -$index double, link_det_minor$$ -$index speed, double$$ -$index double, speed$$ -$index minor, speed double$$ -$index determinant, speed double$$ $head Specifications$$ See $cref link_det_minor$$. @@ -36,7 +31,7 @@ $head Implementation$$ $codep */ -# include +# include # include # include @@ -45,8 +40,8 @@ global_onetape, global_atomic, global_optimize; bool link_det_minor( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &det ) { @@ -56,7 +51,7 @@ // setup CppAD::det_by_minor Det(size); size_t n = size * size; // number of independent variables - + // ------------------------------------------------------ while(repeat--) { // get the next matrix diff -Nru cppad-2015.00.00.9/speed/double/makefile.am cppad-2016.00.00.1/speed/double/makefile.am --- cppad-2015.00.00.9/speed/double/makefile.am 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/makefile.am 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3481 2014-12-17 23:39:47Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -18,7 +18,7 @@ # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -check_PROGRAMS = speed_double +check_PROGRAMS = speed_double # AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # diff -Nru cppad-2015.00.00.9/speed/double/makefile.in cppad-2016.00.00.1/speed/double/makefile.in --- cppad-2015.00.00.9/speed/double/makefile.in 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/makefile.in 2016-02-09 08:31:53.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = speed_double$(EXEEXT) subdir = speed/double -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -150,6 +159,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -253,26 +263,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -311,12 +324,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -366,7 +379,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu speed/double/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/double/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -627,6 +639,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + main.cpp: cp $(srcdir)/../main.cpp main.cpp diff -Nru cppad-2015.00.00.9/speed/double/mat_mul.cpp cppad-2016.00.00.1/speed/double/mat_mul.cpp --- cppad-2015.00.00.9/speed/double/mat_mul.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/mat_mul.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mat_mul.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,18 +24,13 @@ $$ $section CppAD Speed: Matrix Multiplication (Double Version)$$ +$mindex speed multiply link_mat_mul$$ -$index cppad, speed matrix multiply$$ -$index speed, cppad matrix multiply$$ -$index matrix, multiply speed cppad$$ -$index multiply, matrix speed cppad$$ $head Specifications$$ See $cref link_mat_mul$$. $head Implementation$$ -$index cppad, link_mat_mul$$ -$index link_mat_mul, cppad$$ $codep */ # include # include @@ -46,8 +41,8 @@ global_onetape, global_atomic, global_optimize; bool link_mat_mul( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz @@ -65,7 +60,7 @@ // do computation mat_sum_sq(size, x, y, z); - + } return true; } diff -Nru cppad-2015.00.00.9/speed/double/ode.cpp cppad-2016.00.00.1/speed/double/ode.cpp --- cppad-2015.00.00.9/speed/double/ode.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/ode.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,12 +25,8 @@ $$ $section Double Speed: Ode Solution$$ +$mindex link_ode speed$$ -$index link_ode, double$$ -$index double, link_ode$$ -$index speed, double$$ -$index double, speed$$ -$index ode, speed double$$ $head Specifications$$ See $cref link_ode$$. @@ -39,7 +35,7 @@ $codep */ # include -# include +# include # include # include @@ -66,7 +62,7 @@ CppAD::vector f(n); while(repeat--) - { // choose next x value + { // choose next x value uniform_01(n, x); // evaluate function diff -Nru cppad-2015.00.00.9/speed/double/poly.cpp cppad-2016.00.00.1/speed/double/poly.cpp --- cppad-2015.00.00.9/speed/double/poly.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/poly.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: poly.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,13 +21,9 @@ $$ $section Double Speed: Evaluate a Polynomial$$ +$mindex link_poly speed$$ -$index link_poly, double$$ -$index double, link_poly$$ -$index speed, double$$ -$index double, speed$$ -$index polynomial, speed double$$ $head Specifications$$ See $cref link_poly$$. @@ -43,11 +39,11 @@ global_onetape, global_atomic, global_optimize; bool link_poly( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &a , // coefficients of polynomial CppAD::vector &z , // polynomial argument value - CppAD::vector &p ) // second derivative w.r.t z + CppAD::vector &p ) // second derivative w.r.t z { if(global_onetape||global_atomic||global_optimize) return false; diff -Nru cppad-2015.00.00.9/speed/double/sparse_hessian.cpp cppad-2016.00.00.1/speed/double/sparse_hessian.cpp --- cppad-2015.00.00.9/speed/double/sparse_hessian.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/sparse_hessian.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_hessian.cpp 3136 2014-03-02 11:54:07Z bradbell $ */ +// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,13 +23,8 @@ $$ $section Double Speed: Sparse Hessian$$ +$mindex link_sparse_hessian speed$$ -$index link_sparse_hessian, double$$ -$index double, link_sparse_hessian$$ -$index speed, double$$ -$index double, speed$$ -$index sparse, speed double$$ -$index hessian, speed double$$ $head Specifications$$ See $cref link_sparse_hessian$$. @@ -37,7 +32,7 @@ $head Implementation$$ $codep */ -# include +# include # include # include @@ -46,12 +41,13 @@ global_onetape, global_atomic, global_optimize, global_boolsparsity; bool link_sparse_hessian( - size_t size , - size_t repeat , + size_t size , + size_t repeat , const CppAD::vector& row , const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& hessian ) + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ) { if(global_onetape||global_atomic||global_optimize||global_boolsparsity) return false; @@ -60,12 +56,12 @@ using CppAD::vector; size_t order = 0; // derivative order corresponding to function size_t n = size; // argument space dimension - size_t m = 1; // range space dimension + size_t m = 1; // range space dimension vector y(m); // function value // choose a value for x CppAD::uniform_01(n, x); - + // ------------------------------------------------------ while(repeat--) diff -Nru cppad-2015.00.00.9/speed/double/sparse_jacobian.cpp cppad-2016.00.00.1/speed/double/sparse_jacobian.cpp --- cppad-2015.00.00.9/speed/double/sparse_jacobian.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/double/sparse_jacobian.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_jacobian.cpp 3138 2014-03-02 18:46:11Z bradbell $ */ +// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -29,13 +29,8 @@ $$ $section Double Speed: Sparse Jacobian$$ +$mindex link_sparse_jacobian speed$$ -$index link_sparse_jacobian, double$$ -$index double, link_sparse_jacobian$$ -$index speed, double$$ -$index double, speed$$ -$index sparse, speed double$$ -$index jacobian, speed double$$ $head Specifications$$ See $cref link_sparse_jacobian$$. @@ -43,7 +38,7 @@ $head Implementation$$ $codep */ -# include +# include # include # include @@ -52,8 +47,8 @@ global_onetape, global_atomic, global_optimize, global_boolsparsity; bool link_sparse_jacobian( - size_t size , - size_t repeat , + size_t size , + size_t repeat , size_t m , const CppAD::vector& row , const CppAD::vector& col , @@ -75,7 +70,7 @@ while(repeat--) { // choose a value for x CppAD::uniform_01(n, x); - + // computation of the function CppAD::sparse_jac_fun(m, n, x, row, col, order, yp); } diff -Nru cppad-2015.00.00.9/speed/example/det_by_lu.cpp cppad-2016.00.00.1/speed/example/det_by_lu.cpp --- cppad-2015.00.00.9/speed/example/det_by_lu.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/det_by_lu.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_by_lu.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: det_by_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,9 +18,7 @@ $$ $section Determinant Using Lu Factorization: Example and Test$$ -$index determinant, by minors$$ -$index example, determinant by minors$$ -$index test, determinant by minors$$ +$mindex minors$$ $code $verbatim%speed/example/det_by_lu.cpp%0%// BEGIN C++%// END C++%1%$$ diff -Nru cppad-2015.00.00.9/speed/example/det_by_minor.cpp cppad-2016.00.00.1/speed/example/det_by_minor.cpp --- cppad-2015.00.00.9/speed/example/det_by_minor.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/det_by_minor.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_by_minor.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: det_by_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,9 +17,7 @@ $$ $section Determinant Using Expansion by Minors: Example and Test$$ -$index determinant, by minors$$ -$index example, determinant by minors$$ -$index test, determinant by minors$$ +$mindex minors$$ $code $verbatim%speed/example/det_by_minor.cpp%0%// BEGIN C++%// END C++%1%$$ diff -Nru cppad-2015.00.00.9/speed/example/det_of_minor.cpp cppad-2016.00.00.1/speed/example/det_of_minor.cpp --- cppad-2015.00.00.9/speed/example/det_of_minor.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/det_of_minor.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_of_minor.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: det_of_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,10 +18,8 @@ $$ $section Determinant of a Minor: Example and Test$$ +$mindex det_of_minor$$ -$index det_of_minor, example$$ -$index example, det_of_minor$$ -$index test, det_of_minor$$ $code $verbatim%speed/example/det_of_minor.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -46,13 +44,13 @@ for(i= 0; i < m; i++) { r[i] = i+1; c[i] = i+1; - } + } r[m] = 0; c[m] = 0; // values in the matrix A double data[] = { - 1., 2., 3., - 3., 2., 1., + 1., 2., 3., + 3., 2., 1., 2., 1., 2. }; // construct vector a with the values of the matrix A @@ -68,7 +66,7 @@ // minor where row 0 and column 1 are removed r[m] = 1; // skip row index 0 by starting at row index 1 c[0] = 2; // skip column index 1 by pointing from index 0 to index 2 - // evaluate determinant of the minor + // evaluate determinant of the minor n = m - 1; // dimension of the minor det = CppAD::det_of_minor(a, m, m-1, r, c); diff -Nru cppad-2015.00.00.9/speed/example/elapsed_seconds.cpp cppad-2016.00.00.1/speed/example/elapsed_seconds.cpp --- cppad-2015.00.00.9/speed/example/elapsed_seconds.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/elapsed_seconds.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: elapsed_seconds.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: elapsed_seconds.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,11 +18,8 @@ $$ $section Elapsed Seconds: Example and Test$$ +$mindex seconds timer$$ -$index elapsed, seconds$$ -$index seconds, elapsed$$ -$index example, timer$$ -$index test, timer$$ $code $verbatim%speed/example/elapsed_seconds.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -31,7 +28,7 @@ $end */ // BEGIN C++ -# include +# include # include # include diff -Nru cppad-2015.00.00.9/speed/example/example.cpp cppad-2016.00.00.1/speed/example/example.cpp --- cppad-2015.00.00.9/speed/example/example.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/example.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: example.cpp 3114 2014-02-22 16:20:39Z bradbell $ */ +// $Id: example.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,12 +15,10 @@ $spell $$ -$index speed, example program$$ -$index program, speed example$$ -$index example, speed program$$ $section Run the Speed Examples$$ +$mindex program$$ $head Running Tests$$ To build this program and run its correctness tests see $cref cmake_check$$. @@ -60,7 +58,7 @@ size_t n_exception = sizeof(exception_list) / sizeof(exception_list[0]); bool Run(bool TestOk(void), std::string name) { bool ok = true; - std::streamsize width = 20; + std::streamsize width = 20; std::cout.width( width ); std::cout.setf( std::ios_base::left ); std::cout << name; diff -Nru cppad-2015.00.00.9/speed/example/makefile.am cppad-2016.00.00.1/speed/example/makefile.am --- cppad-2015.00.00.9/speed/example/makefile.am 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/makefile.am 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3481 2014-12-17 23:39:47Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -17,7 +17,7 @@ EXTRA_DIST = \ speed_program.cpp # -check_PROGRAMS = speed_example +check_PROGRAMS = speed_example # AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # @@ -37,7 +37,7 @@ sparse_jac_fun.cpp \ speed_test.cpp \ time_test.cpp \ - ../src/microsoft_timer.cpp + ../src/microsoft_timer.cpp test: check ./speed_example diff -Nru cppad-2015.00.00.9/speed/example/makefile.in cppad-2016.00.00.1/speed/example/makefile.in --- cppad-2015.00.00.9/speed/example/makefile.in 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/makefile.in 2016-02-09 08:31:53.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = speed_example$(EXEEXT) subdir = speed/example -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -153,6 +162,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -183,12 +193,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -269,26 +279,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -349,7 +362,7 @@ sparse_jac_fun.cpp \ speed_test.cpp \ time_test.cpp \ - ../src/microsoft_timer.cpp + ../src/microsoft_timer.cpp all: all-am @@ -367,7 +380,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu speed/example/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/example/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -640,6 +652,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + test: check ./speed_example diff -Nru cppad-2015.00.00.9/speed/example/mat_sum_sq.cpp cppad-2016.00.00.1/speed/example/mat_sum_sq.cpp --- cppad-2015.00.00.9/speed/example/mat_sum_sq.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/mat_sum_sq.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mat_sum_sq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: mat_sum_sq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -17,10 +17,8 @@ $$ $section Sum of the Elements of the Square of a Matrix: Example and Test$$ +$mindex mat_sum_sq$$ -$index mat_sum_sq, example$$ -$index example, mat_sum_sq$$ -$index test, mat_sum_sq$$ $code $verbatim%speed/example/mat_sum_sq.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -31,7 +29,7 @@ // BEGIN C++ # include # include -# include +# include # include bool mat_sum_sq() @@ -53,24 +51,24 @@ // check y_00 check = x_00 * x_00 + x_01 * x_10; - ok &= (check == y[0]); + ok &= (check == y[0]); // check y_01 check = x_00 * x_01 + x_01 * x_11; - ok &= (check == y[1]); + ok &= (check == y[1]); // check y_10 check = x_10 * x_00 + x_11 * x_10; - ok &= (check == y[2]); + ok &= (check == y[2]); // check y_11 check = x_10 * x_01 + x_11 * x_11; - ok &= (check == y[3]); - + ok &= (check == y[3]); + // check z check = y[0] + y[1] + y[2] + y[3]; - ok &= (check == z[0]); - + ok &= (check == z[0]); + return ok; } // END C++ diff -Nru cppad-2015.00.00.9/speed/example/ode_evaluate.cpp cppad-2016.00.00.1/speed/example/ode_evaluate.cpp --- cppad-2015.00.00.9/speed/example/ode_evaluate.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/ode_evaluate.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_evaluate.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_evaluate.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,11 +14,9 @@ $spell $$ -$index ode_evaluate, example$$ -$index example, ode_evaluate$$ -$index test, ode_evaluate$$ $section ode_evaluate: Example and test$$ +$mindex ode_evaluate$$ $code $verbatim%speed/example/ode_evaluate.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -69,7 +67,7 @@ size_t k; for(k = 0; k < n * n; k++) ok &= NearEqual(ym[k], dy[k] , 1e-7, 1e-7); - + return ok; } // END C++ diff -Nru cppad-2015.00.00.9/speed/example/sparse_hes_fun.cpp cppad-2016.00.00.1/speed/example/sparse_hes_fun.cpp --- cppad-2015.00.00.9/speed/example/sparse_hes_fun.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/sparse_hes_fun.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_hes_fun.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sparse_hes_fun.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,11 +15,9 @@ hes $$ -$index sparse_hes_fun, example$$ -$index example, sparse_hes_fun$$ -$index test, sparse_hes_fun$$ $section sparse_hes_fun: Example and test$$ +$mindex sparse_hes_fun$$ $code $verbatim%speed/example/sparse_hes_fun.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -38,13 +36,13 @@ typedef CppAD::AD ADScalar; - size_t i, j, k; + size_t j, k; double eps = 10. * CppAD::numeric_limits::epsilon(); - size_t n = 3; + size_t n = 5; size_t m = 1; - size_t K = 5; + size_t K = 2 * n; CppAD::vector row(K), col(K); - CppAD::vector x(n), yp(n * n); + CppAD::vector x(n), ypp(K); CppAD::vector a_x(n), a_y(m); // choose x @@ -53,8 +51,12 @@ // choose row, col for(k = 0; k < K; k++) - { row[k] = k % n; - col[k] = (K - k) % n; + { row[k] = k % 3; + col[k] = k / 3; + } + for(k = 0; k < K; k++) + { for(size_t k1 = 0; k1 < K; k1++) + assert( k == k1 || row[k] != row[k1] || col[k] != col[k1] ); } // declare independent variables @@ -66,7 +68,7 @@ // evaluate Hessian order = 2; - CppAD::sparse_hes_fun(n, x, row, col, order, yp); + CppAD::sparse_hes_fun(n, x, row, col, order, ypp); // use AD to evaluate Hessian CppAD::ADFun f(a_x, a_y); @@ -74,9 +76,9 @@ // compoute Hessian of f_0 (x) hes = f.Hessian(x, 0); - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - ok &= NearEqual(hes[i * n + j], yp[i * n + j] , eps, eps); + for(k = 0; k < K; k++) + { size_t index = row[k] * n + col[k]; + ok &= NearEqual(hes[index], ypp[k] , eps, eps); } return ok; } diff -Nru cppad-2015.00.00.9/speed/example/sparse_jac_fun.cpp cppad-2016.00.00.1/speed/example/sparse_jac_fun.cpp --- cppad-2015.00.00.9/speed/example/sparse_jac_fun.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/sparse_jac_fun.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_jac_fun.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sparse_jac_fun.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,11 +15,9 @@ jac $$ -$index sparse_jac_fun, example$$ -$index example, sparse_jac_fun$$ -$index test, sparse_jac_fun$$ $section sparse_jac_fun: Example and test$$ +$mindex sparse_jac_fun$$ $code $verbatim%speed/example/sparse_jac_fun.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -38,13 +36,13 @@ bool ok = true; - size_t i, j, k; + size_t j, k; double eps = CppAD::numeric_limits::epsilon(); size_t n = 3; size_t m = 4; size_t K = 5; CppAD::vector row(K), col(K); - CppAD::vector x(n), yp(m * n); + CppAD::vector x(n), yp(K); CppAD::vector< AD > a_x(n), a_y(m); // choose x @@ -73,11 +71,10 @@ CppAD::vector jac(m * n); jac = f.Jacobian(x); - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - ok &= NearEqual(jac[i * n + j], yp[i * n + j] , eps, eps); + for(k = 0; k < K; k++) + { size_t index = row[k] * n + col[k]; + ok &= NearEqual(jac[index], yp[k] , eps, eps); } - return ok; } // END C++ diff -Nru cppad-2015.00.00.9/speed/example/speed_program.cpp cppad-2016.00.00.1/speed/example/speed_program.cpp --- cppad-2015.00.00.9/speed/example/speed_program.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/speed_program.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: speed_program.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: speed_program.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-08 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,11 +26,9 @@ cpp $$ -$index SpeedTest, example$$ -$index example, SpeedTest$$ -$index test, speed$$ $section Example Use of SpeedTest$$ +$mindex test speed$$ $head Running This Program$$ On a Unix system that includes the $code g++$$ compiler, @@ -43,7 +41,7 @@ $head Program$$ $codep */ -# include +# include std::string Test(size_t size, size_t repeat) { // setup @@ -81,7 +79,7 @@ /* $$ $head Output$$ -Executing of the program above generated the following output +Executing of the program above generated the following output (the rates will be different for each particular system): $codep double: c[*] = a[*] + b[*] diff -Nru cppad-2015.00.00.9/speed/example/speed_test.cpp cppad-2016.00.00.1/speed/example/speed_test.cpp --- cppad-2015.00.00.9/speed/example/speed_test.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/speed_test.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: speed_test.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: speed_test.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,11 +25,9 @@ cpp $$ -$index speed_test, example$$ -$index example, speed_test$$ -$index test, speed$$ $section speed_test: Example and test$$ +$mindex speed_test$$ $code $verbatim%speed/example/speed_test.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -38,8 +36,8 @@ $end */ // BEGIN C++ -# include -# include +# include +# include namespace { // empty namespace using CppAD::vector; @@ -91,7 +89,7 @@ ok &= (std::fabs(rel_diff) <= .1); if( ! ok ) std::cout << std::endl << "rel_diff = " << rel_diff << std::endl; - + a.clear(); b.clear(); c.clear(); diff -Nru cppad-2015.00.00.9/speed/example/time_test.cpp cppad-2016.00.00.1/speed/example/time_test.cpp --- cppad-2015.00.00.9/speed/example/time_test.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/example/time_test.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: time_test.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: time_test.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,11 +25,9 @@ cpp $$ -$index time_test, example$$ -$index example, time_test$$ -$index test, time$$ $section time_test: Example and test$$ +$mindex time_test$$ $code $verbatim%speed/example/time_test.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -38,8 +36,8 @@ $end */ // BEGIN C++ -# include -# include +# include +# include namespace { // empty namespace using CppAD::vector; @@ -75,7 +73,7 @@ { bool ok = true; // minimum amount of time to run test - double time_min = 0.5; + double time_min = 0.5; // size of first test case size_ = 20; @@ -94,7 +92,7 @@ ok &= (std::fabs(rel_diff) <= .1); if( ! ok ) std::cout << std::endl << "rel_diff = " << rel_diff << std::endl; - + a.clear(); b.clear(); c.clear(); diff -Nru cppad-2015.00.00.9/speed/fadbad/det_lu.cpp cppad-2016.00.00.1/speed/fadbad/det_lu.cpp --- cppad-2015.00.00.9/speed/fadbad/det_lu.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/det_lu.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_lu.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,14 +28,8 @@ $$ $section Fadbad Speed: Gradient of Determinant Using Lu Factorization$$ +$mindex link_det_lu speed matrix factor$$ -$index link_det_lu, fadbad$$ -$index fadbad, link_det_lu$$ -$index speed, fadbad$$ -$index fadbad, speed$$ -$index lu, speed fadbad$$ -$index matrix, factor speed fadbad$$ -$index factor, matrix speed fadbad$$ $head Specifications$$ See $cref link_det_lu$$. @@ -45,14 +39,14 @@ # include # include # include -# include +# include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_lu( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { @@ -65,16 +59,16 @@ // setup // // object for computing determinant - typedef fadbad::B ADScalar; - typedef CppAD::vector ADVector; + typedef fadbad::B ADScalar; + typedef CppAD::vector ADVector; CppAD::det_by_lu Det(size); size_t i; // temporary index size_t m = 1; // number of dependent variables size_t n = size * size; // number of independent variables ADScalar detA; // AD value of the determinant - ADVector A(n); // AD version of matrix - + ADVector A(n); // AD version of matrix + // ------------------------------------------------------ while(repeat--) { // get the next matrix diff -Nru cppad-2015.00.00.9/speed/fadbad/det_minor.cpp cppad-2016.00.00.1/speed/fadbad/det_minor.cpp --- cppad-2015.00.00.9/speed/fadbad/det_minor.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/det_minor.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_minor.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,13 +27,8 @@ $$ $section Fadbad Speed: Gradient of Determinant by Minor Expansion$$ +$mindex link_det_minor speed$$ -$index link_det_minor, fadbad$$ -$index fadbad, link_det_minor$$ -$index speed, fadbad$$ -$index fadbad, speed$$ -$index minor, speed fadbad$$ -$index determinant, speed fadbad$$ $head Specifications$$ See $cref link_det_minor$$. @@ -44,36 +39,36 @@ # include # include # include -# include +# include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_minor( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_atomic ) - return false; + return false; if( global_memory || global_onetape || global_optimize ) - return false; + return false; // ----------------------------------------------------- // setup // object for computing determinant - typedef fadbad::B ADScalar; - typedef CppAD::vector ADVector; + typedef fadbad::B ADScalar; + typedef CppAD::vector ADVector; CppAD::det_by_minor Det(size); size_t i; // temporary index size_t m = 1; // number of dependent variables size_t n = size * size; // number of independent variables ADScalar detA; // AD value of the determinant - ADVector A(n); // AD version of matrix - + ADVector A(n); // AD version of matrix + // ------------------------------------------------------ while(repeat--) { // get the next matrix diff -Nru cppad-2015.00.00.9/speed/fadbad/makefile.am cppad-2016.00.00.1/speed/fadbad/makefile.am --- cppad-2015.00.00.9/speed/fadbad/makefile.am 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/makefile.am 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3481 2014-12-17 23:39:47Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -19,7 +19,7 @@ # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -check_PROGRAMS = speed_fadbad +check_PROGRAMS = speed_fadbad # AM_CPPFLAGS = \ -I$(top_srcdir) \ diff -Nru cppad-2015.00.00.9/speed/fadbad/makefile.in cppad-2016.00.00.1/speed/fadbad/makefile.in --- cppad-2015.00.00.9/speed/fadbad/makefile.in 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/makefile.in 2016-02-09 08:31:52.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = speed_fadbad$(EXEEXT) subdir = speed/fadbad -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -150,6 +159,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -254,26 +264,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -312,12 +325,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -373,7 +386,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu speed/fadbad/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/fadbad/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -634,6 +646,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + main.cpp: cp $(srcdir)/../main.cpp main.cpp diff -Nru cppad-2015.00.00.9/speed/fadbad/mat_mul.cpp cppad-2016.00.00.1/speed/fadbad/mat_mul.cpp --- cppad-2015.00.00.9/speed/fadbad/mat_mul.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/mat_mul.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mat_mul.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,13 +27,8 @@ $$ $section Fadbad Speed: Matrix Multiplication$$ +$mindex link_mat_mul speed multiply$$ -$index link_mat_mul, fadbad$$ -$index fadbad, link_mat_mul$$ -$index speed, fadbad$$ -$index fadbad, speed$$ -$index matrix, speed fadbad$$ -$index multiply, speed fadbad$$ $head Specifications$$ See $cref link_mat_mul$$. @@ -44,14 +39,14 @@ # include # include # include -# include +# include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_mat_mul( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz ) @@ -66,8 +61,8 @@ // setup // object for computing determinant - typedef fadbad::B ADScalar; - typedef CppAD::vector ADVector; + typedef fadbad::B ADScalar; + typedef CppAD::vector ADVector; size_t j; // temporary index size_t m = 1; // number of dependent variables @@ -75,7 +70,7 @@ ADVector X(n); // AD domain space vector ADVector Y(n); // Store product matrix ADVector Z(m); // AD range space vector - + // ------------------------------------------------------ while(repeat--) { // get the next matrix diff -Nru cppad-2015.00.00.9/speed/fadbad/ode.cpp cppad-2016.00.00.1/speed/fadbad/ode.cpp --- cppad-2015.00.00.9/speed/fadbad/ode.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/ode.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -31,13 +31,9 @@ $$ $section Fadbad Speed: Ode$$ +$mindex link_ode speed$$ -$index link_ode, fadbad$$ -$index fadbad, link_ode$$ -$index speed, fadbad$$ -$index fadbad, speed$$ -$index ode, speed fadbad$$ $head Specifications$$ See $cref link_ode$$. @@ -48,7 +44,7 @@ # include # include # include -# include +# include # include # include @@ -89,7 +85,7 @@ // ------------------------------------------------------------- while(repeat--) - { // choose next x value + { // choose next x value CppAD::uniform_01(n, x); for(j = 0; j < n; j++) { // set value of x[j] diff -Nru cppad-2015.00.00.9/speed/fadbad/poly.cpp cppad-2016.00.00.1/speed/fadbad/poly.cpp --- cppad-2015.00.00.9/speed/fadbad/poly.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/poly.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: poly.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -35,12 +35,8 @@ $$ $section Fadbad Speed: Second Derivative of a Polynomial$$ +$mindex link_poly speed$$ -$index link_poly, fadbad$$ -$index fadbad, link_poly$$ -$index speed, fadbad$$ -$index fadbad, speed$$ -$index polynomial, speed fadbad$$ $head Specifications$$ See $cref link_poly$$. @@ -48,8 +44,8 @@ $head Implementation$$ $codep */ -# include -# include +# include +# include # include # include @@ -57,11 +53,11 @@ extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_poly( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &a , // coefficients of polynomial CppAD::vector &z , // polynomial argument value - CppAD::vector &ddp ) // second derivative w.r.t z + CppAD::vector &ddp ) // second derivative w.r.t z { if( global_atomic ) return false; @@ -69,7 +65,7 @@ return false; // ----------------------------------------------------- // setup - size_t i; // temporary index + size_t i; // temporary index fadbad::T Z; // domain space AD value fadbad::T P; // range space AD value diff -Nru cppad-2015.00.00.9/speed/fadbad/sparse_hessian.cpp cppad-2016.00.00.1/speed/fadbad/sparse_hessian.cpp --- cppad-2015.00.00.9/speed/fadbad/sparse_hessian.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/sparse_hessian.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,16 +1,16 @@ -/* $Id: sparse_hessian.cpp 3136 2014-03-02 11:54:07Z bradbell $ */ +// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -# include +# include /* $begin fadbad_sparse_hessian.cpp$$ @@ -24,14 +24,15 @@ $section Fadbad Speed: Sparse Hessian$$ $codep */ -// A fadbad version of this test is not yet available +// A fadbad version of this test is not yet available bool link_sparse_hessian( size_t size , size_t repeat , const CppAD::vector& row , const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& hessian + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ) { return false; diff -Nru cppad-2015.00.00.9/speed/fadbad/sparse_jacobian.cpp cppad-2016.00.00.1/speed/fadbad/sparse_jacobian.cpp --- cppad-2015.00.00.9/speed/fadbad/sparse_jacobian.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/fadbad/sparse_jacobian.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,16 +1,16 @@ -/* $Id: sparse_jacobian.cpp 3138 2014-03-02 18:46:11Z bradbell $ */ +// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include -# include +# include /* $begin fadbad_sparse_jacobian.cpp$$ @@ -27,8 +27,8 @@ $codep */ // A fadbad version of this test is not yet available bool link_sparse_jacobian( - size_t size , - size_t repeat , + size_t size , + size_t repeat , size_t m , const CppAD::vector& row , const CppAD::vector& col , diff -Nru cppad-2015.00.00.9/speed/main.cpp cppad-2016.00.00.1/speed/main.cpp --- cppad-2015.00.00.9/speed/main.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/main.cpp 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: main.cpp 3320 2014-09-11 23:06:21Z bradbell $ */ +// $Id: main.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,14 +16,14 @@ # include # include # include -# include +# include # include # include -# include +# include # include -# include -# include -# include +# include +# include +# include # ifdef CPPAD_ADOLC_SPEED # define AD_PACKAGE "adolc" @@ -67,11 +67,9 @@ Jacobian $$ -$index cppad, speed test$$ -$index speed, test cppad$$ -$index test, cppad speed$$ $section Running the Speed Test Program$$ +$mindex cppad uniform_01$$ $head Syntax$$ $codei%speed/%package%/speed_%package% %test% %seed% %option_list%$$ @@ -87,12 +85,12 @@ $icode package$$ specifies one of the AD package. The CppAD distribution comes with support for the following packages: $cref/adolc/speed_adolc/$$, -$cref/cppad/speed_cppad/$$, -$cref/fadbad/speed_fadbad/$$, +$cref/cppad/speed_cppad/$$, +$cref/fadbad/speed_fadbad/$$, $cref/sacado/speed_sacado/$$. You can extend this program to include other package. -Such an extension need not include all the tests. -For example, +Such an extension need not include all the tests. +For example, $cref link_sparse_hessian$$ just returns $code false$$ for the $cref/fadbad/fadbad_sparse_hessian.cpp/$$ and $cref/sacado/sacado_sparse_hessian.cpp/$$ packages. @@ -106,7 +104,7 @@ This enables one to compare the speed of computing function values in $code double$$ to the speed of the derivative computations. (It is often useful to divide the speed of the derivative computation by -the speed of the function evaluation in $code double$$.) +the speed of the function evaluation in $code double$$.) $subhead profile$$ In the special case where $icode package$$ is $code profile$$, @@ -137,7 +135,6 @@ all of the speed tests are run. $head seed$$ -$index uniform_01$$ The command line argument $icode seed$$ is a positive integer. The random number simulator $cref uniform_01$$ is initialized with the call @@ -149,8 +146,8 @@ $head option_list$$ This is a list of options that follow $icode seed$$ value. The order of the options does not matter and the list can be empty. -Each option in the list, must be separate -command line argument to the main program. +Each option in the list, must be separate +command line argument to the main program. The documentation below specifics how CppAD uses these options, see the examples in $cref speed_adolc$$ for how another package might uses these options. @@ -164,7 +161,7 @@ If this external symbol is true, CppAD will use one taping of the operation sequence for all the repetitions of that speed test. -Otherwise, the +Otherwise, the $cref/operation sequence/glossary/Operation/Sequence/$$ will be retaped for each test repetition. $pre @@ -172,11 +169,11 @@ $$ All of the tests, except $cref/det_lu/link_det_lu/$$, have a fixed operations sequence. -The operation sequence for $code det_lu$$ +The operation sequence for $code det_lu$$ may be different for each repetition of the test because it -depends on the matrix for which the determinant is being calculated. +depends on the matrix for which the determinant is being calculated. For this reason, the CppAD test -$cref cppad_det_lu.cpp$$ returns false +$cref cppad_det_lu.cpp$$ returns false (indicating that the test not implemented) when $code global_onetape$$ is true. @@ -196,7 +193,7 @@ extern bool global_atomic $$ is true and otherwise it is false. -If this external symbol is true, CppAD will use its user defined +If this external symbol is true, CppAD will use its user defined $cref/atomic/atomic_base/$$ operation is used for the test. If no such atomic operation exists, and atomic is chosen, CppAD returns false for the test. @@ -208,13 +205,13 @@ $$ is true and otherwise it is false. If it is true, the CppAD -$cref/hold_memory/ta_hold_memory/$$ routine will be called by +$cref/hold_memory/ta_hold_memory/$$ routine will be called by the main program before any of the tests are executed. This should make the CppAD $code thread_alloc$$ allocator faster. -If it is false, CppAD will used standard memory allocation. +If it is false, CppAD will used standard memory allocation. $head Sparsity Options$$ -The following options only apply to the +The following options only apply to the $cref/sparse_jacobian/link_sparse_jacobian/$$ and $cref/sparse_hessian/link_sparse_hessian/$$ tests. The other tests will ignore these options: @@ -227,8 +224,8 @@ is true and otherwise it is false. If it is true, CppAD will use a $cref/vector of bool/glossary/Sparsity Pattern/Vector of Boolean/$$ -for its sparsity patterns. -Otherwise it will use a +for its sparsity patterns. +Otherwise it will use a $cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$. $subhead colpack$$ @@ -238,8 +235,8 @@ $$ is true and otherwise it is false. If this external symbol is true, -CppAD will use $cref/colpack/colpack_prefix/$$ to do the coloring -for its +CppAD will use $cref/colpack/colpack_prefix/$$ to do the coloring +for its Otherwise, it will use it's own coloring algorithm. $head Correctness Results$$ @@ -250,7 +247,7 @@ %$$ is generated for each correctness test where $icode package$$ and $icode test$$ are as above, -$icode optionlist$$ are the options (in $icode option_list$$) +$icode optionlist$$ are the options (in $icode option_list$$) separated by the underbar $code _$$ character (whereas they are separated by spaces in $icode option_list$$), and $icode flag$$ is $code true$$ or $code false$$. @@ -270,15 +267,19 @@ The values $icode rate_1$$, ..., $icode rate_n$$ are the number of times per second that the corresponding size problem executed. -$subhead sparse_jacobian$$ -The $cref/sparse_jacobian/link_sparse_jacobian/$$ test has an extra output +$subhead n_sweep$$ +The $cref/sparse_jacobian/link_sparse_jacobian/$$ +and $cref/sparse_hessian/link_sparse_hessian/$$ tests has an extra output line with the following form $codei% - %package%_sparse_jacobian_n_sweep = [ %n_sweep_1%, %...%, %n_sweep_n% ] + %package%_sparse_%test%_n_sweep = [ %n_sweep_1%, %...%, %n_sweep_n% ] %$$ -The values $icode n_sweep_1$$, ..., $icode n_sweep_n$$ are the number of -sweeps (colors) used for each sparse Jacobian calculation; see -$cref/n_sweep/sparse_jacobian/n_sweep/$$. +were $icode test$$ is $code jacobian$$ ($code hessian$$). +The values $icode n_sweep_1$$, ..., $icode n_sweep_n$$ are the number of +sweeps (colors) used for each sparse Jacobian (Hessian) calculation; see +$icode n_sweep$$ for +$cref/sparse_jacobian/sparse_jacobian/n_sweep/$$ and +$cref/sparse_hessian/sparse_hessian/n_sweep/$$. $children% @@ -307,7 +308,7 @@ $tend -$end +$end ----------------------------------------------------------------------------- */ // external routines @@ -327,6 +328,7 @@ // info is different for each test extern void info_sparse_jacobian(size_t size, size_t& n_sweep); +extern void info_sparse_hessian(size_t size, size_t& n_sweep); // -------------------------------------------------------------------------- @@ -373,11 +375,11 @@ static size_t Run_error_count = 0; bool run_correct( bool available_case(void) , - bool correct_case(bool) , + bool correct_case(bool) , const char *case_name ) { bool available = available_case(); bool ok = true; - if( available ) + if( available ) { # ifdef CPPAD_DOUBLE_SPEED ok = correct_case(true); @@ -416,7 +418,7 @@ // ---------------------------------------------------------------- // function that runs one speed case void run_speed( - void speed_case(size_t size, size_t repeat) , + void speed_case(size_t size, size_t repeat) , const CppAD::vector& size_vec , const std::string& case_name ) { double time_min = 1.; @@ -428,7 +430,7 @@ for(size_t i = 0; i < size_vec.size(); i++) { if( i == 0 ) cout << "[ "; - else cout << ", "; + else cout << ", "; cout << std::flush; size_t size = size_vec[i]; double time = CppAD::time_test(speed_case, time_min, size); @@ -460,9 +462,9 @@ struct test_struct { const char *name; const test_enum index; - }; + }; const test_struct test_list[]= { - { "correct", test_correct }, + { "correct", test_correct }, { "speed", test_speed }, { "det_lu", test_det_lu }, { "det_minor", test_det_minor }, @@ -509,7 +511,7 @@ } } if( error ) - { cout << "usage: ./speed_" + { cout << "usage: ./speed_" << AD_PACKAGE << " test seed option_list" << endl; cout << "test choices: " << endl; for(i = 0; i < n_test; i++) @@ -540,7 +542,7 @@ CppAD::vector size_poly(n_size); CppAD::vector size_sparse_hessian(n_size); CppAD::vector size_sparse_jacobian(n_size); - for(i = 0; i < n_size; i++) + for(i = 0; i < n_size; i++) { size_det_minor[i] = i + 1; size_det_lu[i] = 10 * i + 1; size_mat_mul[i] = 10 * i + 1; @@ -554,42 +556,42 @@ { // run all the correctness tests case test_correct: - ok &= run_correct( available_det_lu, correct_det_lu, "det_lu" + ok &= run_correct( available_det_lu, correct_det_lu, "det_lu" ); ok &= run_correct( - available_det_minor, correct_det_minor, "det_minor" + available_det_minor, correct_det_minor, "det_minor" ); ok &= run_correct( - available_mat_mul, correct_mat_mul, "mat_mul" + available_mat_mul, correct_mat_mul, "mat_mul" ); ok &= run_correct( - available_ode, correct_ode, "ode" + available_ode, correct_ode, "ode" ); - ok &= run_correct( available_poly, correct_poly, "poly" + ok &= run_correct( available_poly, correct_poly, "poly" ); ok &= run_correct( - available_sparse_hessian, + available_sparse_hessian, correct_sparse_hessian, - "sparse_hessian" + "sparse_hessian" ); ok &= run_correct( - available_sparse_jacobian, + available_sparse_jacobian, correct_sparse_jacobian, - "sparse_jacobian" + "sparse_jacobian" ); // summarize results assert( ok || (Run_error_count > 0) ); if( ok ) - { cout << "All " << int(Run_ok_count) + { cout << "All " << int(Run_ok_count) << " correctness tests passed." << endl; } else - { cout << int(Run_error_count) + { cout << int(Run_error_count) << " correctness tests failed." << endl; } break; // --------------------------------------------------------- - // run all the speed tests + // run all the speed tests case test_speed: if( available_det_lu() ) run_speed( speed_det_lu, size_det_lu, "det_lu" @@ -618,7 +620,7 @@ case test_det_lu: if( ! available_det_lu() ) - { not_available_message( argv[1] ); + { not_available_message( argv[1] ); exit(1); } ok &= run_correct( @@ -630,7 +632,7 @@ case test_det_minor: if( ! available_det_minor() ) - { not_available_message( argv[1] ); + { not_available_message( argv[1] ); exit(1); } ok &= run_correct( @@ -642,7 +644,7 @@ case test_mat_mul: if( ! available_mat_mul() ) - { not_available_message( argv[1] ); + { not_available_message( argv[1] ); exit(1); } ok &= run_correct( @@ -654,7 +656,7 @@ case test_ode: if( ! available_ode() ) - { not_available_message( argv[1] ); + { not_available_message( argv[1] ); exit(1); } ok &= run_correct( @@ -666,7 +668,7 @@ case test_poly: if( ! available_poly() ) - { not_available_message( argv[1] ); + { not_available_message( argv[1] ); exit(1); } ok &= run_correct( @@ -678,7 +680,7 @@ case test_sparse_hessian: if( ! available_sparse_hessian() ) - { not_available_message( argv[1] ); + { not_available_message( argv[1] ); exit(1); } ok &= run_correct( @@ -687,13 +689,24 @@ "sparse_hessian" ); run_speed( - speed_sparse_hessian, size_sparse_hessian, "sparse_hessian"); + speed_sparse_hessian, size_sparse_hessian, "sparse_hessian" + ); + cout << AD_PACKAGE << "_sparse_hessian_sweep = "; + for(i = 0; i < size_sparse_hessian.size(); i++) + { if( i == 0 ) + cout << "[ "; + else cout << ", "; + size_t n_sweep; + info_sparse_hessian(size_sparse_hessian[i], n_sweep); + cout << n_sweep; + } + cout << " ]" << endl; break; // --------------------------------------------------------- case test_sparse_jacobian: if( ! available_sparse_jacobian() ) - { not_available_message( argv[1] ); + { not_available_message( argv[1] ); exit(1); } ok &= run_correct( @@ -702,13 +715,13 @@ "sparse_jacobian" ); run_speed( - speed_sparse_jacobian, size_sparse_jacobian, "sparse_jacobian" + speed_sparse_jacobian, size_sparse_jacobian, "sparse_jacobian" ); cout << AD_PACKAGE << "_sparse_jacobian_n_sweep = "; for(i = 0; i < size_sparse_jacobian.size(); i++) { if( i == 0 ) cout << "[ "; - else cout << ", "; + else cout << ", "; size_t n_sweep; info_sparse_jacobian(size_sparse_jacobian[i], n_sweep); cout << n_sweep; @@ -716,7 +729,7 @@ cout << " ]" << endl; break; // --------------------------------------------------------- - + default: assert(0); } diff -Nru cppad-2015.00.00.9/speed/profile/CMakeLists.txt cppad-2016.00.00.1/speed/profile/CMakeLists.txt --- cppad-2015.00.00.9/speed/profile/CMakeLists.txt 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/profile/CMakeLists.txt 2016-02-09 08:31:52.000000000 +0000 @@ -1,25 +1,25 @@ -# $Id: CMakeLists.txt 3139 2014-03-02 21:12:00Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the speed/profile directory tests +# Build the speed/profile directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory -# Adds flags to the compiler command line for sources in the current directory -# and below. This command can be used to add any flags, but it was originally -# intended to add preprocessor definitions. -ADD_DEFINITIONS("-DCPPAD_PROFILE_SPEED -pg") +# Adds flags to the compiler command line for sources in the current directory +# and below. This command can be used to add any flags, but it was originally +# intended to add preprocessor definitions. +ADD_DEFINITIONS("-DCPPAD_PROFILE_SPEED ${cppad_profile_flag}") -# Extra flags used by the linker when creating an executable. -SET(CMAKE_EXE_LINKER_FLAGS "-pg") +# Extra flags used by the linker when creating an executable. +SET(CMAKE_EXE_LINKER_FLAGS ${cppad_profile_flag}) # Local include directories to search (not in package_prefix/includdir) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) @@ -27,11 +27,11 @@ # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) -ADD_EXECUTABLE(speed_profile EXCLUDE_FROM_ALL ../main.cpp +ADD_EXECUTABLE(speed_profile EXCLUDE_FROM_ALL ../main.cpp ../cppad/ode.cpp - ../cppad/det_lu.cpp - ../cppad/det_minor.cpp - ../cppad/mat_mul.cpp + ../cppad/det_lu.cpp + ../cppad/det_minor.cpp + ../cppad/mat_mul.cpp ../cppad/poly.cpp ../cppad/sparse_hessian.cpp ../cppad/sparse_jacobian.cpp @@ -43,7 +43,6 @@ ../src/link_sparse_hessian.cpp ../src/link_sparse_jacobian.cpp ../src/microsoft_timer.cpp - ${colpack_sources} ) # Compiler flags for cppad source @@ -51,10 +50,13 @@ # profile builds it own copy of src/speed library (see ADD_EXECUTABLE above) # TARGET_LINK_LIBRARIES(speed_profile speed_src ) -TARGET_LINK_LIBRARIES(speed_profile ${colpack_libs} ) +TARGET_LINK_LIBRARIES(speed_profile + ${cppad_lib} + ${colpack_libs} +) # Add the check_speed_profile target -ADD_CUSTOM_TARGET(check_speed_profile +ADD_CUSTOM_TARGET(check_speed_profile speed_profile correct 54321 DEPENDS speed_profile ) diff -Nru cppad-2015.00.00.9/speed/profile/makefile.am cppad-2016.00.00.1/speed/profile/makefile.am --- cppad-2015.00.00.9/speed/profile/makefile.am 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/profile/makefile.am 2016-02-09 08:31:52.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3481 2014-12-17 23:39:47Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -69,7 +69,7 @@ EXTRA_DIST = \ gprof.sed # -check_PROGRAMS = speed_profile +check_PROGRAMS = speed_profile # AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # diff -Nru cppad-2015.00.00.9/speed/profile/makefile.in cppad-2016.00.00.1/speed/profile/makefile.in --- cppad-2015.00.00.9/speed/profile/makefile.in 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/profile/makefile.in 2016-02-09 08:31:52.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = speed_profile$(EXEEXT) subdir = speed/profile -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(srcdir)/gprof.sed.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = gprof.sed CONFIG_CLEAN_VPATH_FILES = @@ -153,6 +162,8 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/gprof.sed.in $(srcdir)/makefile.in \ + $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -256,26 +267,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -314,12 +328,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -381,7 +395,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu speed/profile/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/profile/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -652,6 +665,8 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + # main.cpp: $(srcdir)/../main.cpp cp $(srcdir)/../main.cpp main.cpp diff -Nru cppad-2015.00.00.9/speed/sacado/det_lu.cpp cppad-2016.00.00.1/speed/sacado/det_lu.cpp --- cppad-2015.00.00.9/speed/sacado/det_lu.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/det_lu.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_lu.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,14 +30,8 @@ $$ $section Sacado Speed: Gradient of Determinant Using Lu Factorization$$ +$mindex link_det_lu speed matrix factor$$ -$index link_det_lu, sacado$$ -$index sacado, link_det_lu$$ -$index speed, sacado$$ -$index sacado, speed$$ -$index lu, speed sacado$$ -$index matrix, factor speed sacado$$ -$index factor, matrix speed sacado$$ $head Specifications$$ See $cref link_det_lu$$. @@ -47,14 +41,14 @@ # include # include # include -# include +# include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_lu( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { @@ -67,15 +61,15 @@ // setup // // object for computing determinant - typedef Sacado::Rad::ADvar ADScalar; - typedef CppAD::vector ADVector; + typedef Sacado::Rad::ADvar ADScalar; + typedef CppAD::vector ADVector; CppAD::det_by_lu Det(size); size_t i; // temporary index size_t n = size * size; // number of independent variables ADScalar detA; // AD value of the determinant - ADVector A(n); // AD version of matrix - + ADVector A(n); // AD version of matrix + // ------------------------------------------------------ while(repeat--) { // get the next matrix diff -Nru cppad-2015.00.00.9/speed/sacado/det_minor.cpp cppad-2016.00.00.1/speed/sacado/det_minor.cpp --- cppad-2015.00.00.9/speed/sacado/det_minor.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/det_minor.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: det_minor.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,13 +27,8 @@ $$ $section Sacado Speed: Gradient of Determinant by Minor Expansion$$ +$mindex link_det_minor speed$$ -$index link_det_minor, sacado$$ -$index sacado, link_det_minor$$ -$index speed, sacado$$ -$index sacado, speed$$ -$index minor, speed sacado$$ -$index determinant, speed sacado$$ $head Specifications$$ See $cref link_det_minor$$. @@ -44,35 +39,35 @@ # include # include # include -# include +# include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_minor( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_atomic ) - return false; + return false; if( global_memory || global_onetape || global_optimize ) - return false; + return false; // ----------------------------------------------------- // setup // object for computing determinant - typedef Sacado::Rad::ADvar ADScalar; - typedef CppAD::vector ADVector; + typedef Sacado::Rad::ADvar ADScalar; + typedef CppAD::vector ADVector; CppAD::det_by_minor Det(size); size_t i; // temporary index size_t n = size * size; // number of independent variables ADScalar detA; // AD value of the determinant - ADVector A(n); // AD version of matrix - + ADVector A(n); // AD version of matrix + // ------------------------------------------------------ while(repeat--) { // get the next matrix @@ -88,7 +83,7 @@ // reverse mode compute gradient of last computed value; i.e., detA ADScalar::Gradcomp(); - // return gradient + // return gradient for(i =0; i < n; i++) gradient[i] = A[i].adj(); // partial detA w.r.t A[i] } diff -Nru cppad-2015.00.00.9/speed/sacado/makefile.am cppad-2016.00.00.1/speed/sacado/makefile.am --- cppad-2015.00.00.9/speed/sacado/makefile.am 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/makefile.am 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3481 2014-12-17 23:39:47Z bradbell $ +# $Id: makefile.am 3757 2015-11-30 12:03:07Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -19,7 +19,7 @@ # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -check_PROGRAMS = speed_sacado +check_PROGRAMS = speed_sacado # AM_CPPFLAGS = \ -I$(top_srcdir) \ @@ -29,7 +29,7 @@ # # BEGIN OPTIMIZE AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_SACADO_SPEED \ - -DRAD_EQ_ALIAS -DRAD_AUTO_AD_Const $(CXX_FLAGS) + -DRAD_EQ_ALIAS -DRAD_AUTO_AD_Const $(CXX_FLAGS) # END OPTIMIZE # # BEGIN DEBUG @@ -50,4 +50,4 @@ sparse_jacobian.cpp test: check - ./speed_sacado correct 123 + ./speed_sacado correct 123 diff -Nru cppad-2015.00.00.9/speed/sacado/makefile.in cppad-2016.00.00.1/speed/sacado/makefile.in --- cppad-2015.00.00.9/speed/sacado/makefile.in 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/makefile.in 2016-02-09 08:31:53.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ host_triplet = @host@ check_PROGRAMS = speed_sacado$(EXEEXT) subdir = speed/sacado -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -150,6 +159,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -254,26 +264,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -312,12 +325,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -336,7 +349,7 @@ # # BEGIN OPTIMIZE AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_SACADO_SPEED \ - -DRAD_EQ_ALIAS -DRAD_AUTO_AD_Const $(CXX_FLAGS) + -DRAD_EQ_ALIAS -DRAD_AUTO_AD_Const $(CXX_FLAGS) # END OPTIMIZE # @@ -374,7 +387,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu speed/sacado/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/sacado/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -635,11 +647,13 @@ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: makefile + main.cpp: cp $(srcdir)/../main.cpp main.cpp test: check - ./speed_sacado correct 123 + ./speed_sacado correct 123 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru cppad-2015.00.00.9/speed/sacado/mat_mul.cpp cppad-2016.00.00.1/speed/sacado/mat_mul.cpp --- cppad-2015.00.00.9/speed/sacado/mat_mul.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/mat_mul.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mat_mul.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,13 +26,8 @@ $$ $section Sacado Speed: Matrix Multiplication$$ +$mindex link_mat_mul speed multiply$$ -$index link_mat_mul, sacado$$ -$index sacado, link_mat_mul$$ -$index speed, sacado$$ -$index sacado, speed$$ -$index matrix, speed sacado$$ -$index multiply, speed sacado$$ $head Specifications$$ See $cref link_mat_mul$$. @@ -41,7 +36,7 @@ $codep */ # include -# include +# include # include # include @@ -49,8 +44,8 @@ extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_mat_mul( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz ) @@ -62,8 +57,8 @@ // setup // object for computing determinant - typedef Sacado::Rad::ADvar ADScalar; - typedef CppAD::vector ADVector; + typedef Sacado::Rad::ADvar ADScalar; + typedef CppAD::vector ADVector; size_t j; // temporary index size_t m = 1; // number of dependent variables @@ -72,7 +67,7 @@ ADVector Y(n); // Store product matrix ADVector Z(m); // AD range space vector ADScalar f; - + // ------------------------------------------------------ while(repeat--) { // get the next matrix diff -Nru cppad-2015.00.00.9/speed/sacado/ode.cpp cppad-2016.00.00.1/speed/sacado/ode.cpp --- cppad-2015.00.00.9/speed/sacado/ode.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/ode.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,12 +25,8 @@ $$ $section Sacado Speed: Gradient of Ode Solution$$ +$mindex link_ode speed$$ -$index link_ode, sacado$$ -$index sacado, link_ode$$ -$index speed, sacado$$ -$index sacado, speed$$ -$index ode, speed sacado$$ $head Specifications$$ See $cref link_ode$$. @@ -41,7 +37,7 @@ # include // # include # include -# include +# include # include # include @@ -76,7 +72,7 @@ // ------------------------------------------------------------- while(repeat--) - { // choose next x value + { // choose next x value CppAD::uniform_01(n, x); for(j = 0; j < n; j++) { // set up for X as the independent variable vector diff -Nru cppad-2015.00.00.9/speed/sacado/poly.cpp cppad-2016.00.00.1/speed/sacado/poly.cpp --- cppad-2015.00.00.9/speed/sacado/poly.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/poly.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: poly.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,12 +36,8 @@ $$ $section Sacado Speed: Second Derivative of a Polynomial$$ +$mindex link_poly speed$$ -$index link_poly, sacado$$ -$index sacado, link_poly$$ -$index speed, sacado$$ -$index sacado, speed$$ -$index polynomial, speed sacado$$ $head Specifications$$ See $cref link_poly$$. @@ -50,8 +46,8 @@ $codep */ -# include -# include +# include +# include # include # include @@ -59,11 +55,11 @@ extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_poly( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &a , // coefficients of polynomial CppAD::vector &z , // polynomial argument value - CppAD::vector &ddp ) // second derivative w.r.t z + CppAD::vector &ddp ) // second derivative w.r.t z { if( global_atomic ) return false; @@ -74,9 +70,9 @@ typedef Sacado::Tay::Taylor ADScalar; CppAD::vector A(size); - size_t i; // temporary index + size_t i; // temporary index ADScalar Z; // domain space AD value - ADScalar P; // range space AD value + ADScalar P; // range space AD value unsigned int order = 2; // order of Taylor coefficients Z.resize(order+1, false); P.resize(order+1, false); diff -Nru cppad-2015.00.00.9/speed/sacado/sparse_hessian.cpp cppad-2016.00.00.1/speed/sacado/sparse_hessian.cpp --- cppad-2015.00.00.9/speed/sacado/sparse_hessian.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/sparse_hessian.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,16 +1,16 @@ -/* $Id: sparse_hessian.cpp 3136 2014-03-02 11:54:07Z bradbell $ */ +// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -# include +# include /* $begin sacado_sparse_hessian.cpp$$ @@ -25,14 +25,15 @@ $section Sacado Speed: Sparse Hessian$$ $codep */ -// A sacado version of this test is not yet implemented +// A sacado version of this test is not yet implemented extern bool link_sparse_hessian( size_t size , size_t repeat , const CppAD::vector& row , const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& hessian + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ) { return false; diff -Nru cppad-2015.00.00.9/speed/sacado/sparse_jacobian.cpp cppad-2016.00.00.1/speed/sacado/sparse_jacobian.cpp --- cppad-2015.00.00.9/speed/sacado/sparse_jacobian.cpp 2015-02-24 08:31:39.000000000 +0000 +++ cppad-2016.00.00.1/speed/sacado/sparse_jacobian.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,16 +1,16 @@ -/* $Id: sparse_jacobian.cpp 3138 2014-03-02 18:46:11Z bradbell $ */ +// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include -# include +# include /* $begin sacado_sparse_jacobian.cpp$$ @@ -27,8 +27,8 @@ $codep */ // A sacado version of this test is not yet available bool link_sparse_jacobian( - size_t size , - size_t repeat , + size_t size , + size_t repeat , size_t m , const CppAD::vector& row , const CppAD::vector& col , diff -Nru cppad-2015.00.00.9/speed/src/CMakeLists.txt cppad-2016.00.00.1/speed/src/CMakeLists.txt --- cppad-2015.00.00.9/speed/src/CMakeLists.txt 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/CMakeLists.txt 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: CMakeLists.txt 3122 2014-02-26 03:23:19Z bradbell $ +# $Id: CMakeLists.txt 3754 2015-11-26 22:23:05Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -16,7 +16,9 @@ # add_library( [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN) # ) -ADD_LIBRARY(speed_src EXCLUDE_FROM_ALL +# Make libspeed_src a static library because this is just for testing +# and is not installed (do not have to worry about library search path). +ADD_LIBRARY(speed_src STATIC EXCLUDE_FROM_ALL link_det_lu.cpp link_det_minor.cpp link_mat_mul.cpp @@ -25,7 +27,6 @@ link_sparse_hessian.cpp link_sparse_jacobian.cpp microsoft_timer.cpp - ${colpack_sources} ) # Compiler flags for cppad source diff -Nru cppad-2015.00.00.9/speed/src/link_det_lu.cpp cppad-2016.00.00.1/speed/src/link_det_lu.cpp --- cppad-2015.00.00.9/speed/src/link_det_lu.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/link_det_lu.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: link_det_lu.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: link_det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,36 +18,33 @@ CppAD $$ -$index link_det_lu$$ -$index det_lu, speed test$$ -$index speed, test det_lu$$ -$index test, det_lu speed$$ $section Speed Testing Gradient of Determinant Using Lu Factorization$$ +$mindex link_det_lu test$$ $head Prototype$$ $codei%extern bool link_det_lu( - size_t %size% , - size_t %repeat% , + size_t %size% , + size_t %repeat% , CppAD::vector &%matrix% , - CppAD::vector &%gradient% + CppAD::vector &%gradient% ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. -This is used by the $cref speed_main$$ program +This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Method$$ -The same template routine $cref det_by_lu$$ is used -by the different AD packages. +The same template routine $cref det_by_lu$$ is used +by the different AD packages. $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, -the corresponding return value for $code link_det_lu$$ +the corresponding return value for $code link_det_lu$$ should be $code false$$. $head size$$ @@ -60,34 +57,34 @@ $head matrix$$ The argument $icode matrix$$ is a vector with $icode%size%*%size%$$ elements. -The input value of its elements does not matter. +The input value of its elements does not matter. The output value of its elements is the last matrix that the gradient (or determinant) is computed for. $head gradient$$ The argument $icode gradient$$ is a vector with $icode%size%*%size%$$ elements. -The input value of its elements does not matter. +The input value of its elements does not matter. The output value of its elements is the gradient of the determinant of $icode matrix$$ with respect to its elements. $subhead double$$ -In the case where $icode package$$ is $code double$$, -only the first element of $icode gradient$$ is used and it is actually +In the case where $icode package$$ is $code double$$, +only the first element of $icode gradient$$ is used and it is actually the determinant value (the gradient value is not computed). -$end +$end ----------------------------------------------------------------------------- */ -# include +# include # include # include extern bool link_det_lu( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , - CppAD::vector &gradient + CppAD::vector &gradient ); diff -Nru cppad-2015.00.00.9/speed/src/link_det_minor.cpp cppad-2016.00.00.1/speed/src/link_det_minor.cpp --- cppad-2015.00.00.9/speed/src/link_det_minor.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/link_det_minor.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: link_det_minor.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: link_det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,26 +18,23 @@ CppAD $$ -$index link_det_minor$$ -$index det_minor, speed test$$ -$index speed, test det_minor$$ -$index test, det_minor speed$$ $section Speed Testing Gradient of Determinant by Minor Expansion$$ +$mindex link_det_minor test$$ $head Prototype$$ $codei%extern bool link_det_minor( - size_t %size% , - size_t %repeat% , + size_t %size% , + size_t %repeat% , CppAD::vector &%matrix% , - CppAD::vector &%gradient% + CppAD::vector &%gradient% ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. -This is used by the $cref speed_main$$ program +This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Method$$ @@ -47,7 +44,7 @@ $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, -the corresponding return value for $code link_det_minor$$ +the corresponding return value for $code link_det_minor$$ should be $code false$$. $head size$$ @@ -59,37 +56,37 @@ that the gradient (or determinant) is computed for. $head matrix$$ -The argument $icode matrix$$ is a vector with +The argument $icode matrix$$ is a vector with $icode%size%*%size%$$ elements. -The input value of its elements does not matter. +The input value of its elements does not matter. The output value of its elements is the last matrix that the gradient (or determinant) is computed for. $head gradient$$ -The argument $icode gradient$$ is a vector with +The argument $icode gradient$$ is a vector with $icode%size%*%size%$$ elements. -The input value of its elements does not matter. +The input value of its elements does not matter. The output value of its elements is the gradient of the determinant of $icode matrix$$ with respect to its elements. $subhead double$$ -In the case where $icode package$$ is $code double$$, -only the first element of $icode gradient$$ is used and it is actually +In the case where $icode package$$ is $code double$$, +only the first element of $icode gradient$$ is used and it is actually the determinant value (the gradient value is not computed). -$end +$end ----------------------------------------------------------------------------- */ -# include +# include # include # include extern bool link_det_minor( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &matrix , - CppAD::vector &gradient + CppAD::vector &gradient ); bool available_det_minor(void) diff -Nru cppad-2015.00.00.9/speed/src/link_mat_mul.cpp cppad-2016.00.00.1/speed/src/link_mat_mul.cpp --- cppad-2015.00.00.9/speed/src/link_mat_mul.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/link_mat_mul.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: link_mat_mul.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: link_mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,34 +19,30 @@ dz $$ -$index link_mat_mul$$ -$index matrix, multiply speed test$$ -$index multiply, matrix speed test$$ -$index speed, test matrix multiple$$ -$index test, matrix multiple speed$$ $section Speed Testing Derivative of Matrix Multiply$$ +$mindex link_mat_mul test multiple$$ $head Prototype$$ $codei%extern bool link_mat_mul( - size_t %size% , - size_t %repeat% , + size_t %size% , + size_t %repeat% , CppAD::vector& %x% , CppAD::vector& %z% , - CppAD::vector& %dz% + CppAD::vector& %dz% ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. -This is used by the $cref speed_main$$ program +This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, -the corresponding return value for $code link_mat_mul$$ +the corresponding return value for $code link_mat_mul$$ should be $code false$$. $head n$$ @@ -55,13 +51,13 @@ $head repeat$$ The argument $icode repeat$$ is the number of different argument values -that the derivative of $icode z$$ (or just the value of $icode z$$) -will be computed. +that the derivative of $icode z$$ (or just the value of $icode z$$) +will be computed. $head x$$ -The argument $icode x$$ is a vector with +The argument $icode x$$ is a vector with $icode%x%.size() = %size% * %size%$$ elements. -The input value of its elements does not matter. +The input value of its elements does not matter. The output value of its elements is the last random matrix that is multiplied and then summed to form $icode z$$; $latex \[ @@ -72,35 +68,35 @@ $head z$$ The argument $icode z$$ is a vector with one element. The input value of the element does not matter. -The output of its element the sum of the elements of +The output of its element the sum of the elements of $icode%y% = %x% * %x%$$; i.e., $latex \[ \begin{array}{rcl} - y_{i,j} & = & \sum_{k=0}^{s-1} x_{i,k} x_{k, j} + y_{i,j} & = & \sum_{k=0}^{s-1} x_{i,k} x_{k, j} \\ z & = & \sum_{i=0}^{s-1} \sum_{j=0}^{s-1} y_{i,j} \end{array} \] $$ $head dz$$ -The argument $icode dz$$ is a vector with +The argument $icode dz$$ is a vector with $icode%dz%.size() = %size% * %size%$$. The input values of its elements do not matter. The output value of its elements form the derivative of $icode z$$ with respect to $icode x$$. -$end +$end ----------------------------------------------------------------------------- */ -# include -# include +# include +# include extern bool link_mat_mul( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector& x , CppAD::vector& z , - CppAD::vector& dz + CppAD::vector& dz ); bool available_mat_mul(void) { size_t size = 2; @@ -143,7 +139,7 @@ // partial w.r.t. x11 check = x01 + x10 + x11 + x11; ok &= CppAD::NearEqual(check, dz[1 * size + 1], 1e-10, 1e-10); - + return ok; } diff -Nru cppad-2015.00.00.9/speed/src/link_ode.cpp cppad-2016.00.00.1/speed/src/link_ode.cpp --- cppad-2015.00.00.9/speed/src/link_ode.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/link_ode.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: link_ode.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: link_ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,12 +19,9 @@ CppAD $$ -$index link_ode$$ -$index ode, speed test$$ -$index speed, test ode$$ -$index test, ode speed$$ $section Speed Testing the Jacobian of Ode Solution$$ +$mindex link_ode test$$ $head Prototype$$ $codei%extern bool link_ode( @@ -46,7 +43,7 @@ by th different AD packages. $head f$$ -The function +The function $latex f : \B{R}^n \rightarrow \B{R}^n$$ that is defined and computed by evaluating $cref ode_evaluate$$ with a call of the form $codei% @@ -63,13 +60,13 @@ should be $code false$$. $head size$$ -The argument $icode size$$ +The argument $icode size$$ is the number of variables in the ordinary differential equations which is also equal to $latex n$$. $head repeat$$ The argument $icode repeat$$ is the number of times the -Jacobian is computed. +Jacobian is computed. $head x$$ The argument $icode x$$ is a vector with $latex n$$ elements. @@ -81,7 +78,7 @@ $head jacobian$$ The argument $icode jacobian$$ is a vector with $latex n^2$$ elements. -The input value of its elements does not matter. +The input value of its elements does not matter. The output value of its elements is the Jacobian of the function $latex f(x)$$ that corresponds to output value of $icode x$$. To be more specific, for @@ -96,12 +93,12 @@ are modified and they are to the function value $latex f(x)$$ corresponding to the output value of $icode x$$. -$end +$end ----------------------------------------------------------------------------- */ -# include +# include # include -# include +# include extern bool link_ode( size_t size , diff -Nru cppad-2015.00.00.9/speed/src/link_poly.cpp cppad-2016.00.00.1/speed/src/link_poly.cpp --- cppad-2015.00.00.9/speed/src/link_poly.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/link_poly.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: link_poly.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: link_poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,27 +19,24 @@ ddp $$ -$index link_poly$$ -$index polynomial, speed test$$ -$index speed, test polynomial$$ -$index test, polynomial speed$$ $section Speed Testing Second Derivative of a Polynomial$$ +$mindex link_poly test$$ $head Prototype$$ $codei%extern bool link_poly( - size_t %size% , - size_t %repeat% , + size_t %size% , + size_t %repeat% , CppAD::vector &%a% , CppAD::vector &%z% , - CppAD::vector &%ddp + CppAD::vector &%ddp ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. -This is used by the $cref speed_main$$ program +This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Method$$ @@ -49,7 +46,7 @@ $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, -the corresponding return value for $code link_poly$$ +the corresponding return value for $code link_poly$$ should be $code false$$. $head size$$ @@ -58,12 +55,12 @@ $head repeat$$ The argument $icode repeat$$ is the number of different argument values -that the second derivative (or just the polynomial) will be computed at. +that the second derivative (or just the polynomial) will be computed at. $head a$$ The argument $icode a$$ is a vector with $icode%size%$$ elements. -The input value of its elements does not matter. -The output value of its elements is the coefficients of the +The input value of its elements does not matter. +The output value of its elements is the coefficients of the polynomial that is differentiated ($th i$$ element is coefficient of order $icode i$$). @@ -76,27 +73,27 @@ $head ddp$$ The argument $icode ddp$$ is a vector with one element. The input value of its element does not matter. -The output value of its element is the +The output value of its element is the second derivative of the polynomial with respect to it's argument value. $subhead double$$ In the case where $icode package$$ is $code double$$, -the output value of the element of $icode ddp$$ +the output value of the element of $icode ddp$$ is the polynomial value (the second derivative is not computed). -$end +$end ----------------------------------------------------------------------------- */ -# include -# include -# include +# include +# include +# include extern bool link_poly( - size_t size , - size_t repeat , + size_t size , + size_t repeat , CppAD::vector &a , CppAD::vector &z , - CppAD::vector &ddp + CppAD::vector &ddp ); bool available_poly(void) { size_t size = 10; diff -Nru cppad-2015.00.00.9/speed/src/link_sparse_hessian.cpp cppad-2016.00.00.1/speed/src/link_sparse_hessian.cpp --- cppad-2015.00.00.9/speed/src/link_sparse_hessian.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/link_sparse_hessian.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: link_sparse_hessian.cpp 3223 2014-03-19 15:13:26Z bradbell $ */ +// $Id: link_sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,14 +16,13 @@ const bool CppAD + cppad + colpack $$ -$index link_sparse_hessian$$ -$index sparse, speed test$$ -$index speed, test sparse$$ -$index test, sparse speed$$ $section Speed Testing Sparse Hessian$$ +$mindex link_sparse_hessian test$$ $head Prototype$$ $codei%extern bool link_sparse_hessian( @@ -31,18 +30,19 @@ size_t %repeat% , CppAD::vector& %x% , const CppAD::vector& %row% , - const CppAD::vector& %col% , - CppAD::vector& %hessian% + const CppAD::vector& %col% , + CppAD::vector& %hessian% , + size_t %n_sweep% ); %$$ $head Method$$ Given a row index vector $latex row$$ and a second column vector $latex col$$, -the corresponding function -$latex f : \B{R}^n \rightarrow \B{R} $$ +the corresponding function +$latex f : \B{R}^n \rightarrow \B{R} $$ is defined by $cref sparse_hes_fun$$. -The non-zero entries in the Hessian of this function have +The non-zero entries in the Hessian of this function have one of the following forms: $latex \[ \DD{f}{x[row[k]]}{x[row[k]]} @@ -93,53 +93,52 @@ const CppAD::vector %col% %$$ Its size must be the same as $icode row$$; i.e., $latex K$$. -It contains the column indices for the corresponding function +It contains the column indices for the corresponding function $latex f(x)$$. All the elements of $icode col$$ are between zero and $latex n-1$$. -$pre - -$$ -There are no duplicate row and column entires; i.e., if $icode%j% != %k%$$, +There are no duplicated entries requested, to be specific, +if $icode%k1% != %k2%$$ then $codei% - %row%[%j%] != %row%[%k%] || %col%[%j%] != %col%[%k%] + ( %row%[%k1%] , %col%[%k1%] ) != ( %row%[%k2%] , %col%[%k2%] ) %$$ -Only the lower triangle of the Hessian is included in the indices; i.e., -$codei%row%[%k%] >= %col%[%k%]%$$. -Furthermore, for all the non-zero entries in the lower triangle -are included; i.e., if $latex i \geq j$$ and -$latex \DD{f}{x[i]}{x[j]} \neq 0$$, -there is an index $icode k$$ such that -$icode%i% = %row%[%k%]%$$ and -$icode%j% = %col%[%k%]%$$. $head hessian$$ The argument $icode hessian$$ has prototype $codei% CppAD::vector& hessian %$$ -and its size is $latex n \times n$$. -The input value of its elements does not matter. +and its size is $icode K$$. +The input value of its elements does not matter. The output value of its elements is the Hessian of the function $latex f(x)$$. To be more specific, for -$latex i = 0 , \ldots , n-1$$, -$latex j = 0 , \ldots , n-1$$, +$latex k = 0 , \ldots , K-1$$, $latex \[ - \DD{f}{x[i]}{x[j]} (x) = hessian [ i * n + j ] + \DD{f}{ x[ \R{row}[k] ] }{ x[ \R{col}[k] ]} = \R{hessian} [k] \] $$ +$head n_sweep$$ +The input value of $icode n_sweep$$ does not matter. On output, +it is the value $cref/n_sweep/sparse_hessian/n_sweep/$$ corresponding +to the evaluation of $icode hessian$$. +This is also the number of colors corresponding to the +$cref/coloring method/sparse_hessian/work/color_method/$$, +which can be set to $cref/colpack/speed_main/Sparsity Options/colpack/$$, +and is otherwise $code cppad$$. + + $subhead double$$ In the case where $icode package$$ is $code double$$, -only the first element of $icode hessian$$ is used and it is actually +only the first element of $icode hessian$$ is used and it is actually the value of $latex f(x)$$ (derivatives are not computed). -$end +$end ----------------------------------------------------------------------------- */ -# include -# include +# include +# include # include # include -# include +# include /*! \{ @@ -150,7 +149,7 @@ using CppAD::vector; /*! - Class used by choose_row_col to determin order of row and column indices + Class used by choose_row_col to determin order of row and column indices */ class Key { public: @@ -162,19 +161,19 @@ Key(void) { } /*! - Construct from a value for row and col + Construct from a value for row and col \param row row value for this key \param col column value for this key - */ + */ Key(size_t row, size_t col) : row_(row), col_(col) { } /*! - Compare this key with another key using < operator + Compare this key with another key using < operator \param other the other key. @@ -202,51 +201,31 @@ */ void choose_row_col( size_t n , - vector& row , + vector& row , vector& col ) - { size_t r, c, k, K = 5 * n; - - // get the random indices - vector random(2 * K); - CppAD::uniform_01(2 * K, random); - - // sort the temporary row and colunn choices - vector keys(K + n); - vector ind(K + n); - for(k = 0; k < K; k++) - { r = size_t( n * random[k] ); - r = std::min(n-1, r); - // - c = size_t( n * random[k + K] ); - c = std::min(n-1, c); - // - // force to lower triangle - if( c > r ) - std::swap(r, c); - // - keys[k] = Key(r, c); - } - // include the diagonal - for(k = 0; k < n; k++) - keys[k + K] = Key(k, k); - CppAD::index_sort(keys, ind); + { size_t i, j, k, ell; + size_t max_per_row = 5; - // remove duplicates while setting the return value for row and col + // generate the row and column indices row.resize(0); col.resize(0); - size_t r_previous = keys[ ind[0] ].row_; - size_t c_previous = keys[ ind[0] ].col_; - row.push_back(r_previous); - col.push_back(c_previous); - for(k = 1; k < K; k++) - { r = keys[ ind[k] ].row_; - c = keys[ ind[k] ].row_; - if( r != r_previous || c != c_previous) - { row.push_back(r); - col.push_back(c); + for(i = 0; i < n; i++) + { // generate max_per_row random column indices between 0 and i + vector random(max_per_row); + CppAD::uniform_01(max_per_row, random); + + // set the indices for this row + size_t k_start = col.size(); + for(ell = 0; ell < max_per_row; ell++) + { j = std::min(i, size_t(random[ell] * i) ); + bool ok = true; + for(k = k_start; k < col.size(); k++) + ok &= j != col[k]; + if( ok ) + { row.push_back(i); + col.push_back(j); + } } - r_previous = r; - c_previous = c; } } } @@ -268,13 +247,19 @@ is the row indices correpsonding to non-zero Hessian entries. \param col [in] -is the column indices corresponding to non-zero Hessian entries. +is the column indices corresponding to non-zero Hessian entries; +col.size() == row.size(). \param hessian [out] -is a vector with size n * n -containing the value of the Hessian of f(x) +is a vector, with hessian.size() == row.size(), +containing the value of the Hessian of f(x) corresponding to the last repetition. +\param n_sweep [out] +The input value of this parameter does not matter. +Upon return, it is the number of sweeps (colors) corresponding +to the sparse hessian claculation. + \return is true, if the sparse Hessian speed test is implemented for this package, and false otherwise. @@ -283,9 +268,10 @@ size_t size , size_t repeat , const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& hessian + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ); /*! @@ -295,16 +281,17 @@ true, if spare Hessian available for this package, and false otherwise. */ bool available_sparse_hessian(void) -{ +{ size_t n = 2; size_t repeat = 1; vector x(n); - vector hessian(n * n); - vector row, col; + vector row, col; choose_row_col(n, row, col); + size_t K = row.size(); + vector hessian(K); - return link_sparse_hessian(n, repeat, row, col, x, hessian); - exit(0); + size_t n_sweep; + return link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep); } /*! Does final sparse Hessian value pass correctness test. @@ -316,15 +303,19 @@ true, if correctness test passes, and false otherwise. */ bool correct_sparse_hessian(bool is_package_double) -{ +{ size_t n = 10; size_t repeat = 1; vector x(n); - vector hessian(n * n); vector row, col; choose_row_col(n, row, col); + size_t K = row.size(); + vector hessian(K); - link_sparse_hessian(n, repeat, row, col, x, hessian); + // The double package assumes hessian.size() >= 1 + CPPAD_ASSERT_UNKNOWN( K >= 1 ); + size_t n_sweep; + link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep); size_t order, size; if( is_package_double) @@ -333,13 +324,13 @@ } else { order = 2; // check hessian value - size = n * n; + size = K; } CppAD::vector check(size); CppAD::sparse_hes_fun(n, x, row, col, order, check); bool ok = true; size_t k; - for( k = 0; k < size; k++) + for(k = 0; k < size; k++) ok &= CppAD::NearEqual(check[k], hessian[k], 1e-10, 1e-10); return ok; @@ -355,14 +346,47 @@ is the number of times to repeate the speed test. */ void speed_sparse_hessian(size_t size, size_t repeat) -{ size_t n = size; +{ CPPAD_ASSERT_UNKNOWN( size > 0 ); + static size_t previous_size = 0; + static vector row, col; + + size_t n = size; vector x(n); - vector hessian(n * n); - vector row, col; - choose_row_col(n, row, col); + if( size != previous_size ) + { choose_row_col(n, row, col); + previous_size = size; + } + size_t K = row.size(); + vector hessian(K); // note that cppad/sparse_hessian.cpp assumes that x.size() == size - link_sparse_hessian(n, repeat, row, col, x, hessian); + size_t n_sweep; + link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep); return; } +/*! +Sparse Hessian speed test information. + +\param size [in] +is the \c size parameter in the corresponding call to speed_sparse_hessian. + +\param n_sweep [out] +The input value of this parameter does not matter. +Upon return, it is the value \c n_sweep retruned by the corresponding +call to \c link_sparse_hessian. +*/ +void info_sparse_hessian(size_t size, size_t& n_sweep) +{ size_t n = size; + size_t repeat = 1; + vector row, col; + choose_row_col(n, row, col); + + // note that cppad/speed/sparse_hessian.cpp assumes that x.size() + // is the size corresponding to this test + vector x(n); + size_t K = row.size(); + vector hessian(K); + link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep); + return; +} diff -Nru cppad-2015.00.00.9/speed/src/link_sparse_jacobian.cpp cppad-2016.00.00.1/speed/src/link_sparse_jacobian.cpp --- cppad-2015.00.00.9/speed/src/link_sparse_jacobian.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/link_sparse_jacobian.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: link_sparse_jacobian.cpp 3311 2014-05-28 16:21:08Z bradbell $ */ +// $Id: link_sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,12 +21,9 @@ Jacobian $$ -$index link_sparse_jacobian$$ -$index sparse, speed test$$ -$index speed, test sparse$$ -$index test, sparse speed$$ $section Speed Testing Sparse Jacobian$$ +$mindex link_sparse_jacobian test$$ $head Prototype$$ $codei%extern bool link_sparse_jacobian( @@ -34,7 +31,7 @@ size_t %repeat% , size_t %m% , const CppAD::vector& %row% , - const CppAD::vector& %col% , + const CppAD::vector& %col% , CppAD::vector& %x% , CppAD::vector& %jacobian% , size_t& %n_sweep% @@ -44,7 +41,7 @@ $head Method$$ Given a range space dimension $icode m$$ the row index vector $latex row$$, and column index vector $latex col$$, -a corresponding function $latex f : \B{R}^n \rightarrow \B{R}^m $$ +a corresponding function $latex f : \B{R}^n \rightarrow \B{R}^m $$ is defined by $cref sparse_jac_fun$$. The non-zero entries in the Jacobian of this function have the form $latex \[ @@ -59,11 +56,10 @@ is the dimension of the domain space for $latex f(x)$$. $head repeat$$ -The argument $icode repeat$$ is the number of different functions -$latex f(x)$$ for which the Jacobian is computed for. -Each function corresponds to a randomly chosen index vectors, i.e., -for each repetition a random choice is made for -$latex row[k]$$ and $latex col[k]$$ for $latex k = 0 , \ldots , K-1$$. +The argument $icode repeat$$ is the number of times +to repeat the test +(with a different value for $icode x$$ corresponding to +each repetition). $head m$$ Is the dimension of the range space for the function $latex f(x)$$. @@ -78,9 +74,6 @@ On output, it has been set the column index vector for the last repetition. All the elements of $icode col$$ are between zero and $latex n-1$$. -$pre - -$$ There are no duplicate row and column entires; i.e., if $icode%j% != %k%$$, $codei% %row%[%j%] != %row%[%k%] || %col%[%j%] != %col%[%k%] @@ -93,47 +86,48 @@ %$$ and its size is $latex n$$; i.e., $icode%x%.size() == %size%$$. The input value of the elements of $icode x$$ does not matter. -On output, it has been set to the +On output, it has been set to the argument value for which the function, or its derivative, is being evaluated and placed in $icode jacobian$$. The value of this vector need not change with each repetition. $head jacobian$$ -The argument $icode jacobian$$ is a vector with -$latex m \times n$$ elements. -The input value of its elements does not matter. -The output value of its elements is the Jacobian of the function $latex f(x)$$ -that corresponds to output values of $icode x$$. +The argument $icode jacobian$$ has prototype +$codei% + CppAD::vector& %jacobian% +%$$ +and its size is $icode K$$. +The input value of its elements does not matter. +The output value of its elements is the Jacobian of the function $latex f(x)$$. To be more specific, for -$latex i = 0 , \ldots , m - 1$$, -$latex j = 0 , \ldots , n-1$$, +$latex k = 0 , \ldots , K - 1$$, $latex \[ - \D{f[i]}{x[j]} (x) = jacobian [ i * n + j ] + \D{f[ \R{row}[k] ]}{x[ \R{col}[k] ]} (x) = \R{jacobian} [k] \] $$ $head n_sweep$$ The input value of $icode n_sweep$$ does not matter. On output, it is the value $cref/n_sweep/sparse_jacobian/n_sweep/$$ corresponding to the evaluation of $icode jacobian$$. -This is also the number of colors corresponding to the -$cref/coloring method/sparse_jacobian/work/color_method/$$ -which can be set to $cref/colpack/speed_main/Sparsity Options/colpack/$$ +This is also the number of colors corresponding to the +$cref/coloring method/sparse_jacobian/work/color_method/$$, +which can be set to $cref/colpack/speed_main/Sparsity Options/colpack/$$, and is otherwise $code cppad$$. $subhead double$$ In the case where $icode package$$ is $code double$$, -only the first $latex m$$ +only the first $latex m$$ elements of $icode jacobian$$ are used and they are set to the value of $latex f(x)$$. -$end +$end ----------------------------------------------------------------------------- */ -# include -# include +# include +# include # include # include -# include +# include /*! \{ @@ -144,7 +138,7 @@ using CppAD::vector; /*! - Class used by choose_row_col to determine order of row and column indices + Class used by choose_row_col to determine order of row and column indices */ class Key { public: @@ -156,19 +150,19 @@ Key(void) { } /*! - Construct from a value for row and col + Construct from a value for row and col \param row row value for this key \param col column value for this key - */ + */ Key(size_t row, size_t col) : row_(row), col_(col) { } /*! - Compare this key with another key using < operator + Compare this key with another key using < operator \param other the other key. @@ -200,7 +194,7 @@ void choose_row_col( size_t n , size_t m , - vector& row , + vector& row , vector& col ) { size_t r, c, k, K = 5 * std::max(m, n); @@ -267,8 +261,8 @@ the argument at which the Jacobian was evaluated during the last repetition. \param jacobian [out] -is a vector with size m * n -containing the value of the Jacobian of f(x) +is a vector with size row.size() +containing the value of the Jacobian of f(x) corresponding to the last repetition. \param n_sweep [out] @@ -285,7 +279,7 @@ size_t repeat , size_t m , const CppAD::vector& row , - const CppAD::vector& col , + const CppAD::vector& col , CppAD::vector& x , CppAD::vector& jacobian , size_t& n_sweep @@ -301,11 +295,12 @@ { size_t n = 10; size_t m = 2 * n; size_t repeat = 1; - vector row, col; + vector row, col; choose_row_col(n, m, row, col); vector x(n); - vector jacobian(m * n); + size_t K = row.size(); + vector jacobian(K); size_t n_sweep; return link_sparse_jacobian(n, repeat, m, row, col, x, jacobian, n_sweep); } @@ -319,7 +314,7 @@ true, if correctness test passes, and false otherwise. */ bool correct_sparse_jacobian(bool is_package_double) -{ size_t i, j; +{ size_t i, k; bool ok = true; double eps = 10. * CppAD::numeric_limits::epsilon(); size_t n = 5; @@ -328,35 +323,32 @@ vector row, col; choose_row_col(n, m, row, col); + size_t K = row.size(); + // The double package assumes jacobian.size() >= m + CPPAD_ASSERT_UNKNOWN( K >= m ); vector x(n); - vector jacobian(m * n); + vector jacobian(K); size_t n_sweep; link_sparse_jacobian(n, repeat, m, row, col, x, jacobian, n_sweep); if( is_package_double) - { // check f(x) + { + // check f(x) size_t order = 0; vector check(m); CppAD::sparse_jac_fun(m, n, x, row, col, order, check); for(i = 0; i < m; i++) - { double u = check[i]; - double v = jacobian[i]; - ok &= CppAD::NearEqual(u, v, eps, eps); - } + ok &= CppAD::NearEqual(check[i], jacobian[i], eps, eps); + return ok; } - // check f'(x) + // check f'(x) size_t order = 1; - size_t size = m * n; - vector check(size); + vector check(K); CppAD::sparse_jac_fun(m, n, x, row, col, order, check); - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - { double u = check[ i * n + j ]; - double v = jacobian[ i * n + j ]; - ok &= CppAD::NearEqual(u, v, eps, eps); - } - } + for(k = 0; k < K; k++) + ok &= CppAD::NearEqual(check[k], jacobian[k], eps, eps); + return ok; } /*! @@ -369,15 +361,22 @@ is the number of times to repeate the speed test. */ void speed_sparse_jacobian(size_t size, size_t repeat) -{ size_t n = size; +{ CPPAD_ASSERT_UNKNOWN( size > 0 ); + static size_t previous_size = 0; + static vector row, col; + + size_t n = size; size_t m = 2 * n; - vector row, col; - choose_row_col(n, m, row, col); + if( size != previous_size) + { choose_row_col(n, m, row, col); + previous_size = size; + } // note that cppad/sparse_jacobian.cpp assumes that x.size() // is the size corresponding to this test vector x(n); - vector jacobian(m * n); + size_t K = row.size(); + vector jacobian(K); size_t n_sweep; link_sparse_jacobian(n, repeat, m, row, col, x, jacobian, n_sweep); return; @@ -394,7 +393,7 @@ call to \c link_sparse_jacobian. */ void info_sparse_jacobian(size_t size, size_t& n_sweep) -{ size_t n = size; +{ size_t n = size; size_t m = 2 * n; size_t repeat = 1; vector row, col; @@ -403,9 +402,8 @@ // note that cppad/sparse_jacobian.cpp assumes that x.size() // is the size corresponding to this test vector x(n); - vector jacobian(m * n); + size_t K = row.size(); + vector jacobian(K); link_sparse_jacobian(n, repeat, m, row, col, x, jacobian, n_sweep); return; } - - diff -Nru cppad-2015.00.00.9/speed/src/makefile.am cppad-2016.00.00.1/speed/src/makefile.am --- cppad-2015.00.00.9/speed/src/makefile.am 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/makefile.am 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 2529 2012-10-31 17:37:50Z bradbell $ +# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -19,7 +19,7 @@ # END OPTIMIZE # # BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) +# AM_CXXFLAGS = -g $(CXX_FLAGS) # END DEBUG # AM_CPPFLAGS = \ diff -Nru cppad-2015.00.00.9/speed/src/makefile.in cppad-2016.00.00.1/speed/src/makefile.in --- cppad-2015.00.00.9/speed/src/makefile.in 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/makefile.in 2016-02-09 08:31:53.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,12 +89,11 @@ build_triplet = @build@ host_triplet = @host@ subdir = speed/src -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @@ -156,6 +165,7 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -186,12 +196,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3762 2015-12-01 14:35:37Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -272,26 +282,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -335,7 +348,7 @@ # END OPTIMIZE # # BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) +# AM_CXXFLAGS = -g $(CXX_FLAGS) # END DEBUG # AM_CPPFLAGS = \ @@ -372,7 +385,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu speed/src/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/src/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -630,6 +642,8 @@ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am +.PRECIOUS: makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru cppad-2015.00.00.9/speed/src/microsoft_timer.cpp cppad-2016.00.00.1/speed/src/microsoft_timer.cpp --- cppad-2015.00.00.9/speed/src/microsoft_timer.cpp 2015-02-24 08:31:40.000000000 +0000 +++ cppad-2016.00.00.1/speed/src/microsoft_timer.cpp 2016-02-09 08:31:53.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: microsoft_timer.cpp 3223 2014-03-19 15:13:26Z bradbell $ */ +/* $Id: microsoft_timer.cpp 3724 2015-09-21 05:04:18Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,6 +14,7 @@ $spell Microsoft cpp + src $$ $section Microsoft Version of Elapsed Number of Seconds$$ @@ -24,18 +25,18 @@ $head Purpose$$ This routine is accurate to within .02 seconds -(see $cref elapsed_seconds$$ which uses this routine when +(see $cref elapsed_seconds$$ which uses this routine when the preprocessor symbol $code _MSC_VER$$ is defined). It does not necessary work for time intervals that are greater than a day. It uses $code ::GetSystemTime$$ for timing. $head s$$ -is a $code double$$ equal to the +is a $code double$$ equal to the number of seconds since the first call to $code microsoft_timer$$. $head Linking$$ -The source code for this routine is located in -$code speed/microsoft_timer.cpp$$. +The source code for this routine is located in +$code speed/src/microsoft_timer.cpp$$. The preprocessor symbol $code _MSC_VER$$ must be defined, or this routine is not compiled. diff -Nru cppad-2015.00.00.9/test_more/abs.cpp cppad-2016.00.00.1/test_more/abs.cpp --- cppad-2015.00.00.9/test_more/abs.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/abs.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: abs.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: abs.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/test_more/acos.cpp cppad-2016.00.00.1/test_more/acos.cpp --- cppad-2015.00.00.9/test_more/acos.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/acos.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: acos.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: acos.cpp 3680 2015-05-07 19:17:37Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,11 +11,11 @@ -------------------------------------------------------------------------- */ /* -Old Acos examples now used just for valiadation testing +Old acos examples now used just for valiadation testing */ # include -bool Acos(void) +bool acos(void) { bool ok = true; using CppAD::acos; @@ -27,18 +27,18 @@ Independent(U); // a temporary values - AD x = cos(U[0]); + AD x = cos(U[0]); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = acos(x); // acos( cos(u) ) // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(U[0] , Z[0], 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -49,14 +49,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; diff -Nru cppad-2015.00.00.9/test_more/acosh.cpp cppad-2016.00.00.1/test_more/acosh.cpp --- cppad-2015.00.00.9/test_more/acosh.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/acosh.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,73 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include + +bool acosh(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 200. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // a temporary value + AD cosh_of_x0 = CppAD::cosh(ax[0]); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = CppAD::acosh(cosh_of_x0); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // check value + ok &= NearEqual(ay[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // forward computation of higher order partials w.r.t. x[0] + size_t n_order = 5; + for(size_t order = 2; order < n_order; order++) + { dx[0] = 0.; + dy = f.Forward(order, dx); + ok &= NearEqual(dy[0], 0., eps, eps); + } + // reverse computation of derivatives + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n_order * n); + w[0] = 1.; + dw = f.Reverse(n_order, w); + ok &= NearEqual(dw[0], 1., eps, eps); + for(size_t order = 1; order < n_order; order++) + ok &= NearEqual(dw[order * n + 0], 0., eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/test_more/add.cpp cppad-2016.00.00.1/test_more/add.cpp --- cppad-2015.00.00.9/test_more/add.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/add.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: add.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: add.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -40,7 +40,7 @@ // dependent variable values Z[x] = U[s] + U[t]; // AD + AD Z[y] = Z[x] + 1.; // AD + double - Z[z] = 1. + Z[y]; // double + AD + Z[z] = 1. + Z[y]; // double + AD // create f: U -> Z and vectors used for derivative calculations ADFun f(U, Z); @@ -80,24 +80,24 @@ // independent variable vector double u0 = .5; CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; + U[0] = u0; Independent(U); AD a = U[0] + 1.; // AD + double AD b = a + 2; // AD + int - AD c = 3. + b; // double + AD - AD d = 4 + c; // int + AD + AD c = 3. + b; // double + AD + AD d = 4 + c; // int + AD - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = d + U[0]; // AD + AD + Z[0] = d + U[0]; // AD + AD // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(Z[0] , 2 * u0 + 10, 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -108,14 +108,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -134,6 +134,6 @@ bool Add(void) { bool ok = true; ok &= AddTestOne(); - ok &= AddTestTwo(); + ok &= AddTestTwo(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/add_eq.cpp cppad-2016.00.00.1/test_more/add_eq.cpp --- cppad-2015.00.00.9/test_more/add_eq.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/add_eq.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: add_eq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: add_eq.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -41,7 +41,7 @@ Z[y] = U[t]; Z[x] += U[s]; // parameter += variable Z[x] += U[t]; // variable += variable - Z[y] += .5; // variable += double + Z[y] += .5; // variable += double // use .5 because it is represented exactly in binary and // because it makes sure that += does not slice the double to an int @@ -80,22 +80,22 @@ // independent variable vector double u0 = .5; CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; + U[0] = u0; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = U[0]; // initial value Z[0] += 2; // AD += int Z[0] += 4.; // AD += double - Z[0] += U[0]; // AD += AD + Z[0] += U[0]; // AD += AD // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(Z[0] , u0+2+4+u0, 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -106,14 +106,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; diff -Nru cppad-2015.00.00.9/test_more/add_zero.cpp cppad-2016.00.00.1/test_more/add_zero.cpp --- cppad-2015.00.00.9/test_more/add_zero.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/add_zero.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: add_zero.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: add_zero.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ typedef CppAD::AD< ADdouble > ADDdouble; bool AddZero(void) -{ +{ using namespace CppAD; bool ok = true; diff -Nru cppad-2015.00.00.9/test_more/adfun_copy.cpp cppad-2016.00.00.1/test_more/adfun_copy.cpp --- cppad-2015.00.00.9/test_more/adfun_copy.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/adfun_copy.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: adfun_copy.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: adfun_copy.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/test_more/alloc_openmp.cpp cppad-2016.00.00.1/test_more/alloc_openmp.cpp --- cppad-2015.00.00.9/test_more/alloc_openmp.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/alloc_openmp.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: alloc_openmp.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: alloc_openmp.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -47,21 +47,21 @@ // Test routine called by the master thread (thread_num = 0). bool alloc_openmp(void) { bool ok = true; - + int num_threads = NUMBER_THREADS; // call setup for using thread_alloc in parallel mode. thread_alloc::parallel_setup( size_t(num_threads), in_parallel, thread_number ); - + // Execute the worker function in parallel int thread_num; # pragma omp parallel for for(thread_num = 0; thread_num < num_threads; thread_num++) worker(); // end omp parallel for - + // now inform CppAD that there is only one thread thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); @@ -69,7 +69,7 @@ { // check calculations by this thread in parallel model ok &= thread_all_[thread_num].x[0] == static_cast(thread_num); - // test having master thread (thread number zero) + // test having master thread (thread number zero) // free memory that was allocated by thread number thread_num. thread_all_[thread_num].x.clear(); } diff -Nru cppad-2015.00.00.9/test_more/asin.cpp cppad-2016.00.00.1/test_more/asin.cpp --- cppad-2015.00.00.9/test_more/asin.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/asin.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: asin.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: asin.cpp 3675 2015-05-05 14:26:18Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,7 +16,7 @@ # include -bool Asin(void) +bool asin(void) { bool ok = true; using CppAD::asin; @@ -28,18 +28,18 @@ Independent(U); // a temporary values - AD x = sin(U[0]); + AD x = sin(U[0]); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = asin(x); // asin( sin(u) ) // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(U[0] , Z[0], 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -50,14 +50,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; diff -Nru cppad-2015.00.00.9/test_more/asinh.cpp cppad-2016.00.00.1/test_more/asinh.cpp --- cppad-2015.00.00.9/test_more/asinh.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/asinh.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,73 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include + +bool asinh(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // a temporary value + AD sinh_of_x0 = CppAD::sinh(ax[0]); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = CppAD::asinh(sinh_of_x0); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // check value + ok &= NearEqual(ay[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // forward computation of higher order partials w.r.t. x[0] + size_t n_order = 5; + for(size_t order = 2; order < n_order; order++) + { dx[0] = 0.; + dy = f.Forward(order, dx); + ok &= NearEqual(dy[0], 0., eps, eps); + } + // reverse computation of derivatives + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n_order * n); + w[0] = 1.; + dw = f.Reverse(n_order, w); + ok &= NearEqual(dw[0], 1., eps, eps); + for(size_t order = 1; order < n_order; order++) + ok &= NearEqual(dw[order * n + 0], 0., eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/test_more/assign.cpp cppad-2016.00.00.1/test_more/assign.cpp --- cppad-2015.00.00.9/test_more/assign.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/assign.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: assign.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: assign.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -28,17 +28,17 @@ // declare independent variables and start tape recording CppAD::Independent(x); - - // range space vector + + // range space vector size_t m = 3; CPPAD_TESTVECTOR(AD) y(m); // assign an AD object equal to an independent variable // (choose the first independent variable to check a special case) // use the value returned by the assignment (for another assignment) - y[0] = y[1] = x[0]; + y[0] = y[1] = x[0]; - // assign an AD object equal to an expression + // assign an AD object equal to an expression y[1] = x[1] + 1.; y[2] = x[2] + 2.; diff -Nru cppad-2015.00.00.9/test_more/atan2.cpp cppad-2016.00.00.1/test_more/atan2.cpp --- cppad-2015.00.00.9/test_more/atan2.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/atan2.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: atan2.cpp 3083 2014-01-10 18:35:07Z bradbell $ */ +// $Id: atan2.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -45,14 +45,14 @@ // a temporary values AD x = cos(U[0]); - AD y = sin(U[0]); + AD y = sin(U[0]); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = atan2(y, x); + Z[0] = atan2(y, x); // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); @@ -82,14 +82,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; diff -Nru cppad-2015.00.00.9/test_more/atan.cpp cppad-2016.00.00.1/test_more/atan.cpp --- cppad-2015.00.00.9/test_more/atan.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/atan.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: atan.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: atan.cpp 3682 2015-05-08 21:59:05Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -33,7 +33,7 @@ // some temporary values AD x = cos(U[s]); - AD y = sin(U[s]); + AD y = sin(U[s]); AD z = y / x; // tan(s) // dependent variable vector and indices @@ -44,11 +44,11 @@ Z[a] = atan(z); // atan( tan(s) ) // create f: U -> Z and vectors used for dierivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v( f.Domain() ); CPPAD_TESTVECTOR(double) w( f.Range() ); - // check value + // check value ok &= NearEqual(U[s] , Z[a], 1e-10 , 1e-10); // forward computation of partials w.r.t. s @@ -66,7 +66,7 @@ f.Forward(1, v); v[s] = 0.; w = f.Forward(2, v); - ok &= NearEqual(2. * w[a], 0e0, 1e-10 , 1e-10); // d^2 a / (ds ds) + ok &= NearEqual(2. * w[a], 0e0, 1e-10 , 1e-10); // d^2 a / (ds ds) // reverse computation of second partials of a CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); @@ -91,18 +91,18 @@ Independent(U); // a temporary values - AD x = sin(U[0]) / cos(U[0]); + AD x = sin(U[0]) / cos(U[0]); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = atan(x); // atan( tan(u) ) // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(U[0] , Z[0], 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -113,14 +113,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -136,9 +136,9 @@ } // END empty namespace -bool Atan(void) +bool atan(void) { bool ok = true; ok &= AtanTestOne(); - ok &= AtanTestTwo(); + ok &= AtanTestTwo(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/atanh.cpp cppad-2016.00.00.1/test_more/atanh.cpp --- cppad-2015.00.00.9/test_more/atanh.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/atanh.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,73 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include + +bool atanh(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // a temporary value + AD tanh_of_x0 = CppAD::tanh(ax[0]); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = CppAD::atanh(tanh_of_x0); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // check value + ok &= NearEqual(ay[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // forward computation of higher order partials w.r.t. x[0] + size_t n_order = 5; + for(size_t order = 2; order < n_order; order++) + { dx[0] = 0.; + dy = f.Forward(order, dx); + ok &= NearEqual(dy[0], 0., eps, eps); + } + // reverse computation of derivatives + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n_order * n); + w[0] = 1.; + dw = f.Reverse(n_order, w); + ok &= NearEqual(dw[0], 1., eps, eps); + for(size_t order = 1; order < n_order; order++) + ok &= NearEqual(dw[order * n + 0], 0., eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/test_more/azmul.cpp cppad-2016.00.00.1/test_more/azmul.cpp --- cppad-2015.00.00.9/test_more/azmul.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/azmul.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,267 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include +# include + +namespace { + bool test_forward(void) + { bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + double inf = std::numeric_limits::infinity(); + double eps = 10. * std::numeric_limits::epsilon(); + + typedef AD a1double; + typedef AD a2double; + + // domain space vector + size_t n = 2; + size_t m = 3; + + // double level + CPPAD_TESTVECTOR(double) x(n), z(m); + x[0] = 3.0; + x[1] = 4.0; + + // start a1 level recording + CPPAD_TESTVECTOR(a1double) a1x(n), a1dx(n), a1y(m), a1z(m); + for(size_t j = 0; j < n; j++) + a1x[j] = x[j]; + CppAD::Independent(a1x); + + // start a2 level recording + CPPAD_TESTVECTOR(a2double) a2x(n), a2y(m); + for(size_t j = 0; j < n; j++) + a2x[j] = a1x[j]; + CppAD::Independent(a2x); + + // y + a2y[0] = CppAD::azmul(a2x[0], a2x[1]); // azmul(variable, variable) + a2y[1] = CppAD::azmul(a1x[0], a2x[1]); // azmul(parameter, variable) + a2y[2] = CppAD::azmul(a2x[0], a1x[1]); // azmul(variable, parameter) + + // create f: x -> y and stop a2 recording + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + + // check y + a1y = a1f.Forward(0, a1x); // azmul(variable, variable) only + for(size_t i = 0; i < m; i++) + ok &= NearEqual(a1y[i] , x[0] * x[1], eps, eps); + + for(size_t j = 0; j < n; j++) + a1dx[j] = a1double(1.0); + a1z = a1f.Forward(1, a1dx); + + // create g: x -> z and stop a1 recording + CppAD::ADFun g; + g.Dependent(a1x, a1z); + + // check value when x[0] is not zero + z = g.Forward(0, x); + + // z_0 = d_lambda [ ( x[0] + lambda ) * ( x[1] + lambda ) ] + ok &= NearEqual(z[0] , x[0] + x[1], eps, eps); + + // z_1 = d_lambda [ x[0] * ( x[1] + lambda ) ] + ok &= NearEqual(z[1] , x[0], eps, eps); + + // z_2 = d_lambda [ ( x[0] + lambda ) * x[1] ] + ok &= NearEqual(z[2] , x[1], eps, eps); + + // check value x[0] is zero and x[1] is infinity + x[0] = 0.0; + x[1] = inf; + z = g.Forward(0, x); + ok &= z[0] == inf; + ok &= z[1] == 0.0; + ok &= z[2] == inf; + + return ok; + } + bool test_reverse(void) + { bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + double inf = std::numeric_limits::infinity(); + double eps = 10. * std::numeric_limits::epsilon(); + + typedef AD a1double; + typedef AD a2double; + + // domain space vector + size_t n = 2; + size_t m = 3; + + // double level + CPPAD_TESTVECTOR(double) x(n), z(n); + x[0] = 3.0; + x[1] = 4.0; + + // start a1 level recording + CPPAD_TESTVECTOR(a1double) a1x(n), a1dx(n), a1w(m), a1z(n); + for(size_t j = 0; j < n; j++) + a1x[j] = x[j]; + CppAD::Independent(a1x); + + // start a2 level recording + CPPAD_TESTVECTOR(a2double) a2x(n), a2y(m); + for(size_t j = 0; j < n; j++) + a2x[j] = a1x[j]; + CppAD::Independent(a2x); + + // y + a2y[0] = CppAD::azmul(a2x[0], a2x[1]); // azmul(variable, variable) + a2y[1] = CppAD::azmul(a1x[0], a2x[1]); // azmul(parameter, variable) + a2y[2] = CppAD::azmul(a2x[0], a1x[1]); // azmul(variable, parameter) + + // create f: x -> y and stop a2 recording + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + + // w(x) = y[0] + y[1] + y[2] + for(size_t i = 0; i < m; i++) + a1w[i] = a1double(1.0); + a1f.Forward(0, a1x); + a1dx = a1f.Reverse(1, a1w); + + // create g: x -> z and stop a1 recording + CppAD::ADFun g; + g.Dependent(a1x, a1dx); + + // check value when x[0] is not zero + z = g.Forward(0, x); + + // partial y[0] w.r.t x[0] = x[1] + // partial y[1] w.r.t x[0] = 0 + // partial y[2] w.r.t x[0] = x[1] + ok &= NearEqual(z[0] , x[1] + x[1], eps, eps); + + // partial y[0] w.r.t x[1] = x[0] + // partial y[1] w.r.t x[1] = x[0] + // partial y[2] w.r.t x[1] = 0 + ok &= NearEqual(z[1] , x[0] + x[0], eps, eps); + + // check value x[0] is zero and x[1] is infinity + x[0] = 0.0; + x[1] = inf; + z = g.Forward(0, x); + ok &= z[0] == inf; + ok &= z[1] == 0.0; + + return ok; + } + bool test_forward_dir(void) + { bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + double inf = std::numeric_limits::infinity(); + double eps = 10. * std::numeric_limits::epsilon(); + + typedef AD a1double; + typedef AD a2double; + + // domain space vector + size_t n = 2; + size_t m = 3; + size_t r = 2; + + // double level + CPPAD_TESTVECTOR(double) x(n), z(r * m); + x[0] = 3.0; + x[1] = 4.0; + + // start a1 level recording + CPPAD_TESTVECTOR(a1double) a1x(n), a1dx(r * n), a1y(m), a1z(r * m); + for(size_t j = 0; j < n; j++) + a1x[j] = x[j]; + CppAD::Independent(a1x); + + // start a2 level recording + CPPAD_TESTVECTOR(a2double) a2x(n), a2y(m); + for(size_t j = 0; j < n; j++) + a2x[j] = a1x[j]; + CppAD::Independent(a2x); + + // y + a2y[0] = CppAD::azmul(a2x[0], a2x[1]); // azmul(variable, variable) + a2y[1] = CppAD::azmul(a1x[0], a2x[1]); // azmul(parameter, variable) + a2y[2] = CppAD::azmul(a2x[0], a1x[1]); // azmul(variable, parameter) + + // create f: x -> y and stop a2 recording + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + + // check y + a1y = a1f.Forward(0, a1x); // azmul(variable, variable) only + for(size_t i = 0; i < m; i++) + ok &= NearEqual(a1y[i] , x[0] * x[1], eps, eps); + + for(size_t j = 0; j < n; j++) + { for(size_t ell = 0; ell < r; ell++) + a1dx[r * j + ell] = a1double(1.0 + ell); + } + a1z = a1f.Forward(1, r, a1dx); + + + // create g: x -> z and stop a1 recording + CppAD::ADFun g; + g.Dependent(a1x, a1z); + + // check value when x[0] is not zero + z = g.Forward(0, x); + + // z_00 = d_lambda [ ( x[0] + lambda ) * ( x[1] + lambda ) ] + ok &= NearEqual(z[r * 0 + 0] , x[0] + x[1], eps, eps); + + // z_01 = d_lambda [ ( x[0] + 2 * lambda ) * ( x[1] + 2 * lambda ) ] + ok &= NearEqual(z[r * 0 + 1] , 2.0*(x[0] + x[1]), eps, eps); + + // z_10 = d_lambda [ x[0] * ( x[1] + lambda ) ] + ok &= NearEqual(z[r * 1 + 0] , x[0], eps, eps); + + // z_11 = d_lambda [ x[0] * ( x[1] + 2 * lambda ) ] + ok &= NearEqual(z[r * 1 + 1] , 2.0 * x[0], eps, eps); + + // z_20 = d_lambda [ ( x[0] + lambda ) * x[1] ] + ok &= NearEqual(z[r * 2 + 0] , x[1], eps, eps); + + // z_21 = d_lambda [ ( x[0] + 2 * lambda ) * x[1] ] + ok &= NearEqual(z[r * 2 + 1] , 2.0 * x[1], eps, eps); + + // check value x[0] is zero and x[1] is infinity + x[0] = 0.0; + x[1] = inf; + z = g.Forward(0, x); + ok &= z[r * 0 + 0] == inf; + ok &= z[r * 0 + 1] == inf; + ok &= z[r * 1 + 0] == 0.0; + ok &= z[r * 1 + 1] == 0.0; + ok &= z[r * 2 + 0] == inf; + ok &= z[r * 2 + 1] == inf; + + return ok; + } +} +bool azmul(void) +{ bool ok = true; + + ok &= test_forward(); + ok &= test_reverse(); + ok &= test_forward_dir(); + + return ok; +} diff -Nru cppad-2015.00.00.9/test_more/base_adolc.cpp cppad-2016.00.00.1/test_more/base_adolc.cpp --- cppad-2015.00.00.9/test_more/base_adolc.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/base_adolc.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,6 +1,6 @@ -/* $Id: base_adolc.cpp 2794 2013-05-02 08:20:30Z bradbell $ */ +// $Id: base_adolc.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -13,13 +13,13 @@ # include # include -// adouble definitions not in Adolc distribution and +// adouble definitions not in Adolc distribution and // required in order to use CppAD::AD # include # include -bool base_adolc(void) +bool base_adolc(void) { bool ok = true; // initialize test result typedef adouble ADdouble; // for first level of taping @@ -39,7 +39,7 @@ for(j = 0; j < n; j++) aa_x[j] = a_x[j]; // track how aa_x depends on a_x CppAD::Independent(aa_x); // aa_x is independent for ADDdouble - + // compute function size_t m = 5; diff -Nru cppad-2015.00.00.9/test_more/base_alloc.cpp cppad-2016.00.00.1/test_more/base_alloc.cpp --- cppad-2015.00.00.9/test_more/base_alloc.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/base_alloc.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,6 +1,6 @@ -/* $Id: base_alloc.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: base_alloc.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the @@ -29,7 +29,7 @@ size_t i, N = 50; for(i = 0; i < N; i++) a_y[0] += double(i); - + CppAD::ADFun f(a_x, a_y); return ok; diff -Nru cppad-2015.00.00.9/test_more/checkpoint.cpp cppad-2016.00.00.1/test_more/checkpoint.cpp --- cppad-2015.00.00.9/test_more/checkpoint.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/checkpoint.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: checkpoint.cpp 2859 2013-05-28 06:03:21Z bradbell $ */ +/* $Id: checkpoint.cpp 3718 2015-09-01 17:38:39Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -35,104 +35,158 @@ } return true; } -} -bool checkpoint(void) -{ bool ok = true; - using CppAD::checkpoint; - using CppAD::ADFun; - using CppAD::NearEqual; - size_t i, j, k, n = 4, ell = n-1 , m = ell + 1; - double eps = 10. * std::numeric_limits::epsilon(); - - // checkpoint version of the function F(x) - ADVector ax(n), ay(ell), az(m); - for(j = 0; j < n; j++) - ax[j] = double(j); - checkpoint f_check("f_check", f_algo, ax, ay); - checkpoint g_check("g_check", g_algo, ay, az); - - // Record a version of z = g[f(x)] without checkpointing - Independent(ax); - f_algo(ax, ay); - g_algo(ay, az); - ADFun check_not(ax, az); - - // Record a version of z = g[f(x)] with checkpointing - Independent(ax); - f_check(ax, ay); - g_check(ay, az); - ADFun check_yes(ax, az); - - // compare forward mode results for orders 0, 1, 2 - size_t p = 2; - CPPAD_TESTVECTOR(double) x_p(n*(p+1)), z_not(m*(p+1)), z_yes(m*(p+1)); - for(j = 0; j < n; j++) - { for(k = 0; k <= p; k++) - x_p[ j * (p+1) + k ] = 1.0 / (p + 1 - k); - } - z_not = check_not.Forward(p, x_p); - z_yes = check_yes.Forward(p, x_p); - for(i = 0; i < m; i++) - { for(k = 0; k <= p; k++) - { double zik_not = z_not[ i * (p+1) + k]; - double zik_yes = z_yes[ i * (p+1) + k]; - ok &= NearEqual(zik_not, zik_yes, eps, eps); + bool test_one(void) + { bool ok = true; + using CppAD::checkpoint; + using CppAD::ADFun; + using CppAD::NearEqual; + size_t i, j, k, n = 4, ell = n-1 , m = ell + 1; + double eps = 10. * std::numeric_limits::epsilon(); + + // checkpoint version of the function F(x) + ADVector ax(n), ay(ell), az(m); + for(j = 0; j < n; j++) + ax[j] = double(j); + checkpoint f_check("f_check", f_algo, ax, ay); + checkpoint g_check("g_check", g_algo, ay, az); + + // Record a version of z = g[f(x)] without checkpointing + Independent(ax); + f_algo(ax, ay); + g_algo(ay, az); + ADFun check_not(ax, az); + + // Record a version of z = g[f(x)] with checkpointing + Independent(ax); + f_check(ax, ay); + g_check(ay, az); + ADFun check_yes(ax, az); + + // compare forward mode results for orders 0, 1, 2 + size_t p = 2; + CPPAD_TESTVECTOR(double) x_p(n*(p+1)), z_not(m*(p+1)), z_yes(m*(p+1)); + for(j = 0; j < n; j++) + { for(k = 0; k <= p; k++) + x_p[ j * (p+1) + k ] = 1.0 / (p + 1 - k); + } + z_not = check_not.Forward(p, x_p); + z_yes = check_yes.Forward(p, x_p); + for(i = 0; i < m; i++) + { for(k = 0; k <= p; k++) + { double zik_not = z_not[ i * (p+1) + k]; + double zik_yes = z_yes[ i * (p+1) + k]; + ok &= NearEqual(zik_not, zik_yes, eps, eps); + } } - } - // compare reverse mode results - CPPAD_TESTVECTOR(double) w(m*(p+1)), dw_not(n*(p+1)), dw_yes(n*(p+1)); - dw_not = check_not.Reverse(p+1, w); - dw_yes = check_yes.Reverse(p+1, w); - for(j = 0; j < n; j++) - { for(k = 0; k <= p; k++) - { double dwjk_not = dw_not[ j * (p+1) + k]; - double dwjk_yes = dw_yes[ j * (p+1) + k]; - ok &= NearEqual(dwjk_not, dwjk_yes, eps, eps); + // compare reverse mode results + CPPAD_TESTVECTOR(double) w(m*(p+1)), dw_not(n*(p+1)), dw_yes(n*(p+1)); + dw_not = check_not.Reverse(p+1, w); + dw_yes = check_yes.Reverse(p+1, w); + for(j = 0; j < n; j++) + { for(k = 0; k <= p; k++) + { double dwjk_not = dw_not[ j * (p+1) + k]; + double dwjk_yes = dw_yes[ j * (p+1) + k]; + ok &= NearEqual(dwjk_not, dwjk_yes, eps, eps); + } } - } - // mix sparsity so test both cases - f_check.option( CppAD::atomic_base::bool_sparsity_enum ); - g_check.option( CppAD::atomic_base::set_sparsity_enum ); - - // compare forward mode Jacobian sparsity patterns - size_t q = n - 1; - CppAD::vector< std::set > r(n), s_not(m), s_yes(m); - for(j = 0; j < n; j++) - { if( j < q ) - r[j].insert(j); - else - { r[j].insert(0); - r[j].insert(1); + // mix sparsity so test both cases + f_check.option( CppAD::atomic_base::bool_sparsity_enum ); + g_check.option( CppAD::atomic_base::set_sparsity_enum ); + + // compare forward mode Jacobian sparsity patterns + size_t q = n - 1; + CppAD::vector< std::set > r(n), s_not(m), s_yes(m); + for(j = 0; j < n; j++) + { if( j < q ) + r[j].insert(j); + else + { r[j].insert(0); + r[j].insert(1); + } } + s_not = check_not.ForSparseJac(q, r); + s_yes = check_yes.ForSparseJac(q, r); + for(i = 0; i < m; i++) + ok &= s_not[i] == s_yes[i]; + + // compare reverse mode Jacobian sparsity patterns + CppAD::vector< std::set > s(m), r_not(m), r_yes(m); + for(i = 0; i < m; i++) + s[i].insert(i); + r_not = check_not.RevSparseJac(m, s); + r_yes = check_yes.RevSparseJac(m, s); + for(i = 0; i < m; i++) + ok &= s_not[i] == s_yes[i]; + + + // compare reverse mode Hessian sparsity patterns + CppAD::vector< std::set > s_one(1), h_not(q), h_yes(q); + for(i = 0; i < m; i++) + s_one[0].insert(i); + h_not = check_not.RevSparseHes(q, s_one); + h_yes = check_yes.RevSparseHes(q, s_one); + for(i = 0; i < q; i++) + ok &= h_not[i] == h_yes[i]; + + checkpoint::clear(); + return ok; + } + + bool h_algo(const ADVector& ax, ADVector& ay) + { ay[0] = ax[0]; + ay[1] = ax[1] + ax[2]; + return true; } - s_not = check_not.ForSparseJac(q, r); - s_yes = check_yes.ForSparseJac(q, r); - for(i = 0; i < m; i++) - ok &= s_not[i] == s_yes[i]; - - // compare reverse mode Jacobian sparsity patterns - CppAD::vector< std::set > s(m), r_not(m), r_yes(m); - for(i = 0; i < m; i++) - s[i].insert(i); - r_not = check_not.RevSparseJac(m, s); - r_yes = check_yes.RevSparseJac(m, s); - for(i = 0; i < m; i++) - ok &= s_not[i] == s_yes[i]; - - - // compare reverse mode Hessian sparsity patterns - CppAD::vector< std::set > s_one(1), h_not(q), h_yes(q); - for(i = 0; i < m; i++) - s_one[0].insert(i); - h_not = check_not.RevSparseHes(q, s_one); - h_yes = check_yes.RevSparseHes(q, s_one); - for(i = 0; i < q; i++) - ok &= h_not[i] == h_yes[i]; - - checkpoint::clear(); + bool test_two(void) + { bool ok = true; + using CppAD::checkpoint; + using CppAD::ADFun; + using CppAD::NearEqual; + + // checkpoint version of H(x) + size_t m = 2; + size_t n = 3; + ADVector ax(n), ay(m); + for(size_t j = 0; j < n; j++) + ax[j] = double(j); + checkpoint h_check("h_check", h_algo, ax, ay); + + // record function using h_check + Independent(ax); + h_check(ax, ay); + ADFun h(ax, ay); + + for(size_t k = 0; k < 3; k++) + { if( k == 0 ) + h_check.option(CppAD::atomic_base::pack_sparsity_enum); + if( k == 1 ) + h_check.option(CppAD::atomic_base::bool_sparsity_enum); + if( k == 2 ) + h_check.option(CppAD::atomic_base::set_sparsity_enum); + + // compute sparsity pattern h_1(x) = x[1] + x[2] + CppAD::vector< std::set > r(1), s(1); + r[0].insert(1); + s = h.RevSparseJac(1, r); + + // check result + std::set check; + check.insert(1); + check.insert(2); + ok &= s[0] == check; + } + + return ok; + } +} + +bool checkpoint(void) +{ bool ok = true; + ok &= test_one(); + ok &= test_two(); return ok; } // END C++ diff -Nru cppad-2015.00.00.9/test_more/check_simple_vector.cpp cppad-2016.00.00.1/test_more/check_simple_vector.cpp --- cppad-2015.00.00.9/test_more/check_simple_vector.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/check_simple_vector.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: check_simple_vector.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: check_simple_vector.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,7 +19,7 @@ template void Case(const Scalar& x, const Scalar& y) { using CppAD::CheckSimpleVector; - + CheckSimpleVector > (x, y); CheckSimpleVector > (x, y); CheckSimpleVector > (x, y); diff -Nru cppad-2015.00.00.9/test_more/CMakeLists.txt cppad-2016.00.00.1/test_more/CMakeLists.txt --- cppad-2015.00.00.9/test_more/CMakeLists.txt 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/CMakeLists.txt 2016-02-09 08:31:57.000000000 +0000 @@ -1,33 +1,29 @@ -# $Id: CMakeLists.txt 3526 2014-12-29 21:56:45Z bradbell $ +# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- -# Build the test_more directory tests +# Build the test_more directory tests # Inherit environment from ../CMakeList.txt -# Specifies build type for this directory. Possible values are +# Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) -# This directory does not contain any multi-threading tests, so -# test using CPPAD_MAX_NUM_THREADS equal to one (its smallest value) -ADD_DEFINITIONS("-DCPPAD_MAX_NUM_THREADS=1") +# This directory now contains omp_alloc.cpp which uses multi-threading, so +# so no longer can set CPPAD_MAX_NUM_THREADS equal to one (its smallest value) +# ADD_DEFINITIONS("-DCPPAD_MAX_NUM_THREADS=1") # adolc_prefix SET(sources base_adolc.cpp) sources_libs_define(adolc "${sources}" adolc ADOLC_TEST) -# colpack_prefix -SET(sources ../cppad/local/cppad_colpack.cpp) -sources_libs_define(colpack "${sources}" ColPack COLPACK_TEST) - # ipopt_prefix SET(sources ipopt_solve.cpp) sources_libs_define(ipopt "${sources}" "${ipopt_LIBRARIES}" IPOPT_TEST) @@ -35,13 +31,13 @@ # sources that use eigen IF ( eigen_prefix ) # compile eigen library separately so can use different compiler flags - ADD_LIBRARY(test_more_eigen_lib EXCLUDE_FROM_ALL + ADD_LIBRARY(test_more_eigen_lib EXCLUDE_FROM_ALL cppad_eigen.cpp ) # Adds -D define flags to the compilation of source files. ADD_DEFINITIONS("-DCPPAD_EIGEN_TEST") - # Add other compiler flags - add_cppad_cxx_flags(test_more_eigen_lib) + # Add other compiler flags + add_cppad_cxx_flags(test_more_eigen_lib) # # Add eigen to list of libraries SET(eigen_libs test_more_eigen_lib) @@ -53,7 +49,7 @@ # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh.in + ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh ) @@ -61,19 +57,27 @@ # source1 source2 ... sourceN # ) ADD_EXECUTABLE(test_more EXCLUDE_FROM_ALL test_more.cpp + old_usead_2.cpp + old_usead_1.cpp + old_tan.cpp + old_reciprocal.cpp + old_mat_mul.cpp ${adolc_sources} - ${colpack_sources} ${ipopt_sources} abs.cpp acos.cpp + acosh.cpp adfun_copy.cpp asin.cpp + asinh.cpp assign.cpp add.cpp add_eq.cpp add_zero.cpp atan.cpp + atanh.cpp atan2.cpp + azmul.cpp base_alloc.cpp check_simple_vector.cpp checkpoint.cpp @@ -81,6 +85,7 @@ compare_change.cpp cond_exp.cpp cond_exp_ad.cpp + cond_exp_rev.cpp copy.cpp cos.cpp cosh.cpp @@ -90,6 +95,7 @@ div_zero_one.cpp erf.cpp exp.cpp + expm1.cpp extern_value.cpp for_hess.cpp for_sparse_jac.cpp @@ -99,16 +105,21 @@ from_base.cpp fun_check.cpp jacobian.cpp - limits.cpp + num_limits.cpp log.cpp + log1p.cpp log10.cpp mul.cpp + mul_cskip.cpp mul_eq.cpp mul_level.cpp + mul_cond_rev.cpp + mul_zdouble.cpp mul_zero_one.cpp near_equal_ext.cpp neg.cpp ode_err_control.cpp + omp_alloc.cpp optimize.cpp parameter.cpp poly.cpp @@ -136,22 +147,25 @@ sub_zero.cpp tan.cpp test_vector.cpp + to_string.cpp track_new_del.cpp value.cpp vec_ad.cpp vec_ad_par.cpp - vec_unary.cpp + vec_unary.cpp + zdouble.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags(test_more) # List of libraries to be linked into the specified target -TARGET_LINK_LIBRARIES(test_more - ${colpack_libs} - ${adolc_libs} +TARGET_LINK_LIBRARIES(test_more + ${cppad_lib} + ${adolc_libs} ${ipopt_libs} ${eigen_libs} + ${colpack_libs} ) # Add the check_test_more target diff -Nru cppad-2015.00.00.9/test_more/compare_change.cpp cppad-2016.00.00.1/test_more/compare_change.cpp --- cppad-2015.00.00.9/test_more/compare_change.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/compare_change.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: compare_change.cpp 2570 2012-11-14 18:25:24Z bradbell $ */ +/* $Id: compare_change.cpp 3607 2015-01-20 16:20:41Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,281 +11,361 @@ -------------------------------------------------------------------------- */ /* -Old CompareChange example and test, now just used for validation testing +Old CompareChange examples and tests, now just used for validation testing */ # include -bool CompareChange(void) -{ bool ok = true; -# ifndef NDEBUG - - using namespace CppAD; - - // ------------------------------- < ---------------------------- - - // create independent variables - CPPAD_TESTVECTOR(AD) X(2); - X[0] = 3.; - X[1] = 4.; - Independent(X); - - // create dependent variables - CPPAD_TESTVECTOR(AD) Y(6); - - // CondExp would never require retaping - if( X[0] < X[1] ) // True variable < variable - Y[0] = X[0]; - else Y[0] = X[1]; - if( X[1] < X[0] ) // False variable < variable - Y[1] = X[0]; - else Y[1] = X[1]; - if( 3.5 < X[1] ) // True parameter < variable - Y[2] = X[0]; - else Y[2] = X[1]; - if( 3.5 < X[0] ) // False parameter < variable - Y[3] = X[0]; - else Y[3] = X[1]; - if( X[0] < 4. ) // True variable < parameter - Y[4] = X[0]; - else Y[4] = X[1]; - if( X[1] < 4. ) // False variable < parameter - Y[5] = X[0]; - else Y[5] = X[1]; - - // f : X -> Y - ADFun *f; - f = new ADFun(X, Y); - - // new argument value - CPPAD_TESTVECTOR(double) x( X.size() ); - x[0] = 4.; - x[1] = 3.; - - // evaluate the function at new argument - CPPAD_TESTVECTOR(double) y( Y.size() ); - y = f->Forward(0, x); - - // check results - ok &= (y[0] == x[0]); // this is what the was taped - ok &= (y[1] == x[1]); - ok &= (y[2] == x[0]); - ok &= (y[3] == x[1]); - ok &= (y[4] == x[0]); - ok &= (y[5] == x[1]); - ok &= (f->CompareChange() == 6); // all comparisions have changed - - // done with this function - delete f; - - // ------------------------------- > ---------------------------- - // create independent variables - Independent(X); - - if( X[0] > X[1] ) // False variable > variable - Y[0] = X[0]; - else Y[0] = X[1]; - if( X[1] > X[0] ) // True variable > variable - Y[1] = X[0]; - else Y[1] = X[1]; - if( 3.5 > X[1] ) // False parameter > variable - Y[2] = X[0]; - else Y[2] = X[1]; - if( 3.5 > X[0] ) // True parameter > variable - Y[3] = X[0]; - else Y[3] = X[1]; - if( X[0] > 3. ) // False variable > parameter - Y[4] = X[0]; - else Y[4] = X[1]; - if( X[1] > 3. ) // True variable > parameter - Y[5] = X[0]; - else Y[5] = X[1]; - - // f : X -> Y - f = new ADFun (X, Y); - - // evaluate the function at new argument - y = f->Forward(0, x); - - // check results - ok &= (y[0] == x[1]); // this is what the was taped - ok &= (y[1] == x[0]); - ok &= (y[2] == x[1]); - ok &= (y[3] == x[0]); - ok &= (y[4] == x[1]); - ok &= (y[5] == x[0]); - ok &= (f->CompareChange() == 6); // all comparisions have changed - - // done with this function - delete f; - - // ------------------------------- <= ---------------------------- - // create independent variables - Independent(X); - - if( X[0] <= X[1] ) // True variable <= variable - Y[0] = X[0]; - else Y[0] = X[1]; - if( X[1] <= X[0] ) // False variable <= variable - Y[1] = X[0]; - else Y[1] = X[1]; - if( 4. <= X[1] ) // True parameter <= variable - Y[2] = X[0]; - else Y[2] = X[1]; - if( 4. <= X[0] ) // False parameter <= variable - Y[3] = X[0]; - else Y[3] = X[1]; - if( X[0] <= 3.5 ) // True variable <= parameter - Y[4] = X[0]; - else Y[4] = X[1]; - if( X[1] <= 3.5 ) // False variable <= parameter - Y[5] = X[0]; - else Y[5] = X[1]; - - // f : X -> Y - f = new ADFun (X, Y); - - // evaluate the function at new argument - y = f->Forward(0, x); - - // check results - ok &= (y[0] == x[0]); // this is what the was taped - ok &= (y[1] == x[1]); - ok &= (y[2] == x[0]); - ok &= (y[3] == x[1]); - ok &= (y[4] == x[0]); - ok &= (y[5] == x[1]); - ok &= (f->CompareChange() == 6); // all comparisions have changed - - // done with this function - delete f; - - - // ------------------------------- >= ---------------------------- - // create independent variables - Independent(X); - - if( X[0] >= X[1] ) // False variable >= variable - Y[0] = X[0]; - else Y[0] = X[1]; - if( X[1] >= X[0] ) // True variable >= variable - Y[1] = X[0]; - else Y[1] = X[1]; - if( 3.5 >= X[1] ) // False parameter >= variable - Y[2] = X[0]; - else Y[2] = X[1]; - if( 3.5 >= X[0] ) // True parameter >= variable - Y[3] = X[0]; - else Y[3] = X[1]; - if( X[0] >= 4. ) // False variable >= parameter - Y[4] = X[0]; - else Y[4] = X[1]; - if( X[1] >= 4. ) // True variable >= parameter - Y[5] = X[0]; - else Y[5] = X[1]; - - // f : X -> Y - f = new ADFun (X, Y); - - // evaluate the function at new argument - y = f->Forward(0, x); - - // check results - ok &= (y[0] == x[1]); // this is what the was taped - ok &= (y[1] == x[0]); - ok &= (y[2] == x[1]); - ok &= (y[3] == x[0]); - ok &= (y[4] == x[1]); - ok &= (y[5] == x[0]); - ok &= (f->CompareChange() == 6); // all comparisions have changed - - // done with this function - delete f; - - // ------------------------------- == ---------------------------- - // create independent variables - Independent(X); - - if( X[0] == X[1] ) // False variable == variable - Y[0] = X[0]; - else Y[0] = X[1]; - if( X[0] == X[0] ) // True variable == variable - Y[1] = X[0]; - else Y[1] = X[1]; - if( 3. == X[1] ) // False parameter == variable - Y[2] = X[0]; - else Y[2] = X[1]; - if( 3. == X[0] ) // True parameter == variable - Y[3] = X[0]; - else Y[3] = X[1]; - if( X[0] == 4. ) // False variable == parameter - Y[4] = X[0]; - else Y[4] = X[1]; - if( X[1] == 4. ) // True variable == parameter - Y[5] = X[0]; - else Y[5] = X[1]; - - // f : X -> Y - f = new ADFun (X, Y); - - // evaluate the function at new argument - y = f->Forward(0, x); - - // check results - ok &= (y[0] == x[1]); // this is what the was taped - ok &= (y[1] == x[0]); - ok &= (y[2] == x[1]); - ok &= (y[3] == x[0]); - ok &= (y[4] == x[1]); - ok &= (y[5] == x[0]); - // the first two comparisions do not change - ok &= (f->CompareChange() == 4); - - // done with this function - delete f; - - // ------------------------------- != ---------------------------- - // create independent variables - Independent(X); - - if( X[0] != X[1] ) // True variable != variable - Y[0] = X[0]; - else Y[0] = X[1]; - if( X[0] != X[0] ) // False variable != variable - Y[1] = X[0]; - else Y[1] = X[1]; - if( 3. != X[1] ) // True parameter != variable - Y[2] = X[0]; - else Y[2] = X[1]; - if( 3. != X[0] ) // False parameter != variable - Y[3] = X[0]; - else Y[3] = X[1]; - if( X[0] != 4. ) // True variable != parameter - Y[4] = X[0]; - else Y[4] = X[1]; - if( X[1] != 4. ) // False variable != parameter - Y[5] = X[0]; - else Y[5] = X[1]; - - // f : X -> Y - f = new ADFun (X, Y); - - // evaluate the function at new argument - y = f->Forward(0, x); - - // check results - ok &= (y[0] == x[0]); // this is what the was taped - ok &= (y[1] == x[1]); - ok &= (y[2] == x[0]); - ok &= (y[3] == x[1]); - ok &= (y[4] == x[0]); - ok &= (y[5] == x[1]); - // the first two comparisions do not change - ok &= (f->CompareChange() == 4); +namespace { + // ---------------------------------------------------------------------- + bool CompareChange_one(void) + { bool ok = true; + + using namespace CppAD; + + // ------------------------------- < ---------------------------- + + // create independent variables + CPPAD_TESTVECTOR(AD) X(2); + X[0] = 3.; + X[1] = 4.; + Independent(X); + + // create dependent variables + CPPAD_TESTVECTOR(AD) Y(6); + + // CondExp would never require retaping + if( X[0] < X[1] ) // True variable < variable + Y[0] = X[0]; + else Y[0] = X[1]; + if( X[1] < X[0] ) // False variable < variable + Y[1] = X[0]; + else Y[1] = X[1]; + if( 3.5 < X[1] ) // True parameter < variable + Y[2] = X[0]; + else Y[2] = X[1]; + if( 3.5 < X[0] ) // False parameter < variable + Y[3] = X[0]; + else Y[3] = X[1]; + if( X[0] < 4. ) // True variable < parameter + Y[4] = X[0]; + else Y[4] = X[1]; + if( X[1] < 4. ) // False variable < parameter + Y[5] = X[0]; + else Y[5] = X[1]; + + // f : X -> Y + ADFun *f; + f = new ADFun(X, Y); + + // new argument value + CPPAD_TESTVECTOR(double) x( X.size() ); + x[0] = 4.; + x[1] = 3.; + + // evaluate the function at new argument + CPPAD_TESTVECTOR(double) y( Y.size() ); + y = f->Forward(0, x); + + // check results + ok &= (y[0] == x[0]); // this is what the was taped + ok &= (y[1] == x[1]); + ok &= (y[2] == x[0]); + ok &= (y[3] == x[1]); + ok &= (y[4] == x[0]); + ok &= (y[5] == x[1]); + ok &= (f->CompareChange() == 6); // all comparisions have changed + + // done with this function + delete f; + + // ------------------------------- > ---------------------------- + // create independent variables + Independent(X); + + if( X[0] > X[1] ) // False variable > variable + Y[0] = X[0]; + else Y[0] = X[1]; + if( X[1] > X[0] ) // True variable > variable + Y[1] = X[0]; + else Y[1] = X[1]; + if( 3.5 > X[1] ) // False parameter > variable + Y[2] = X[0]; + else Y[2] = X[1]; + if( 3.5 > X[0] ) // True parameter > variable + Y[3] = X[0]; + else Y[3] = X[1]; + if( X[0] > 3. ) // False variable > parameter + Y[4] = X[0]; + else Y[4] = X[1]; + if( X[1] > 3. ) // True variable > parameter + Y[5] = X[0]; + else Y[5] = X[1]; + + // f : X -> Y + f = new ADFun (X, Y); + + // evaluate the function at new argument + y = f->Forward(0, x); + + // check results + ok &= (y[0] == x[1]); // this is what the was taped + ok &= (y[1] == x[0]); + ok &= (y[2] == x[1]); + ok &= (y[3] == x[0]); + ok &= (y[4] == x[1]); + ok &= (y[5] == x[0]); + ok &= (f->CompareChange() == 6); // all comparisions have changed + + // done with this function + delete f; + + // ------------------------------- <= ---------------------------- + // create independent variables + Independent(X); + + if( X[0] <= X[1] ) // True variable <= variable + Y[0] = X[0]; + else Y[0] = X[1]; + if( X[1] <= X[0] ) // False variable <= variable + Y[1] = X[0]; + else Y[1] = X[1]; + if( 4. <= X[1] ) // True parameter <= variable + Y[2] = X[0]; + else Y[2] = X[1]; + if( 4. <= X[0] ) // False parameter <= variable + Y[3] = X[0]; + else Y[3] = X[1]; + if( X[0] <= 3.5 ) // True variable <= parameter + Y[4] = X[0]; + else Y[4] = X[1]; + if( X[1] <= 3.5 ) // False variable <= parameter + Y[5] = X[0]; + else Y[5] = X[1]; + + // f : X -> Y + f = new ADFun (X, Y); + + // evaluate the function at new argument + y = f->Forward(0, x); + + // check results + ok &= (y[0] == x[0]); // this is what the was taped + ok &= (y[1] == x[1]); + ok &= (y[2] == x[0]); + ok &= (y[3] == x[1]); + ok &= (y[4] == x[0]); + ok &= (y[5] == x[1]); + ok &= (f->CompareChange() == 6); // all comparisions have changed + + // done with this function + delete f; + + + // ------------------------------- >= ---------------------------- + // create independent variables + Independent(X); + + if( X[0] >= X[1] ) // False variable >= variable + Y[0] = X[0]; + else Y[0] = X[1]; + if( X[1] >= X[0] ) // True variable >= variable + Y[1] = X[0]; + else Y[1] = X[1]; + if( 3.5 >= X[1] ) // False parameter >= variable + Y[2] = X[0]; + else Y[2] = X[1]; + if( 3.5 >= X[0] ) // True parameter >= variable + Y[3] = X[0]; + else Y[3] = X[1]; + if( X[0] >= 4. ) // False variable >= parameter + Y[4] = X[0]; + else Y[4] = X[1]; + if( X[1] >= 4. ) // True variable >= parameter + Y[5] = X[0]; + else Y[5] = X[1]; + + // f : X -> Y + f = new ADFun (X, Y); + + // evaluate the function at new argument + y = f->Forward(0, x); + + // check results + ok &= (y[0] == x[1]); // this is what the was taped + ok &= (y[1] == x[0]); + ok &= (y[2] == x[1]); + ok &= (y[3] == x[0]); + ok &= (y[4] == x[1]); + ok &= (y[5] == x[0]); + ok &= (f->CompareChange() == 6); // all comparisions have changed + + // done with this function + delete f; + + // ------------------------------- == ---------------------------- + // create independent variables + Independent(X); + + if( X[0] == X[1] ) // False variable == variable + Y[0] = X[0]; + else Y[0] = X[1]; + if( X[0] == X[0] ) // True variable == variable + Y[1] = X[0]; + else Y[1] = X[1]; + if( 3. == X[1] ) // False parameter == variable + Y[2] = X[0]; + else Y[2] = X[1]; + if( 3. == X[0] ) // True parameter == variable + Y[3] = X[0]; + else Y[3] = X[1]; + if( X[0] == 4. ) // False variable == parameter + Y[4] = X[0]; + else Y[4] = X[1]; + if( X[1] == 4. ) // True variable == parameter + Y[5] = X[0]; + else Y[5] = X[1]; + + // f : X -> Y + f = new ADFun (X, Y); + + // evaluate the function at new argument + y = f->Forward(0, x); + + // check results + ok &= (y[0] == x[1]); // this is what the was taped + ok &= (y[1] == x[0]); + ok &= (y[2] == x[1]); + ok &= (y[3] == x[0]); + ok &= (y[4] == x[1]); + ok &= (y[5] == x[0]); + // the first two comparisions do not change + ok &= (f->CompareChange() == 4); + + // done with this function + delete f; + + // ------------------------------- != ---------------------------- + // create independent variables + Independent(X); + + if( X[0] != X[1] ) // True variable != variable + Y[0] = X[0]; + else Y[0] = X[1]; + if( X[0] != X[0] ) // False variable != variable + Y[1] = X[0]; + else Y[1] = X[1]; + if( 3. != X[1] ) // True parameter != variable + Y[2] = X[0]; + else Y[2] = X[1]; + if( 3. != X[0] ) // False parameter != variable + Y[3] = X[0]; + else Y[3] = X[1]; + if( X[0] != 4. ) // True variable != parameter + Y[4] = X[0]; + else Y[4] = X[1]; + if( X[1] != 4. ) // False variable != parameter + Y[5] = X[0]; + else Y[5] = X[1]; + + // f : X -> Y + f = new ADFun (X, Y); + + // evaluate the function at new argument + y = f->Forward(0, x); + + // check results + ok &= (y[0] == x[0]); // this is what the was taped + ok &= (y[1] == x[1]); + ok &= (y[2] == x[0]); + ok &= (y[3] == x[1]); + ok &= (y[4] == x[0]); + ok &= (y[5] == x[1]); + // the first two comparisions do not change + ok &= (f->CompareChange() == 4); + + // done with this function + delete f; + + return ok; + } + // ---------------------------------------------------------------------- + template + Type Minimum(const Type &x, const Type &y) + { // Use a comparision to compute the min(x, y) + // (note that CondExp would never require retaping). + if( x < y ) + return x; + return y; + } + + bool CompareChange_two(void) + { bool ok = true; + + using CppAD::AD; + using CppAD::ADFun; + using CppAD::Independent; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 3.; + X[1] = 4.; + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = Minimum(X[0], X[1]); + + // create f: x -> y and stop tape recording + ADFun f(X, Y); + + // evaluate zero mode Forward where conditional has the same result + // note that f.CompareChange is not defined when NDEBUG is true + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(double) y(m); + x[0] = 3.5; + x[1] = 4.; + y = f.Forward(0, x); + ok &= (y[0] == x[0]); + ok &= (y[0] == Minimum(x[0], x[1])); + ok &= (f.CompareChange() == 0); + + // evaluate zero mode Forward where conditional has different result + x[0] = 4.; + x[1] = 3.; + y = f.Forward(0, x); + ok &= (y[0] == x[0]); + ok &= (y[0] != Minimum(x[0], x[1])); + ok &= (f.CompareChange() == 1); + + // re-tape to obtain the new AD operation sequence + X[0] = 4.; + X[1] = 3.; + Independent(X); + Y[0] = Minimum(X[0], X[1]); + + // stop tape and store result in f + f.Dependent(Y); + + // evaluate the function at new argument values + y = f.Forward(0, x); + ok &= (y[0] == x[1]); + ok &= (y[0] == Minimum(x[0], x[1])); + ok &= (f.CompareChange() == 0); - // done with this function - delete f; + return ok; + } +} -# endif +bool compare_change(void) +{ bool ok = true; + ok &= CompareChange_one(); + ok &= CompareChange_two(); return ok; } + +// END C++ diff -Nru cppad-2015.00.00.9/test_more/compare.cpp cppad-2016.00.00.1/test_more/compare.cpp --- cppad-2015.00.00.9/test_more/compare.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/compare.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: compare.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: compare.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,53 +15,53 @@ */ # include -namespace { +namespace { template bool Compare(void) { bool ok = true; using CppAD::AD; - + Type middle = 4; AD three = 3; AD four = 4; AD five = 5; - + // AD > Type - ok &= ! (three > middle); - ok &= ! (four > middle); - ok &= (five > middle); - // Type > AD - ok &= (middle > three ); - ok &= ! (middle > four ); - ok &= ! (middle > five ); - + ok &= ! (three > middle); + ok &= ! (four > middle); + ok &= (five > middle); + // Type > AD + ok &= (middle > three ); + ok &= ! (middle > four ); + ok &= ! (middle > five ); + // AD >= Type - ok &= ! (three >= middle); - ok &= (four >= middle); - ok &= (five >= middle); - // Type > AD - ok &= (middle >= three ); - ok &= (middle >= four ); - ok &= ! (middle >= five ); - + ok &= ! (three >= middle); + ok &= (four >= middle); + ok &= (five >= middle); + // Type > AD + ok &= (middle >= three ); + ok &= (middle >= four ); + ok &= ! (middle >= five ); + // AD < Type - ok &= (three < middle); - ok &= ! (four < middle); - ok &= ! (five < middle); - // Type > AD - ok &= ! (middle < three ); - ok &= ! (middle < four ); - ok &= (middle < five ); - + ok &= (three < middle); + ok &= ! (four < middle); + ok &= ! (five < middle); + // Type > AD + ok &= ! (middle < three ); + ok &= ! (middle < four ); + ok &= (middle < five ); + // AD <= Type - ok &= (three <= middle); - ok &= (four <= middle); - ok &= ! (five <= middle); - // Type > AD - ok &= ! (middle <= three ); - ok &= (middle <= four ); - ok &= (middle <= five ); - + ok &= (three <= middle); + ok &= (four <= middle); + ok &= ! (five <= middle); + // Type > AD + ok &= ! (middle <= three ); + ok &= (middle <= four ); + ok &= (middle <= five ); + return ok; } } diff -Nru cppad-2015.00.00.9/test_more/cond_exp_ad.cpp cppad-2016.00.00.1/test_more/cond_exp_ad.cpp --- cppad-2015.00.00.9/test_more/cond_exp_ad.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/cond_exp_ad.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cond_exp_ad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: cond_exp_ad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -77,7 +77,7 @@ // create fa: Xaa -> Yaa function object ADFun< ADdouble > fa(Xaa, Yaa); - // function values + // function values CPPAD_TESTVECTOR( ADdouble ) Ya(m); Ya = fa.Forward(0, Xa); @@ -227,7 +227,7 @@ // create fa: Xaa -> Yaa function object ADFun< ADdouble > fa(Xaa, Yaa); - // function values + // function values CPPAD_TESTVECTOR( ADdouble ) Ya(m); Ya = fa.Forward(0, Xa); diff -Nru cppad-2015.00.00.9/test_more/cond_exp.cpp cppad-2016.00.00.1/test_more/cond_exp.cpp --- cppad-2015.00.00.9/test_more/cond_exp.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/cond_exp.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cond_exp.cpp 2893 2013-08-13 17:35:21Z bradbell $ */ +/* $Id: cond_exp.cpp 3666 2015-02-28 16:54:17Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,7 +11,7 @@ -------------------------------------------------------------------------- */ /* -Comprehensive test built on 08/07 for new user interface to CondExp +Comprehensive test built on 08/07 for new user interface to CondExp */ // BEGIN C++ @@ -32,9 +32,9 @@ Independent(X); // parameter value - AD one = 1.; + AD one = 1.; - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Y(5); // CondExp(parameter, variable, variable, variable) @@ -44,7 +44,7 @@ Y[3] = CondExpGe(one, X[0], X[1], X[2]); Y[4] = CondExpGt(one, X[0], X[1], X[2]); - // create f: X -> Y + // create f: X -> Y ADFun f(X, Y); // vectors for function values @@ -62,7 +62,7 @@ ok &= Y[3] == X[1]; ok &= Y[4] == X[1]; - // function values + // function values v[0] = 2.; v[1] = 1.; v[2] = 0.; @@ -94,7 +94,7 @@ ok &= (dv[0] == 0.); ok &= (dv[1] == dw[0] + dw[1] ); ok &= (dv[2] == dw[2] + dw[3] + dw[4] ); - + return ok; } bool CondExp_vpvv(void) @@ -110,9 +110,9 @@ Independent(X); // parameter value - AD one = 1.; + AD one = 1.; - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Y(5); // CondExp(variable, parameter, variable, variable) @@ -122,7 +122,7 @@ Y[3] = CondExpGe(X[0], one, X[1], X[2]); Y[4] = CondExpGt(X[0], one, X[1], X[2]); - // create f: X -> Y + // create f: X -> Y ADFun f(X, Y); // vectors for function values @@ -140,7 +140,7 @@ ok &= Y[3] == X[2]; ok &= Y[4] == X[2]; - // function values + // function values v[0] = 2.; v[1] = 1.; v[2] = 0.; @@ -172,7 +172,7 @@ ok &= (dv[0] == 0.); ok &= (dv[1] == dw[3] + dw[4] ); ok &= (dv[2] == dw[0] + dw[1] + dw[2] ); - + return ok; } bool CondExp_vvpv(void) @@ -188,9 +188,9 @@ Independent(X); // parameter value - AD three = 3.; + AD three = 3.; - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Y(5); // CondExp(variable, variable, parameter, variable) @@ -200,7 +200,7 @@ Y[3] = CondExpGe(X[0], X[1], three, X[2]); Y[4] = CondExpGt(X[0], X[1], three, X[2]); - // create f: X -> Y + // create f: X -> Y ADFun f(X, Y); // vectors for function values @@ -218,7 +218,7 @@ ok &= Y[3] == X[2]; ok &= Y[4] == X[2]; - // function values + // function values v[0] = 2.; v[1] = 1.; v[2] = 0.; @@ -250,7 +250,7 @@ ok &= (dv[0] == 0.); ok &= (dv[1] == 0.); ok &= (dv[2] == dw[0] + dw[1] + dw[2] ); - + return ok; } bool CondExp_vvvp(void) @@ -266,9 +266,9 @@ Independent(X); // parameter value - AD three = 3.; + AD three = 3.; - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Y(5); // CondExp(variable, variable, variable, parameter) @@ -278,7 +278,7 @@ Y[3] = CondExpGe(X[0], X[1], X[2], three); Y[4] = CondExpGt(X[0], X[1], X[2], three); - // create f: X -> Y + // create f: X -> Y ADFun f(X, Y); // vectors for function values @@ -296,7 +296,7 @@ ok &= Y[3] == three; ok &= Y[4] == three; - // function values + // function values v[0] = 2.; v[1] = 1.; v[2] = 0.; @@ -328,13 +328,13 @@ ok &= (dv[0] == 0.); ok &= (dv[1] == 0.); ok &= (dv[2] == dw[3] + dw[4] ); - + return ok; } # include bool SecondOrderReverse(void) -{ // Bradley M. Bell 2009-07-04 +{ // Bradley M. Bell 2009-07-04 // Reverse mode for CExpOp was only modifying the highest order partial // This test demonstrated the bug bool ok = true; @@ -351,7 +351,7 @@ CPPAD_TESTVECTOR(AD) Y(m); AD left = X[0]; - AD right = X[0] * X[0]; + AD right = X[0] * X[0]; AD exp_if_true = left; AD exp_if_false = right; @@ -365,7 +365,7 @@ exp_if_true = right; Z = CondExpGt(left, right, exp_if_true, exp_if_false); Y[1] = Z * Z; - + CppAD::ADFun f(X, Y); // first order forward @@ -383,11 +383,11 @@ // check first derivative in dw double check = 2. * Value( X[0] ); - ok &= NearEqual(dw[0], check, eps, eps); + ok &= NearEqual(dw[0], check, eps, eps); // check second derivative in dw check = 2.; - ok &= NearEqual(dw[1], check, eps, eps); + ok &= NearEqual(dw[1], check, eps, eps); // test exp_if_false case w[0] = 0.; @@ -397,11 +397,11 @@ // check first derivative in dw check = 2. * Value( X[0] ); - ok &= NearEqual(dw[0], check, eps, eps); + ok &= NearEqual(dw[0], check, eps, eps); // check second derivative in dw check = 2.; - ok &= NearEqual(dw[1], check, eps, eps); + ok &= NearEqual(dw[1], check, eps, eps); return ok; } @@ -414,7 +414,7 @@ using CppAD::AD; using CppAD::NearEqual; - using CppAD::log; + using CppAD::log; using CppAD::abs; double eps = 100. * std::numeric_limits::epsilon(); @@ -444,7 +444,7 @@ Sum += CppAD::CondExpEq(X[j], Zero, MinusInfinity, Zero); } - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) Y(m); Y[0] = Sum; @@ -454,8 +454,8 @@ // vectors for arguments to the function object f CPPAD_TESTVECTOR(double) x(n); // argument values - CPPAD_TESTVECTOR(double) y(m); // function values - CPPAD_TESTVECTOR(double) w(m); // function weights + CPPAD_TESTVECTOR(double) y(m); // function values + CPPAD_TESTVECTOR(double) w(m); // function weights CPPAD_TESTVECTOR(double) dw(n); // derivative of weighted function // a case where abs( x[j] ) > 0 for all j @@ -463,11 +463,11 @@ double sign = 1.; for(j = 0; j < n; j++) { sign *= -1.; - x[j] = sign * double(j + 1); + x[j] = sign * double(j + 1); check += log( abs( x[j] ) ); } - // function value + // function value y = f.Forward(0, x); ok &= ( y[0] == check ); @@ -476,18 +476,18 @@ dw = f.Reverse(1, w); for(j = 0; j < n; j++) { if( x[j] > 0. ) - ok &= NearEqual(dw[j], 1./abs( x[j] ), eps, eps); - else ok &= NearEqual(dw[j], -1./abs( x[j] ), eps, eps); + ok &= NearEqual(dw[j], 1./abs( x[j] ), eps, eps); + else ok &= NearEqual(dw[j], -1./abs( x[j] ), eps, eps); } // a case where x[0] is equal to zero sign = 1.; for(j = 0; j < n; j++) { sign *= -1.; - x[j] = sign * double(j); + x[j] = sign * double(j); } - // function value + // function value y = f.Forward(0, x); ok &= ( y[0] == -Infinity(0.) ); @@ -497,16 +497,13 @@ dw = f.Reverse(1, w); for(j = 0; j < n; j++) { if( x[j] > 0. ) - ok &= NearEqual(dw[j], 1./abs( x[j] ), eps, eps); + ok &= NearEqual(dw[j], 1./abs( x[j] ), eps, eps); else if( x[j] < 0. ) - ok &= NearEqual(dw[j], -1./abs( x[j] ), eps, eps); + ok &= NearEqual(dw[j], -1./abs( x[j] ), eps, eps); else - { // in this case computing dw[j] ends up multiplying - // -infinity * zero and hence results in Nan - ok &= CppAD::isnan(dw[j]); - } + ok &= NearEqual(dw[j], 0.0, eps, eps); } - + return ok; } } // end empty namespace diff -Nru cppad-2015.00.00.9/test_more/cond_exp_rev.cpp cppad-2016.00.00.1/test_more/cond_exp_rev.cpp --- cppad-2015.00.00.9/test_more/cond_exp_rev.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/cond_exp_rev.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,139 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +// Test that reverse mode handles conditional expressions properly +// in that infinity and nans do not propagate thouh un-used case. + +# include + +bool cond_exp_rev(void) +{ bool ok = true; + using CppAD::vector; + using CppAD::AD; + + AD anan = std::numeric_limits::quiet_NaN(); + AD azero = 0.0; + + + size_t n = 2; + vector< AD > ax(n), ay; + ax[0] = 1.0; + ax[1] = anan; + Independent(ax); + + // AbsOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], abs(ax[1]) )); + + // AcosOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], acos(ax[1]) )); + + // AddvvOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[0] + ax[1] )); + + // AddpvOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], 1.0 + ax[1] )); + + // AsinOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], asin(ax[1]) )); + + // AtanOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], atan(ax[1]) )); + + // CosOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], cos(ax[1]) )); + + // CoshOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], cosh(ax[1]) )); + + // DivvvOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[0] / ax[1] )); + + // DivpvOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], 1.0 / ax[1] )); + + // DivvpOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[1] / 2.0 )); + + // ErfOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], erf(ax[1]) )); + + // ExpOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], exp(ax[1]) )); + + // LogOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], log(ax[1]) )); + + // MulvvOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[0] * ax[1] )); + + // MulpvOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], 2.0 * ax[1] )); + + // PowvvOP + // uses check in log, mul, and exp + ay.push_back( CondExpGt(ax[0], azero, ax[0], pow(ax[1], ax[1]) )); + + // PowvpOP + // uses check in log, mul, and exp + ay.push_back( CondExpGt(ax[0], azero, ax[0], pow(ax[1], 2.0) )); + + // PowpvOP + // uses check in log, mul, and exp + ay.push_back( CondExpGt(ax[0], azero, ax[0], pow(2.0, ax[1]) )); + + // SignOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], sign(ax[1]) )); + + // SinOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], sin(ax[1]) )); + + // SinhOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], sinh(ax[1]) )); + + // SqrtOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], sqrt(ax[1]) )); + + // SubvvOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[0] - ax[1] )); + + // SubpvOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], 1.0 - ax[1] )); + + // SubvpOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[1] - 1.0 )); + + // TanOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], tan(ax[1]) )); + + // TanhOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], tanh(ax[1]) )); + + // create f : x -> y + size_t m = ay.size(); + CppAD::ADFun f(ax, ay); + + // weighting vector and reverse mode derivative + vector w(m), dw(n); + for(size_t i = 0; i < m; i++) + w[i] = 0.0; + + // check DivvOp + for(size_t i = 0; i < m; i++) + { w[i] = 1.0; + dw = f.Reverse(1, w); + ok &= dw[0] == 1.0; + ok &= dw[1] == 0.0; + w[i] = 0.0; + } + + return ok; +} diff -Nru cppad-2015.00.00.9/test_more/copy.cpp cppad-2016.00.00.1/test_more/copy.cpp --- cppad-2015.00.00.9/test_more/copy.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/copy.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: copy.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: copy.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -30,10 +30,10 @@ Independent(U); // create an AD that does not depend on s - AD t = 3.; + AD t = 3.; - // use copy constructor - AD x(U[is]); + // use copy constructor + AD x(U[is]); AD y(t); // check which are parameters @@ -51,10 +51,10 @@ ADFun f(U, Z); CPPAD_TESTVECTOR(double) v( f.Domain() ); CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check parameters flags - ok &= ! f.Parameter(ix); - ok &= f.Parameter(iy); + + // check parameters flags + ok &= ! f.Parameter(ix); + ok &= f.Parameter(iy); // check function values ok &= ( Z[ix] == 2. ); @@ -82,10 +82,10 @@ CppAD::Independent(x); // create an AD that does not depend on x - AD b = 3.; + AD b = 3.; - // use copy constructor - AD u(x[0]); + // use copy constructor + AD u(x[0]); AD v = b; // check which are parameters @@ -102,10 +102,10 @@ CppAD::ADFun f(x, y); CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); - - // check parameters flags - ok &= ! f.Parameter(0); - ok &= f.Parameter(1); + + // check parameters flags + ok &= ! f.Parameter(0); + ok &= f.Parameter(1); // check function values ok &= ( y[0] == 2. ); @@ -123,14 +123,14 @@ { bool ok = true; // initialize test result flag using CppAD::AD; // so can use AD in place of CppAD::AD - // construct directly from Base where Base is double - AD x(1.); + // construct directly from Base where Base is double + AD x(1.); // construct from a type that converts to Base where Base is double AD y = 2; // construct from a type that converts to Base where Base = AD - AD< AD > z(3); + AD< AD > z(3); // check that resulting objects are parameters ok &= Parameter(x); @@ -163,7 +163,7 @@ ok &= Parameter(y); // assign them values - x = 3.; + x = 3.; y = 4.; // just check a simple operation diff -Nru cppad-2015.00.00.9/test_more/cos.cpp cppad-2016.00.00.1/test_more/cos.cpp --- cppad-2015.00.00.9/test_more/cos.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/cos.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cos.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: cos.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,16 +27,16 @@ U[0] = 1.; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = cos(U[0]); + Z[0] = cos(U[0]); // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value double sin_u = sin( Value(U[0]) ); double cos_u = cos( Value(U[0]) ); @@ -48,7 +48,7 @@ double jfac = 1.; v[0] = 1.; for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); double value; if( j % 4 == 1 ) @@ -65,7 +65,7 @@ } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; diff -Nru cppad-2015.00.00.9/test_more/cosh.cpp cppad-2016.00.00.1/test_more/cosh.cpp --- cppad-2015.00.00.9/test_more/cosh.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/cosh.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cosh.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: cosh.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,16 +27,16 @@ U[0] = 1.; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = cosh(U[0]); + Z[0] = cosh(U[0]); // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value double sinh_u = sinh( Value(U[0]) ); double cosh_u = cosh( Value(U[0]) ); @@ -48,7 +48,7 @@ double jfac = 1.; v[0] = 1.; for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); double value; if( j % 2 == 1 ) @@ -61,7 +61,7 @@ } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; diff -Nru cppad-2015.00.00.9/test_more/cppad_eigen.cpp cppad-2016.00.00.1/test_more/cppad_eigen.cpp --- cppad-2015.00.00.9/test_more/cppad_eigen.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/cppad_eigen.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: cppad_eigen.cpp 3070 2013-12-31 15:09:11Z bradbell $ */ +// $Id: cppad_eigen.cpp 3760 2015-12-01 04:12:28Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -32,13 +32,13 @@ ok &= traits::AddCost == 2; ok &= traits::MulCost == 2; - ok &= traits::epsilon() == + ok &= traits::epsilon() == std::numeric_limits::epsilon(); - ok &= traits::dummy_precision() == + ok &= traits::dummy_precision() == 100.* std::numeric_limits::epsilon(); - ok &= traits::highest() == + ok &= traits::highest() == std::numeric_limits::max(); - ok &= traits::lowest() == + ok &= traits::lowest() == std::numeric_limits::min(); AD x = 2.0; @@ -48,14 +48,14 @@ ok &= abs2(x) == 4.0; // Outputing a matrix used to fail before partial specialization of - // struct significant_decimals_default_impl in cppad_eigen.hpp. + // struct significant_decimals_default_impl in cppad_eigen.hpp. Matrix< AD, 1, 1> X; X(0, 0) = AD(1); std::stringstream stream_out; stream_out << X; ok &= "1" == stream_out.str(); -# if ! CPPAD_IMPLICIT_CTOR_FROM_ANY_TYPE +# if ! CPPAD_DEPRECATED // multiplying three matrices together used to cause warning // before making ctor from arbitrary type to AD explicit. typedef CppAD::AD AScalar; @@ -63,9 +63,9 @@ A(0,0) = 1.0; B(0,0) = 2.0; C(0,0) = 3.0; - D = A * B * C; + D = A * B * C; ok &= D(0,0) == 6.0 ; # endif - + return ok; } diff -Nru cppad-2015.00.00.9/test_more/dbl_epsilon.cpp cppad-2016.00.00.1/test_more/dbl_epsilon.cpp --- cppad-2015.00.00.9/test_more/dbl_epsilon.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/dbl_epsilon.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: dbl_epsilon.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: dbl_epsilon.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-08 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,7 +11,7 @@ -------------------------------------------------------------------------- */ /* -Check the value of machine epsilon is accurate enough for the correctness tests +Check the value of machine epsilon is accurate enough for the correctness tests */ # include diff -Nru cppad-2015.00.00.9/test_more/div.cpp cppad-2016.00.00.1/test_more/div.cpp --- cppad-2015.00.00.9/test_more/div.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/div.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: div.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: div.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -47,7 +47,7 @@ // dependent variables Z[x] = U[s] / U[t]; // AD / AD Z[y] = Z[x] / 4.; // AD / double - Z[z] = 5. / Z[y]; // double / AD + Z[z] = 5. / Z[y]; // double / AD Z[u] = Z[z] / one; // division by a parameter equal to one Z[v] = Z[z] / 1.; // division by a double equal to one Z[w] = zero / Z[z]; // division into a parameter equal to zero @@ -60,9 +60,9 @@ ADFun f(U, Z); CPPAD_TESTVECTOR(double) q( f.Domain() ); CPPAD_TESTVECTOR(double) r( f.Range() ); - - // check parameter flag - ok &= f.Parameter(w); + + // check parameter flag + ok &= f.Parameter(w); // check values ok &= NearEqual( Z[x] , 2. / 3. , 1e-10 , 1e-10); @@ -94,9 +94,9 @@ r[y] = r[z] = r[u] = r[v] = r[w] = 0.; Q = f.Reverse(2, r); ok &= NearEqual( - Q[s * f.Domain() + 1], - - 1. / (U[t] * U[t]), - 1e-10, + Q[s * f.Domain() + 1], + - 1. / (U[t] * U[t]), + 1e-10, 1e-10 ); @@ -115,19 +115,19 @@ AD a = U[0] / 1.; // AD / double AD b = a / 2; // AD / int - AD c = 3. / b; // double / AD - AD d = 4 / c; // int / AD + AD c = 3. / b; // double / AD + AD d = 4 / c; // int / AD - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = U[0] * U[0] / d; // AD / AD // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(Value(Z[0]) , u0*u0/(4/(3/(u0/2))), 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -139,14 +139,14 @@ for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -165,7 +165,7 @@ { bool ok = true; using namespace CppAD; - // more testing of variable / variable case + // more testing of variable / variable case double x0 = 2.; double x1 = 3.; size_t n = 2; @@ -183,7 +183,7 @@ dx[0] = 1.; dx[1] = 1.; dy = f.Forward(1, dx); - check = 1. / x1 - x0 / (x1 * x1); + check = 1. / x1 - x0 / (x1 * x1); ok &= NearEqual(dy[0], check, 1e-10 , 1e-10); CPPAD_TESTVECTOR(double) w(m), dw(n); @@ -202,7 +202,7 @@ bool Div(void) { bool ok = true; ok &= DivTestOne(); - ok &= DivTestTwo(); - ok &= DivTestThree(); + ok &= DivTestTwo(); + ok &= DivTestThree(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/div_eq.cpp cppad-2016.00.00.1/test_more/div_eq.cpp --- cppad-2015.00.00.9/test_more/div_eq.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/div_eq.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: div_eq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: div_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -40,14 +40,14 @@ AD one = 1.; // dependent variable values - Z[x] = U[s]; + Z[x] = U[s]; Z[y] = U[t]; Z[x] /= U[t]; // AD *= AD Z[y] /= 5.; // AD *= double zero /= Z[y]; // divide into a parameter equal to zero Z[y] /= one; // divide by a parameter equal to one Z[y] /= 1.; // divide by a double equal to one - + // check that zero is still a parameter // (must do this before creating f because it erases the tape) ok &= Parameter(zero); @@ -58,9 +58,9 @@ CPPAD_TESTVECTOR(double) w( f.Range() ); // check that none of the components of f are parameters - size_t i; - for(i = 0; i < f.Range(); i++) - ok &= ! f.Parameter(i); + size_t i; + for(i = 0; i < f.Range(); i++) + ok &= ! f.Parameter(i); // check functin values ok &= NearEqual(Z[x] , 3. / 2. , 1e-10, 1e-10); @@ -77,7 +77,7 @@ CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); w[x] = 1.; w[y] = 0.; - r = f.Reverse(2, w); + r = f.Reverse(2, w); ok &= NearEqual(r[2 * s + 1] // d^2 x / (dt ds) , - 1. / (U[t] * U[t]) , 1e-10 , 1e-10 ); ok &= NearEqual(r[2 * t + 1] // d^2 x / (dt dt) @@ -94,22 +94,22 @@ // independent variable vector double u0 = .5; CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; + U[0] = u0; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = U[0] * U[0]; // initial value Z[0] /= 2; // AD /= int Z[0] /= 4.; // AD /= double - Z[0] /= U[0]; // AD /= AD + Z[0] /= U[0]; // AD /= AD // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(Z[0] , u0*u0/(2*4*u0), 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -120,14 +120,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -146,6 +146,6 @@ bool DivEq(void) { bool ok = true; ok &= DivEqTestOne(); - ok &= DivEqTestTwo(); + ok &= DivEqTestTwo(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/div_zero_one.cpp cppad-2016.00.00.1/test_more/div_zero_one.cpp --- cppad-2015.00.00.9/test_more/div_zero_one.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/div_zero_one.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: div_zero_one.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: div_zero_one.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ typedef CppAD::AD< ADdouble > ADDdouble; bool DivZeroOne(void) -{ +{ using namespace CppAD; bool ok = true; diff -Nru cppad-2015.00.00.9/test_more/erf.cpp cppad-2016.00.00.1/test_more/erf.cpp --- cppad-2015.00.00.9/test_more/erf.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/erf.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: erf.cpp 3647 2015-02-15 01:06:13Z bradbell $ */ +/* $Id: erf.cpp 3685 2015-05-10 23:17:11Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell @@ -19,7 +19,7 @@ using CppAD::atan; using CppAD::exp; using CppAD::sqrt; - # if CPPAD_COMPILER_HAS_ERF + # if CPPAD_USE_CPLUSPLUS_2011 double eps = 100.0 * std::numeric_limits::epsilon(); # endif // Construct function object corresponding to erf @@ -50,7 +50,7 @@ y1 = f.Forward(1, x1); check = df.Forward(0, x0); ok &= NearEqual(check[0], y1[0], 0., 2e-3); - # if CPPAD_COMPILER_HAS_ERF + # if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(check[0], y1[0], eps, eps); # endif @@ -60,7 +60,7 @@ y2 = f.Forward(2, x2); check = df.Forward(1, x1); ok &= NearEqual(check[0] / 2.0, y2[0], 0., 2e-3); - # if CPPAD_COMPILER_HAS_ERF + # if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(check[0] / 2.0, y2[0], eps, eps); # endif @@ -70,7 +70,7 @@ y3 = f.Forward(3, x3); check = df.Forward(2, x2); ok &= NearEqual(check[0] / 3.0, y3[0], 0., 2e-3); - # if CPPAD_COMPILER_HAS_ERF + # if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(check[0] / 3.0, y3[0], eps, eps); # endif @@ -82,27 +82,28 @@ y4 = f.Forward(4, x4); // ok &= NearEqual(dy[0], y1[0], 0., 2e-3); - # if CPPAD_COMPILER_HAS_ERF + # if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(dy[0], y1[0], eps, eps); # endif // ok &= NearEqual(dy[1], 2.0 * y2[0], 0., 2e-3); - # if CPPAD_COMPILER_HAS_ERF + # if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(dy[1], 2.0 * y2[0], eps, eps); # endif // ok &= NearEqual(dy[2], 3.0 * y3[0], 0., 2e-3); - # if CPPAD_COMPILER_HAS_ERF + # if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(dy[2], 3.0 * y3[0], eps, eps); # endif // ok &= NearEqual(dy[3], 4.0 * y4[0], 0., 2e-3); - # if CPPAD_COMPILER_HAS_ERF + # if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(dy[3], 4.0 * y4[0], eps, eps); # endif return ok; } +# if CPPAD_USE_CPLUSPLUS_2011 bool hessian(void) { bool ok = true; double eps = 1.0 * std::numeric_limits::epsilon(); @@ -145,11 +146,12 @@ } return ok; } +# endif } -bool Erf(void) +bool erf(void) { bool ok = true; ok &= old_example(); -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 ok &= hessian(); # endif return ok; diff -Nru cppad-2015.00.00.9/test_more/exp.cpp cppad-2016.00.00.1/test_more/exp.cpp --- cppad-2015.00.00.9/test_more/exp.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/exp.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: exp.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: exp.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -59,17 +59,17 @@ v = f.Reverse(1,w); ok &= NearEqual(v[s], Z[y] * Z[x], 1e-10 , 1e-10); // dy/ds - // forward computation of second partials w.r.t s + // forward computation of second partials w.r.t s v[s] = 1.; w = f.Forward(1, v); v[s] = 0.; w = f.Forward(2, v); ok &= NearEqual( // d^2 y / (ds ds) - 2. * w[y] , + 2. * w[y] , Z[y] * Z[x] * Z[x] + Z[y] * Z[x], 1e-10 , - 1e-10 - ); + 1e-10 + ); // reverse computation of second partials of y CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); @@ -77,11 +77,11 @@ w[y] = 1.; r = f.Reverse(2, w); ok &= NearEqual( // d^2 y / (ds ds) - r[2 * s + 1] , + r[2 * s + 1] , Z[y] * Z[x] * Z[x] + Z[y] * Z[x], 1e-10 , - 1e-10 - ); + 1e-10 + ); return ok; } @@ -96,16 +96,16 @@ U[0] = 1.; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = exp(U[0]); + Z[0] = exp(U[0]); // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value double exp_u = exp( Value(U[0]) ); ok &= NearEqual(exp_u, Value(Z[0]), 1e-10 , 1e-10); @@ -115,14 +115,14 @@ double jfac = 1.; v[0] = 1.; for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); jfac *= j; ok &= NearEqual(jfac*w[0], exp_u, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -139,6 +139,6 @@ bool Exp(void) { bool ok = true; ok &= ExpTestOne(); - ok &= ExpTestTwo(); + ok &= ExpTestTwo(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/expm1.cpp cppad-2016.00.00.1/test_more/expm1.cpp --- cppad-2015.00.00.9/test_more/expm1.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/expm1.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,73 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include + +bool expm1(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // a temporary value + AD log_p1 = CppAD::log(ax[0] + 1.0); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = CppAD::expm1(log_p1); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // check value + ok &= NearEqual(ay[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // forward computation of higher order partials w.r.t. x[0] + size_t n_order = 5; + for(size_t order = 2; order < n_order; order++) + { dx[0] = 0.; + dy = f.Forward(order, dx); + ok &= NearEqual(dy[0], 0., eps, eps); + } + // reverse computation of derivatives + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n_order * n); + w[0] = 1.; + dw = f.Reverse(n_order, w); + ok &= NearEqual(dw[0], 1., eps, eps); + for(size_t order = 1; order < n_order; order++) + ok &= NearEqual(dw[order * n + 0], 0., eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/test_more/extern_value.cpp cppad-2016.00.00.1/test_more/extern_value.cpp --- cppad-2015.00.00.9/test_more/extern_value.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/extern_value.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: extern_value.cpp 2756 2013-02-27 18:49:28Z bradbell $ */ +// $Id: extern_value.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,15 +15,15 @@ # define INSTANTIATE(Type) template class extern_value< Type > -template +template extern_value::extern_value(Type value) { value_ = value; } -template +template void extern_value::set(Type value) { value_ = value; } -template +template Type extern_value::get(void) { return value_; } diff -Nru cppad-2015.00.00.9/test_more/extern_value.hpp cppad-2016.00.00.1/test_more/extern_value.hpp --- cppad-2015.00.00.9/test_more/extern_value.hpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/extern_value.hpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,19 +1,19 @@ -/* $Id: extern_value.hpp 3275 2014-05-20 17:35:11Z bradbell $ */ +// $Id: extern_value.hpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ -# ifndef CPPAD_EXTERN_VALUE_INCLUDED -# define CPPAD_EXTERN_VALUE_INCLUDED +# ifndef CPPAD_EXTERN_VALUE_HPP +# define CPPAD_EXTERN_VALUE_HPP -template +template class extern_value { private: Type value_; diff -Nru cppad-2015.00.00.9/test_more/for_hess.cpp cppad-2016.00.00.1/test_more/for_hess.cpp --- cppad-2015.00.00.9/test_more/for_hess.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/for_hess.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: for_hess.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: for_hess.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -38,12 +38,12 @@ // define the function CPPAD_TESTVECTOR(AD) Y(2); Y[0] = U[0] * exp( U[1] ); - Y[1] = U[1] * sin( U[2] ); + Y[1] = U[1] * sin( U[2] ); // create the function y = F(u) ADFun F(U, Y); - // formulas for the upper triangle of Hessian of F_0 + // formulas for the upper triangle of Hessian of F_0 CPPAD_TESTVECTOR(double) H0(9); H0[0] = 0.; // d^2 y[0] / d_u[0] d_u[0] H0[1] = exp( u0[1] ); // d^2 y[0] / d_u[0] d_u[1] @@ -87,7 +87,7 @@ F.Forward(1, u1); CPPAD_TESTVECTOR(double) Cij = F.Forward(2, u2); - // diagonal of Hessian in j-th coordinate direction + // diagonal of Hessian in j-th coordinate direction u1[i] = 0.; F.Forward(1, u1); CPPAD_TESTVECTOR(double) Dj = F.Forward(2, u2); diff -Nru cppad-2015.00.00.9/test_more/for_sparse_jac.cpp cppad-2016.00.00.1/test_more/for_sparse_jac.cpp --- cppad-2015.00.00.9/test_more/for_sparse_jac.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/for_sparse_jac.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: for_sparse_jac.cpp 2859 2013-05-28 06:03:21Z bradbell $ */ +// $Id: for_sparse_jac.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -75,14 +75,14 @@ using namespace CppAD; // dimension of the domain space - size_t n = 3; + size_t n = 3; // dimension of the range space size_t m = (4 + 11 + 1) * 3 + 4; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = .1; + X[0] = .1; X[1] = .2; X[2] = .3; Independent(X); @@ -166,7 +166,7 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Py[i * n + j] == Check[i * n + j]); - } + } // --------------------------------------------------------- // dependency matrix for the identity function W(x) = x @@ -187,7 +187,7 @@ { found = Sy[i].find(j) != Sy[i].end(); ok &= (found == Check[i * n + j]); } - } + } return ok; } @@ -197,7 +197,7 @@ using namespace CppAD; // dimension of the domain space - size_t n = 3; + size_t n = 3; // dimension of the range space size_t m = 3; @@ -208,16 +208,16 @@ for(k = 0; k < n-1; k++) Z[k] = 0.; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; X[2] = 2.; Independent(X); // VecAD vector is going to depend on X[1] and X[2] Z[ X[0] ] = X[1]; - Z[ X[1] ] = X[2]; + Z[ X[1] ] = X[2]; // dependent variable vector CPPAD_TESTVECTOR(AD) Y(m); @@ -274,7 +274,7 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Py[i * n + j] == Check[i * n + j]); - } + } // --------------------------------------------------------- // dependency matrix for the identity function W(x) = x @@ -295,7 +295,7 @@ { found = Sy[i].find(j) != Sy[i].end(); ok &= (found == Check[i * n + j]); } - } + } return ok; } @@ -305,14 +305,14 @@ using namespace CppAD; // dimension of the domain space - size_t n = 2; + size_t n = 2; // dimension of the range space size_t m = 3; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; + X[0] = 2.; X[1] = 3.; Independent(X); @@ -367,10 +367,10 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Py[i * n + j] == Check[i * n + j]); - } + } // --------------------------------------------------------- - // dependency matrix for the identity function + // dependency matrix for the identity function CPPAD_TESTVECTOR(std::set) Sx(n); for(i = 0; i < n; i++) { assert( Sx[i].empty() ); @@ -388,7 +388,7 @@ { found = Sy[i].find(j) != Sy[i].end(); ok &= (found == Check[i * n + j]); } - } + } return ok; } @@ -398,14 +398,14 @@ using namespace CppAD; // dimension of the domain space - size_t n = 2; + size_t n = 2; // dimension of the range space size_t m = 3; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; + X[0] = 2.; X[1] = 3.; Independent(X); @@ -461,10 +461,10 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Py[j * m + i] == Check[i * n + j]); - } + } // --------------------------------------------------------- - // dependency matrix for the identity function + // dependency matrix for the identity function CPPAD_TESTVECTOR(std::set) Sx(n); for(i = 0; i < n; i++) { assert( Sx[i].empty() ); @@ -482,7 +482,7 @@ { found = Sy[j].find(i) != Sy[j].end(); ok &= (found == Check[i * n + j]); } - } + } return ok; } diff -Nru cppad-2015.00.00.9/test_more/forward.cpp cppad-2016.00.00.1/test_more/forward.cpp --- cppad-2015.00.00.9/test_more/forward.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/forward.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward.cpp 2570 2012-11-14 18:25:24Z bradbell $ */ +/* $Id: forward.cpp 3744 2015-11-06 15:33:15Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -24,9 +24,9 @@ using namespace CppAD; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(2); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; Independent(X); @@ -37,7 +37,7 @@ // create function object F : X -> Y ADFun F(X, Y); - // use zero order to evaluate F[ (3, 4) ] + // use zero order to evaluate F[ (3, 4) ] VectorDouble x0( F.Domain() ); VectorDouble y0( F.Range() ); x0[0] = 3.; @@ -93,7 +93,7 @@ using namespace CppAD; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) U(3); U[0] = 0.; U[1] = 1.; U[2] = 2.; Independent(U); @@ -107,7 +107,7 @@ prod *= U[i]; } - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) V(2); V[0] = sum; V[1] = prod; @@ -145,9 +145,9 @@ g1[0] = u0[1]*u0[2]; g1[1] = u0[0]*u0[2]; g1[2] = u0[0]*u0[1]; // compare values - ok &= NearEqual(v1[0] , + ok &= NearEqual(v1[0] , g0[0]*u1[0] + g0[1]*u1[1] + g0[2]*u1[2] , 1e-10, 1e-10); - ok &= NearEqual(v1[1] , + ok &= NearEqual(v1[1] , g1[0]*u1[0] + g1[1]*u1[1] + g1[2]*u1[2] , 1e-10, 1e-10); // use ADFun object to evaluate ------------------------------------ @@ -155,7 +155,7 @@ CPPAD_TESTVECTOR(double) u2( f.Domain() ); CPPAD_TESTVECTOR(double) v2( f.Range() ); p = 2; - u2[0] = .5; u2[1] = .4; u2[2] = .3; + u2[0] = .5; u2[1] = .4; u2[2] = .3; v2 = f.Forward(p, u2); // direct evaluation of Hessian of second components of f @@ -166,13 +166,13 @@ H1[6] = u0[1]; H1[7] = u0[0]; H1[8] = 0.; // compare values - ok &= NearEqual(v2[0] , + ok &= NearEqual(v2[0] , g0[0]*u2[0] + g0[1]*u2[1] + g0[2]*u2[2] , 1e-10, 1e-10); size_t j; double v2_1 = 0.; for(i = 0; i < 3; i++) - { v2_1 += g1[i] * u2[i]; + { v2_1 += g1[i] * u2[i]; for(j = 0; j < 3; j++) v2_1 += .5 * u1[i] * H1[i * 3 + j] * u1[j]; } @@ -189,11 +189,12 @@ const char *exp , const char *msg ) { // error hander must not return, so throw an exception - throw std::string(msg); + std::string message = msg; + throw message; } bool forward_nan(void) -{ +{ using CppAD::vector; using CppAD::AD; @@ -218,13 +219,15 @@ y = f.Forward(0, x); } catch( std::string msg ) - { // check that the message contains "nan" - ok = msg.find("nan") != std::string::npos; + { // check that the message contains + // "vector_size = " and "file_name = " + ok = msg.find("vector_size = ") != std::string::npos; + ok = msg.find("file_name = ") != std::string::npos; } return ok; } -} // END empty namespace +} // END empty namespace # include # include diff -Nru cppad-2015.00.00.9/test_more/forward_dir.cpp cppad-2016.00.00.1/test_more/forward_dir.cpp --- cppad-2015.00.00.9/test_more/forward_dir.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/forward_dir.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_dir.cpp 3305 2014-05-24 16:37:42Z bradbell $ */ +/* $Id: forward_dir.cpp 3683 2015-05-10 02:24:16Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,31 +20,31 @@ using CppAD::AD; using CppAD::NearEqual; // --------------------------------------------------------------------- - // Used the check that fun is an idenity funciton - typedef AD (*adfun)(const AD&); + // Used the check that fun is an idenity funciton + typedef AD (*adfun)(const AD&); bool check_identity(adfun identity, double argument) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = argument; - + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = identity(ax[0]); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -53,8 +53,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -62,14 +62,14 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // + ok &= size_t( y2.size() ) == r*m; + // // Y_0 (t) = F[X_0(t)] = X_0(t) // = 0.5 + 1t + 2t^2 double y_1_0 = 1.0; double y_2_0 = 2.0; - // - // Y_1 (t) = F[X_1(t)] = X_1(t) + // + // Y_1 (t) = F[X_1(t)] = X_1(t) // = 0.5 + 2t + 3t^2 double y_1_1 = 2.0; double y_2_1 = 3.0; @@ -82,29 +82,29 @@ return ok; } // --------------------------------------------------------------------- - // AbsOp + // AbsOp bool abs_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; + ax[0] = 0.5; ax[1] = -1.0; - + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = abs( ax[0] ) + abs( 2.0 * ax[1] ); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -113,8 +113,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -122,14 +122,14 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = abs(0.5 + 1t + 2t^2) + abs( 2*(-1.0 + 2t + 3t^2 ) ) double y_1_0 = -3.0; double y_2_0 = -4.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = abs(0.5 + 2t + 3t^2) + abs( 2*(-1.0 + 3t + 4t^2 ) ) double y_1_1 = -4.0; double y_2_1 = -5.0; @@ -142,28 +142,28 @@ return ok; } // --------------------------------------------------------------------- - // AddpvOp + // AddpvOp bool addpv_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = 2.0 + ax[0]; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -172,8 +172,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -181,14 +181,14 @@ x2[ r * j + ell ] = double(j + ell + 3); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = 2.0 + (0.5 + 1t + 3t^2) double y_1_0 = 1.0; double y_2_0 = 3.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = 2.0 + (0.5 + 2t + 4t^2) double y_1_1 = 2.0; double y_2_1 = 4.0; @@ -201,29 +201,29 @@ return ok; } // --------------------------------------------------------------------- - // AddvvOp + // AddvvOp bool addvv_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; + ax[0] = 0.5; ax[1] = 2.0; - + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = ax[0] + ax[1]; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -232,8 +232,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -241,14 +241,14 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = (0.5 + 1t + 2t^2) + (2.0 + 2t + 3t^2) double y_1_0 = 1.0 + 2.0; double y_2_0 = 2.0 + 3.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = (2.0 + 2t + 3t^2) + (2.0 + 3t + 4t^2) double y_1_1 = 2.0 + 3.0; double y_2_1 = 3.0 + 4.0; @@ -261,29 +261,29 @@ return ok; } // --------------------------------------------------------------------- - // CosOp + // CosOp bool cos_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = cos( ax[0] ); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -292,8 +292,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -301,15 +301,15 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = cos( 0.5 + 1t + 2t^2 ) // Y_0' (t) = -sin( 0.5 + 1t + 2t^2) * (1 + 4t) double y_1_0 = - sin(0.5); double y_2_0 = - ( cos(0.5) + 4.0 * sin(0.5) ) / 2.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = cos( 0.5 + 2t + 3t^2 ) // Y_1' (t) = -sin( 0.5 + 2t + 3t^2) * (2 + 6t) double y_1_1 = - sin(0.5) * 2.0; @@ -323,29 +323,29 @@ return ok; } // --------------------------------------------------------------------- - // CoshOp + // CoshOp bool cosh_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = cosh( ax[0] ); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -354,8 +354,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -363,15 +363,15 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = cosh( 0.5 + 1t + 2t^2 ) // Y_0' (t) = sinh( 0.5 + 1t + 2t^2) * (1 + 4t) double y_1_0 = sinh(0.5); double y_2_0 = ( sinh(0.5) * 4.0 + cosh(0.5) ) / 2.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = cosh( 0.5 + 2t + 3t^2 ) // Y_1' (t) = sinh( 0.5 + 2t + 3t^2) * (2 + 6t) double y_1_1 = sinh(0.5) * 2.0; @@ -390,16 +390,16 @@ { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 4; CPPAD_TESTVECTOR(AD) ax(n); for(j = 0; j < n; j++) ax[j] = double(j); - + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 2; CPPAD_TESTVECTOR(AD) ay(m); @@ -408,7 +408,7 @@ // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -417,8 +417,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -426,23 +426,23 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // + ok &= size_t( y2.size() ) == r*m; + // // Y0_0 (t) = X2_0(t) // = 2.0 + 3t + 4t^2 double y0_1_0 = 3.0; double y0_2_0 = 4.0; - // + // // Y1_0 (t) = X3_0(t) // = 3.0 + 4t + 5t^2 double y1_1_0 = 4.0; double y1_2_0 = 5.0; - // + // // Y0_1 (t) = X2_1(t) // = 2.0 + 4t + 5t^2 double y0_1_1 = 4.0; double y0_2_1 = 5.0; - // + // // Y1_1 (t) = X3_0(t) // = 3.0 + 5t + 6t^2 double y1_1_1 = 5.0; @@ -462,40 +462,40 @@ } // --------------------------------------------------------------------- - // CSumOp + // CSumOp bool csum_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 3; CPPAD_TESTVECTOR(AD) ax(n); for(j = 0; j < n; j++) ax[j] = double(j); - + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = 0.0; for(j = 0; j < n; j++) ay[0] += ax[j]; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // optmize the tape so converts summation to on CSumOp operator f.optimize(); - // zero order + // zero order CPPAD_TESTVECTOR(double) x0(n); for(j = 0; j < n; j++) x0[j] = double(j); f.Forward(0, x0); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -504,8 +504,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -513,8 +513,8 @@ x2[ r * j + ell ] = double(j + ell + 3); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // + ok &= size_t( y2.size() ) == r*m; + // double check = 0.0; for(j = 0; j < n; j++) check += x1[ r * j + 0]; @@ -548,20 +548,20 @@ { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = round_off( ax[0] ) + ax[0]; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); @@ -569,9 +569,9 @@ CPPAD_TESTVECTOR(double) x0(n), y0; x0[0] = 2.2; y0 = f.Forward(0, x0); - ok &= y0.size() == m; - ok &= NearEqual(y0[0], round_off(x0[0]) + x0[0], eps, eps); - + ok &= size_t( y0.size() ) == m; + ok &= NearEqual(y0[0], round_off(x0[0]) + x0[0], eps, eps); + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -580,8 +580,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -589,16 +589,16 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // - // Y_0 (t) = F[X_0(t)] - // = 2.0 + (2.2 + 1t + 2t^2) + ok &= size_t( y2.size() ) == r*m; + // + // + // Y_0 (t) = F[X_0(t)] + // = 2.0 + (2.2 + 1t + 2t^2) double y_1_0 = 1.0; double y_2_0 = 2.0; - // - // Y_1 (t) = F[X_1(t)] - // = 2.0 + (2.2 + 2t + 3t^2) + // + // Y_1 (t) = F[X_1(t)] + // = 2.0 + (2.2 + 2t + 3t^2) double y_1_1 = 2.0; double y_2_1 = 3.0; // @@ -615,15 +615,15 @@ { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); @@ -631,7 +631,7 @@ // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -640,8 +640,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -649,14 +649,14 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = 2.0 * (0.5 + 1t + 2t^2) double y_1_0 = 2.0; double y_2_0 = 4.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = 2.0 * (0.5 + 2t + 3t^2)/2.0 double y_1_1 = 4.0; double y_2_1 = 6.0; @@ -669,20 +669,20 @@ return ok; } // --------------------------------------------------------------------- - // DivvpOp + // DivvpOp bool divvp_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); @@ -690,7 +690,7 @@ // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -699,8 +699,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -708,14 +708,14 @@ x2[ r * j + ell ] = double(j + ell + 3); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = (0.5 + 1t + 3t^2)/2.0 double y_1_0 = 1.0 / 2.0; double y_2_0 = 3.0 / 2.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = (0.5 + 2t + 4t^2)/2.0 double y_1_1 = 2.0 / 2.0; double y_2_1 = 4.0 / 2.0; @@ -728,28 +728,28 @@ return ok; } // --------------------------------------------------------------------- - // ExpOp + // ExpOp bool exp_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = exp( ax[0] ); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -758,8 +758,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -767,15 +767,15 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = exp(0.5 + 1t + 2t^2) // Y_0' (t) = exp(0.5 + 1t + 2t^2)*(1 + 4t) double y_1_0 = exp(0.5); double y_2_0 = ( exp(0.5)*4.0 + exp(0.5) ) / 2.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = exp(0.5 + 2t + 3t^2) // Y_1' (t) = exp(0.5 + 2t + 3t^2)*(2 + 6t) double y_1_1 = exp(0.5)*2.0; @@ -794,13 +794,13 @@ { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.0; + ax[0] = 0.0; ax[1] = 1.0; - + // declare independent variables and starting recording CppAD::Independent(ax); @@ -809,13 +809,13 @@ avec[ AD(0) ] = ax[0]; // store a variable avec[ AD(1) ] = ax[1]; // store a variable avec[ AD(2) ] = 5.0; // store a parameter - - // range space vector + + // range space vector size_t m = 2; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = avec[ AD(0) ]; // load using parameter index ay[1] = avec[ ax[0] ]; // load using variable index - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); @@ -824,11 +824,11 @@ x0[0] = 2; x0[1] = 3; y0 = f.Forward(0, x0); - ok &= y0.size() == m; + ok &= size_t( y0.size() ) == m; // y[0] = avec[0] = x[0] ok &= y0[0] == x0[0]; // y[1] = avec[ x[0] ] = avec[2] = 5.0 - ok &= y0[1] == 5.0; + ok &= y0[1] == 5.0; // first order Taylor coefficients size_t r = 2, ell; @@ -838,8 +838,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -847,20 +847,20 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // + ok &= size_t( y2.size() ) == r*m; + // // Y0_0 (t) = 2.0 + 1t + 2t^2 double y0_1_0 = 1.0; double y0_2_0 = 2.0; - // + // // Y1_0 (t) = 5.0 double y1_1_0 = 0.0; double y1_2_0 = 0.0; - // + // // Y0_1 (t) = 2.0 + 2t + 3t^2 double y0_1_1 = 2.0; double y0_2_1 = 3.0; - // + // // Y1_1 (t) = 5.0 double y1_1_1 = 0.0; double y1_2_1 = 0.0; @@ -877,30 +877,30 @@ // return ok; } - + // --------------------------------------------------------------------- - // MulpvOp + // MulpvOp bool mulpv_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = 2.0 * ax[0]; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -909,8 +909,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -918,14 +918,14 @@ x2[ r * j + ell ] = double(j + ell + 3); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = 2.0 * (0.5 + 1t + 3t^2) double y_1_0 = 2.0 * 1.0; double y_2_0 = 2.0 * 3.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = 2.0 * (0.5 + 2t + 4t^2) double y_1_1 = 2.0 * 2.0; double y_2_1 = 2.0 * 4.0; @@ -938,30 +938,78 @@ return ok; } // --------------------------------------------------------------------- + // ParOp + bool par_op(void) + { bool ok = true; + size_t j; + + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.5; + + // declare independent variables and starting recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = 0.0 * ax[0]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // first order Taylor coefficients + size_t r = 2, ell; + CPPAD_TESTVECTOR(double) x1(r*n), y1; + for(ell = 0; ell < r; ell++) + { for(j = 0; j < n; j++) + x1[ r * j + ell ] = double(j + ell + 1); + } + y1 = f.Forward(1, r, x1); + ok &= size_t( y1.size() ) == r*m; + + // secondorder Taylor coefficients + CPPAD_TESTVECTOR(double) x2(r*n), y2; + for(ell = 0; ell < r; ell++) + { for(j = 0; j < n; j++) + x2[ r * j + ell ] = double(j + ell + 2); + } + y2 = f.Forward(2, r, x2); + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = 0.0 + for(ell = 0; ell < r; ell++) + { ok &= y1[ell] == 0.0; + ok &= y2[ell] == 0.0; + } + return ok; + } + // --------------------------------------------------------------------- // PowvvOp (test assuming LogOp, ExpOp and DivvvOp are correct) bool powvv_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; + ax[0] = 0.5; ax[1] = 2.0; - + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 2; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = log( pow( exp(ax[0]) , ax[1] ) ) / ax[1] ; ay[1] = log( pow( exp(ax[0]) , ax[1] ) ) / ax[0] ; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -970,8 +1018,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -979,20 +1027,20 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // + ok &= size_t( y2.size() ) == r*m; + // // Y0_0 (t) = 0.5 + 1t + 2t^2 double y0_1_0 = 1.0; double y0_2_0 = 2.0; - // + // // Y0_1 (t) = 0.5 + 2t + 3t^2 double y0_1_1 = 2.0; double y0_2_1 = 3.0; - // + // // Y1_0 (t) = 2.0 + 2t + 3t^2 double y1_1_0 = 2.0; double y1_2_0 = 3.0; - // + // // Y1_1 (t) = 2.0 + 3t + 4t^2 double y1_1_1 = 3.0; double y1_2_1 = 4.0; @@ -1015,20 +1063,20 @@ { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = sign( ax[0] ) * ax[0]; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); @@ -1036,9 +1084,9 @@ CPPAD_TESTVECTOR(double) x0(n), y0; x0[0] = -3.0; y0 = f.Forward(0, x0); - ok &= y0.size() == m; - ok &= NearEqual(y0[0], CppAD::abs(x0[0]), eps, eps); - + ok &= size_t( y0.size() ) == m; + ok &= NearEqual(y0[0], CppAD::abs(x0[0]), eps, eps); + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -1047,8 +1095,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -1056,16 +1104,16 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // - // Y_0 (t) = F[X_0(t)] - // = -(-3.0 + 1t + 2t^2) + ok &= size_t( y2.size() ) == r*m; + // + // + // Y_0 (t) = F[X_0(t)] + // = -(-3.0 + 1t + 2t^2) double y_1_0 = -1.0; double y_2_0 = -2.0; - // - // Y_1 (t) = F[X_1(t)] - // = -(-3.0 + 2t + 3t^2) + // + // Y_1 (t) = F[X_1(t)] + // = -(-3.0 + 2t + 3t^2) double y_1_1 = -2.0; double y_2_1 = -3.0; // @@ -1078,29 +1126,29 @@ } // --------------------------------------------------------------------- - // SinOp + // SinOp bool sin_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = sin( ax[0] ); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -1109,8 +1157,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -1118,15 +1166,15 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = sin( 0.5 + 1t + 2t^2 ) // Y_0' (t) = cos( 0.5 + 1t + 2t^2) * (1 + 4t) double y_1_0 = cos(0.5); double y_2_0 = ( cos(0.5) * 4.0 - sin(0.5) ) / 2.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = sin( 0.5 + 2t + 3t^2 ) // Y_1' (t) = cos( 0.5 + 2t + 3t^2) * (2 + 6t) double y_1_1 = cos(0.5) * 2.0; @@ -1140,29 +1188,29 @@ return ok; } // --------------------------------------------------------------------- - // SinhOp + // SinhOp bool sinh_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = sinh( ax[0] ); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -1171,8 +1219,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -1180,15 +1228,15 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = sinh( 0.5 + 1t + 2t^2 ) // Y_0' (t) = cosh( 0.5 + 1t + 2t^2) * (1 + 4t) double y_1_0 = cosh(0.5); double y_2_0 = ( cosh(0.5) * 4.0 + sinh(0.5) ) / 2.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = sinh( 0.5 + 2t + 3t^2 ) // Y_1' (t) = cosh( 0.5 + 2t + 3t^2) * (2 + 6t) double y_1_1 = cosh(0.5) * 2.0; @@ -1202,28 +1250,28 @@ return ok; } // --------------------------------------------------------------------- - // SubpvOp + // SubpvOp bool subpv_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = 2.0 - ax[0]; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -1232,8 +1280,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -1241,14 +1289,14 @@ x2[ r * j + ell ] = double(j + ell + 3); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = 2.0 - (0.5 + 1t + 3t^2)/2.0 double y_1_0 = - 1.0; double y_2_0 = - 3.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = 3.0 - (0.5 + 2t + 4t^2)/2.0 double y_1_1 = - 2.0; double y_2_1 = - 4.0; @@ -1261,29 +1309,29 @@ return ok; } // --------------------------------------------------------------------- - // SubvvOp + // SubvvOp bool subvv_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 2; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; + ax[0] = 0.5; ax[1] = 2.0; - + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = ax[0] - 2.0 * ax[1]; - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -1292,8 +1340,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -1301,14 +1349,14 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = (0.5 + 1t + 2t^2) - 2.0 * (2.0 + 2t + 3t^2) double y_1_0 = 1.0 - 4.0; double y_2_0 = 2.0 - 6.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = (2.0 + 2t + 3t^2) - 2.0 * (2.0 + 3t + 4t^2) double y_1_1 = 2.0 - 6.0; double y_2_1 = 3.0 - 8.0; @@ -1321,28 +1369,28 @@ return ok; } // --------------------------------------------------------------------- - // TanOp + // TanOp bool tan_op(void) { bool ok = true; double eps = 10. * std::numeric_limits::epsilon(); size_t j; - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = tan( ax[0] ); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -1351,8 +1399,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -1360,17 +1408,17 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // - // Y_0 (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == r*m; + // + // Y_0 (t) = F[X_0(t)] // = tan(0.5 + 1t + 2t^2) // Y_0' (t) = cos(0.5 + 1t + 2t^2)^(-2)*(1 + 4t) // Y_0''(0) = 2*cos(0.5)^(-3)*sin(0.5) + 4*cos(0.5)^(-2) double sec_sq = 1.0 / ( cos(0.5) * cos(0.5) ); double y_1_0 = sec_sq; double y_2_0 = (2.0 * tan(0.5) + 4.0) * sec_sq / 2.0; - // - // Y_1 (t) = F[X_1(t)] + // + // Y_1 (t) = F[X_1(t)] // = tan(0.5 + 2t + 3t^2) // Y_1' (t) = cos(0.5 + 2t + 3t^2)^(-2)*(2 + 6t) // Y_1''(0) = 2*cos(0.5)^(-3)*sin(0.5)*2*2 + 6*cos(0.5)^(-2) @@ -1385,7 +1433,7 @@ return ok; } // --------------------------------------------------------------------- - // Usr*Op + // Usr*Op typedef CPPAD_TESTVECTOR(AD) avector; void usr_algo(const avector& x, avector& z) { z[0] = ( x[0] + x[1] ) / 2.0; @@ -1401,7 +1449,7 @@ // define checkpoint function size_t n = 2; avector ax(n), az(3); - ax[0] = 0.5; + ax[0] = 0.5; ax[1] = 2.0; CppAD::checkpoint usr_check("usr_check", usr_algo, ax, az); @@ -1410,7 +1458,7 @@ // record checkpoint function usr_check(ax, az); - + // range space vector size_t m = 2; avector ay(m); @@ -1419,7 +1467,7 @@ // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; @@ -1428,8 +1476,8 @@ x1[ r * j + ell ] = double(j + ell + 1); } y1 = f.Forward(1, r, x1); - ok &= y1.size() == r*m; - + ok &= size_t( y1.size() ) == r*m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(r*n), y2; for(ell = 0; ell < r; ell++) @@ -1437,20 +1485,20 @@ x2[ r * j + ell ] = double(j + ell + 2); } y2 = f.Forward(2, r, x2); - ok &= y2.size() == r*m; - // + ok &= size_t( y2.size() ) == r*m; + // // Y0_0 (t) = 0.5 + 1t + 2t^2 double y0_1_0 = 1.0; double y0_2_0 = 2.0; - // + // // Y0_1 (t) = 0.5 + 2t + 3t^2 double y0_1_1 = 2.0; double y0_2_1 = 3.0; - // + // // Y1_0 (t) = 2.0 + 2t + 3t^2 double y1_1_0 = 2.0; double y1_2_0 = 3.0; - // + // // Y1_1 (t) = 2.0 + 3t + 4t^2 double y1_1_1 = 3.0; double y1_2_1 = 4.0; @@ -1471,25 +1519,43 @@ // Inverse functions assume the following already tested: // CosOp, SinOp, TanOp, ExpOp, MulvvOp, DivvpOp, AddpvOp // - // AcosOp + // AcosOp AD acos_fun(const AD& x) { return acos( cos(x) ); } bool acos_op(void) { return check_identity(acos_fun, 0.5); } // - // AsinOp + // AcoshOp + AD acosh_fun(const AD& x) + { return acosh( cosh(x) ); } + bool acosh_op(void) + { return check_identity(acosh_fun, 0.5); } + // + // AsinOp AD asin_fun(const AD& x) { return asin( sin(x) ); } bool asin_op(void) { return check_identity(asin_fun, 0.5); } // - // AtanOp + // AsinhOp + AD asinh_fun(const AD& x) + { return asinh( sinh(x) ); } + bool asinh_op(void) + { return check_identity(asinh_fun, 0.5); } + // + // AtanOp AD atan_fun(const AD& x) { return atan( tan(x) ); } bool atan_op(void) { return check_identity(atan_fun, 0.5); } // - // LogOp + // AtanhOp + AD atanh_fun(const AD& x) + { return atanh( tanh(x) ); } + bool atanh_op(void) + { return check_identity(atanh_fun, 0.5); } + // + // LogOp AD log_fun(const AD& x) { return log( exp(x) ); } bool log_op(void) @@ -1539,8 +1605,11 @@ // ok &= abs_op(); ok &= acos_op(); + ok &= acosh_op(); ok &= asin_op(); + ok &= asinh_op(); ok &= atan_op(); + ok &= atanh_op(); ok &= addpv_op(); ok &= addvv_op(); ok &= cexp_op(); @@ -1555,6 +1624,7 @@ ok &= load_op(); ok &= log_op(); ok &= mulpv_op(); + ok &= par_op(); ok &= powpv_op(); ok &= powvp_op(); ok &= powvv_op(); diff -Nru cppad-2015.00.00.9/test_more/forward_order.cpp cppad-2016.00.00.1/test_more/forward_order.cpp --- cppad-2015.00.00.9/test_more/forward_order.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/forward_order.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: forward_order.cpp 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: forward_order.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -88,7 +88,7 @@ size_t p = 2, p1 = p+1; CPPAD_TESTVECTOR(double) x(n), x_p(n * p1), y_p(m * p1); for(j = 0; j < n; j++) - { x[j] = double(j) / double(n); + { x[j] = double(j) / double(n); x_p[j * p1 + 0] = x[j]; // order 0 x_p[j * p1 + 1] = 1.; // order 1 x_p[j * p1 + 2] = 0.; // order 2 diff -Nru cppad-2015.00.00.9/test_more/from_base.cpp cppad-2016.00.00.1/test_more/from_base.cpp --- cppad-2015.00.00.9/test_more/from_base.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/from_base.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: from_base.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: from_base.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -21,13 +21,13 @@ using namespace CppAD; - // construct directly form Base where Base = double - AD x(1.); + // construct directly form Base where Base = double + AD x(1.); AD y = 2.; - // construct from a type that can be converted to Base + // construct from a type that can be converted to Base // where Base = AD - AD< AD > X(1.); + AD< AD > X(1.); AD< AD > Y(2); // check that resulting objects are parameters diff -Nru cppad-2015.00.00.9/test_more/fun_check.cpp cppad-2016.00.00.1/test_more/fun_check.cpp --- cppad-2015.00.00.9/test_more/fun_check.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/fun_check.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: fun_check.cpp 3214 2014-03-18 20:50:38Z bradbell $ */ +// $Id: fun_check.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -32,12 +32,12 @@ size_t i; for(i = 0; i < n; i++) { // This operaiton sequence depends on x - if( x[i] >= 0 ) + if( x[i] >= 0 ) y[i] = exp(x[i]); else y[i] = exp(-x[i]); } return y; - } + } }; // template function FunCheckCases in empty namespace template @@ -74,13 +74,13 @@ // create function object to use with double Fun g(n); - // function values should agree when the independent variable + // function values should agree when the independent variable // values are the same as during recording Vector x(n); size_t j; for(j = 0; j < n; j++) x[j] = Value(X[j]); - double r = 1e-10; + double r = 1e-10; double a = 1e-10; ok &= FunCheck(f, g, x, a, r); @@ -105,7 +105,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool FunCheck(void) @@ -117,7 +117,7 @@ typedef std::valarray Vector3; typedef std::valarray< CppAD::AD > ADVector3; // Run with Vector and ADVector equal to three different cases - // all of which are Simple Vectors with elements of type + // all of which are Simple Vectors with elements of type // double and AD respectively. ok &= FunCheckCases< Vector1, ADVector2 >(); ok &= FunCheckCases< Vector2, ADVector3 >(); diff -Nru cppad-2015.00.00.9/test_more/ipopt_solve.cpp cppad-2016.00.00.1/test_more/ipopt_solve.cpp --- cppad-2015.00.00.9/test_more/ipopt_solve.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/ipopt_solve.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ipopt_solve.cpp 2896 2013-09-17 21:23:55Z bradbell $ */ +// $Id: ipopt_solve.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,7 +26,7 @@ { assert( fg.size() == 3 ); assert( x.size() == 4 ); - // Fortran style indexing + // Fortran style indexing AD x1 = x[0]; AD x2 = x[1]; AD x3 = x[2]; @@ -42,14 +42,14 @@ } }; } - + bool ipopt_solve(void) { bool ok = true; size_t i, j; typedef CPPAD_TESTVECTOR( double ) Dvector; // number of independent variables (domain dimension for f and g) - size_t nx = 4; + size_t nx = 4; // number of constraints (range dimension for g) size_t ng = 2; // initial value of the independent variables @@ -67,25 +67,25 @@ // lower and upper limits for g Dvector gl(ng), gu(ng); gl[0] = 25.0; gu[0] = 1.0e19; - gl[1] = 40.0; gu[1] = 40.0; + gl[1] = 40.0; gu[1] = 40.0; // object that computes objective and constraints FG_eval fg_eval; - // options + // options std::string base_options; // turn off any printing - base_options += "Integer print_level 0\n"; + base_options += "Integer print_level 0\n"; base_options += "String sb yes\n"; // maximum number of iterations base_options += "Integer max_iter 10\n"; // approximate accuracy in first order necessary conditions; - // see Mathematical Programming, Volume 106, Number 1, + // see Mathematical Programming, Volume 106, Number 1, // Pages 25-57, Equation (6) base_options += "Numeric tol 1e-6\n"; // derivative testing base_options += "String derivative_test second-order\n"; - // maximum amount of random pertubation; e.g., + // maximum amount of random pertubation; e.g., // when evaluation finite diff base_options += "Numeric point_perturbation_radius 0.\n"; @@ -112,7 +112,7 @@ ); ok &= solution.status==CppAD::ipopt::solve_result::success; // - // Check some of the solution values + // Check some of the solution values for(j = 0; j < nx; j++) { ok &= CppAD::NearEqual( check_x[j], solution.x[j], rel_tol, abs_tol diff -Nru cppad-2015.00.00.9/test_more/jacobian.cpp cppad-2016.00.00.1/test_more/jacobian.cpp --- cppad-2015.00.00.9/test_more/jacobian.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/jacobian.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: jacobian.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: jacobian.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -44,7 +44,7 @@ } -} // End empty namespace +} // End empty namespace bool jacobian(void) { bool ok = true; @@ -73,7 +73,7 @@ for(k = 0; k < m *n; k++) ok &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10); - // one argument sparse jacobian + // one argument sparse jacobian jac_g = fun_g.SparseJacobian(x); for(k = 0; k < m *n; k++) ok &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10); diff -Nru cppad-2015.00.00.9/test_more/limits.cpp cppad-2016.00.00.1/test_more/limits.cpp --- cppad-2015.00.00.9/test_more/limits.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/limits.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ -/* $Id: limits.cpp 2884 2013-08-06 14:29:20Z bradbell $ */ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell - -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. - -A copy of this license is included in the COPYING file of this distribution. -Please visit http://www.coin-or.org/CppAD/ for information on other licenses. --------------------------------------------------------------------------- */ - -/* -$begin limits.cpp$$ -$spell -$$ - -$section Numeric Limits: Example and Test$$ -$index limits$$ -$index example, limits$$ -$index test, limits$$ - -$head Assumption$$ -This code assumes that the decimal point is infront of the mantissa. -Hence dividing the minimum normalized value looses precision, -while multiplying the maximum normalized value results in infinity. - -$head Externals$$ -This example using external routines to get and set values -so that the complier does not set the correspdong code and optimize -it out. - -$code -$verbatim%example/limits.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ - -# ifdef _MSC_VER -// Supress Microsoft compiler warning about possible loss of precision, -// in the constructors (when converting to std::complex) -// Type one = 1 -// Type two = 2 -// 1 and 2 are small enough so no loss of precision when converting to float. -# pragma warning(disable:4244) -# endif - -# include -# include -# include "extern_value.hpp" - -namespace { - using CppAD::vector; - using CppAD::abs_geq; - - template - Type add_one(const Type& value) - { return( Type(1) + value ); } - // ----------------------------------------------------------------- - template - bool check_epsilon(void) - { bool ok = true; - typedef extern_value value; - value eps( CppAD::numeric_limits::epsilon() ); - value one( Type(1) ); - value two( Type(2) ); - value tmp( Type(0) ); - // - tmp.set( add_one( eps.get() / two.get() ) ); - ok &= one.get() == tmp.get(); - // - tmp.set( add_one( eps.get() ) ); - ok &= one.get() != tmp.get(); - return ok; - } - // ----------------------------------------------------------------- - template - bool check_min(void) - { bool ok = true; - typedef extern_value value; - value min( CppAD::numeric_limits::min() ); - value eps3( Type(3) * CppAD::numeric_limits::epsilon() ); - value one( Type(1) ); - value hun( Type(100) ); - value tmp( Type(0) ); - // - tmp.set( min.get() / hun.get() ); - tmp.set( tmp.get() * hun.get() ); - ok &= abs_geq(tmp.get()/min.get() - one.get(), eps3.get()); - // - tmp.set( min.get() * hun.get() ); - tmp.set( tmp.get() / hun.get() ); - ok &= ! abs_geq(tmp.get()/min.get() - one.get(), eps3.get()); - return ok; - } - - // ----------------------------------------------------------------- - template - bool check_max(void) - { bool ok = true; - typedef extern_value value; - value max2( CppAD::numeric_limits::max() / Type(2) ); - value eps3( Type(3) * CppAD::numeric_limits::epsilon() ); - value one( Type(1) ); - value hun( Type(100) ); - value tmp( Type(0) ); - - // In complex case, this operaiton can result in (inf, 0) - tmp.set( max2.get() * hun.get() ); - - // In complex case, this operaiotn can result in (inf,-nan) - // (where nan corresponds to inf * 0) - tmp.set( tmp.get() / hun.get() ); - - if( ! CppAD::isnan( tmp.get() ) ) ok &= abs_geq( - tmp.get() / max2.get() - one.get(), eps3.get() - ); - // - tmp.set( max2.get() / hun.get() ); - tmp.set( tmp.get() * hun.get() ); - ok &= ! abs_geq(tmp.get() / max2.get() - one.get(), eps3.get() ); - return ok; - } -} - -bool limits(void) -{ bool ok = true; - using CppAD::AD; - - // ------------------------------------------------------------------- - // epsilon for Base types defined by CppAD - ok &= check_epsilon(); - ok &= check_epsilon(); - ok &= check_epsilon< std::complex >(); - ok &= check_epsilon< std::complex >(); - - // epsilon for some AD types. - ok &= check_epsilon< AD >(); - ok &= check_epsilon< AD >(); - ok &= check_epsilon< AD > >(); - ok &= check_epsilon< AD > >(); - - // ------------------------------------------------------------------- - // min for Base types defined by CppAD - ok &= check_min(); - ok &= check_min(); - ok &= check_min< std::complex >(); - ok &= check_min< std::complex >(); - - // min for some AD types. - ok &= check_min< AD >(); - ok &= check_min< AD >(); - ok &= check_min< AD > >(); - ok &= check_min< AD > >(); - - // ------------------------------------------------------------------- - // max for Base types defined by CppAD - ok &= check_max(); - ok &= check_max(); - ok &= check_max< std::complex >(); - ok &= check_max< std::complex >(); - - // max for some AD types. - ok &= check_max< AD >(); - ok &= check_max< AD >(); - ok &= check_max< AD< std::complex > >(); - ok &= check_max< AD< std::complex > >(); - - return ok; -} -// END C++ diff -Nru cppad-2015.00.00.9/test_more/log10.cpp cppad-2016.00.00.1/test_more/log10.cpp --- cppad-2015.00.00.9/test_more/log10.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/log10.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: log10.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: log10.cpp 3684 2015-05-10 14:01:21Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,7 +15,7 @@ */ # include -bool Log10(void) +bool log10(void) { bool ok = true; using CppAD::log10; diff -Nru cppad-2015.00.00.9/test_more/log1p.cpp cppad-2016.00.00.1/test_more/log1p.cpp --- cppad-2015.00.00.9/test_more/log1p.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/log1p.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -0,0 +1,73 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +# include + +bool log1p(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + + // 10 times machine epsilon + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // a temporary value + AD expm1_of_x0 = CppAD::expm1(ax[0]); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = CppAD::log1p(expm1_of_x0); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // check value + ok &= NearEqual(ay[0] , x0, eps, eps); + + // forward computation of first partial w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1., eps, eps); + + // forward computation of higher order partials w.r.t. x[0] + size_t n_order = 5; + for(size_t order = 2; order < n_order; order++) + { dx[0] = 0.; + dy = f.Forward(order, dx); + ok &= NearEqual(dy[0], 0., eps, eps); + } + // reverse computation of derivatives + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n_order * n); + w[0] = 1.; + dw = f.Reverse(n_order, w); + ok &= NearEqual(dw[0], 1., eps, eps); + for(size_t order = 1; order < n_order; order++) + ok &= NearEqual(dw[order * n + 0], 0., eps, eps); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/test_more/log.cpp cppad-2016.00.00.1/test_more/log.cpp --- cppad-2015.00.00.9/test_more/log.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/log.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: log.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +/* $Id: log.cpp 3684 2015-05-10 14:01:21Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -65,11 +65,11 @@ v[s] = 0.; w = f.Forward(2, v); ok &= NearEqual( - 2. * w[y] , + 2. * w[y] , - 1. / (Z[x]*Z[x]*U[s]*U[s]) - 1. / (Z[x]*U[s]*U[s]), 1e-10 , - 1e-10 - ); + 1e-10 + ); // reverse computation of second partials of y CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); @@ -77,11 +77,11 @@ w[y] = 1.; r = f.Reverse(2, w); ok &= NearEqual( - r[2 * s + 1] , + r[2 * s + 1] , - 1. / (Z[x]*Z[x]*U[s]*U[s]) - 1. / (Z[x]*U[s]*U[s]), 1e-10 , - 1e-10 - ); + 1e-10 + ); return ok; } @@ -99,16 +99,16 @@ // a temporary values AD x = exp(U[0]); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = log(x); // log( exp(u) ) // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(U[0] , Z[0], 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -119,14 +119,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -142,9 +142,9 @@ } // END empty namespace -bool Log(void) +bool log(void) { bool ok = true; ok &= LogTestOne(); - ok &= LogTestTwo(); + ok &= LogTestTwo(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/makefile.am cppad-2016.00.00.1/test_more/makefile.am --- cppad-2015.00.00.9/test_more/makefile.am 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/makefile.am 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -# $Id: makefile.am 3526 2014-12-29 21:56:45Z bradbell $ +# $Id: makefile.am 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -16,16 +16,16 @@ # # ------------------------------------------------------------------------- if CppAD_OPENMP -OPENMP_SRC_FILES = alloc_openmp.cpp +OPENMP_SRC_FILES = alloc_openmp.cpp else OPENMP_SRC_FILES = endif # ------------------------------------------------------------------------- if CppAD_ADOLC -ADOLC_SRC_FILES = base_adolc.cpp +ADOLC_SRC_FILES = base_adolc.cpp ADOLC_EXTRA_FILES = ADOLC_LIB = -ladolc -lColPack -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64 -ADOLC_FLAGS = -DCPPAD_ADOLC_TEST -I$(ADOLC_DIR)/include +ADOLC_FLAGS = -DCPPAD_ADOLC_TEST -I$(ADOLC_DIR)/include else ADOLC_EXTRA_FILES = base_adolc.cpp ADOLC_SRC_FILES = @@ -34,11 +34,11 @@ endif # ------------------------------------------------------------------------- if CppAD_IPOPT -IPOPT_SRC_FILES = ipopt_solve.cpp +IPOPT_SRC_FILES = ipopt_solve.cpp IPOPT_EXTRA_FILES = IPOPT_LIB = -lipopt \ $(CPPAD_IPOPT_LIBS) $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB) -IPOPT_FLAGS = -DCPPAD_IPOPT_TEST -I$(IPOPT_DIR)/include +IPOPT_FLAGS = -DCPPAD_IPOPT_TEST -I$(IPOPT_DIR)/include else IPOPT_EXTRA_FILES = ipopt_solve.cpp IPOPT_SRC_FILES = @@ -56,7 +56,7 @@ -g \ $(CXX_FLAGS_EIGEN) \ -DCPPAD_EIGEN_TEST \ - -I$(EIGEN_DIR)/include + -I$(EIGEN_DIR)/include else EIGEN_EXTRA_FILES = cppad_eigen.cpp EIGEN_LIB = @@ -77,12 +77,12 @@ $(EIGEN_INCLUDE) \ $(ADOLC_FLAGS) \ $(IPOPT_FLAGS) \ - $(OPENMP_FLAGS) + $(OPENMP_FLAGS) # AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(IPOPT_FLAGS) $(CXX_FLAGS) # -AM_LDFLAGS = $(OPENMP_FLAGS) -LDADD = $(ADOLC_LIB) $(IPOPT_LIB) $(EIGEN_LIB) $(OPENMP_FLAGS) +AM_LDFLAGS = $(OPENMP_FLAGS) +LDADD = $(ADOLC_LIB) $(IPOPT_LIB) $(EIGEN_LIB) $(OPENMP_FLAGS) # test_more_SOURCES = \ $(ADOLC_SRC_FILES) \ @@ -91,14 +91,18 @@ test_more.cpp \ abs.cpp \ acos.cpp \ + acosh.cpp \ adfun_copy.cpp \ asin.cpp \ + asinh.cpp \ assign.cpp \ add.cpp \ add_eq.cpp \ add_zero.cpp \ atan.cpp \ + atanh.cpp \ atan2.cpp \ + azmul.cpp \ base_alloc.cpp \ check_simple_vector.cpp \ checkpoint.cpp \ @@ -106,6 +110,7 @@ compare_change.cpp \ cond_exp.cpp \ cond_exp_ad.cpp \ + cond_exp_rev.cpp \ copy.cpp \ cos.cpp \ cosh.cpp \ @@ -115,6 +120,7 @@ div_zero_one.cpp \ erf.cpp \ exp.cpp \ + expm1.cpp \ extern_value.cpp \ extern_value.hpp \ for_hess.cpp \ @@ -125,16 +131,27 @@ from_base.cpp \ fun_check.cpp \ jacobian.cpp \ - limits.cpp \ + num_limits.cpp \ log.cpp \ + log1p.cpp \ log10.cpp \ mul.cpp \ + mul_cskip.cpp \ mul_eq.cpp \ mul_level.cpp \ + mul_cond_rev.cpp \ + mul_zdouble.cpp \ mul_zero_one.cpp \ near_equal_ext.cpp \ neg.cpp \ ode_err_control.cpp \ + old_usead_2.cpp \ + old_usead_1.cpp \ + old_tan.cpp \ + old_reciprocal.cpp \ + old_mat_mul.cpp \ + old_mat_mul.hpp \ + omp_alloc.cpp \ optimize.cpp \ parameter.cpp \ poly.cpp \ @@ -162,11 +179,13 @@ sub_zero.cpp \ tan.cpp \ test_vector.cpp \ + to_string.cpp \ track_new_del.cpp \ value.cpp \ vec_ad.cpp \ vec_ad_par.cpp \ - vec_unary.cpp + vec_unary.cpp \ + zdouble.cpp test: check ./test_more diff -Nru cppad-2015.00.00.9/test_more/makefile.in cppad-2016.00.00.1/test_more/makefile.in --- cppad-2015.00.00.9/test_more/makefile.in 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/makefile.in 2016-02-09 08:31:56.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.13.4 from makefile.am. +# makefile.in generated by automake 1.15 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -80,12 +90,11 @@ host_triplet = @host@ check_PROGRAMS = test_more$(EXEEXT) subdir = test_more -DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/makefile.am \ - $(srcdir)/test_one.sh.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test_one.sh CONFIG_CLEAN_VPATH_FILES = @@ -102,58 +111,70 @@ @CppAD_EIGEN_DIR_TRUE@ libeigen_a-cppad_eigen.$(OBJEXT) libeigen_a_OBJECTS = $(am_libeigen_a_OBJECTS) am__test_more_SOURCES_DIST = base_adolc.cpp ipopt_solve.cpp \ - alloc_openmp.cpp test_more.cpp abs.cpp acos.cpp adfun_copy.cpp \ - asin.cpp assign.cpp add.cpp add_eq.cpp add_zero.cpp atan.cpp \ - atan2.cpp base_alloc.cpp check_simple_vector.cpp \ - checkpoint.cpp compare.cpp compare_change.cpp cond_exp.cpp \ - cond_exp_ad.cpp copy.cpp cos.cpp cosh.cpp dbl_epsilon.cpp \ - div.cpp div_eq.cpp div_zero_one.cpp erf.cpp exp.cpp \ + alloc_openmp.cpp test_more.cpp abs.cpp acos.cpp acosh.cpp \ + adfun_copy.cpp asin.cpp asinh.cpp assign.cpp add.cpp \ + add_eq.cpp add_zero.cpp atan.cpp atanh.cpp atan2.cpp azmul.cpp \ + base_alloc.cpp check_simple_vector.cpp checkpoint.cpp \ + compare.cpp compare_change.cpp cond_exp.cpp cond_exp_ad.cpp \ + cond_exp_rev.cpp copy.cpp cos.cpp cosh.cpp dbl_epsilon.cpp \ + div.cpp div_eq.cpp div_zero_one.cpp erf.cpp exp.cpp expm1.cpp \ extern_value.cpp extern_value.hpp for_hess.cpp \ for_sparse_jac.cpp forward.cpp forward_dir.cpp \ forward_order.cpp from_base.cpp fun_check.cpp jacobian.cpp \ - limits.cpp log.cpp log10.cpp mul.cpp mul_eq.cpp mul_level.cpp \ - mul_zero_one.cpp near_equal_ext.cpp neg.cpp \ - ode_err_control.cpp optimize.cpp parameter.cpp poly.cpp \ - pow.cpp pow_int.cpp print_for.cpp romberg_one.cpp rosen_34.cpp \ + num_limits.cpp log.cpp log1p.cpp log10.cpp mul.cpp \ + mul_cskip.cpp mul_eq.cpp mul_level.cpp mul_cond_rev.cpp \ + mul_zdouble.cpp mul_zero_one.cpp near_equal_ext.cpp neg.cpp \ + ode_err_control.cpp old_usead_2.cpp old_usead_1.cpp \ + old_tan.cpp old_reciprocal.cpp old_mat_mul.cpp old_mat_mul.hpp \ + omp_alloc.cpp optimize.cpp parameter.cpp poly.cpp pow.cpp \ + pow_int.cpp print_for.cpp romberg_one.cpp rosen_34.cpp \ runge_45.cpp reverse.cpp rev_sparse_hes.cpp rev_sparse_jac.cpp \ rev_two.cpp simple_vector.cpp sin.cpp sin_cos.cpp sinh.cpp \ sparse_hessian.cpp sparse_jacobian.cpp sparse_vec_ad.cpp \ sqrt.cpp std_math.cpp sub.cpp sub_eq.cpp sub_zero.cpp tan.cpp \ - test_vector.cpp track_new_del.cpp value.cpp vec_ad.cpp \ - vec_ad_par.cpp vec_unary.cpp + test_vector.cpp to_string.cpp track_new_del.cpp value.cpp \ + vec_ad.cpp vec_ad_par.cpp vec_unary.cpp zdouble.cpp @CppAD_ADOLC_TRUE@am__objects_1 = base_adolc.$(OBJEXT) @CppAD_IPOPT_TRUE@am__objects_2 = ipopt_solve.$(OBJEXT) @CppAD_OPENMP_TRUE@am__objects_3 = alloc_openmp.$(OBJEXT) am_test_more_OBJECTS = $(am__objects_1) $(am__objects_2) \ $(am__objects_3) test_more.$(OBJEXT) abs.$(OBJEXT) \ - acos.$(OBJEXT) adfun_copy.$(OBJEXT) asin.$(OBJEXT) \ - assign.$(OBJEXT) add.$(OBJEXT) add_eq.$(OBJEXT) \ - add_zero.$(OBJEXT) atan.$(OBJEXT) atan2.$(OBJEXT) \ + acos.$(OBJEXT) acosh.$(OBJEXT) adfun_copy.$(OBJEXT) \ + asin.$(OBJEXT) asinh.$(OBJEXT) assign.$(OBJEXT) add.$(OBJEXT) \ + add_eq.$(OBJEXT) add_zero.$(OBJEXT) atan.$(OBJEXT) \ + atanh.$(OBJEXT) atan2.$(OBJEXT) azmul.$(OBJEXT) \ base_alloc.$(OBJEXT) check_simple_vector.$(OBJEXT) \ checkpoint.$(OBJEXT) compare.$(OBJEXT) \ compare_change.$(OBJEXT) cond_exp.$(OBJEXT) \ - cond_exp_ad.$(OBJEXT) copy.$(OBJEXT) cos.$(OBJEXT) \ - cosh.$(OBJEXT) dbl_epsilon.$(OBJEXT) div.$(OBJEXT) \ - div_eq.$(OBJEXT) div_zero_one.$(OBJEXT) erf.$(OBJEXT) \ - exp.$(OBJEXT) extern_value.$(OBJEXT) for_hess.$(OBJEXT) \ + cond_exp_ad.$(OBJEXT) cond_exp_rev.$(OBJEXT) copy.$(OBJEXT) \ + cos.$(OBJEXT) cosh.$(OBJEXT) dbl_epsilon.$(OBJEXT) \ + div.$(OBJEXT) div_eq.$(OBJEXT) div_zero_one.$(OBJEXT) \ + erf.$(OBJEXT) exp.$(OBJEXT) expm1.$(OBJEXT) \ + extern_value.$(OBJEXT) for_hess.$(OBJEXT) \ for_sparse_jac.$(OBJEXT) forward.$(OBJEXT) \ forward_dir.$(OBJEXT) forward_order.$(OBJEXT) \ from_base.$(OBJEXT) fun_check.$(OBJEXT) jacobian.$(OBJEXT) \ - limits.$(OBJEXT) log.$(OBJEXT) log10.$(OBJEXT) mul.$(OBJEXT) \ - mul_eq.$(OBJEXT) mul_level.$(OBJEXT) mul_zero_one.$(OBJEXT) \ + num_limits.$(OBJEXT) log.$(OBJEXT) log1p.$(OBJEXT) \ + log10.$(OBJEXT) mul.$(OBJEXT) mul_cskip.$(OBJEXT) \ + mul_eq.$(OBJEXT) mul_level.$(OBJEXT) mul_cond_rev.$(OBJEXT) \ + mul_zdouble.$(OBJEXT) mul_zero_one.$(OBJEXT) \ near_equal_ext.$(OBJEXT) neg.$(OBJEXT) \ - ode_err_control.$(OBJEXT) optimize.$(OBJEXT) \ - parameter.$(OBJEXT) poly.$(OBJEXT) pow.$(OBJEXT) \ - pow_int.$(OBJEXT) print_for.$(OBJEXT) romberg_one.$(OBJEXT) \ - rosen_34.$(OBJEXT) runge_45.$(OBJEXT) reverse.$(OBJEXT) \ - rev_sparse_hes.$(OBJEXT) rev_sparse_jac.$(OBJEXT) \ - rev_two.$(OBJEXT) simple_vector.$(OBJEXT) sin.$(OBJEXT) \ - sin_cos.$(OBJEXT) sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \ + ode_err_control.$(OBJEXT) old_usead_2.$(OBJEXT) \ + old_usead_1.$(OBJEXT) old_tan.$(OBJEXT) \ + old_reciprocal.$(OBJEXT) old_mat_mul.$(OBJEXT) \ + omp_alloc.$(OBJEXT) optimize.$(OBJEXT) parameter.$(OBJEXT) \ + poly.$(OBJEXT) pow.$(OBJEXT) pow_int.$(OBJEXT) \ + print_for.$(OBJEXT) romberg_one.$(OBJEXT) rosen_34.$(OBJEXT) \ + runge_45.$(OBJEXT) reverse.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \ + rev_sparse_jac.$(OBJEXT) rev_two.$(OBJEXT) \ + simple_vector.$(OBJEXT) sin.$(OBJEXT) sin_cos.$(OBJEXT) \ + sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) sparse_vec_ad.$(OBJEXT) \ sqrt.$(OBJEXT) std_math.$(OBJEXT) sub.$(OBJEXT) \ sub_eq.$(OBJEXT) sub_zero.$(OBJEXT) tan.$(OBJEXT) \ - test_vector.$(OBJEXT) track_new_del.$(OBJEXT) value.$(OBJEXT) \ - vec_ad.$(OBJEXT) vec_ad_par.$(OBJEXT) vec_unary.$(OBJEXT) + test_vector.$(OBJEXT) to_string.$(OBJEXT) \ + track_new_del.$(OBJEXT) value.$(OBJEXT) vec_ad.$(OBJEXT) \ + vec_ad_par.$(OBJEXT) vec_unary.$(OBJEXT) zdouble.$(OBJEXT) test_more_OBJECTS = $(am_test_more_OBJECTS) test_more_LDADD = $(LDADD) am__DEPENDENCIES_1 = @@ -234,6 +255,8 @@ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/makefile.in $(srcdir)/test_one.sh.in \ + $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ @@ -264,12 +287,12 @@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3660 2015-02-22 17:37:25Z bradbell $ +# $Id: makefile.in 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -350,26 +373,29 @@ builddir = @builddir@ cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ cppad_boostvector = @cppad_boostvector@ -cppad_cflags = @cppad_cflags@ -cppad_compiler_has_erf = @cppad_compiler_has_erf@ cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ +cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ -cppad_implicit_ctor_from_any_type = @cppad_implicit_ctor_from_any_type@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ -cppad_libs = @cppad_libs@ cppad_max_num_threads = @cppad_max_num_threads@ -cppad_requires = @cppad_requires@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ cppad_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ +cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ @@ -410,19 +436,19 @@ @CppAD_OPENMP_FALSE@OPENMP_SRC_FILES = # # ------------------------------------------------------------------------- -@CppAD_OPENMP_TRUE@OPENMP_SRC_FILES = alloc_openmp.cpp +@CppAD_OPENMP_TRUE@OPENMP_SRC_FILES = alloc_openmp.cpp @CppAD_ADOLC_FALSE@ADOLC_SRC_FILES = # ------------------------------------------------------------------------- -@CppAD_ADOLC_TRUE@ADOLC_SRC_FILES = base_adolc.cpp +@CppAD_ADOLC_TRUE@ADOLC_SRC_FILES = base_adolc.cpp @CppAD_ADOLC_FALSE@ADOLC_EXTRA_FILES = base_adolc.cpp @CppAD_ADOLC_TRUE@ADOLC_EXTRA_FILES = @CppAD_ADOLC_FALSE@ADOLC_LIB = @CppAD_ADOLC_TRUE@ADOLC_LIB = -ladolc -lColPack -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64 @CppAD_ADOLC_FALSE@ADOLC_FLAGS = -@CppAD_ADOLC_TRUE@ADOLC_FLAGS = -DCPPAD_ADOLC_TEST -I$(ADOLC_DIR)/include +@CppAD_ADOLC_TRUE@ADOLC_FLAGS = -DCPPAD_ADOLC_TEST -I$(ADOLC_DIR)/include @CppAD_IPOPT_FALSE@IPOPT_SRC_FILES = # ------------------------------------------------------------------------- -@CppAD_IPOPT_TRUE@IPOPT_SRC_FILES = ipopt_solve.cpp +@CppAD_IPOPT_TRUE@IPOPT_SRC_FILES = ipopt_solve.cpp @CppAD_IPOPT_FALSE@IPOPT_EXTRA_FILES = ipopt_solve.cpp @CppAD_IPOPT_TRUE@IPOPT_EXTRA_FILES = @CppAD_IPOPT_FALSE@IPOPT_LIB = @@ -430,7 +456,7 @@ @CppAD_IPOPT_TRUE@ $(CPPAD_IPOPT_LIBS) $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB) @CppAD_IPOPT_FALSE@IPOPT_FLAGS = -@CppAD_IPOPT_TRUE@IPOPT_FLAGS = -DCPPAD_IPOPT_TEST -I$(IPOPT_DIR)/include +@CppAD_IPOPT_TRUE@IPOPT_FLAGS = -DCPPAD_IPOPT_TEST -I$(IPOPT_DIR)/include @CppAD_EIGEN_DIR_FALSE@EIGEN_EXTRA_FILES = cppad_eigen.cpp # ------------------------------------------------------------------------- # make a special library so can have it's own compile flags (see configure.ac) @@ -443,7 +469,7 @@ @CppAD_EIGEN_DIR_TRUE@ -g \ @CppAD_EIGEN_DIR_TRUE@ $(CXX_FLAGS_EIGEN) \ @CppAD_EIGEN_DIR_TRUE@ -DCPPAD_EIGEN_TEST \ -@CppAD_EIGEN_DIR_TRUE@ -I$(EIGEN_DIR)/include +@CppAD_EIGEN_DIR_TRUE@ -I$(EIGEN_DIR)/include # ------------------------------------------------------------------------- # Microsoft project files and script to run a single test @@ -460,13 +486,13 @@ $(EIGEN_INCLUDE) \ $(ADOLC_FLAGS) \ $(IPOPT_FLAGS) \ - $(OPENMP_FLAGS) + $(OPENMP_FLAGS) # AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(IPOPT_FLAGS) $(CXX_FLAGS) # -AM_LDFLAGS = $(OPENMP_FLAGS) -LDADD = $(ADOLC_LIB) $(IPOPT_LIB) $(EIGEN_LIB) $(OPENMP_FLAGS) +AM_LDFLAGS = $(OPENMP_FLAGS) +LDADD = $(ADOLC_LIB) $(IPOPT_LIB) $(EIGEN_LIB) $(OPENMP_FLAGS) # test_more_SOURCES = \ $(ADOLC_SRC_FILES) \ @@ -475,14 +501,18 @@ test_more.cpp \ abs.cpp \ acos.cpp \ + acosh.cpp \ adfun_copy.cpp \ asin.cpp \ + asinh.cpp \ assign.cpp \ add.cpp \ add_eq.cpp \ add_zero.cpp \ atan.cpp \ + atanh.cpp \ atan2.cpp \ + azmul.cpp \ base_alloc.cpp \ check_simple_vector.cpp \ checkpoint.cpp \ @@ -490,6 +520,7 @@ compare_change.cpp \ cond_exp.cpp \ cond_exp_ad.cpp \ + cond_exp_rev.cpp \ copy.cpp \ cos.cpp \ cosh.cpp \ @@ -499,6 +530,7 @@ div_zero_one.cpp \ erf.cpp \ exp.cpp \ + expm1.cpp \ extern_value.cpp \ extern_value.hpp \ for_hess.cpp \ @@ -509,16 +541,27 @@ from_base.cpp \ fun_check.cpp \ jacobian.cpp \ - limits.cpp \ + num_limits.cpp \ log.cpp \ + log1p.cpp \ log10.cpp \ mul.cpp \ + mul_cskip.cpp \ mul_eq.cpp \ mul_level.cpp \ + mul_cond_rev.cpp \ + mul_zdouble.cpp \ mul_zero_one.cpp \ near_equal_ext.cpp \ neg.cpp \ ode_err_control.cpp \ + old_usead_2.cpp \ + old_usead_1.cpp \ + old_tan.cpp \ + old_reciprocal.cpp \ + old_mat_mul.cpp \ + old_mat_mul.hpp \ + omp_alloc.cpp \ optimize.cpp \ parameter.cpp \ poly.cpp \ @@ -546,11 +589,13 @@ sub_zero.cpp \ tan.cpp \ test_vector.cpp \ + to_string.cpp \ track_new_del.cpp \ value.cpp \ vec_ad.cpp \ vec_ad_par.cpp \ - vec_unary.cpp + vec_unary.cpp \ + zdouble.cpp all: all-am @@ -568,7 +613,6 @@ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test_more/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu test_more/makefile -.PRECIOUS: makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -612,15 +656,19 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acos.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acosh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_zero.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adfun_copy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc_openmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asinh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assign.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atanh.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/azmul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_adolc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_alloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_simple_vector.Po@am__quote@ @@ -629,6 +677,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compare_change.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cond_exp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cond_exp_ad.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cond_exp_rev.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cos.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cosh.Po@am__quote@ @@ -638,6 +687,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/div_zero_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/erf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expm1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extern_value.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_hess.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_jac.Po@am__quote@ @@ -649,16 +699,26 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipopt_solve.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jacobian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeigen_a-cppad_eigen.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/limits.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log10.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log1p.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_cond_rev.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_cskip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_level.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_zdouble.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_zero_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/near_equal_ext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/neg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/num_limits.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_err_control.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_mat_mul.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_reciprocal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_tan.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_usead_1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_usead_2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omp_alloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimize.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parameter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @@ -687,11 +747,13 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_more.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_vector.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/to_string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track_new_del.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/value.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_ad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_ad_par.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_unary.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zdouble.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -926,6 +988,8 @@ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am +.PRECIOUS: makefile + test: check ./test_more diff -Nru cppad-2015.00.00.9/test_more/mul_cond_rev.cpp cppad-2016.00.00.1/test_more/mul_cond_rev.cpp --- cppad-2015.00.00.9/test_more/mul_cond_rev.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/mul_cond_rev.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -0,0 +1,220 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +/* +Test of multi-level conditional expressions reverse mode +*/ + +# include + +bool mul_cond_rev(void) +{ + bool ok = true; + using CppAD::vector; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + // + typedef CppAD::AD a1double; + typedef CppAD::AD a2double; + // + a1double a1zero = 0.0; + a2double a2zero = a1zero; + a1double a1one = 1.0; + a2double a2one = a1one; + // + // -------------------------------------------------------------------- + // create a1f = f(x) + size_t n = 1; + size_t m = 25; + // + vector a2x(n), a2y(m); + a2x[0] = a2double( 5.0 ); + Independent(a2x); + // + size_t i = 0; + // variable that is greater than one when x[0] is zero + // and less than one when x[0] is 1.0 or greater + a2double a2switch = a2one / (a2x[0] + a2double(0.5)); + // variable that is infinity when x[0] is zero + // and a normal number when x[0] is 1.0 or greater + a2double a2inf_var = a2one / a2x[0]; + // variable that is nan when x[0] is zero + // and a normal number when x[0] is 1.0 or greater + a2double a2nan_var = ( a2one / a2inf_var ) / a2x[0]; + // variable that is one when x[0] is zero + // and less then one when x[0] is 1.0 or greater + a2double a2one_var = a2one / ( a2one + a2x[0] ); + // div + a2y[i++] = CondExpGt(a2x[0], a2zero, a2nan_var, a2zero); + // abs + a2y[i++] = CondExpGt(a2x[0], a2zero, abs( a2y[0] ), a2zero); + // add + a2y[i++] = CondExpGt(a2x[0], a2zero, a2nan_var + a2nan_var, a2zero); + // acos + a2y[i++] = CondExpGt(a2x[0], a2zero, acos(a2switch), a2zero); + // asin + a2y[i++] = CondExpGt(a2x[0], a2zero, asin(a2switch), a2zero); + // atan + a2y[i++] = CondExpGt(a2x[0], a2zero, atan(a2nan_var), a2zero); + // cos + a2y[i++] = CondExpGt(a2x[0], a2zero, cos(a2nan_var), a2zero); + // cosh + a2y[i++] = CondExpGt(a2x[0], a2zero, cosh(a2nan_var), a2zero); + // exp + a2y[i++] = CondExpGt(a2x[0], a2zero, exp(a2nan_var), a2zero); + // log + a2y[i++] = CondExpGt(a2x[0], a2zero, log(a2x[0]), a2zero); + // mul + a2y[i++] = CondExpGt(a2x[0], a2zero, a2x[0] * a2inf_var, a2zero); + // pow + a2y[i++] = CondExpGt(a2x[0], a2zero, pow(a2inf_var, a2x[0]), a2zero); + // sin + a2y[i++] = CondExpGt(a2x[0], a2zero, sin(a2nan_var), a2zero); + // sinh + a2y[i++] = CondExpGt(a2x[0], a2zero, sinh(a2nan_var), a2zero); + // sqrt + a2y[i++] = CondExpGt(a2x[0], a2zero, sqrt(a2x[0]), a2zero); + // sub + a2y[i++] = CondExpGt(a2x[0], a2zero, a2inf_var - a2nan_var, a2zero); + // tan + a2y[i++] = CondExpGt(a2x[0], a2zero, tan(a2nan_var), a2zero); + // tanh + a2y[i++] = CondExpGt(a2x[0], a2zero, tanh(a2nan_var), a2zero); + // azmul + a2y[i++] = CondExpGt(a2x[0], a2zero, azmul(a2x[0], a2inf_var), a2zero); + // + // Operations that are C+11 atomic + // + // acosh + a2y[i++] = CondExpGt(a2x[0], a2zero, acosh( a2x[0] ), a2zero); + // asinh + a2y[i++] = CondExpGt(a2x[0], a2zero, asinh( a2nan_var ), a2zero); + // atanh + a2y[i++] = CondExpGt(a2x[0], a2zero, atanh( a2one_var ), a2zero); + // erf + a2y[i++] = CondExpGt(a2x[0], a2zero, erf( a2nan_var ), a2zero); + // expm1 + a2y[i++] = CondExpGt(a2x[0], a2zero, expm1(a2nan_var), a2zero); + // log1p + a2y[i++] = CondExpGt(a2x[0], a2zero, log1p(- a2one_var ), a2zero); + // + ok &= i == m; + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + // -------------------------------------------------------------------- + // create h = f(x) + vector a1x(n), a1y(m); + a1x[0] = 5.0; + // + Independent(a1x); + i = 0; + a1double a1switch = a1one / (a1x[0] + a1double(0.5)); + a1double a1inf_var = a1one / a1x[0]; + a1double a1nan_var = ( a1one / a1inf_var ) / a1x[0]; + a1double a1one_var = a1one / ( a1one + a1x[0] ); + // div + a1y[i++] = CondExpGt(a1x[0], a1zero, a1nan_var, a1zero); + // abs + a1y[i++] = CondExpGt(a1x[0], a1zero, abs( a1y[0] ), a1zero); + // add + a1y[i++] = CondExpGt(a1x[0], a1zero, a1nan_var + a1nan_var, a1zero); + // acos + a1y[i++] = CondExpGt(a1x[0], a1zero, acos(a1switch), a1zero); + // asin + a1y[i++] = CondExpGt(a1x[0], a1zero, asin(a1switch), a1zero); + // atan + a1y[i++] = CondExpGt(a1x[0], a1zero, atan(a1nan_var), a1zero); + // cos + a1y[i++] = CondExpGt(a1x[0], a1zero, cos(a1nan_var), a1zero); + // cosh + a1y[i++] = CondExpGt(a1x[0], a1zero, cosh(a1nan_var), a1zero); + // exp + a1y[i++] = CondExpGt(a1x[0], a1zero, exp(a1nan_var), a1zero); + // log + a1y[i++] = CondExpGt(a1x[0], a1zero, log(a1x[0]), a1zero); + // mul + a1y[i++] = CondExpGt(a1x[0], a1zero, a1x[0] * a1inf_var, a1zero); + // pow + a1y[i++] = CondExpGt(a1x[0], a1zero, pow(a1inf_var, a1x[0]), a1zero); + // sin + a1y[i++] = CondExpGt(a1x[0], a1zero, sin(a1nan_var), a1zero); + // sinh + a1y[i++] = CondExpGt(a1x[0], a1zero, sinh(a1nan_var), a1zero); + // sqrt + a1y[i++] = CondExpGt(a1x[0], a1zero, sqrt(a1x[0]), a1zero); + // sub + a1y[i++] = CondExpGt(a1x[0], a1zero, a1inf_var - a1nan_var, a1zero); + // tan + a1y[i++] = CondExpGt(a1x[0], a1zero, tan(a1nan_var), a1zero); + // tanh + a1y[i++] = CondExpGt(a1x[0], a1zero, tanh(a1nan_var), a1zero); + // azmul + a1y[i++] = CondExpGt(a1x[0], a1zero, azmul(a1x[0], a1inf_var), a1zero); + // + // Operations that are C+11 atomic + // + // acosh + a1y[i++] = CondExpGt(a1x[0], a1zero, acosh( a1x[0] ), a1zero); + // asinh + a1y[i++] = CondExpGt(a1x[0], a1zero, asinh( a1nan_var ), a1zero); + // atanh + a1y[i++] = CondExpGt(a1x[0], a1zero, atanh( a1one_var ), a1zero); + // erf + a1y[i++] = CondExpGt(a1x[0], a1zero, erf( a1nan_var ), a1zero); + // expm1 + a1y[i++] = CondExpGt(a1x[0], a1zero, expm1(a1nan_var), a1zero); + // log1p + a1y[i++] = CondExpGt(a1x[0], a1zero, log1p(- a1one_var ), a1zero); + // + ok &= i == m; + CppAD::ADFun h; + h.Dependent(a1x, a1y); + // -------------------------------------------------------------------- + // create g = f'(x) + vector a1dy(m), a1w(m); + a1x[0] = 2.0; + for(i = 0; i < m; i++) + a1w[i] = 0.0; + // + Independent(a1x); + a1f.Forward(0, a1x); + // + for(i = 0; i < m; i++) + { a1w[i] = 1.0; + vector dyi_dx = a1f.Reverse(1, a1w); + a1dy[i] = dyi_dx[0]; + a1w[i] = 0.0; + } + CppAD::ADFun g; // g uses reverse mode derivatives + g.Dependent(a1x, a1dy); + // -------------------------------------------------------------------- + // check case where x[0] > 0 + vector x(1), dx(1), dg(m), dh(m); + x[0] = 2.0; + dx[0] = 1.0; + h.Forward(0, x); + dh = h.Forward(1, dx); // dh uses forward mode derivatives + dg = g.Forward(0, x); + for(i = 0; i < m; i++) + ok &= NearEqual(dg[i], dh[i], eps, eps); + // -------------------------------------------------------------------- + // check case where x[0] = 0 + x[0] = 0.0; + dg = g.Forward(0, x); + h.Forward(0, x); + dh = h.Forward(1, dx); + for(i = 0; i < m; i++) + { ok &= dg[i] == 0.0; + ok &= dh[i] == 0.0; + } + // -------------------------------------------------------------------- + return ok; +} diff -Nru cppad-2015.00.00.9/test_more/mul.cpp cppad-2016.00.00.1/test_more/mul.cpp --- cppad-2015.00.00.9/test_more/mul.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/mul.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: mul.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -45,7 +45,7 @@ // assign the dependent variables Z[x] = U[s] * U[t]; // AD * AD Z[y] = Z[x] * 4.; // AD * double - Z[z] = 4. * Z[y]; // double * AD + Z[z] = 4. * Z[y]; // double * AD Z[u] = one * Z[z]; // multiplication by parameter equal to one Z[v] = zero * Z[z]; // multiplication by parameter equal to zero @@ -71,7 +71,7 @@ q[s] = 1.; q[t] = 0.; r = f.Forward(1, q); - ok &= ( r[x] == U[t] ); // dx/ds + ok &= ( r[x] == U[t] ); // dx/ds ok &= ( r[y] == U[t] * 4. ); // dy/ds ok &= ( r[z] == 4. * U[t] * 4. ); // dz/ds ok &= ( r[u] == r[z] ); // du/ds @@ -106,19 +106,19 @@ AD a = U[0] * 1.; // AD * double AD b = a * 2; // AD * int - AD c = 3. * b; // double * AD - AD d = 4 * c; // int * AD + AD c = 3. * b; // double * AD + AD d = 4 * c; // int * AD - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = U[0] * d; // AD * AD // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(Value(Z[0]) , u0*4*3*2*u0, 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -135,13 +135,13 @@ else value = 0.; jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -165,6 +165,6 @@ bool Mul(void) { bool ok = true; ok &= MulTestOne(); - ok &= MulTestTwo(); + ok &= MulTestTwo(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/mul_cskip.cpp cppad-2016.00.00.1/test_more/mul_cskip.cpp --- cppad-2015.00.00.9/test_more/mul_cskip.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/mul_cskip.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,71 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +# include +# include + +// Test multiple level conditional skip where value of comparision is +// uncertain during forward mode base Base value can be a variable. +bool mul_cskip(void) +{ bool ok = true; + using namespace CppAD; + using CppAD::vector; + + typedef AD a1type; + typedef AD a2type; + + size_t n = 2; + size_t m = 1; + vector x(n), y(m); + x[0] = 0.0; + x[1] = 1.0; + + // start recording a2type operations + vector a2x(n), a2y(m); + for (size_t j = 0; j < n; j++) + a2x[j] = a2type( a1type(x[j]) ); + Independent(a2x); + + // a1f(x) = x_0 * x_1 if x[0] == 1 + // 0.0 otherwise + a2type a2zero = a2type(0.0); + a2type a2one = a2type(1.0); + a2type a2p = a2x[0] * a2x[1]; + a2y[0] = CondExpEq(a2x[0], a2one, a2p, a2zero); + ADFun a1f(a2x, a2y); + + // Optimization will check to see if we can skip part of conditional + // expression that is not used. + a1f.optimize(); + + // f(x) = x_0 * x_1 if x[0] == 1 + // 0.0 otherwise + vector a1x(n), a1y(m); + for (size_t j = 0; j < n; j++) + a1x[j] = a1type(x[j]); + Independent(a1x); + a1y = a1f.Forward(0, a1x); + CppAD::ADFun f(a1x, a1y); + + // check case where x[0] == 1 + x[0] = 1.0; + x[1] = 2.0; + y = f.Forward(0, x); + ok &= y[0] == x[1]; + + // check case where x[0] != 1 + x[0] = 3.0; + x[1] = 2.0; + y = f.Forward(0, x); + ok &= y[0] == 0.0; + + return ok; +} diff -Nru cppad-2015.00.00.9/test_more/mul_eq.cpp cppad-2016.00.00.1/test_more/mul_eq.cpp --- cppad-2015.00.00.9/test_more/mul_eq.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/mul_eq.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul_eq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: mul_eq.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -87,22 +87,22 @@ // independent variable vector double u0 = .5; CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; + U[0] = u0; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = U[0]; // initial value Z[0] *= 2; // AD *= int Z[0] *= 4.; // AD *= double - Z[0] *= U[0]; // AD *= AD + Z[0] *= U[0]; // AD *= AD // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(Z[0] , u0*2*4*u0, 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -119,13 +119,13 @@ else value = 0.; jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -149,6 +149,6 @@ bool MulEq(void) { bool ok = true; ok &= MulEqTestOne(); - ok &= MulEqTestTwo(); + ok &= MulEqTestTwo(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/mul_level.cpp cppad-2016.00.00.1/test_more/mul_level.cpp --- cppad-2015.00.00.9/test_more/mul_level.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/mul_level.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul_level.cpp 3071 2014-01-01 04:02:27Z bradbell $ */ +// $Id: mul_level.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -15,7 +15,7 @@ # include # include # include -// adouble definitions not in Adolc distribution and +// adouble definitions not in Adolc distribution and // required in order to use CppAD::AD # include # endif @@ -25,7 +25,7 @@ namespace { // BEGIN empty namespace -bool One(void) +bool One(void) { bool ok = true; // initialize test result using CppAD::NearEqual; double eps = 10. * std::numeric_limits::epsilon(); @@ -94,13 +94,13 @@ sum += x[i] * x[i]; // check computed assignment AD< AD > -= int - sum -= 1; + sum -= 1; - // check double * AD< AD > + // check double * AD< AD > return .5 * sum; -} +} -bool Two(void) +bool Two(void) { bool ok = true; // initialize test result typedef CppAD::AD ADdouble; // for one level of taping @@ -127,7 +127,7 @@ // declare inner function (corresponding to ADDdouble calculation) CppAD::ADFun a_F(aa_x, aa_f); - // compute f'(x) + // compute f'(x) size_t p = 1; // order of derivative of a_F CPPAD_TESTVECTOR(ADdouble) a_w(1); // weight vector for a_F CPPAD_TESTVECTOR(ADdouble) a_df(n); // value of derivative @@ -155,7 +155,7 @@ # ifdef CPPAD_ADOLC_TEST -bool adolc(void) +bool adolc(void) { bool ok = true; // initialize test result typedef adouble ADdouble; // for first level of taping @@ -186,14 +186,14 @@ // declare inner function (corresponding to ADDdouble calculation) CppAD::ADFun a_F(aa_x, aa_f); - // compute f'(x) + // compute f'(x) size_t p = 1; // order of derivative of a_F CPPAD_TESTVECTOR(ADdouble) a_w(1); // weight vector for a_F CPPAD_TESTVECTOR(ADdouble) a_df(n); // value of derivative a_w[0] = 1; // weighted function same as a_F a_df = a_F.Reverse(p, a_w); // gradient of f - // declare outter function + // declare outter function // (corresponding to the tape of adouble operations) double df_j; for(j = 0; j < n; j++) @@ -251,7 +251,7 @@ ay = af.Forward(0, ax); ADFun g(ax, ay); - // evaluate h(x) = g(x) + // evaluate h(x) = g(x) x[0] = 1.; y = g.Forward(0, x); diff -Nru cppad-2015.00.00.9/test_more/mul_zdouble.cpp cppad-2016.00.00.1/test_more/mul_zdouble.cpp --- cppad-2015.00.00.9/test_more/mul_zdouble.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/mul_zdouble.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,145 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ +// Check that multilevel reverse with conditial expressions works properly +// when using AD< AD >. + +# include +namespace { + using CppAD::AD; + using CppAD::zdouble; + using CppAD::ADFun; + using CppAD::vector; + typedef AD a1type; + typedef AD a2type; + typedef vector (*a2fun)(const vector& a2x); + // + zdouble eps = 10. * std::numeric_limits::epsilon(); + size_t n_ = 2; + size_t m_ = 1; + // + void record(a2fun fun, ADFun& g) + { vector x(n_); + vector a1x(n_), a1w(m_), a1z(m_ * n_); + vector a2x(n_), a2y(m_); + // + for(size_t j = 0; j < n_; j++) + { x[j] = 0.0; + a1x[j] = a1type( x[j] ); + a2x[j] = a2type( a1x[j] ); + } + Independent(a2x); + // f(x) = x[0] / x[1] if x[1] > 0.0 else 0.0 + a2y = fun(a2x); + ADFun a1f; + a1f.Dependent(a2x, a2y); + // use reverse mode to calculate g(x) = f'(x) + a1w[0] = a1type(1.0); + Independent(a1x); + a1f.Forward(0, a1x); + a1z = a1f.Reverse(1, a1w); + g.Dependent(a1x, a1z); + // + return; + } + // ---------------------------------------------------------------------- + vector div(const vector& a2x) + { vector a2y(m_); + a2type a2zero = a2type(0.0); + a2type a2four = a2type(4.0); + a2y[0] = CondExpGt(a2x[1], a2zero, a2x[0] / a2x[1], a2zero); + a2y[0] += CondExpGt(a2x[1], a2zero, a2four / a2x[1], a2zero); + return a2y; + } + bool check_div(void) + { bool ok = true; + // record division operations + ADFun g; + record(div, g); + vector x(n_), z(n_); + // check result where x[1] <= 0.0 (would be nan without absoute zero) + x[0] = 0.0; + x[1] = 0.0; + z = g.Forward(0, x); + z = g.Forward(0, x); + ok &= z[0] == 0.0; + ok &= z[1] == 0.0; + // check result where x[1] > 0.0 + x[0] = 2.0; + x[1] = 3.0; + z = g.Forward(0, x); + ok &= CppAD::NearEqual(z[0], 1.0/x[1], eps, eps); + ok &= CppAD::NearEqual(z[1], - (x[0]+4.0)/(x[1]*x[1]), eps, eps); + // + return ok; + } + // ---------------------------------------------------------------------- + vector mul(const vector& a2x) + { vector a2y(m_); + a2type a2zero = a2type(0.0); + a2type a2four = a2type(4.0); + a2y[0] = CondExpLt(a2x[0], a2four, a2x[0] * a2x[1], a2zero); + a2y[0] += CondExpLt(a2x[0], a2four, a2four * a2x[1], a2zero); + a2y[0] += CondExpLt(a2x[0], a2four, a2x[1] * a2four, a2zero); + return a2y; + } + bool check_mul(void) + { bool ok = true; + // record multiplication operations + ADFun g; + record(mul, g); + vector x(n_), z(n_); + // check result where x[0] > 4 (would be nan without absoute zero) + ok &= std::numeric_limits::has_infinity; + x[0] = std::numeric_limits::infinity(); + x[1] = 0.0; + z = g.Forward(0, x); + ok &= z[0] == 0.0; + ok &= z[1] == 0.0; + // check result where x[0] < 4 + x[0] = 2.0; + x[1] = 3.0; + z = g.Forward(0, x); + ok &= CppAD::NearEqual(z[0], x[1], eps, eps); + ok &= CppAD::NearEqual(z[1], x[0]+8.0, eps, eps); + // + return ok; + } + // ---------------------------------------------------------------------- + bool check_numeric_limits(void) + { bool ok = true; + // + double double_eps = std::numeric_limits::epsilon(); + zdouble zdouble_eps = CppAD::numeric_limits::epsilon(); + ok &= double_eps == zdouble_eps; + // + double double_min = std::numeric_limits::min(); + zdouble zdouble_min = CppAD::numeric_limits::min(); + ok &= double_min == zdouble_min; + // + double double_max = std::numeric_limits::max(); + zdouble zdouble_max = CppAD::numeric_limits::max(); + ok &= double_max == zdouble_max; + // + return ok; + } + +} + +bool mul_zdouble(void) +{ bool ok = true; + + ok &= check_div(); + ok &= check_mul(); + ok &= check_numeric_limits(); + + return ok; +} diff -Nru cppad-2015.00.00.9/test_more/mul_zero_one.cpp cppad-2016.00.00.1/test_more/mul_zero_one.cpp --- cppad-2015.00.00.9/test_more/mul_zero_one.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/mul_zero_one.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: mul_zero_one.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: mul_zero_one.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ typedef CppAD::AD< ADdouble > ADDdouble; bool MulZeroOne(void) -{ +{ using namespace CppAD; bool ok = true; diff -Nru cppad-2015.00.00.9/test_more/near_equal_ext.cpp cppad-2016.00.00.1/test_more/near_equal_ext.cpp --- cppad-2015.00.00.9/test_more/near_equal_ext.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/near_equal_ext.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: near_equal_ext.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: near_equal_ext.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,16 +22,16 @@ using CppAD::AD; using CppAD::NearEqual; - // double + // double double x = 1.00000; double y = 1.00001; double a = .00005; double r = .00005; - double zero = 0.; + double zero = 0.; double inf = 1. / zero; double nan = 0. / zero; - // AD + // AD AD X(x); AD Y(y); AD Inf(inf); diff -Nru cppad-2015.00.00.9/test_more/neg.cpp cppad-2016.00.00.1/test_more/neg.cpp --- cppad-2015.00.00.9/test_more/neg.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/neg.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: neg.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: neg.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -35,7 +35,7 @@ size_t x = 0; // dependent variable values - Z[x] = - U[t]; // - AD + Z[x] = - U[t]; // - AD // create f: U -> Z and vectors used for derivative calculations ADFun f(U, Z); @@ -63,7 +63,7 @@ r = f.Reverse(2, w); ok &= ( r[2 * s + 1] == 0. ); // d^2 x / (ds ds) ok &= ( r[2 * t + 1] == 0. ); // d^2 x / (ds dt) - + return ok; } // END C++ diff -Nru cppad-2015.00.00.9/test_more/num_limits.cpp cppad-2016.00.00.1/test_more/num_limits.cpp --- cppad-2015.00.00.9/test_more/num_limits.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/num_limits.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,198 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +old num_limits.cpp example / test +$spell +$$ + +$section Numeric Limits: Example and Test$$ +$index limits$$ +$index example, limits$$ +$index test, limits$$ + +$head Assumption$$ +This code assumes that the decimal point is infront of the mantissa. +Hence dividing the minimum normalized value looses precision, +while multiplying the maximum normalized value results in infinity. + +$head Externals$$ +This example using external routines to get and set values +so that the complier does not set the correspdong code and optimize +it out. + +$code +old verbatim%example/num_limits.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ + +# ifdef _MSC_VER +// Supress Microsoft compiler warning about possible loss of precision, +// in the constructors (when converting to std::complex) +// Type one = 1 +// Type two = 2 +// 1 and 2 are small enough so no loss of precision when converting to float. +# pragma warning(disable:4244) +# endif + +# include +# include +# include "extern_value.hpp" + +namespace { + using CppAD::vector; + using CppAD::abs_geq; + + template + Type add_one(const Type& value) + { return( Type(1) + value ); } + // ----------------------------------------------------------------- + template + bool check_epsilon(void) + { bool ok = true; + typedef extern_value value; + value eps( CppAD::numeric_limits::epsilon() ); + value one( Type(1) ); + value two( Type(2) ); + value tmp( Type(0) ); + // + tmp.set( add_one( eps.get() / two.get() ) ); + ok &= one.get() == tmp.get(); + // + tmp.set( add_one( eps.get() ) ); + ok &= one.get() != tmp.get(); + return ok; + } + // ----------------------------------------------------------------- + template + bool check_min(void) + { bool ok = true; + typedef extern_value value; + value min( CppAD::numeric_limits::min() ); + value eps3( Type(3) * CppAD::numeric_limits::epsilon() ); + value one( Type(1) ); + value hun( Type(100) ); + value tmp( Type(0) ); + // + tmp.set( min.get() / hun.get() ); + tmp.set( tmp.get() * hun.get() ); + ok &= abs_geq(tmp.get()/min.get() - one.get(), eps3.get()); + // + tmp.set( min.get() * hun.get() ); + tmp.set( tmp.get() / hun.get() ); + ok &= ! abs_geq(tmp.get()/min.get() - one.get(), eps3.get()); + return ok; + } + + // ----------------------------------------------------------------- + template + bool check_max(void) + { bool ok = true; + typedef extern_value value; + value max2( CppAD::numeric_limits::max() / Type(2) ); + value eps3( Type(3) * CppAD::numeric_limits::epsilon() ); + value one( Type(1) ); + value hun( Type(100) ); + value tmp( Type(0) ); + + // In complex case, this operaiton can result in (inf, 0) + tmp.set( max2.get() * hun.get() ); + + // In complex case, this operaiotn can result in (inf,-nan) + // (where nan corresponds to inf * 0) + tmp.set( tmp.get() / hun.get() ); + + if( ! CppAD::isnan( tmp.get() ) ) ok &= abs_geq( + tmp.get() / max2.get() - one.get(), eps3.get() + ); + // + tmp.set( max2.get() / hun.get() ); + tmp.set( tmp.get() * hun.get() ); + ok &= ! abs_geq(tmp.get() / max2.get() - one.get(), eps3.get() ); + return ok; + } + // ----------------------------------------------------------------- + template + bool check_quiet_NaN(void) + { bool ok = true; + typedef extern_value value; + value nan( CppAD::numeric_limits::quiet_NaN() ); + value same( nan.get() ); + // + ok &= nan.get() != same.get(); + ok &= ! (nan.get() == same.get() ); + // + return ok; + } +} + +bool num_limits(void) +{ bool ok = true; + using CppAD::AD; + + // ------------------------------------------------------------------- + // epsilon for Base types defined by CppAD + ok &= check_epsilon(); + ok &= check_epsilon(); + ok &= check_epsilon< std::complex >(); + ok &= check_epsilon< std::complex >(); + + // epsilon for some AD types. + ok &= check_epsilon< AD >(); + ok &= check_epsilon< AD >(); + ok &= check_epsilon< AD > >(); + ok &= check_epsilon< AD > >(); + + // ------------------------------------------------------------------- + // min for Base types defined by CppAD + ok &= check_min(); + ok &= check_min(); + ok &= check_min< std::complex >(); + ok &= check_min< std::complex >(); + + // min for some AD types. + ok &= check_min< AD >(); + ok &= check_min< AD >(); + ok &= check_min< AD > >(); + ok &= check_min< AD > >(); + + // ------------------------------------------------------------------- + // max for Base types defined by CppAD + ok &= check_max(); + ok &= check_max(); + ok &= check_max< std::complex >(); + ok &= check_max< std::complex >(); + + // max for some AD types. + ok &= check_max< AD >(); + ok &= check_max< AD >(); + ok &= check_max< AD< std::complex > >(); + ok &= check_max< AD< std::complex > >(); + // ------------------------------------------------------------------- + // quiet_NaN for Base types defined by CppAD + ok &= check_quiet_NaN(); + ok &= check_quiet_NaN(); + ok &= check_quiet_NaN< std::complex >(); + ok &= check_quiet_NaN< std::complex >(); + + // quiet_NaN for some AD types. + ok &= check_quiet_NaN< AD >(); + ok &= check_quiet_NaN< AD >(); + ok &= check_quiet_NaN< AD< std::complex > >(); + ok &= check_quiet_NaN< AD< std::complex > >(); + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/test_more/ode_err_control.cpp cppad-2016.00.00.1/test_more/ode_err_control.cpp --- cppad-2015.00.00.9/test_more/ode_err_control.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/ode_err_control.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: ode_err_control.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: ode_err_control.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,10 +12,10 @@ # include // for size_t # include // for exp -# include // CppAD::OdeErrControl -# include // CppAD::NearEqual -# include // CppAD::vector -# include // CppAD::Runge45 +# include // CppAD::OdeErrControl +# include // CppAD::NearEqual +# include // CppAD::vector +# include // CppAD::Runge45 /* ------------------------------------------------------------------------- Test relative error with zero initial conditions. @@ -30,13 +30,13 @@ public: // constructor Fun_one(size_t n_) : n(n_) - { } + { } // given x(0) = 0 // solution is x_i (t) = t^(i+1) void Ode( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f) { size_t i; f[0] = 1.; @@ -54,8 +54,8 @@ Method_one(size_t n_) : F(n_) { } void step( - double ta, - double tb, + double ta, + double tb, CppAD::vector &xa , CppAD::vector &xb , CppAD::vector &eb ) @@ -70,8 +70,8 @@ { bool ok = true; // initial return value // Runge45 should yield exact results for x_i (t) = t^(i+1), i < 4 - size_t n = 6; - + size_t n = 6; + // construct method for n component solution Method_one method(n); @@ -96,7 +96,7 @@ CppAD::vector ef(n); CppAD::vector xf(n); - + xf = OdeErrControl(method, ti, tf, xi, smin, smax, scur, eabs, erel, ef); @@ -111,7 +111,7 @@ /* Old example now just a test -Define +Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} @@ -123,7 +123,7 @@ $latex \[ \begin{array}{rcl} X_0^{(1)} (t) & = & - w_0 X_0 (t) \\ - X_1^{(1)} (t) & = & + w_0 X_0 (t) - w_1 X_1 (t) + X_1^{(1)} (t) & = & + w_0 X_0 (t) - w_1 X_1 (t) \end{array} \] $$ */ @@ -136,15 +136,15 @@ public: // constructor Fun_two(const CppAD::vector &w_) : w(w_) - { } + { } // set f = x'(t) void Ode( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f) { f[0] = - w[0] * x[0]; - f[1] = + w[0] * x[0] - w[1] * x[1]; + f[1] = + w[0] * x[0] - w[1] * x[1]; } }; @@ -157,8 +157,8 @@ Method_two(const CppAD::vector &w_) : F(w_) { } void step( - double ta, - double tb, + double ta, + double tb, CppAD::vector &xa , CppAD::vector &xb , CppAD::vector &eb ) @@ -199,7 +199,7 @@ CppAD::vector maxabs(2); size_t nstep; - + xf = OdeErrControl(method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); @@ -214,7 +214,7 @@ return ok; } /* -Define +Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} @@ -229,19 +229,19 @@ \begin{array}{rcl} X_0 (t) & = & \exp ( \alpha t^2 ) \\ X_1 (t) & = & \int_0^t \exp( - \alpha s^2 ) {\bf d} s \\ -& = & +& = & \frac{1}{ \sqrt{\alpha} \int_0^{\sqrt{\alpha} t} \exp( - r^2 ) {\bf d} r \\ & = & \frac{\sqrt{\pi}}{ 2 \sqrt{\alpha} {\rm erf} ( \sqrt{\alpha} t ) \end{array} \] $$ If $latex X_0 (t) < 0$$, -we return $code nan$$ in order to inform +we return $code nan$$ in order to inform $code OdeErrControl$$ that its is taking to large a step. */ -# include // CppAD::Rosen34 +# include // CppAD::Rosen34 # include namespace { @@ -253,15 +253,15 @@ public: // constructor Fun_three(double alpha) : alpha_(alpha), was_negative_(false) - { } + { } // set f = x'(t) void Ode( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f) { f[0] = 2. * alpha_ * t * x[0]; - f[1] = 1. / x[0]; + f[1] = 1. / x[0]; // case where ODE does not make sense if( x[0] < 0. || x[1] < 0. ) { was_negative_ = true; @@ -270,12 +270,12 @@ } // set f_t = df / dt void Ode_ind( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f_t) { f_t[0] = 2. * alpha_ * x[0]; - f_t[1] = 0.; + f_t[1] = 0.; if( x[0] < 0. || x[1] < 0. ) { was_negative_ = true; f_t[0] = CppAD::nan(0.); @@ -283,8 +283,8 @@ } // set f_x = df / dx void Ode_dep( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f_x) { double x0_sq = x[0] * x[0]; f_x[0 * 2 + 0] = 2. * alpha_ * t; // f0 w.r.t. x0 @@ -310,8 +310,8 @@ Method_three(double alpha) : F(alpha) { } void step( - double ta, - double tb, + double ta, + double tb, CppAD::vector &xa , CppAD::vector &xb , CppAD::vector &eb ) @@ -350,7 +350,7 @@ CppAD::vector maxabs(2); size_t nstep; - + xf = OdeErrControl(method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); @@ -378,13 +378,13 @@ public: // constructor Fun_four(size_t n_) : n(n_) - { } + { } // given x(0) = 0 // solution is x_i (t) = t^(i+1) void Ode( - const double &t, - const CppAD::vector &x, + const double &t, + const CppAD::vector &x, CppAD::vector &f) { size_t i; f[0] = CppAD::nan(0.); @@ -402,8 +402,8 @@ Method_four(size_t n_) : F(n_) { } void step( - double ta, - double tb, + double ta, + double tb, CppAD::vector &xa , CppAD::vector &xb , CppAD::vector &eb ) @@ -416,9 +416,9 @@ bool OdeErrControl_four(void) { bool ok = true; // initial return value - + // construct method for n component solution - size_t n = 6; + size_t n = 6; Method_four method(n); // inputs to OdeErrControl @@ -443,7 +443,7 @@ // outputs from OdeErrControl CppAD::vector ef(n); CppAD::vector xf(n); - + xf = OdeErrControl(method, ti, tf, xi, smin, smax, scur, eabs, erel, ef); diff -Nru cppad-2015.00.00.9/test_more/old_mat_mul.cpp cppad-2016.00.00.1/test_more/old_mat_mul.cpp --- cppad-2015.00.00.9/test_more/old_mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/old_mat_mul.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,267 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin old_mat_mul.cpp$$ +$spell + mul +$$ + +$section Old Matrix Multiply as a User Atomic Operation: Example and Test$$ + +$head Deprecated 2013-05-27$$ +This example has been deprecated; +see $cref atomic_mat_mul.cpp$$. + +$children% + test_more/old_mat_mul.hpp +%$$ +$head Include File$$ +This routine uses the include file $cref old_mat_mul.hpp$$. + +$code +$verbatim%test_more/old_mat_mul.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include +# include "old_mat_mul.hpp" + +bool old_mat_mul(void) +{ bool ok = true; + using CppAD::AD; + + // matrix sizes for this test + size_t nr_result = 2; + size_t n_middle = 2; + size_t nc_result = 2; + + // declare the AD vectors ax and ay and X + size_t n = nr_result * n_middle + n_middle * nc_result; + size_t m = nr_result * nc_result; + CppAD::vector< AD > X(4), ax(n), ay(m); + size_t i, j; + for(j = 0; j < X.size(); j++) + X[j] = (j + 1); + + // X is the vector of independent variables + CppAD::Independent(X); + // left matrix + ax[0] = X[0]; // left[0,0] = x[0] = 1 + ax[1] = X[1]; // left[0,1] = x[1] = 2 + ax[2] = 5.; // left[1,0] = 5 + ax[3] = 6.; // left[1,1] = 6 + // right matrix + ax[4] = X[2]; // right[0,0] = x[2] = 3 + ax[5] = 7.; // right[0,1] = 7 + ax[6] = X[3]; // right[1,0] = x[3] = 4 + ax[7] = 8.; // right[1,1] = 8 + /* + [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] + [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] + */ + + // The call back routines need to know the dimensions of the matrices. + // Store information about the matrix multiply for this call to mat_mul. + call_info info; + info.nr_result = nr_result; + info.n_middle = n_middle; + info.nc_result = nc_result; + // info.vx gets set by forward during call to mat_mul below + assert( info.vx.size() == 0 ); + size_t id = info_.size(); + info_.push_back(info); + + // user defined AD version of matrix multiply + mat_mul(id, ax, ay); + //---------------------------------------------------------------------- + // check AD results + ok &= ay[0] == (1*3 + 2*4); ok &= Variable( ay[0] ); + ok &= ay[1] == (1*7 + 2*8); ok &= Variable( ay[1] ); + ok &= ay[2] == (5*3 + 6*4); ok &= Variable( ay[2] ); + ok &= ay[3] == (5*7 + 6*8); ok &= Parameter( ay[3] ); + //---------------------------------------------------------------------- + // use mat_mul to define a function g : X -> ay + CppAD::ADFun G; + G.Dependent(X, ay); + // g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2 + 6*x3 , 5*7 + 6*8 ]^T + //---------------------------------------------------------------------- + // Test zero order forward mode evaluation of g(x) + CppAD::vector x( X.size() ), y(m); + for(j = 0; j < X.size() ; j++) + x[j] = j + 2; + y = G.Forward(0, x); + ok &= y[0] == x[0] * x[2] + x[1] * x[3]; + ok &= y[1] == x[0] * 7. + x[1] * 8.; + ok &= y[2] == 5. * x[2] + 6. * x[3]; + ok &= y[3] == 5. * 7. + 6. * 8.; + + //---------------------------------------------------------------------- + // Test first order forward mode evaluation of g'(x) * [1, 2, 3, 4]^T + // g'(x) = [ x2, x3, x0, x1 ] + // [ 7 , 8, 0, 0 ] + // [ 0 , 0, 5, 6 ] + // [ 0 , 0, 0, 0 ] + CppAD::vector dx( X.size() ), dy(m); + for(j = 0; j < X.size() ; j++) + dx[j] = j + 1; + dy = G.Forward(1, dx); + ok &= dy[0] == 1. * x[2] + 2. * x[3] + 3. * x[0] + 4. * x[1]; + ok &= dy[1] == 1. * 7. + 2. * 8. + 3. * 0. + 4. * 0.; + ok &= dy[2] == 1. * 0. + 2. * 0. + 3. * 5. + 4. * 6.; + ok &= dy[3] == 1. * 0. + 2. * 0. + 3. * 0. + 4. * 0.; + + //---------------------------------------------------------------------- + // Test second order forward mode + // g_0^2 (x) = [ 0, 0, 1, 0 ], g_0^2 (x) * [1] = [3] + // [ 0, 0, 0, 1 ] [2] [4] + // [ 1, 0, 0, 0 ] [3] [1] + // [ 0, 1, 0, 0 ] [4] [2] + CppAD::vector ddx( X.size() ), ddy(m); + for(j = 0; j < X.size() ; j++) + ddx[j] = 0.; + ddy = G.Forward(2, ddx); + // [1, 2, 3, 4] * g_0^2 (x) * [1, 2, 3, 4]^T = 1*3 + 2*4 + 3*1 + 4*2 + ok &= 2. * ddy[0] == 1. * 3. + 2. * 4. + 3. * 1. + 4. * 2.; + // for i > 0, [1, 2, 3, 4] * g_i^2 (x) * [1, 2, 3, 4]^T = 0 + ok &= ddy[1] == 0.; + ok &= ddy[2] == 0.; + ok &= ddy[3] == 0.; + + //---------------------------------------------------------------------- + // Test second order reverse mode + CppAD::vector w(m), dw(2 * X.size() ); + for(i = 0; i < m; i++) + w[i] = 0.; + w[0] = 1.; + dw = G.Reverse(2, w); + // g_0'(x) = [ x2, x3, x0, x1 ] + ok &= dw[0*2 + 0] == x[2]; + ok &= dw[1*2 + 0] == x[3]; + ok &= dw[2*2 + 0] == x[0]; + ok &= dw[3*2 + 0] == x[1]; + // g_0'(x) * [1, 2, 3, 4] = 1 * x2 + 2 * x3 + 3 * x0 + 4 * x1 + // g_0^2 (x) * [1, 2, 3, 4] = [3, 4, 1, 2] + ok &= dw[0*2 + 1] == 3.; + ok &= dw[1*2 + 1] == 4.; + ok &= dw[2*2 + 1] == 1.; + ok &= dw[3*2 + 1] == 2.; + + //---------------------------------------------------------------------- + // Test forward and reverse Jacobian sparsity pattern + /* + [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] + [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] + so the sparsity pattern should be + s[0] = {0, 1, 2, 3} + s[1] = {0, 1} + s[2] = {2, 3} + s[3] = {} + */ + CppAD::vector< std::set > r( X.size() ), s(m); + for(j = 0; j < X.size() ; j++) + { assert( r[j].empty() ); + r[j].insert(j); + } + s = G.ForSparseJac( X.size() , r); + for(j = 0; j < X.size() ; j++) + { // s[0] = {0, 1, 2, 3} + ok &= s[0].find(j) != s[0].end(); + // s[1] = {0, 1} + if( j == 0 || j == 1 ) + ok &= s[1].find(j) != s[1].end(); + else ok &= s[1].find(j) == s[1].end(); + // s[2] = {2, 3} + if( j == 2 || j == 3 ) + ok &= s[2].find(j) != s[2].end(); + else ok &= s[2].find(j) == s[2].end(); + } + // s[3] == {} + ok &= s[3].empty(); + + //---------------------------------------------------------------------- + // Test reverse Jacobian sparsity pattern + /* + [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] + [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] + so the sparsity pattern should be + r[0] = {0, 1, 2, 3} + r[1] = {0, 1} + r[2] = {2, 3} + r[3] = {} + */ + for(i = 0; i < m; i++) + { s[i].clear(); + s[i].insert(i); + } + r = G.RevSparseJac(m, s); + for(j = 0; j < X.size() ; j++) + { // r[0] = {0, 1, 2, 3} + ok &= r[0].find(j) != r[0].end(); + // r[1] = {0, 1} + if( j == 0 || j == 1 ) + ok &= r[1].find(j) != r[1].end(); + else ok &= r[1].find(j) == r[1].end(); + // r[2] = {2, 3} + if( j == 2 || j == 3 ) + ok &= r[2].find(j) != r[2].end(); + else ok &= r[2].find(j) == r[2].end(); + } + // r[3] == {} + ok &= r[3].empty(); + + //---------------------------------------------------------------------- + /* Test reverse Hessian sparsity pattern + g_0^2 (x) = [ 0, 0, 1, 0 ] and for i > 0, g_i^2 = 0 + [ 0, 0, 0, 1 ] + [ 1, 0, 0, 0 ] + [ 0, 1, 0, 0 ] + so for the sparsity pattern for the first component of g is + h[0] = {2} + h[1] = {3} + h[2] = {0} + h[3] = {1} + */ + CppAD::vector< std::set > h( X.size() ), t(1); + t[0].clear(); + t[0].insert(0); + h = G.RevSparseHes(X.size() , t); + size_t check[] = {2, 3, 0, 1}; + for(j = 0; j < X.size() ; j++) + { // h[j] = { check[j] } + for(i = 0; i < n; i++) + { if( i == check[j] ) + ok &= h[j].find(i) != h[j].end(); + else ok &= h[j].find(i) == h[j].end(); + } + } + t[0].clear(); + for( j = 1; j < X.size(); j++) + t[0].insert(j); + h = G.RevSparseHes(X.size() , t); + for(j = 0; j < X.size() ; j++) + { // h[j] = { } + for(i = 0; i < X.size(); i++) + ok &= h[j].find(i) == h[j].end(); + } + + // -------------------------------------------------------------------- + // Free temporary work space. (If there are future calls to + // old_mat_mul they would create new temporary work space.) + CppAD::user_atomic::clear(); + info_.clear(); + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/test_more/old_mat_mul.hpp cppad-2016.00.00.1/test_more/old_mat_mul.hpp --- cppad-2015.00.00.9/test_more/old_mat_mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/old_mat_mul.hpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,439 @@ +// $Id$ +# ifndef CPPAD_OLD_MAT_MUL_HPP +# define CPPAD_OLD_MAT_MUL_HPP + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin old_mat_mul.hpp$$ +$spell + old_mat_mul.hpp + cppad + CppAD + namespace + struct + nr + nc + bool + vx + const + im + mj + ij + px + py + std + tx + ty + resize + nz + var + jac + Jacobian + hes + vy +$$ + + +$section Define Matrix Multiply as a User Atomic Operation$$ +$mindex old_mat_mul old_atomic test$$ + + +$head Syntax$$ +This file is located in the $code example$$ directory. +It can be copied to the current working directory and included +with the syntax +$codei% + # include "old_mat_mul.hpp" +%$$ + +$head Example$$ +The file $cref old_mat_mul.cpp$$ contains an example use of +$code old_mat_mul.hpp$$. +It returns true if it succeeds and false otherwise. + +$head Begin Source$$ +$codep */ +# include // Include CppAD definitions +namespace { // Begin empty namespace + using CppAD::vector; // Let vector denote CppAD::vector +/* $$ + +$head Extra Call Information$$ +$codep */ + // Information we will attach to each mat_mul call + struct call_info { + size_t nr_result; + size_t n_middle; + size_t nc_result; + vector vx; + }; + vector info_; // vector of call information + + // number of orders for this operation (k + 1) + size_t n_order_ = 0; + // number of rows in the result matrix + size_t nr_result_ = 0; + // number of columns in left matrix and number of rows in right matrix + size_t n_middle_ = 0; + // number of columns in the result matrix + size_t nc_result_ = 0; + // which components of x are variables + vector* vx_ = CPPAD_NULL; + + // get the information corresponding to this call + void get_info(size_t id, size_t k, size_t n, size_t m) + { n_order_ = k + 1; + nr_result_ = info_[id].nr_result; + n_middle_ = info_[id].n_middle; + nc_result_ = info_[id].nc_result; + vx_ = &(info_[id].vx); + + assert(n == nr_result_ * n_middle_ + n_middle_ * nc_result_); + assert(m == nr_result_ * nc_result_); + } + +/* $$ +$head Matrix Indexing$$ +$codep */ + // Convert left matrix index pair and order to a single argument index + size_t left(size_t i, size_t j, size_t ell) + { assert( i < nr_result_ ); + assert( j < n_middle_ ); + return (i * n_middle_ + j) * n_order_ + ell; + } + // Convert right matrix index pair and order to a single argument index + size_t right(size_t i, size_t j, size_t ell) + { assert( i < n_middle_ ); + assert( j < nc_result_ ); + size_t offset = nr_result_ * n_middle_; + return (offset + i * nc_result_ + j) * n_order_ + ell; + } + // Convert result matrix index pair and order to a single result index + size_t result(size_t i, size_t j, size_t ell) + { assert( i < nr_result_ ); + assert( j < nc_result_ ); + return (i * nc_result_ + j) * n_order_ + ell; + } +/* $$ + +$head One Matrix Multiply$$ +Forward mode matrix multiply left times right and sum into result: +$codep */ + void multiply_and_sum( + size_t order_left , + size_t order_right, + const vector& tx , + vector& ty ) + { size_t i, j; + size_t order_result = order_left + order_right; + for(i = 0; i < nr_result_; i++) + { for(j = 0; j < nc_result_; j++) + { double sum = 0.; + size_t middle, im_left, mj_right, ij_result; + for(middle = 0; middle < n_middle_; middle++) + { im_left = left(i, middle, order_left); + mj_right = right(middle, j, order_right); + sum += tx[im_left] * tx[mj_right]; + } + ij_result = result(i, j, order_result); + ty[ ij_result ] += sum; + } + } + return; + } +/* $$ + +$head Reverse Partials One Order$$ +Compute reverse mode partials for one order and sum into px: +$codep */ + void reverse_multiply( + size_t order_left , + size_t order_right, + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) + { size_t i, j; + size_t order_result = order_left + order_right; + for(i = 0; i < nr_result_; i++) + { for(j = 0; j < nc_result_; j++) + { size_t middle, im_left, mj_right, ij_result; + for(middle = 0; middle < n_middle_; middle++) + { ij_result = result(i, j, order_result); + im_left = left(i, middle, order_left); + mj_right = right(middle, j, order_right); + // sum += tx[im_left] * tx[mj_right]; + px[im_left] += tx[mj_right] * py[ij_result]; + px[mj_right] += tx[im_left] * py[ij_result]; + } + } + } + return; + } +/* $$ +$head Set Union$$ +$codep */ + void my_union( + std::set& result , + const std::set& left , + const std::set& right ) + { std::set temp; + std::set_union( + left.begin() , + left.end() , + right.begin() , + right.end() , + std::inserter(temp, temp.begin()) + ); + result.swap(temp); + } +/* $$ + +$head CppAD User Atomic Callback Functions$$ +$codep */ + // ---------------------------------------------------------------------- + // forward mode routine called by CppAD + bool mat_mul_forward( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { size_t i, j, ell; + get_info(id, k, n, m); + + // check if this is during the call to mat_mul(id, ax, ay) + if( vx.size() > 0 ) + { assert( k == 0 && vx.size() > 0 ); + + // store the vx information in info_ + assert( vx_->size() == 0 ); + info_[id].vx.resize(n); + for(j = 0; j < n; j++) + info_[id].vx[j] = vx[j]; + assert( vx_->size() == n ); + + // now compute vy + for(i = 0; i < nr_result_; i++) + { for(j = 0; j < nc_result_; j++) + { // compute vy[ result(i, j, 0) ] + bool var = false; + bool nz_left, nz_right; + size_t middle, im_left, mj_right, ij_result; + for(middle = 0; middle < n_middle_; middle++) + { im_left = left(i, middle, k); + mj_right = right(middle, j, k); + nz_left = vx[im_left] | (tx[im_left] != 0.); + nz_right = vx[mj_right] | (tx[mj_right]!= 0.); + // if not multiplying by the constant zero + if( nz_left & nz_right ) + var |= (vx[im_left] | vx[mj_right]); + } + ij_result = result(i, j, k); + vy[ij_result] = var; + } + } + } + + // initialize result as zero + for(i = 0; i < nr_result_; i++) + { for(j = 0; j < nc_result_; j++) + ty[ result(i, j, k) ] = 0.; + } + // sum the product of proper orders + for(ell = 0; ell <=k; ell++) + multiply_and_sum(ell, k-ell, tx, ty); + + // All orders are implemented and there are no possible error + // conditions, so always return true. + return true; + } + // ---------------------------------------------------------------------- + // reverse mode routine called by CppAD + bool mat_mul_reverse( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { get_info(id, k, n, m); + + size_t ell = n * n_order_; + while(ell--) + px[ell] = 0.; + + size_t order = n_order_; + while(order--) + { // reverse sum the products for specified order + for(ell = 0; ell <=order; ell++) + reverse_multiply(ell, order-ell, tx, ty, px, py); + } + + // All orders are implemented and there are no possible error + // conditions, so always return true. + return true; + } + + // ---------------------------------------------------------------------- + // forward Jacobian sparsity routine called by CppAD + bool mat_mul_for_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + vector< std::set >& s ) + { size_t i, j, k, im_left, middle, mj_right, ij_result; + k = 0; + get_info(id, k, n, m); + + for(i = 0; i < nr_result_; i++) + { for(j = 0; j < nc_result_; j++) + { ij_result = result(i, j, k); + s[ij_result].clear(); + for(middle = 0; middle < n_middle_; middle++) + { im_left = left(i, middle, k); + mj_right = right(middle, j, k); + + // s[ij_result] = union( s[ij_result], r[im_left] ) + my_union(s[ij_result], s[ij_result], r[im_left]); + + // s[ij_result] = union( s[ij_result], r[mj_right] ) + my_union(s[ij_result], s[ij_result], r[mj_right]); + } + } + } + return true; + } + // ---------------------------------------------------------------------- + // reverse Jacobian sparsity routine called by CppAD + bool mat_mul_rev_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + vector< std::set >& r , + const vector< std::set >& s ) + { size_t i, j, k, im_left, middle, mj_right, ij_result; + k = 0; + get_info(id, k, n, m); + + for(j = 0; j < n; j++) + r[j].clear(); + + for(i = 0; i < nr_result_; i++) + { for(j = 0; j < nc_result_; j++) + { ij_result = result(i, j, k); + for(middle = 0; middle < n_middle_; middle++) + { im_left = left(i, middle, k); + mj_right = right(middle, j, k); + + // r[im_left] = union( r[im_left], s[ij_result] ) + my_union(r[im_left], r[im_left], s[ij_result]); + + // r[mj_right] = union( r[mj_right], s[ij_result] ) + my_union(r[mj_right], r[mj_right], s[ij_result]); + } + } + } + return true; + } + // ---------------------------------------------------------------------- + // reverse Hessian sparsity routine called by CppAD + bool mat_mul_rev_hes_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + const vector& s , + vector& t , + const vector< std::set >& u , + vector< std::set >& v ) + { size_t i, j, k, im_left, middle, mj_right, ij_result; + k = 0; + get_info(id, k, n, m); + + for(j = 0; j < n; j++) + { t[j] = false; + v[j].clear(); + } + + assert( vx_->size() == n ); + for(i = 0; i < nr_result_; i++) + { for(j = 0; j < nc_result_; j++) + { ij_result = result(i, j, k); + for(middle = 0; middle < n_middle_; middle++) + { im_left = left(i, middle, k); + mj_right = right(middle, j, k); + + // back propagate Jacobian sparsity + t[im_left] = (t[im_left] | s[ij_result]); + t[mj_right] = (t[mj_right] | s[ij_result]); + // Visual Studio C++ 2008 warns unsafe mix of int and + // bool if we use the following code directly above: + // t[im_left] |= s[ij_result]; + // t[mj_right] |= s[ij_result]; + + // back propagate Hessian sparsity + // v[im_left] = union( v[im_left], u[ij_result] ) + // v[mj_right] = union( v[mj_right], u[ij_result] ) + my_union(v[im_left], v[im_left], u[ij_result] ); + my_union(v[mj_right], v[mj_right], u[ij_result] ); + + // Check for case where the (i,j) result element + // is in reverse Jacobian and both left and right + // operands in multiplication are variables + if(s[ij_result] & (*vx_)[im_left] & (*vx_)[mj_right]) + { // v[im_left] = union( v[im_left], r[mj_right] ) + my_union(v[im_left], v[im_left], r[mj_right] ); + // v[mj_right] = union( v[mj_right], r[im_left] ) + my_union(v[mj_right], v[mj_right], r[im_left] ); + } + } + } + } + return true; + } +/* $$ + +$head Declare mat_mul Function$$ +Declare the $code AD$$ routine $codei%mat_mul(%id%, %ax%, %ay%)%$$ +and end empty namespace +(we could use any $cref/simple vector template class/SimpleVector/$$ +instead of $code CppAD::vector$$): +$codep */ + CPPAD_USER_ATOMIC( + mat_mul , + CppAD::vector , + double , + mat_mul_forward , + mat_mul_reverse , + mat_mul_for_jac_sparse , + mat_mul_rev_jac_sparse , + mat_mul_rev_hes_sparse + ) +} // End empty namespace +/* $$ +$end +*/ + +# endif diff -Nru cppad-2015.00.00.9/test_more/old_reciprocal.cpp cppad-2016.00.00.1/test_more/old_reciprocal.cpp --- cppad-2015.00.00.9/test_more/old_reciprocal.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/old_reciprocal.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -0,0 +1,371 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin old_reciprocal.cpp$$ +$section Old Atomic Operation Reciprocal: Example and Test$$ + +$head Deprecated 2013-05-27$$ +This example has been deprecated; +see $cref atomic_reciprocal.cpp$$ instead. + +$head Theory$$ +The example below defines the user atomic function +$latex f : \B{R}^n \rightarrow \B{R}^m$$ where +$latex n = 1$$, $latex m = 1$$, and $latex f(x) = 1 / x$$. + +$code +$verbatim%test_more/old_reciprocal.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include + +namespace { // Begin empty namespace + using CppAD::vector; + // ---------------------------------------------------------------------- + // a utility to compute the union of two sets. + void my_union( + std::set& result , + const std::set& left , + const std::set& right ) + { std::set temp; + std::set_union( + left.begin() , + left.end() , + right.begin() , + right.end() , + std::inserter(temp, temp.begin()) + ); + result.swap(temp); + } + + // ---------------------------------------------------------------------- + // forward mode routine called by CppAD + bool reciprocal_forward( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + assert( k == 0 || vx.size() == 0 ); + bool ok = false; + double f, fp, fpp; + + // Must always define the case k = 0. + // Do not need case k if not using f.Forward(q, xp) for q >= k. + switch(k) + { case 0: + // this case must be implemented + if( vx.size() > 0 ) + vy[0] = vx[0]; + // y^0 = f( x^0 ) = 1 / x^0 + ty[0] = 1. / tx[0]; + ok = true; + break; + + case 1: + // needed if first order forward mode is used + assert( vx.size() == 0 ); + // y^1 = f'( x^0 ) x^1 + f = ty[0]; + fp = - f / tx[0]; + ty[1] = fp * tx[1]; + ok = true; + break; + + case 2: + // needed if second order forward mode is used + assert( vx.size() == 0 ); + // Y''(t) = X'(t)^\R{T} f''[X(t)] X'(t) + f'[X(t)] X''(t) + // 2 y^2 = x^1 * f''( x^0 ) x^1 + 2 f'( x^0 ) x^2 + f = ty[0]; + fp = - f / tx[0]; + fpp = - 2.0 * fp / tx[0]; + ty[2] = tx[1] * fpp * tx[1] / 2.0 + fp * tx[2]; + ok = true; + break; + } + return ok; + } + // ---------------------------------------------------------------------- + // reverse mode routine called by CppAD + bool reciprocal_reverse( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { // Do not need case k if not using f.Reverse(k+1, w). + assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + bool ok = false; + + double f, fp, fpp, fppp; + switch(k) + { case 0: + // needed if first order reverse mode is used + // reverse: F^0 ( tx ) = y^0 = f( x^0 ) + f = ty[0]; + fp = - f / tx[0]; + px[0] = py[0] * fp;; + ok = true; + break; + + case 1: + // needed if second order reverse mode is used + // reverse: F^1 ( tx ) = y^1 = f'( x^0 ) x^1 + f = ty[0]; + fp = - f / tx[0]; + fpp = - 2.0 * fp / tx[0]; + px[1] = py[1] * fp; + px[0] = py[1] * fpp * tx[1]; + // reverse: F^0 ( tx ) = y^0 = f( x^0 ); + px[0] += py[0] * fp; + + ok = true; + break; + + case 2: + // needed if third order reverse mode is used + // reverse: F^2 ( tx ) = y^2 = + // = x^1 * f''( x^0 ) x^1 / 2 + f'( x^0 ) x^2 + f = ty[0]; + fp = - f / tx[0]; + fpp = - 2.0 * fp / tx[0]; + fppp = - 3.0 * fpp / tx[0]; + px[2] = py[2] * fp; + px[1] = py[2] * fpp * tx[1]; + px[0] = py[2] * tx[1] * fppp * tx[1] / 2.0 + fpp * tx[2]; + // reverse: F^1 ( tx ) = y^1 = f'( x^0 ) x^1 + px[1] += py[1] * fp; + px[0] += py[1] * fpp * tx[1]; + // reverse: F^0 ( tx ) = y^0 = f( x^0 ); + px[0] += py[0] * fp; + + ok = true; + break; + } + return ok; + } + // ---------------------------------------------------------------------- + // forward Jacobian sparsity routine called by CppAD + bool reciprocal_for_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + vector< std::set >& s ) + { // Can just return false if not using f.ForSparseJac + assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + + // sparsity for S(x) = f'(x) * R is same as sparsity for R + s[0] = r[0]; + + return true; + } + // ---------------------------------------------------------------------- + // reverse Jacobian sparsity routine called by CppAD + bool reciprocal_rev_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + vector< std::set >& r , + const vector< std::set >& s ) + { // Can just return false if not using RevSparseJac. + assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + + // sparsity for R(x) = S * f'(x) is same as sparsity for S + for(size_t q = 0; q < p; q++) + r[q] = s[q]; + + return true; + } + // ---------------------------------------------------------------------- + // reverse Hessian sparsity routine called by CppAD + bool reciprocal_rev_hes_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + const vector& s , + vector& t , + const vector< std::set >& u , + vector< std::set >& v ) + { // Can just return false if not use RevSparseHes. + assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + + // sparsity for T(x) = S(x) * f'(x) is same as sparsity for S + t[0] = s[0]; + + // V(x) = [ f'(x)^T * g''(y) * f'(x) + g'(y) * f''(x) ] * R + // U(x) = g''(y) * f'(x) * R + // S(x) = g'(y) + + // back propagate the sparsity for U because derivative of + // reciprocal may be non-zero + v[0] = u[0]; + + // convert forward Jacobian sparsity to Hessian sparsity + // because second derivative of reciprocal may be non-zero + if( s[0] ) + my_union(v[0], v[0], r[0] ); + + + return true; + } + // --------------------------------------------------------------------- + // Declare the AD routine reciprocal(id, ax, ay) + CPPAD_USER_ATOMIC( + reciprocal , + CppAD::vector , + double , + reciprocal_forward , + reciprocal_reverse , + reciprocal_for_jac_sparse , + reciprocal_rev_jac_sparse , + reciprocal_rev_hes_sparse + ) +} // End empty namespace + +bool old_reciprocal(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // -------------------------------------------------------------------- + // Create the function f(x) + // + // domain space vector + size_t n = 1; + double x0 = 0.5; + vector< AD > ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + vector< AD > ay(m); + + // call user function and store reciprocal(x) in au[0] + vector< AD > au(m); + size_t id = 0; // not used + reciprocal(id, ax, au); // u = 1 / x + + // call user function and store reciprocal(u) in ay[0] + reciprocal(id, au, ay); // y = 1 / u = x + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, ay); // f(x) = x + + // -------------------------------------------------------------------- + // Check forward mode results + // + // check function value + double check = x0; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector x_q(n), y_q(m); + q = 0; + x_q[0] = x0; + y_q = f.Forward(q, x_q); + ok &= NearEqual(y_q[0] , check, eps, eps); + + // check first order forward mode + q = 1; + x_q[0] = 1; + y_q = f.Forward(q, x_q); + check = 1.; + ok &= NearEqual(y_q[0] , check, eps, eps); + + // check second order forward mode + q = 2; + x_q[0] = 0; + y_q = f.Forward(q, x_q); + check = 0.; + ok &= NearEqual(y_q[0] , check, eps, eps); + + // -------------------------------------------------------------------- + // Check reverse mode results + // + // third order reverse mode + q = 3; + vector w(m), dw(n * q); + w[0] = 1.; + dw = f.Reverse(q, w); + check = 1.; + ok &= NearEqual(dw[0] , check, eps, eps); + check = 0.; + ok &= NearEqual(dw[1] , check, eps, eps); + ok &= NearEqual(dw[2] , check, eps, eps); + + // -------------------------------------------------------------------- + // forward mode sparstiy pattern + size_t p = n; + CppAD::vectorBool r1(n * p), s1(m * p); + r1[0] = true; // compute sparsity pattern for x[0] + s1 = f.ForSparseJac(p, r1); + ok &= s1[0] == true; // f[0] depends on x[0] + + // -------------------------------------------------------------------- + // reverse mode sparstiy pattern + q = m; + CppAD::vectorBool s2(q * m), r2(q * n); + s2[0] = true; // compute sparsity pattern for f[0] + r2 = f.RevSparseJac(q, s2); + ok &= r2[0] == true; // f[0] depends on x[0] + + // -------------------------------------------------------------------- + // Hessian sparsity (using previous ForSparseJac call) + CppAD::vectorBool s3(m), h(p * n); + s3[0] = true; // compute sparsity pattern for f[0] + h = f.RevSparseHes(p, s3); + ok &= h[0] == true; // second partial of f[0] w.r.t. x[0] may be non-zero + + // ----------------------------------------------------------------- + // Free all temporary work space associated with old_atomic objects. + // (If there are future calls to user atomic functions, they will + // create new temporary work space.) + CppAD::user_atomic::clear(); + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/test_more/old_tan.cpp cppad-2016.00.00.1/test_more/old_tan.cpp --- cppad-2015.00.00.9/test_more/old_tan.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/old_tan.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,423 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin old_tan.cpp$$ +$spell + Tanh +$$ + +$section Old Tan and Tanh as User Atomic Operations: Example and Test$$ + +$head Deprecated 2013-05-27$$ +This example has not deprecated; +see $cref atomic_tangent.cpp$$ instead. + +$head Theory$$ +The code below uses the $cref tan_forward$$ and $cref tan_reverse$$ +to implement the tangent ($icode%id% == 0%$$) and hyperbolic tangent +($icode%id% == 1%$$) functions as user atomic operations. + +$code +$verbatim%test_more/old_tan.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include + +namespace { // Begin empty namespace + using CppAD::vector; + + // a utility to compute the union of two sets. + void my_union( + std::set& result , + const std::set& left , + const std::set& right ) + { std::set temp; + std::set_union( + left.begin() , + left.end() , + right.begin() , + right.end() , + std::inserter(temp, temp.begin()) + ); + result.swap(temp); + } + + // ---------------------------------------------------------------------- + // forward mode routine called by CppAD + bool old_tan_forward( + size_t id , + size_t order , + size_t n , + size_t m , + const vector& vx , + vector& vzy , + const vector& tx , + vector& tzy + ) + { + assert( id == 0 || id == 1 ); + assert( n == 1 ); + assert( m == 2 ); + assert( tx.size() >= (order+1) * n ); + assert( tzy.size() >= (order+1) * m ); + + size_t n_order = order + 1; + size_t j = order; + size_t k; + + // check if this is during the call to old_tan(id, ax, ay) + if( vx.size() > 0 ) + { assert( vx.size() >= n ); + assert( vzy.size() >= m ); + + // now setvzy + vzy[0] = vx[0]; + vzy[1] = vx[0]; + } + + if( j == 0 ) + { // z^{(0)} = tan( x^{(0)} ) or tanh( x^{(0)} ) + if( id == 0 ) + tzy[0] = tan( tx[0] ); + else tzy[0] = tanh( tx[0] ); + + // y^{(0)} = z^{(0)} * z^{(0)} + tzy[n_order + 0] = tzy[0] * tzy[0]; + } + else + { float j_inv = 1.f / float(j); + if( id == 1 ) + j_inv = - j_inv; + + // z^{(j)} = x^{(j)} +- sum_{k=1}^j k x^{(k)} y^{(j-k)} / j + tzy[j] = tx[j]; + for(k = 1; k <= j; k++) + tzy[j] += tx[k] * tzy[n_order + j-k] * k * j_inv; + + // y^{(j)} = sum_{k=0}^j z^{(k)} z^{(j-k)} + tzy[n_order + j] = 0.; + for(k = 0; k <= j; k++) + tzy[n_order + j] += tzy[k] * tzy[j-k]; + } + + // All orders are implemented and there are no possible errors + return true; + } + // ---------------------------------------------------------------------- + // reverse mode routine called by CppAD + bool old_tan_reverse( + size_t id , + size_t order , + size_t n , + size_t m , + const vector& tx , + const vector& tzy , + vector& px , + const vector& pzy + ) + { + assert( id == 0 || id == 1 ); + assert( n == 1 ); + assert( m == 2 ); + assert( tx.size() >= (order+1) * n ); + assert( tzy.size() >= (order+1) * m ); + assert( px.size() >= (order+1) * n ); + assert( pzy.size() >= (order+1) * m ); + + size_t n_order = order + 1; + size_t j, k; + + // copy because partials w.r.t. y and z need to change + vector qzy = pzy; + + // initialize accumultion of reverse mode partials + for(k = 0; k < n_order; k++) + px[k] = 0.; + + // eliminate positive orders + for(j = order; j > 0; j--) + { float j_inv = 1.f / float(j); + if( id == 1 ) + j_inv = - j_inv; + + // H_{x^{(k)}} += delta(j-k) +- H_{z^{(j)} y^{(j-k)} * k / j + px[j] += qzy[j]; + for(k = 1; k <= j; k++) + px[k] += qzy[j] * tzy[n_order + j-k] * k * j_inv; + + // H_{y^{j-k)} += +- H_{z^{(j)} x^{(k)} * k / j + for(k = 1; k <= j; k++) + qzy[n_order + j-k] += qzy[j] * tx[k] * k * j_inv; + + // H_{z^{(k)}} += H_{y^{(j-1)}} * z^{(j-k-1)} * 2. + for(k = 0; k < j; k++) + qzy[k] += qzy[n_order + j-1] * tzy[j-k-1] * 2.f; + } + + // eliminate order zero + if( id == 0 ) + px[0] += qzy[0] * (1.f + tzy[n_order + 0]); + else + px[0] += qzy[0] * (1.f - tzy[n_order + 0]); + + return true; + } + // ---------------------------------------------------------------------- + // forward Jacobian sparsity routine called by CppAD + bool old_tan_for_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + vector< std::set >& s ) + { + assert( n == 1 ); + assert( m == 2 ); + assert( id == 0 || id == 1 ); + assert( r.size() >= n ); + assert( s.size() >= m ); + + // sparsity for z and y are the same as for x + s[0] = r[0]; + s[1] = r[0]; + + return true; + } + // ---------------------------------------------------------------------- + // reverse Jacobian sparsity routine called by CppAD + bool old_tan_rev_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + vector< std::set >& r , + const vector< std::set >& s ) + { + assert( n == 1 ); + assert( m == 2 ); + assert( id == 0 || id == 1 ); + assert( r.size() >= n ); + assert( s.size() >= m ); + + // note that, if the users code only uses z, and not y, + // we could just set r[0] = s[0] + my_union(r[0], s[0], s[1]); + return true; + } + // ---------------------------------------------------------------------- + // reverse Hessian sparsity routine called by CppAD + bool old_tan_rev_hes_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + const vector& s , + vector& t , + const vector< std::set >& u , + vector< std::set >& v ) + { + assert( n == 1 ); + assert( m == 2 ); + assert( id == 0 || id == 1 ); + assert( r.size() >= n ); + assert( s.size() >= m ); + assert( t.size() >= n ); + assert( u.size() >= m ); + assert( v.size() >= n ); + + // back propagate Jacobian sparsity. If users code only uses z, + // we could just set t[0] = s[0]; + t[0] = s[0] | s[1]; + + // back propagate Hessian sparsity, ... + my_union(v[0], u[0], u[1]); + + // convert forward Jacobian sparsity to Hessian sparsity + // because tan and tanh are nonlinear + if( t[0] ) + my_union(v[0], v[0], r[0]); + + return true; + } + // --------------------------------------------------------------------- + // Declare the AD routine old_tan(id, ax, ay) + CPPAD_USER_ATOMIC( + old_tan , + CppAD::vector , + float , + old_tan_forward , + old_tan_reverse , + old_tan_for_jac_sparse , + old_tan_rev_jac_sparse , + old_tan_rev_hes_sparse + ) +} // End empty namespace + +bool old_tan(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + float eps = 10.f * CppAD::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + float x0 = 0.5; + CppAD::vector< AD > ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 3; + CppAD::vector< AD > af(m); + + // temporary vector for old_tan computations + // (old_tan computes tan or tanh and its square) + CppAD::vector< AD > az(2); + + // call user tan function and store tan(x) in f[0] (ignore tan(x)^2) + size_t id = 0; + old_tan(id, ax, az); + af[0] = az[0]; + + // call user tanh function and store tanh(x) in f[1] (ignore tanh(x)^2) + id = 1; + old_tan(id, ax, az); + af[1] = az[0]; + + // put a constant in f[2] = tanh(1.) (for sparsity pattern testing) + CppAD::vector< AD > one(1); + one[0] = 1.; + old_tan(id, one, az); + af[2] = az[0]; + + // create f: x -> f and stop tape recording + CppAD::ADFun F; + F.Dependent(ax, af); + + // check function value + float tan = std::tan(x0); + ok &= NearEqual(af[0] , tan, eps, eps); + float tanh = std::tanh(x0); + ok &= NearEqual(af[1] , tanh, eps, eps); + + // check zero order forward + CppAD::vector x(n), f(m); + x[0] = x0; + f = F.Forward(0, x); + ok &= NearEqual(f[0] , tan, eps, eps); + ok &= NearEqual(f[1] , tanh, eps, eps); + + // compute first partial of f w.r.t. x[0] using forward mode + CppAD::vector dx(n), df(m); + dx[0] = 1.; + df = F.Forward(1, dx); + + // compute derivative of tan - tanh using reverse mode + CppAD::vector w(m), dw(n); + w[0] = 1.; + w[1] = 1.; + w[2] = 0.; + dw = F.Reverse(1, w); + + // tan'(x) = 1 + tan(x) * tan(x) + // tanh'(x) = 1 - tanh(x) * tanh(x) + float tanp = 1.f + tan * tan; + float tanhp = 1.f - tanh * tanh; + ok &= NearEqual(df[0], tanp, eps, eps); + ok &= NearEqual(df[1], tanhp, eps, eps); + ok &= NearEqual(dw[0], w[0]*tanp + w[1]*tanhp, eps, eps); + + // compute second partial of f w.r.t. x[0] using forward mode + CppAD::vector ddx(n), ddf(m); + ddx[0] = 0.; + ddf = F.Forward(2, ddx); + + // compute second derivative of tan - tanh using reverse mode + CppAD::vector ddw(2); + ddw = F.Reverse(2, w); + + // tan''(x) = 2 * tan(x) * tan'(x) + // tanh''(x) = - 2 * tanh(x) * tanh'(x) + // Note that second order Taylor coefficient for u half the + // corresponding second derivative. + float two = 2; + float tanpp = two * tan * tanp; + float tanhpp = - two * tanh * tanhp; + ok &= NearEqual(two * ddf[0], tanpp, eps, eps); + ok &= NearEqual(two * ddf[1], tanhpp, eps, eps); + ok &= NearEqual(ddw[0], w[0]*tanp + w[1]*tanhp , eps, eps); + ok &= NearEqual(ddw[1], w[0]*tanpp + w[1]*tanhpp, eps, eps); + + // Forward mode computation of sparsity pattern for F. + size_t p = n; + // user vectorBool because m and n are small + CppAD::vectorBool r1(p), s1(m * p); + r1[0] = true; // propagate sparsity for x[0] + s1 = F.ForSparseJac(p, r1); + ok &= (s1[0] == true); // f[0] depends on x[0] + ok &= (s1[1] == true); // f[1] depends on x[0] + ok &= (s1[2] == false); // f[2] does not depend on x[0] + + // Reverse mode computation of sparsity pattern for F. + size_t q = m; + CppAD::vectorBool s2(q * m), r2(q * n); + // Sparsity pattern for identity matrix + size_t i, j; + for(i = 0; i < q; i++) + { for(j = 0; j < m; j++) + s2[i * q + j] = (i == j); + } + r2 = F.RevSparseJac(q, s2); + ok &= (r2[0] == true); // f[0] depends on x[0] + ok &= (r2[1] == true); // f[1] depends on x[0] + ok &= (r2[2] == false); // f[2] does not depend on x[0] + + // Hessian sparsity for f[0] + CppAD::vectorBool s3(m), h(p * n); + s3[0] = true; + s3[1] = false; + s3[2] = false; + h = F.RevSparseHes(p, s3); + ok &= (h[0] == true); // Hessian is non-zero + + // Hessian sparsity for f[2] + s3[0] = false; + s3[2] = true; + h = F.RevSparseHes(p, s3); + ok &= (h[0] == false); // Hessian is zero + + // check tanh results for a large value of x + x[0] = std::numeric_limits::max() / two; + f = F.Forward(0, x); + tanh = 1.; + ok &= NearEqual(f[1], tanh, eps, eps); + df = F.Forward(1, dx); + tanhp = 0.; + ok &= NearEqual(df[1], tanhp, eps, eps); + + // -------------------------------------------------------------------- + // Free all temporary work space associated with old_atomic objects. + // (If there are future calls to user atomic functions, they will + // create new temporary work space.) + CppAD::user_atomic::clear(); + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/test_more/old_usead_1.cpp cppad-2016.00.00.1/test_more/old_usead_1.cpp --- cppad-2015.00.00.9/test_more/old_usead_1.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/old_usead_1.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,369 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin old_usead_1.cpp$$ +$spell + checkpoint + var +$$ + +$section Using AD to Compute Atomic Function Derivatives$$ +$mindex inside user checkpoint$$ + +$head Deprecated 2013-05-27$$ +This example has been deprecated because it is easier to use the +$cref checkpoint$$ class instead. + +$head Purpose$$ +Consider the case where an inner function is used repeatedly in the +definition of an outer function. +In this case, it may reduce the number of variables +$cref/size_var/seq_property/size_var/$$, +and hence the required memory. + +$head Simple Case$$ +This example is the same as $cref old_reciprocal.cpp$$, except that it +uses AD to compute the +derivatives needed by an atomic function. +This is a simple example of an inner function, and hence not really +useful for the purpose above; +see $cref old_usead_2.cpp$$ for a more complete example. + +$code +$verbatim%test_more/old_usead_1.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include + +namespace { // Begin empty namespace + using CppAD::AD; + using CppAD::ADFun; + using CppAD::vector; + + // ---------------------------------------------------------------------- + // function that computes reciprocal + ADFun* r_ptr_; + void create_r(void) + { vector< AD > ax(1), ay(1); + ax[0] = 1; + CppAD::Independent(ax); + ay[0] = 1.0 / ax[0]; + r_ptr_ = new ADFun(ax, ay); + } + void destroy_r(void) + { delete r_ptr_; + r_ptr_ = CPPAD_NULL; + } + + // ---------------------------------------------------------------------- + // forward mode routine called by CppAD + bool reciprocal_forward( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + assert( k == 0 || vx.size() == 0 ); + bool ok = true; + vector x_q(1), y_q(1); + + // check for special case + if( vx.size() > 0 ) + vy[0] = vx[0]; + + // make sure r_ has proper lower order Taylor coefficients stored + // then compute ty[k] + for(size_t q = 0; q <= k; q++) + { x_q[0] = tx[q]; + y_q = r_ptr_->Forward(q, x_q); + if( q == k ) + ty[k] = y_q[0]; + assert( q == k || ty[q] == y_q[0] ); + } + return ok; + } + // ---------------------------------------------------------------------- + // reverse mode routine called by CppAD + bool reciprocal_reverse( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + bool ok = true; + vector x_q(1), w(k+1), dw(k+1); + + // make sure r_ has proper forward mode coefficients + size_t q; + for(q = 0; q <= k; q++) + { x_q[0] = tx[q]; +# ifdef NDEBUG + r_ptr_->Forward(q, x_q); +# else + vector y_q(1); + y_q = r_ptr_->Forward(q, x_q); + assert( ty[q] == y_q[0] ); +# endif + } + for(q = 0; q <=k; q++) + w[q] = py[q]; + dw = r_ptr_->Reverse(k+1, w); + for(q = 0; q <=k; q++) + px[q] = dw[q]; + + return ok; + } + // ---------------------------------------------------------------------- + // forward Jacobian sparsity routine called by CppAD + bool reciprocal_for_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + vector< std::set >& s ) + { assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + bool ok = true; + + vector< std::set > R(1), S(1); + R[0] = r[0]; + S = r_ptr_->ForSparseJac(p, R); + s[0] = S[0]; + + return ok; + } + // ---------------------------------------------------------------------- + // reverse Jacobian sparsity routine called by CppAD + bool reciprocal_rev_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + vector< std::set >& r , + const vector< std::set >& s ) + { + assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + bool ok = true; + + vector< std::set > R(p), S(p); + size_t q; + for(q = 0; q < p; q++) + S[q] = s[q]; + R = r_ptr_->RevSparseJac(p, S); + for(q = 0; q < p; q++) + r[q] = R[q]; + + return ok; + } + // ---------------------------------------------------------------------- + // reverse Hessian sparsity routine called by CppAD + bool reciprocal_rev_hes_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + const vector& s , + vector& t , + const vector< std::set >& u , + vector< std::set >& v ) + { // Can just return false if not use RevSparseHes. + assert( id == 0 ); + assert( n == 1 ); + assert( m == 1 ); + bool ok = true; + + // compute sparsity pattern for T(x) = S(x) * f'(x) + vector T(1), S(1); + S[0] = s[0]; + T = r_ptr_->RevSparseJac(1, S); + t[0] = T[0]; + + // compute sparsity pattern for A(x) = U(x)^T * f'(x) + vector Ut(p), A(p); + size_t q; + for(q = 0; q < p; q++) + Ut[q] = false; + std::set::iterator itr; + for(itr = u[0].begin(); itr != u[0].end(); itr++) + Ut[*itr] = true; + A = r_ptr_-> RevSparseJac(p, Ut); + + // compute sparsity pattern for H(x) = R^T * (S * F)''(x) + vector H(p), R(n); + for(q = 0; q < p; q++) + R[q] = false; + for(itr = r[0].begin(); itr != r[0].end(); itr++) + R[*itr] = true; + r_ptr_->ForSparseJac(p, R); + H = r_ptr_->RevSparseHes(p, S); + + // compute sparsity pattern for V(x) = A(x)^T + H(x)^T + v[0].clear(); + for(q = 0; q < p; q++) + if( A[q] | H[q] ) + v[0].insert(q); + + return ok; + } + // --------------------------------------------------------------------- + // Declare the AD routine reciprocal(id, ax, ay) + CPPAD_USER_ATOMIC( + reciprocal , + CppAD::vector , + double , + reciprocal_forward , + reciprocal_reverse , + reciprocal_for_jac_sparse , + reciprocal_rev_jac_sparse , + reciprocal_rev_hes_sparse + ) +} // End empty namespace + +bool old_usead_1(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // -------------------------------------------------------------------- + // Create the ADFun r_ + create_r(); + + // -------------------------------------------------------------------- + // Create the function f(x) + // + // domain space vector + size_t n = 1; + double x0 = 0.5; + vector< AD > ax(n); + ax[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + vector< AD > ay(m); + + // call user function and store reciprocal(x) in au[0] + vector< AD > au(m); + size_t id = 0; // not used + reciprocal(id, ax, au); // u = 1 / x + + // call user function and store reciprocal(u) in ay[0] + reciprocal(id, au, ay); // y = 1 / u = x + + // create f: x -> y and stop tape recording + ADFun f; + f.Dependent(ax, ay); // f(x) = x + + // -------------------------------------------------------------------- + // Check function value results + // + // check function value + double check = x0; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector x_q(n), y_q(m); + q = 0; + x_q[0] = x0; + y_q = f.Forward(q, x_q); + ok &= NearEqual(y_q[0] , check, eps, eps); + + // check first order forward mode + q = 1; + x_q[0] = 1; + y_q = f.Forward(q, x_q); + check = 1.; + ok &= NearEqual(y_q[0] , check, eps, eps); + + // check second order forward mode + q = 2; + x_q[0] = 0; + y_q = f.Forward(q, x_q); + check = 0.; + ok &= NearEqual(y_q[0] , check, eps, eps); + + // -------------------------------------------------------------------- + // Check reverse mode results + // + // third order reverse mode + q = 3; + vector w(m), dw(n * q); + w[0] = 1.; + dw = f.Reverse(q, w); + check = 1.; + ok &= NearEqual(dw[0] , check, eps, eps); + check = 0.; + ok &= NearEqual(dw[1] , check, eps, eps); + ok &= NearEqual(dw[2] , check, eps, eps); + + // -------------------------------------------------------------------- + // forward mode sparstiy pattern + size_t p = n; + CppAD::vectorBool r1(n * p), s1(m * p); + r1[0] = true; // compute sparsity pattern for x[0] + s1 = f.ForSparseJac(p, r1); + ok &= s1[0] == true; // f[0] depends on x[0] + + // -------------------------------------------------------------------- + // reverse mode sparstiy pattern + q = m; + CppAD::vectorBool s2(q * m), r2(q * n); + s2[0] = true; // compute sparsity pattern for f[0] + r2 = f.RevSparseJac(q, s2); + ok &= r2[0] == true; // f[0] depends on x[0] + + // -------------------------------------------------------------------- + // Hessian sparsity (using previous ForSparseJac call) + CppAD::vectorBool s3(m), h(p * n); + s3[0] = true; // compute sparsity pattern for f[0] + h = f.RevSparseJac(p, s3); + ok &= h[0] == true; // second partial of f[0] w.r.t. x[0] may be non-zero + + // ----------------------------------------------------------------- + // Free all memory associated with the object r_ptr + destroy_r(); + + // ----------------------------------------------------------------- + // Free all temporary work space associated with old_atomic objects. + // (If there are future calls to user atomic functions, they will + // create new temporary work space.) + CppAD::user_atomic::clear(); + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/test_more/old_usead_2.cpp cppad-2016.00.00.1/test_more/old_usead_2.cpp --- cppad-2015.00.00.9/test_more/old_usead_2.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/old_usead_2.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,496 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin old_usead_2.cpp$$ +$spell + checkpoint + var +$$ + +$section Using AD to Compute Atomic Function Derivatives$$ +$mindex inside user checkpoint$$ + + +$head Deprecated 2013-05-27$$ +This example has been deprecated because it is easier to use the +$cref checkpoint$$ class instead. + +$head Purpose$$ +Consider the case where an inner function is used repeatedly in the +definition of an outer function. +In this case, it may reduce the number of variables +$cref/size_var/seq_property/size_var/$$, +and hence the required memory. + +$code +$verbatim%test_more/old_usead_2.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include + +namespace { // Begin empty namespace + using CppAD::AD; + using CppAD::ADFun; + using CppAD::vector; + + // ---------------------------------------------------------------------- + // ODE for [t, t^2 / 2 ] in form required by Runge45 + class Fun { + public: + void Ode( + const AD &t, + const vector< AD > &z, + vector< AD > &f) + { assert( z.size() == 2 ); + assert( f.size() == 2 ); + f[0] = 1.0; + f[1] = z[0]; + } + }; + + // ---------------------------------------------------------------------- + // Create function that takes on Runge45 step for the ODE above + ADFun* r_ptr_; + void create_r(void) + { size_t n = 3, m = 2; + vector< AD > x(n), zi(m), y(m), e(m); + // The value of x does not matter because the operation sequence + // does not depend on x. + x[0] = 0.0; // initial value z_0 (t) at t = ti + x[1] = 0.0; // initial value z_1 (t) at t = ti + x[2] = 0.1; // final time for this integration + CppAD::Independent(x); + zi[0] = x[0]; // z_0 (t) at t = ti + zi[1] = x[1]; // z_1 (t) at t = ti + AD ti = 0.0; // t does not appear in ODE so does not matter + AD tf = x[2]; // final time + size_t M = 3; // number of Runge45 steps to take + Fun F; + y = CppAD::Runge45(F, M, ti, tf, zi, e); + r_ptr_ = new ADFun(x, y); + } + void destroy_r(void) + { delete r_ptr_; + r_ptr_ = CPPAD_NULL; + } + + // ---------------------------------------------------------------------- + // forward mode routine called by CppAD + bool solve_ode_forward( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { assert( id == 0 ); + assert( n == 3 ); + assert( m == 2 ); + assert( k == 0 || vx.size() == 0 ); + bool ok = true; + vector xp(n), yp(m); + size_t i, j; + + // check for special case + if( vx.size() > 0 ) + { //Compute r, a Jacobian sparsity pattern. + // Use reverse mode because m < n. + vector< std::set > s(m), r(m); + for(i = 0; i < m; i++) + s[i].insert(i); + r = r_ptr_->RevSparseJac(m, s); + std::set::const_iterator itr; + for(i = 0; i < m; i++) + { vy[i] = false; + for(itr = s[i].begin(); itr != s[i].end(); itr++) + { j = *itr; + assert( j < n ); + // y[i] depends on the value of x[j] + // Visual Studio 2013 generates warning without bool below + vy[i] |= bool( vx[j] ); + } + } + } + // make sure r_ has proper lower order Taylor coefficients stored + // then compute ty[k] + for(size_t q = 0; q <= k; q++) + { for(j = 0; j < n; j++) + xp[j] = tx[j * (k+1) + q]; + yp = r_ptr_->Forward(q, xp); + if( q == k ) + { for(i = 0; i < m; i++) + ty[i * (k+1) + q] = yp[i]; + } +# ifndef NDEBUG + else + { for(i = 0; i < m; i++) + assert( ty[i * (k+1) + q] == yp[i] ); + } +# endif + } + // no longer need the Taylor coefficients in r_ptr_ + // (have to reconstruct them every time) + r_ptr_->capacity_order(0); + return ok; + } + // ---------------------------------------------------------------------- + // reverse mode routine called by CppAD + bool solve_ode_reverse( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { assert( id == 0 ); + assert( n == 3 ); + assert( m == 2 ); + bool ok = true; + vector xp(n), w( (k+1) * m ), dw( (k+1) * n ); + + // make sure r_ has proper forward mode coefficients + size_t i, j, q; + for(q = 0; q <= k; q++) + { for(j = 0; j < n; j++) + xp[j] = tx[j * (k+1) + q]; +# ifdef NDEBUG + r_ptr_->Forward(q, xp); +# else + vector yp(m); + yp = r_ptr_->Forward(q, xp); + for(i = 0; i < m; i++) + assert( ty[i * (k+1) + q] == yp[i] ); +# endif + } + for(i = 0; i < m; i++) + { for(q = 0; q <=k; q++) + w[ i * (k+1) + q] = py[ i * (k+1) + q]; + } + dw = r_ptr_->Reverse(k+1, w); + for(j = 0; j < n; j++) + { for(q = 0; q <=k; q++) + px[ j * (k+1) + q] = dw[ j * (k+1) + q]; + } + // no longer need the Taylor coefficients in r_ptr_ + // (have to reconstruct them every time) + r_ptr_->capacity_order(0); + + return ok; + } + // ---------------------------------------------------------------------- + // forward Jacobian sparsity routine called by CppAD + bool solve_ode_for_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + vector< std::set >& s ) + { assert( id == 0 ); + assert( n == 3 ); + assert( m == 2 ); + bool ok = true; + + vector< std::set > R(n), S(m); + for(size_t j = 0; j < n; j++) + R[j] = r[j]; + S = r_ptr_->ForSparseJac(p, R); + for(size_t i = 0; i < m; i++) + s[i] = S[i]; + + // no longer need the forward mode sparsity pattern + // (have to reconstruct them every time) + r_ptr_->size_forward_set(0); + + return ok; + } + // ---------------------------------------------------------------------- + // reverse Jacobian sparsity routine called by CppAD + bool solve_ode_rev_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + vector< std::set >& r , + const vector< std::set >& s ) + { + assert( id == 0 ); + assert( n == 3 ); + assert( m == 2 ); + bool ok = true; + + vector< std::set > R(p), S(p); + std::set::const_iterator itr; + size_t i; + // untranspose s + for(i = 0; i < m; i++) + { for(itr = s[i].begin(); itr != s[i].end(); itr++) + S[*itr].insert(i); + } + R = r_ptr_->RevSparseJac(p, S); + // transpose r + for(i = 0; i < m; i++) + r[i].clear(); + for(i = 0; i < p; i++) + { for(itr = R[i].begin(); itr != R[i].end(); itr++) + r[*itr].insert(i); + } + return ok; + } + // ---------------------------------------------------------------------- + // reverse Hessian sparsity routine called by CppAD + bool solve_ode_rev_hes_sparse( + size_t id , + size_t n , + size_t m , + size_t p , + const vector< std::set >& r , + const vector& s , + vector& t , + const vector< std::set >& u , + vector< std::set >& v ) + { // Can just return false if not use RevSparseHes. + assert( id == 0 ); + assert( n == 3 ); + assert( m == 2 ); + bool ok = true; + std::set::const_iterator itr; + + // compute sparsity pattern for T(x) = S(x) * f'(x) + vector< std::set > S(1); + size_t i, j; + S[0].clear(); + for(i = 0; i < m; i++) + if( s[i] ) + S[0].insert(i); + t = r_ptr_->RevSparseJac(1, s); + + // compute sparsity pattern for A(x)^T = U(x)^T * f'(x) + vector< std::set > Ut(p), At(p); + for(i = 0; i < m; i++) + { for(itr = u[i].begin(); itr != u[i].end(); itr++) + Ut[*itr].insert(i); + } + At = r_ptr_->RevSparseJac(p, Ut); + + // compute sparsity pattern for H(x)^T = R^T * (S * F)''(x) + vector< std::set > R(n), Ht(p); + for(j = 0; j < n; j++) + R[j] = r[j]; + r_ptr_->ForSparseJac(p, R); + Ht = r_ptr_->RevSparseHes(p, S); + + // compute sparsity pattern for V(x) = A(x) + H(x)^T + for(j = 0; j < n; j++) + v[j].clear(); + for(i = 0; i < p; i++) + { for(itr = At[i].begin(); itr != At[i].end(); itr++) + v[*itr].insert(i); + for(itr = Ht[i].begin(); itr != Ht[i].end(); itr++) + v[*itr].insert(i); + } + + // no longer need the forward mode sparsity pattern + // (have to reconstruct them every time) + r_ptr_->size_forward_set(0); + + return ok; + } + // --------------------------------------------------------------------- + // Declare the AD routine solve_ode(id, ax, ay) + CPPAD_USER_ATOMIC( + solve_ode , + CppAD::vector , + double , + solve_ode_forward , + solve_ode_reverse , + solve_ode_for_jac_sparse , + solve_ode_rev_jac_sparse , + solve_ode_rev_hes_sparse + ) +} // End empty namespace + +bool old_usead_2(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // -------------------------------------------------------------------- + // Create the ADFun r_ + create_r(); + + // -------------------------------------------------------------------- + // domain and range space vectors + size_t n = 3, m = 2; + vector< AD > au(n), ax(n), ay(m); + au[0] = 0.0; // value of z_0 (t) = t, at t = 0 + ax[1] = 0.0; // value of z_1 (t) = t^2/2, at t = 0 + au[2] = 1.0; // final t + CppAD::Independent(au); + size_t M = 2; // number of r steps to take + ax[0] = au[0]; // value of z_0 (t) = t, at t = 0 + ax[1] = au[1]; // value of z_1 (t) = t^2/2, at t = 0 + AD dt = au[2] / M; // size of each r step + ax[2] = dt; + for(size_t i_step = 0; i_step < M; i_step++) + { size_t id = 0; // not used + solve_ode(id, ax, ay); + ax[0] = ay[0]; + ax[1] = ay[1]; + } + + // create f: u -> y and stop tape recording + // y_0(t) = u_0 + t = u_0 + u_2 + // y_1(t) = u_1 + u_0 * t + t^2 / 2 = u_1 + u_0 * u_2 + u_2^2 / 2 + // where t = u_2 + ADFun f; + f.Dependent(au, ay); + + // -------------------------------------------------------------------- + // Check forward mode results + // + // zero order forward + vector up(n), yp(m); + size_t q = 0; + double u0 = 0.5; + double u1 = 0.25; + double u2 = 0.75; + double check; + up[0] = u0; + up[1] = u1; + up[2] = u2; + yp = f.Forward(q, up); + check = u0 + u2; + ok &= NearEqual( yp[0], check, eps, eps); + check = u1 + u0 * u2 + u2 * u2 / 2.0; + ok &= NearEqual( yp[1], check, eps, eps); + // + // forward mode first derivative w.r.t t + q = 1; + up[0] = 0.0; + up[1] = 0.0; + up[2] = 1.0; + yp = f.Forward(q, up); + check = 1.0; + ok &= NearEqual( yp[0], check, eps, eps); + check = u0 + u2; + ok &= NearEqual( yp[1], check, eps, eps); + // + // forward mode second order Taylor coefficient w.r.t t + q = 2; + up[0] = 0.0; + up[1] = 0.0; + up[2] = 0.0; + yp = f.Forward(q, up); + check = 0.0; + ok &= NearEqual( yp[0], check, eps, eps); + check = 1.0 / 2.0; + ok &= NearEqual( yp[1], check, eps, eps); + // -------------------------------------------------------------------- + // reverse mode derivatives of \partial_t y_1 (t) + vector w(m * q), dw(n * q); + w[0 * q + 0] = 0.0; + w[1 * q + 0] = 0.0; + w[0 * q + 1] = 0.0; + w[1 * q + 1] = 1.0; + dw = f.Reverse(q, w); + // derivative of y_1(u) = u_1 + u_0 * u_2 + u_2^2 / 2, w.r.t. u + // is equal deritative of \partial_u2 y_1(u) w.r.t \partial_u2 u + check = u2; + ok &= NearEqual( dw[0 * q + 1], check, eps, eps); + check = 1.0; + ok &= NearEqual( dw[1 * q + 1], check, eps, eps); + check = u0 + u2; + ok &= NearEqual( dw[2 * q + 1], check, eps, eps); + // derivative of \partial_t y_1 w.r.t u = u_0 + t, w.r.t u + check = 1.0; + ok &= NearEqual( dw[0 * q + 0], check, eps, eps); + check = 0.0; + ok &= NearEqual( dw[1 * q + 0], check, eps, eps); + check = 1.0; + ok &= NearEqual( dw[2 * q + 0], check, eps, eps); + // -------------------------------------------------------------------- + // forward mode sparsity pattern for the Jacobian + // f_u = [ 1, 0, 1 ] + // [ u_2, 1, u_2 ] + size_t i, j, p = n; + CppAD::vectorBool r(n * p), s(m * p); + // r = identity sparsity pattern + for(i = 0; i < n; i++) + for(j = 0; j < p; j++) + r[i*n +j] = (i == j); + s = f.ForSparseJac(p, r); + ok &= s[ 0 * p + 0] == true; + ok &= s[ 0 * p + 1] == false; + ok &= s[ 0 * p + 2] == true; + ok &= s[ 1 * p + 0] == true; + ok &= s[ 1 * p + 1] == true; + ok &= s[ 1 * p + 2] == true; + // -------------------------------------------------------------------- + // reverse mode sparsity pattern for the Jacobian + q = m; + s.resize(q * m); + r.resize(q * n); + // s = identity sparsity pattern + for(i = 0; i < q; i++) + for(j = 0; j < m; j++) + s[i*m +j] = (i == j); + r = f.RevSparseJac(q, s); + ok &= r[ 0 * n + 0] == true; + ok &= r[ 0 * n + 1] == false; + ok &= r[ 0 * n + 2] == true; + ok &= r[ 1 * n + 0] == true; + ok &= r[ 1 * n + 1] == true; + ok &= r[ 1 * n + 2] == true; + + // -------------------------------------------------------------------- + // Hessian sparsity for y_1 (u) = u_1 + u_0 * u_2 + u_2^2 / 2 + s.resize(m); + s[0] = false; + s[1] = true; + r.resize(n * n); + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + r[ i * n + j ] = (i == j); + CppAD::vectorBool h(n * n); + h = f.RevSparseHes(n, s); + ok &= h[0 * n + 0] == false; + ok &= h[0 * n + 1] == false; + ok &= h[0 * n + 2] == true; + ok &= h[1 * n + 0] == false; + ok &= h[1 * n + 1] == false; + ok &= h[1 * n + 2] == false; + ok &= h[2 * n + 0] == true; + ok &= h[2 * n + 1] == false; + ok &= h[2 * n + 2] == true; + + // -------------------------------------------------------------------- + destroy_r(); + + // Free all temporary work space associated with old_atomic objects. + // (If there are future calls to user atomic functions, they will + // create new temporary work space.) + CppAD::user_atomic::clear(); + + return ok; +} +// END C++ diff -Nru cppad-2015.00.00.9/test_more/omp_alloc.cpp cppad-2016.00.00.1/test_more/omp_alloc.cpp --- cppad-2015.00.00.9/test_more/omp_alloc.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/omp_alloc.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,191 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin omp_alloc.cpp$$ +$spell + openmp +$$ + +$section OpenMP Memory Allocator: Example and Test$$ +$mindex allocation multi thread$$ + + +$head Deprecated 2011-08-31$$ +This example is only intended to help convert calls to $cref omp_alloc$$ +to calls to $cref thread_alloc$$. + +$code +$verbatim%test_more/omp_alloc.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include +# include +# include + +namespace { // Begin empty namespace + +bool omp_alloc_bytes(void) +{ bool ok = true; + using CppAD::omp_alloc; + size_t thread; + + // check initial memory values + ok &= ! CppAD::memory_leak(); + + // amount of static memory used by thread zero + size_t static_inuse = omp_alloc::inuse(0); + + // determine the currently executing thread + // (should be zero because not in parallel mode) + thread = omp_alloc::get_thread_num(); + + // repeatedly allocate enough memory for at least two size_t values. + size_t min_size_t = 2; + size_t min_bytes = min_size_t * sizeof(size_t); + size_t n_outter = 10; + size_t n_inner = 5; + size_t cap_bytes(0), i, j, k; + for(i = 0; i < n_outter; i++) + { // Do not use CppAD::vector here because its use of omp_alloc + // complicates the inuse and avaialble results. + std::vector v_ptr(n_inner); + for( j = 0; j < n_inner; j++) + { // allocate enough memory for min_size_t size_t objects + v_ptr[j] = omp_alloc::get_memory(min_bytes, cap_bytes); + size_t* ptr = reinterpret_cast(v_ptr[j]); + // determine the number of size_t values we have obtained + size_t cap_size_t = cap_bytes / sizeof(size_t); + ok &= min_size_t <= cap_size_t; + // use placement new to call the size_t copy constructor + for(k = 0; k < cap_size_t; k++) + new(ptr + k) size_t(i + j + k); + // check that the constructor worked + for(k = 0; k < cap_size_t; k++) + ok &= ptr[k] == (i + j + k); + } + // check that n_inner * cap_bytes are inuse and none are available + ok &= omp_alloc::inuse(thread) == n_inner*cap_bytes + static_inuse; + ok &= omp_alloc::available(thread) == 0; + // return the memrory to omp_alloc + for(j = 0; j < n_inner; j++) + omp_alloc::return_memory(v_ptr[j]); + // check that now n_inner * cap_bytes are now available + // and none are in use + ok &= omp_alloc::inuse(thread) == static_inuse; + ok &= omp_alloc::available(thread) == n_inner * cap_bytes; + } + // return all the available memory to the system + omp_alloc::free_available(thread); + ok &= ! CppAD::memory_leak(); + + return ok; +} + +class my_char { +public: + char ch_ ; + my_char(void) : ch_(' ') + { } + my_char(const my_char& my_ch) : ch_(my_ch.ch_) + { } +}; + +bool omp_alloc_array(void) +{ bool ok = true; + using CppAD::omp_alloc; + size_t i; + + // check initial memory values + size_t thread = omp_alloc::get_thread_num(); + ok &= thread == 0; + ok &= ! CppAD::memory_leak(); + size_t static_inuse = omp_alloc::inuse(0); + + // initial allocation of an array + size_t size_min = 3; + size_t size_one; + my_char *array_one = + omp_alloc::create_array(size_min, size_one); + + // check the values and change them to null 'x' + for(i = 0; i < size_one; i++) + { ok &= array_one[i].ch_ == ' '; + array_one[i].ch_ = 'x'; + } + + // now create a longer array + size_t size_two; + my_char *array_two = + omp_alloc::create_array(2 * size_min, size_two); + + // check the values in array one + for(i = 0; i < size_one; i++) + ok &= array_one[i].ch_ == 'x'; + + // check the values in array two + for(i = 0; i < size_two; i++) + ok &= array_two[i].ch_ == ' '; + + // check the amount of inuse and available memory + // (an extra size_t value is used for each memory block). + size_t check = static_inuse + sizeof(my_char)*(size_one + size_two); + ok &= omp_alloc::inuse(thread) - check < sizeof(my_char); + ok &= omp_alloc::available(thread) == 0; + + // delete the arrays + omp_alloc::delete_array(array_one); + omp_alloc::delete_array(array_two); + ok &= omp_alloc::inuse(thread) == static_inuse; + check = sizeof(my_char)*(size_one + size_two); + ok &= omp_alloc::available(thread) - check < sizeof(my_char); + + // free the memory for use by this thread + omp_alloc::free_available(thread); + ok &= ! CppAD::memory_leak(); + + return ok; +} +} // End empty namespace + +bool omp_alloc(void) +{ bool ok = true; + using CppAD::omp_alloc; + + // check initial state of allocator + ok &= omp_alloc::get_max_num_threads() == 1; + + // set the maximum number of threads greater than one + // so that omp_alloc holds onto memory + CppAD::omp_alloc::set_max_num_threads(2); + ok &= omp_alloc::get_max_num_threads() == 2; + ok &= ! CppAD::memory_leak(); + + // now use memory allocator in state where it holds onto memory + ok &= omp_alloc_bytes(); + ok &= omp_alloc_array(); + + // check that the tests have not held onto memory + ok &= ! CppAD::memory_leak(); + + // set the maximum number of threads back to one + // so that omp_alloc no longer holds onto memory + CppAD::omp_alloc::set_max_num_threads(1); + + return ok; +} + + +// END C++ diff -Nru cppad-2015.00.00.9/test_more/optimize.cpp cppad-2016.00.00.1/test_more/optimize.cpp --- cppad-2015.00.00.9/test_more/optimize.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/optimize.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: optimize.cpp 3643 2015-02-12 11:47:46Z bradbell $ */ +/* $Id: optimize.cpp 3735 2015-10-01 13:43:46Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -16,38 +16,48 @@ namespace { + // include conditional skip optimization + bool conditional_skip_; + + // accuracy for almost equal checks + double eps_ = 10. * std::numeric_limits::epsilon(); + using CppAD::NearEqual; + // note this enum type is not part of the API (but its values are) - CppAD::atomic_base::option_enum atomic_sparsity_option; + CppAD::atomic_base::option_enum atomic_sparsity_option_; // // ---------------------------------------------------------------- // Test nested conditional expressions. - int nested_cond_exp(void) + bool nested_cond_exp(void) { bool ok = true; using CppAD::AD; using CppAD::vector; - - // independent variable vector + + // independent variable vector vector< AD > ax(2), ay(1); ax[0] = 1.0; ax[1] = 2.0; Independent(ax); - + // first conditional expression AD ac1 = CondExpLe(ax[0], ax[1], 2.0 * ax[0], 3.0 * ax[1] ); - + // second conditional expression AD ac2 = CondExpGe(ax[0], ax[1], 4.0 * ax[0], 5.0 * ax[1] ); - + // third conditional expression AD ac3 = CondExpLt(ax[0], ax[1], 6.0 * ac1, 7.0 * ac2 ); - + // create function object f : ax -> ay ay[0] = ac3; CppAD::ADFun f(ax, ay); - + // now optimize the operation sequence - f.optimize(); - + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + // now zero order forward vector x(2), y(1); for(size_t i = 0; i < 3; i++) @@ -66,13 +76,13 @@ if( x[0] >= x[1] ) c2 = 4.0 * x[0]; else c2 = 5.0 * x[1]; - + // third conditional expression double c3; if( x[0] < x[1] ) c3 = 6.0 * c1; else c3 = 7.0 * c2; - + ok &= y[0] == c3; } return ok; @@ -81,55 +91,58 @@ // Test for bug where checkpoint function did not depend on // the operands in the logical comparison because of the CondExp // sparsity pattern. - void j_algo( + void j_algo( const CppAD::vector< CppAD::AD >& ax , CppAD::vector< CppAD::AD >& ay ) { ay[0] = CondExpGt(ax[0], ax[1], ax[2], ax[3]); } - + bool atomic_cond_exp_sparsity(void) { bool ok = true; using CppAD::AD; using CppAD::vector; - + // Create a checkpoint version of the function g vector< AD > au(4), av(1); for(size_t i = 0; i < 4; i++) au[i] = AD(i); CppAD::checkpoint j_check("j_check", j_algo, au, av); - - // independent variable vector + + // independent variable vector vector< AD > ax(2), ay(1); ax[0] = 1.; ax[1] = 1.; Independent(ax); - + // call atomic function that does not get used - for(size_t i = 0; i < 4; i++) + for(size_t i = 0; i < 4; i++) au[i] = ax[0] + AD(i + 1) * ax[1]; j_check(au, ay); - + // create function object f : ax -> ay CppAD::ADFun f(ax, ay); - + // now optimize the operation sequence - j_check.option( atomic_sparsity_option ); - f.optimize(); - + j_check.option( atomic_sparsity_option_ ); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + // check result where true case is used; i.e., au[0] > au[1] vector x(2), y(1); x[0] = 1.; x[1] = -1; y = f.Forward(0, x); ok &= y[0] == x[0] + double(3) * x[1]; - - + + // check result where false case is used; i.e., au[0] <= au[1] x[0] = 1.; x[1] = 1; y = f.Forward(0, x); ok &= y[0] == x[0] + double(4) * x[1]; - + return ok; } // ------------------------------------------------------------------- @@ -155,7 +168,7 @@ CppAD::checkpoint k_check("k_check", k_algo, ax, ag); CppAD::checkpoint h_check("h_check", h_algo, ax, ah); - // independent variable vector + // independent variable vector Independent(ax); // atomic function calls that get conditionally used @@ -163,12 +176,12 @@ h_check(ax, ah); // conditional expression - ay[0] = CondExpLt(ax[0], ax[1], ag[0], ah[0]); - + ay[0] = CondExpLt(ax[0], ax[1], ag[0], ah[0]); + // create function object f : ax -> ay CppAD::ADFun f; f.Dependent(ax, ay); - + // use zero order to evaluate when condition is true CppAD::vector x(2), dx(2); CppAD::vector y(1), dy(1), w(1); @@ -178,12 +191,15 @@ ok &= y[0] == x[0] + x[1]; // before optimize - k_check.option( atomic_sparsity_option ); - h_check.option( atomic_sparsity_option ); + k_check.option( atomic_sparsity_option_ ); + h_check.option( atomic_sparsity_option_ ); ok &= f.number_skip() == 0; // now optimize the operation sequence - f.optimize(); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); // optimized zero order forward when condition is false x[0] = 4.; @@ -205,12 +221,12 @@ dx = f.Reverse(1, w); ok &= dx[0] == 1.; ok &= dx[1] == -1.; - + return ok; } // ------------------------------------------------------------------- // Test of optimizing out arguments to an atomic function - void g_algo( + void g_algo( const CppAD::vector< CppAD::AD >& ax , CppAD::vector< CppAD::AD >& ay ) { ay = ax; } @@ -219,45 +235,48 @@ { bool ok = true; using CppAD::AD; using CppAD::vector; - + // Create a checkpoint version of the function g vector< AD > ax(2), ay(2), az(1); ax[0] = 0.; ax[1] = 1.; CppAD::checkpoint g_check("g_check", g_algo, ax, ay); - - // independent variable vector + + // independent variable vector Independent(ax); - + // call atomic function that does not get used g_check(ax, ay); - + // conditional expression - az[0] = CondExpLt(ax[0], ax[1], ax[0] + ax[1], ax[0] - ax[1]); - + az[0] = CondExpLt(ax[0], ax[1], ax[0] + ax[1], ax[0] - ax[1]); + // create function object f : ax -> az CppAD::ADFun f(ax, az); // number of variables before optimization // (include ay[0] and ay[1]) size_t n_before = f.size_var(); - + // now optimize the operation sequence - g_check.option( atomic_sparsity_option ); - f.optimize(); + g_check.option( atomic_sparsity_option_ ); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); - // number of variables after optimization + // number of variables after optimization // (does not include ay[0] and ay[1]) size_t n_after = f.size_var(); ok &= n_after + 2 == n_before; - + // check optimization works ok vector x(2), z(1); x[0] = 4.; x[1] = 3.; z = f.Forward(0, x); ok &= z[0] == x[0] - x[1]; - + return ok; } bool atomic_arguments(void) @@ -279,16 +298,19 @@ au[1] = ax[0] - ax[1]; // this argument also requires a new variable g_check(au, aw); - // now create f(x) = x_0 - x_1 + // now create f(x) = x_0 - x_1 ay[0] = aw[0]; CppAD::ADFun f(ax, ay); // number of variables before optimization size_t n_before = f.size_var(); - + // now optimize f so that the calculation of au[1] is removed - g_check.option( atomic_sparsity_option ); - f.optimize(); + g_check.option( atomic_sparsity_option_ ); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); // check difference in number of variables size_t n_after = f.size_var(); @@ -299,7 +321,7 @@ x[0] = 5.0; x[1] = 6.0; y = f.Forward(0, x); - ok &= (y[0] == x[0] + x[1]); + ok &= (y[0] == x[0] + x[1]); return ok; } @@ -310,62 +332,56 @@ void depend_fun (const Vector& x, Vector& y, size_t& original, size_t& opt) { typedef typename Vector::value_type Scalar; - Scalar a; - Scalar one(1), two(2), three(3), four(4); - original = 0; - opt = 0; + Scalar not_used; + Scalar one(1), two(2), three(3); + + // independent variable and phantom at beginning + original = 1 + x.size(); + opt = 1 + x.size(); // unary operator where operand is arg[0] - a = CppAD::abs(x[0]); - if( a < 1. ) - y[0] = sin(x[0]); - else y[0] = cos(x[0]); + // (note that sin corresponds to two tape variables) + not_used = CppAD::abs(x[0]); + y[0] = sin(x[0]); original += 3; opt += 2; // binary operator where left operand is a variable // and right operand is a parameter - a = x[1] + 2.; - if( a < 3. ) - y[1] = x[1] * 3.; - else y[1] = x[1] / 2.; + not_used = not_used + 2.; + y[1] = x[1] * 3.; original += 2; opt += 1; // binary operator where left operand is a parameter // and right operation is a variable - a = 2. - x[2]; - if( a < 4. ) - y[2] = 3. / x[2]; - else y[2] = 4. + x[2]; + not_used = 2. - not_used; + y[2] = 3. / x[2]; original += 2; opt += 1; // binary operator where both operands are variables - a = x[3] - x[2]; - if( a < 4. ) - y[3] = x[3] / x[2]; - else y[3] = x[3] + x[2]; + not_used = x[3] - not_used; + y[3] = x[3] / x[2]; original += 2; opt += 1; - // this conditional expression that will be optimized out - a = CppAD::CondExpLt(x[0], x[1], x[2], x[3]); - // 1 of the following 2 conditional expressions will be kept - if( a < 5. ) - y[4] = CppAD::CondExpLt(x[4], one, two, three); - else y[4] = CppAD::CondExpLt(x[4], two, three, four); - original += 2; + // conditional expression that will be optimized out + not_used = CppAD::CondExpLt(x[0], x[1], x[2], x[3]) + not_used; + y[4] = CppAD::CondExpLt(x[4], one, two, three); + original += 3; opt += 1; - // Make sure that a parameter dependent variable + // y[5] does not depend on the value of not_used. + // Make sure a parameter, corresponding to a dependent variable, // is not optimized out of the operation sequence. - // In addition, we do not use the argument x[5], to - // make sure it is not optimized out. - y[5] = 1.; + y[5] = 0.0 * not_used; original += 1; opt += 1; + // Wwe do not use the argument x[5], to + // make sure it is not optimized out. + return; } @@ -376,48 +392,51 @@ size_t original; size_t opt; size_t i, j; - + // domain space vector size_t n = 6; CppAD::vector< AD > X(n); for(j = 0; j < n; j++) - X[j] = 1. / double(j + 1); - + X[j] = 1. / double(j + 1); + // declare independent variables and start tape recording CppAD::Independent(X); - - // range space vector + + // range space vector size_t m = n; CppAD::vector< AD > Y(m); depend_fun(X, Y, original, opt); - + // create f: X -> Y and stop tape recording CppAD::ADFun F; - F.Dependent(X, Y); - + F.Dependent(X, Y); + CppAD::vector x(n), y(m), check(m); for(j = 0; j < n; j++) x[j] = Value(X[j]); y = F.Forward(0, x); depend_fun(x, check, original, opt); for(i = 0; i < m; i++) - ok &= CppAD::NearEqual(y[i], check[i], 1e-10, 1e-10); - + ok &= NearEqual(y[i], check[i], eps_, eps_); + // Check size before optimization - ok &= F.size_var() == (n + 1 + original); - + ok &= F.size_var() == original; + // Optimize the operation sequence - F.optimize(); - + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + // Check size after optimization - ok &= F.size_var() == (n + 1 + opt); - + ok &= F.size_var() == opt; + // check result now // (should have already been checked if NDEBUG not defined) y = F.Forward(0, x); for(i = 0; i < m; i++) - ok &= CppAD::NearEqual(y[i], check[i], 1e-10, 1e-10); - + ok &= NearEqual(y[i], check[i], eps_, eps_); + return ok; } @@ -431,7 +450,7 @@ size_t n = 2; CppAD::vector< AD > X(n); for(j = 0; j < n; j++) - X[j] = double(j); + X[j] = double(j); // range space vector size_t m = 3; @@ -443,7 +462,7 @@ U[i] = 0; for(j = 0; j < n; j++) V[j] = 0; - + // declare independent variables and start tape recording CppAD::Independent(X); @@ -462,15 +481,15 @@ { AD I(i); Y[i] = U[I]; } - + // create f: X -> Y and stop tape recording - // Y[ X[0] ] = X[1] and other components of Y are zero. + // Y[ X[0] ] = X[1] and other components of Y are zero. CppAD::ADFun F; - F.Dependent(X, Y); + F.Dependent(X, Y); // Check number of VecAD vectors plus number of VecAD elements - ok &= (F.size_VecAD() == 2 + n + m); - + ok &= (F.size_VecAD() == 2 + n + m); + CppAD::vector x(n), y(m); for(j = 0; j < n; j++) x[j] = double(j); @@ -482,17 +501,20 @@ else ok &= (y[i] == x[1]); } - F.optimize(); + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); // Check number of VecAD vectors plus number of VecAD elements - ok &= (F.size_VecAD() == 1 + m); + ok &= (F.size_VecAD() == 1 + m); y = F.Forward(0, x); for(i = 0; i < m; i++) { if( i != static_cast(x[0]) ) ok &= (y[i] == 0.); else ok &= (y[i] == x[1]); } - + return ok; } bool depend_three(void) @@ -503,21 +525,24 @@ size_t n = 3; size_t j; - + vector< AD > X(n), Y(n); - vector x(n), y(n); - + vector x(n), y(n); + for(j = 0; j < n; j++) X[j] = x[j] = double(j+2); - + CppAD::Independent(X); - + Y[0] = pow(X[0], 2.0); Y[1] = pow(2.0, X[1]); Y[2] = pow(X[0], X[1]); - + CppAD::ADFun F(X, Y); - F.optimize(); + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); y = F.Forward(0, x); // Use identically equal because the result of the operations @@ -527,28 +552,27 @@ ok &= ( y[j] == Value(Y[j]) ); // check reverse mode derivative - vector w(n), dw(n); + vector w(n), dw(n); w[0] = 0.; w[1] = 0.; w[2] = 1.; dw = F.Reverse(1, w); - double eps = 20. * std::numeric_limits::epsilon(); double check = x[1] * pow( x[0], x[1] - 1. ); - ok &= CppAD::NearEqual( dw[0], check, eps, eps ); + ok &= NearEqual( dw[0], check, eps_, eps_ ); check = log( x[0] ) * pow( x[0], x[1] ); - ok &= CppAD::NearEqual( dw[1], check, eps, eps ); + ok &= NearEqual( dw[1], check, eps_, eps_ ); check = 0.; - ok &= CppAD::NearEqual( dw[2], check, eps, eps ); - + ok &= NearEqual( dw[2], check, eps_, eps_ ); + return ok; } bool depend_four(void) { // erf function is a special case for optimize bool ok = true; -# if CPPAD_COMPILER_HAS_ERF +# if CPPAD_USE_CPLUSPLUS_2011 using CppAD::AD; using CppAD::vector; @@ -566,11 +590,13 @@ vector y_original = F.Forward(0, x); size_t size_original = F.size_var(); - F.optimize(); - // version 20150000 does not remove duplicate erf function calls. - ok &= F.size_var() == size_original; + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + ok &= F.size_var() + 5 == size_original; vector y = F.Forward(0, x); - ok &= CppAD::NearEqual(y[0], y_original[0], 1e-10, 1e-10); + ok &= NearEqual(y[0], y_original[0], eps_, eps_); # endif return ok; } @@ -585,7 +611,7 @@ opt = 0; // unary operator where operand is arg[0] and one result - Scalar a1 = CppAD::exp(x[0]); + Scalar a1 = CppAD::exp(x[0]); original += 1; opt += 1; @@ -654,48 +680,51 @@ size_t original; size_t opt; size_t i, j; - + // domain space vector size_t n = 7; CppAD::vector< AD > X(n); for(j = 0; j < n; j++) - X[j] = 1. / double(j + 1); - + X[j] = 1. / double(j + 1); + // declare independent variables and start tape recording CppAD::Independent(X); - - // range space vector + + // range space vector size_t m = n; CppAD::vector< AD > Y(m); duplicate_fun(X, Y, original, opt); - + // create f: X -> Y and stop tape recording CppAD::ADFun F; - F.Dependent(X, Y); - + F.Dependent(X, Y); + CppAD::vector x(n), y(m), check(m); for(j = 0; j < n; j++) x[j] = Value(X[j]); y = F.Forward(0, x); duplicate_fun(x, check, original, opt); for(i = 0; i < m; i++) - ok &= CppAD::NearEqual(y[i], check[i], 1e-10, 1e-10); - + ok &= NearEqual(y[i], check[i], eps_, eps_); + // Check size before optimization ok &= F.size_var() == (n + 1 + original); - + // Optimize the operation sequence - F.optimize(); - + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + // Check size after optimization ok &= F.size_var() == (n + 1 + opt); - + // check result now // (should have already been checked if NDEBUG not defined) y = F.Forward(0, x); for(i = 0; i < m; i++) - ok &= CppAD::NearEqual(y[i], check[i], 1e-10, 1e-10); - + ok &= NearEqual(y[i], check[i], eps_, eps_); + return ok; } // ------------------------------------------------------------------- @@ -710,7 +739,7 @@ size_t n = 1; CppAD::vector< AD > X(n); for(j = 0; j < n; j++) - X[j] = double(j + 2); + X[j] = double(j + 2); // range space vector size_t m = 1; @@ -730,19 +759,19 @@ // create a duplicate that can only be dectected using new // argument indices - AD B2 = A2 / 2.; + AD B2 = A2 / 2.; - // Make a new variable for result + // Make a new variable for result // and make it depend on all the variables Y[0] = B1 + B2; // create f: X -> Y and stop tape recording CppAD::ADFun F; - F.Dependent(X, Y); + F.Dependent(X, Y); // check number of variables in original function - ok &= (F.size_var() == 1 + n + m + 4 ); - + ok &= (F.size_var() == 1 + n + m + 4 ); + CppAD::vector x(n), y(m); for(j = 0; j < n; j++) x[j] = double(j + 2); @@ -751,10 +780,13 @@ for(i = 0; i < m; i++) ok &= ( y[i] == Value( Y[i] ) ); - F.optimize(); + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); // check number of variables in optimized version - ok &= (F.size_var() == 1 + n + m + 2 ); + ok &= (F.size_var() == 1 + n + m + 2 ); y = F.Forward(0, x); for(i = 0; i < m; i++) @@ -774,7 +806,7 @@ size_t n = 1; CppAD::vector< AD > X(n); for(j = 0; j < n; j++) - X[j] = double(j + 2); + X[j] = double(j + 2); // range space vector size_t m = 1; @@ -794,19 +826,19 @@ // create a duplicate that can only be dectected using new // argument indices - AD B2 = 2. * A2; + AD B2 = 2. * A2; - // Make a new variable for result + // Make a new variable for result // and make it depend on all the variables Y[0] = B1 + B2; // create f: X -> Y and stop tape recording CppAD::ADFun F; - F.Dependent(X, Y); + F.Dependent(X, Y); // check number of variables in original function - ok &= (F.size_var() == 1 + n + m + 4 ); - + ok &= (F.size_var() == 1 + n + m + 4 ); + CppAD::vector x(n), y(m); for(j = 0; j < n; j++) x[j] = double(j + 2); @@ -815,10 +847,13 @@ for(i = 0; i < m; i++) ok &= ( y[i] == Value( Y[i] ) ); - F.optimize(); + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); // check number of variables in optimized version - ok &= (F.size_var() == 1 + n + m + 2 ); + ok &= (F.size_var() == 1 + n + m + 2 ); y = F.Forward(0, x); for(i = 0; i < m; i++) @@ -846,7 +881,7 @@ // declare independent variables and start tape recording CppAD::Independent(X); - // check a huge number of same operation with different operands + // check a huge number of same operation with different operands size_t n_operations = std::min( size_t(CPPAD_HASH_TABLE_SIZE) + 5, size_t(std::numeric_limits::max()) - 5 @@ -857,21 +892,24 @@ // create f: X -> Y and stop tape recording CppAD::ADFun F; - F.Dependent(X, Y); + F.Dependent(X, Y); // check number of variables in original function - ok &= (F.size_var() == 1 + n + n_operations ); - + ok &= (F.size_var() == 1 + n + n_operations ); + CppAD::vector x(n), y(m); x[0] = 1.; y = F.Forward(0, x); ok &= ( y[0] == Value( Y[0] ) ); - F.optimize(); + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); // check same number of variables in optimized version - ok &= (F.size_var() == 1 + n + n_operations ); + ok &= (F.size_var() == 1 + n + n_operations ); y = F.Forward(0, x); ok &= ( y[0] == Value( Y[0] ) ); @@ -890,7 +928,7 @@ size_t n = 7; CppAD::vector< AD > X(n); for(j = 0; j < n; j++) - X[j] = double(j + 2); + X[j] = double(j + 2); size_t n_original = 1 + n; size_t n_optimize = 1 + n; @@ -918,11 +956,11 @@ n_optimize += 1; CppAD::ADFun F; - F.Dependent(X, Y); + F.Dependent(X, Y); // check number of variables in original function - ok &= (F.size_var() == n_original ); - + ok &= (F.size_var() == n_original ); + CppAD::vector x(n), y(m); for(j = 0; j < n; j++) x[j] = double(j + 2); @@ -931,10 +969,13 @@ for(i = 0; i < m; i++) ok &= ( y[i] == Value( Y[i] ) ); - F.optimize(); + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); // check number of variables in optimized version - ok &= (F.size_var() == n_optimize ); + ok &= (F.size_var() == n_optimize ); y = F.Forward(0, x); for(i = 0; i < m; i++) @@ -945,41 +986,44 @@ // ------------------------------------------------------------------- bool forward_csum(void) { bool ok = true; - + using namespace CppAD; - - // independent variable vector + + // independent variable vector CppAD::vector< AD > X(2); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; Independent(X); - + // compute sum of elements in X CppAD::vector< AD > Y(1); Y[0] = X[0] + X[0] + X[1]; - + // create function object F : X -> Y ADFun F(X, Y); - + // now optimize the operation sequence - F.optimize(); - - // use zero order to evaluate F[ (3, 4) ] + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + + // use zero order to evaluate F[ (3, 4) ] CppAD::vector x0( F.Domain() ); CppAD::vector y0( F.Range() ); x0[0] = 3.; x0[1] = 4.; y0 = F.Forward(0, x0); - ok &= NearEqual(y0[0] , x0[0]+x0[0]+x0[1], 1e-10, 1e-10); - + ok &= NearEqual(y0[0] , x0[0]+x0[0]+x0[1], eps_, eps_); + // evaluate derivative of F in X[0] direction CppAD::vector x1( F.Domain() ); CppAD::vector y1( F.Range() ); x1[0] = 1.; x1[1] = 0.; y1 = F.Forward(1, x1); - ok &= NearEqual(y1[0] , x1[0]+x1[0]+x1[1], 1e-10, 1e-10); - + ok &= NearEqual(y1[0] , x1[0]+x1[0]+x1[1], eps_, eps_); + // evaluate second derivative of F in X[0] direction CppAD::vector x2( F.Domain() ); CppAD::vector y2( F.Range() ); @@ -987,91 +1031,94 @@ x2[1] = 0.; y2 = F.Forward(2, x2); double F_00 = 2. * y2[0]; - ok &= NearEqual(F_00, 0., 1e-10, 1e-10); - + ok &= NearEqual(F_00, 0., eps_, eps_); + return ok; } // ------------------------------------------------------------------- bool reverse_csum(void) { bool ok = true; - + using namespace CppAD; - - // independent variable vector + + // independent variable vector CppAD::vector< AD > X(2); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; Independent(X); - + // compute sum of elements in X CppAD::vector< AD > Y(1); Y[0] = X[0] - (X[0] - X[1]); - + // create function object F : X -> Y ADFun F(X, Y); - + // now optimize the operation sequence - F.optimize(); - - // use zero order to evaluate F[ (3, 4) ] + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + + // use zero order to evaluate F[ (3, 4) ] CppAD::vector x0( F.Domain() ); CppAD::vector y0( F.Range() ); x0[0] = 3.; x0[1] = 4.; y0 = F.Forward(0, x0); - ok &= NearEqual(y0[0] , x0[0]-x0[0]+x0[1], 1e-10, 1e-10); - - // evaluate derivative of F + ok &= NearEqual(y0[0] , x0[0]-x0[0]+x0[1], eps_, eps_); + + // evaluate derivative of F CppAD::vector dF( F.Domain() ); CppAD::vector w( F.Range() ); w[0] = 1.; dF = F.Reverse(1, w); - ok &= NearEqual(dF[0] , 0., 1e-10, 1e-10); - ok &= NearEqual(dF[1] , 1., 1e-10, 1e-10); - + ok &= NearEqual(dF[0] , 0., eps_, eps_); + ok &= NearEqual(dF[1] , 1., eps_, eps_); + return ok; } bool forward_sparse_jacobian() { bool ok = true; using namespace CppAD; - + // dimension of the domain space - size_t n = 3; - + size_t n = 3; + // dimension of the range space size_t m = 3; - - // independent variable vector + + // independent variable vector CppAD::vector< AD > X(n); - X[0] = 2.; + X[0] = 2.; X[1] = 3.; X[2] = 4.; Independent(X); - + // dependent variable vector CppAD::vector< AD > Y(m); - + // check results vector CppAD::vector< bool > Check(m * n); - + // initialize index into Y size_t index = 0; - - // Y[0] + + // Y[0] Y[index] = X[0] + X[1] + 5.; Check[index * n + 0] = true; Check[index * n + 1] = true; Check[index * n + 2] = false; index++; - - // Y[1] + + // Y[1] Y[index] = Y[0] - (X[1] + X[2]); Check[index * n + 0] = true; Check[index * n + 1] = true; Check[index * n + 2] = true; index++; - // Y[2] + // Y[2] // 2DO: There is a subtitle issue that has to do with using reverse // jacobian sparsity patterns during the optimization process. // We need an option to include X[0] in the sparsity pattern @@ -1081,27 +1128,30 @@ Check[index * n + 1] = true; Check[index * n + 2] = true; index++; - + // check final index assert( index == m ); - + // create function object F : X -> Y ADFun F(X, Y); - F.optimize(); - + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + // --------------------------------------------------------- - // dependency matrix for the identity function + // dependency matrix for the identity function CppAD::vector< std::set > Sx(n); size_t i, j; for(i = 0; i < n; i++) { assert( Sx[i].empty() ); Sx[i].insert(i); } - + // evaluate the dependency matrix for F(x) CppAD::vector< std::set > Sy(m); Sy = F.ForSparseJac(n, Sx); - + // check values bool found; for(i = 0; i < m; i++) @@ -1109,64 +1159,67 @@ { found = Sy[i].find(j) != Sy[i].end(); ok &= (found == Check[i * n + j]); } - } - + } + return ok; } bool reverse_sparse_jacobian() { bool ok = true; using namespace CppAD; - + // dimension of the domain space - size_t n = 3; - + size_t n = 3; + // dimension of the range space size_t m = 3; - - // independent variable vector + + // independent variable vector CppAD::vector< AD > X(n); - X[0] = 2.; + X[0] = 2.; X[1] = 3.; X[2] = 4.; Independent(X); - + // dependent variable vector CppAD::vector< AD > Y(m); - + // check results vector CppAD::vector< bool > Check(m * n); - + // initialize index into Y size_t index = 0; - - // Y[0] + + // Y[0] Y[index] = X[0] + X[1] + 5.; Check[index * n + 0] = true; Check[index * n + 1] = true; Check[index * n + 2] = false; index++; - - // Y[1] + + // Y[1] Y[index] = Y[0] - (X[1] + X[2]); Check[index * n + 0] = true; Check[index * n + 1] = true; Check[index * n + 2] = true; index++; - // Y[2] + // Y[2] Y[index] = CondExpLe(X[0], X[1], X[1]+X[1], X[2]-X[2]); Check[index * n + 0] = false; Check[index * n + 1] = true; Check[index * n + 2] = true; index++; - + // check final index assert( index == m ); - + // create function object F : X -> Y ADFun F(X, Y); - F.optimize(); - + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + // ---------------------------------------------------------- // dependency matrix for the identity function CppAD::vector< bool > Py(m * m); @@ -1175,38 +1228,38 @@ { for(j = 0; j < m; j++) Py[ i * m + j ] = (i == j); } - + // evaluate the dependency matrix for F(x) CppAD::vector< bool > Px(m * n); Px = F.RevSparseJac(m, Py); - + // check values for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Px[i * n + j] == Check[i * n + j]); - } - + } + return ok; } bool reverse_sparse_hessian(void) { bool ok = true; using CppAD::AD; size_t i, j; - + size_t n = 3; - CppAD::vector< AD > X(n); + CppAD::vector< AD > X(n); X[0] = 1.; X[1] = 2.; X[2] = 3.; CppAD::Independent(X); - + size_t m = 1; CppAD::vector< AD > Y(m); - Y[0] = CondExpGe( X[0], X[1], - X[0] + (2. + X[1] + 3.) * X[1], + Y[0] = CondExpGe( X[0], X[1], + X[0] + (2. + X[1] + 3.) * X[1], X[0] + (2. + X[2] + 3.) * X[1] ); - + CppAD::vector check(n * n); check[0 * n + 0] = false; // partial w.r.t. x[0], x[0] check[0 * n + 1] = false; // x[0], x[1] @@ -1219,22 +1272,25 @@ check[2 * n + 0] = false; // partial w.r.t. x[2], x[0] check[2 * n + 1] = true; // x[2], x[1] check[2 * n + 2] = false; // x[2], x[2] - + // create function object F : X -> Y CppAD::ADFun F(X, Y); - F.optimize(); - + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + // sparsity pattern for the identity function U(x) = x CppAD::vector Px(n * n); for(i = 0; i < n; i++) for(j = 0; j < n; j++) Px[ i * n + j ] = (i == j); - + // compute sparsity pattern for Jacobian of F(U(x)) CppAD::vector P_jac(m * n); P_jac = F.ForSparseJac(n, Px); - - // compute sparsity pattern for Hessian of F_k ( U(x) ) + + // compute sparsity pattern for Hessian of F_k ( U(x) ) CppAD::vector Py(m); CppAD::vector Pxx(n * n); Py[0] = true; @@ -1242,7 +1298,7 @@ // check values for(i = 0; i < n * n; i++) ok &= (Pxx[i] == check[i]); - + return ok; } // check that CondExp properly detects dependencies @@ -1251,15 +1307,15 @@ using CppAD::AD; AD zero(0.), one(1.), two(2.), three(3.); - + size_t n = 4; - CppAD::vector< AD > X(n); + CppAD::vector< AD > X(n); X[0] = zero; X[1] = one; X[2] = two; X[3] = three; CppAD::Independent(X); - + size_t m = 4; CppAD::vector< AD > Y(m); Y[0] = CondExpLt(X[0] + .5, one, two, three); @@ -1268,7 +1324,10 @@ Y[3] = CondExpLt(zero, one, two, X[3] + .5); CppAD::ADFun f(X, Y); - f.optimize(); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); CppAD::vector x(n), y(m); size_t i; @@ -1287,18 +1346,18 @@ return ok; } - // check that CondExp properly handels expressions that get + // check that CondExp properly handels expressions that get // removed during opitmization bool cond_exp_removed(void) { bool ok = true; using CppAD::AD; AD zero(0.); - + size_t n = 1; - CppAD::vector< AD > X(n); + CppAD::vector< AD > X(n); X[0] = 1.0; CppAD::Independent(X); - + size_t m = 1; CppAD::vector< AD > Y(m); @@ -1307,17 +1366,20 @@ Y[0] = CondExpLt(X[0], zero, true_case, false_case); CppAD::ADFun f(X, Y); - f.optimize(); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); CppAD::vector x(n), y(m), w(m), dw(n); x[0] = 1.0; y = f.Forward(0, x); - ok &= NearEqual(y[0], false_case, 1e-10, 1e-10); + ok &= NearEqual(y[0], false_case, eps_, eps_); w[0] = 1.0; dw = f.Reverse(1, w); // derivative of cos is minus sin - ok &= NearEqual(dw[0], - true_case, 1e-10, 1e-10); + ok &= NearEqual(dw[0], - true_case, eps_, eps_); return ok; } @@ -1339,15 +1401,15 @@ bool old_atomic_forward( size_t id , - size_t k , + size_t k , size_t n , size_t m , const CppAD::vector& vx , CppAD::vector& vy , - const CppAD::vector& tx , + const CppAD::vector& tx , CppAD::vector& ty ) { assert(n == 3 && m == 2); - if( k > 0 ) + if( k > 0 ) return false; // y[0] = x[0] + x[1] @@ -1355,20 +1417,20 @@ // y[1] = x[1] + x[2] ty[1] = tx[1] + tx[2]; - + if( vy.size() > 0 ) { vy[0] = (vx[0] | vx[1]); vy[1] = (vx[1] | vx[2]); } - return true; + return true; } bool old_atomic_reverse( size_t id , - size_t k , - size_t n , - size_t m , - const CppAD::vector& tx , + size_t k , + size_t n , + size_t m , + const CppAD::vector& tx , const CppAD::vector& ty , CppAD::vector& px , const CppAD::vector& py ) @@ -1401,7 +1463,7 @@ my_union(r[1], r[1], s[1]); my_union(r[2], r[2], s[1]); - return true; + return true; } bool old_atomic_rev_hes_sparse( @@ -1424,7 +1486,7 @@ old_atomic_reverse , old_atomic_for_jac_sparse , old_atomic_rev_jac_sparse , - old_atomic_rev_hes_sparse + old_atomic_rev_hes_sparse ) bool old_atomic_test(void) @@ -1475,7 +1537,7 @@ for(j = 0; j < n; j++) ax[j] = 1. / 3.; CppAD::Independent(ax); - + // dependent variable vector size_t m = 1; CppAD::vector< AD > ay(m); @@ -1486,11 +1548,14 @@ else ay[0] -= ax[j]; } CppAD::ADFun f(ax, ay); - + // Used to fail assert in optimize that forward mode results // are identically equal - f.optimize(); - + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + return ok; } // ----------------------------------------------------------------------- @@ -1500,27 +1565,30 @@ bool discrete_function(void) { bool ok = true; using CppAD::vector; - + vector< CppAD::AD > ax(1), ay(1); - ax[0] = 0.0; + ax[0] = 0.0; CppAD::Independent(ax); - ay[0] = floor(ax[0]) + floor(ax[0]); + ay[0] = floor(ax[0]) + floor(ax[0]); CppAD::ADFun f(ax, ay); - + size_t size_before = f.size_var(); - f.optimize(); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); size_t size_after = f.size_var(); ok &= size_after + 1 == size_before; - + vector x(1), y(1); x[0] = -2.2; y = f.Forward(0, x); ok &= y[0] == -6.0; - + return ok; } // ---------------------------------------------------------------- - void i_algo( + void i_algo( const CppAD::vector< CppAD::AD >& ax , CppAD::vector< CppAD::AD >& ay ) { ay[0] = 1.0 / ax[0]; } @@ -1530,18 +1598,18 @@ { bool ok = true; using CppAD::AD; using CppAD::vector; - + // Create a checkpoint version of the function i_algo vector< AD > au(1), av(1), aw(1); au[0] = 1.0; CppAD::checkpoint i_check("i_check", i_algo, au, av); - - // independent variable vector + + // independent variable vector vector< AD > ax(2), ay(1); ax[0] = 1.0; ax[1] = 2.0; Independent(ax); - + // call atomic function that does not get used au[0] = ax[0]; i_check(au, av); @@ -1559,11 +1627,14 @@ x[0] = 1.0; x[1] = 2.0; y_before = f.Forward(0, x); - f.optimize(); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); y_after = f.Forward(0, x); - + ok &= y_before[0] == y_after[0]; - + return ok; } // @@ -1573,14 +1644,14 @@ { bool ok = true; using CppAD::AD; using CppAD::vector; - + // Create a checkpoint version of the function i_algo vector< AD > au(1), av(1), aw(1); au[0] = 1.0; CppAD::checkpoint i_check("i_check", i_algo, au, av); - + vector< AD > ax(2), ay(1); - AD zero = 0.0; + AD zero = 0.0; ax[0] = 1.0; ax[1] = 1.0; Independent(ax); @@ -1600,7 +1671,10 @@ dx[0] = 2.0; dx[1] = 2.0; dy_before = f.Forward(1, dx); - f.optimize(); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); y_after = f.Forward(0, x); dy_after = f.Forward(1, dx); @@ -1615,24 +1689,27 @@ Type my_max(const CppAD::vector& arg) { Type res = arg[0]; for(size_t j = 0;j < arg.size(); j++) - res = CondExpGt(res, arg[j], res, arg[j]); + res = CondExpGt(res, arg[j], res, arg[j]); return res; - } + } bool cond_exp_reverse(void) { bool ok = true; size_t n = 3; using CppAD::vector; using CppAD::AD; - + vector< AD > ax(n), ay(1); for(size_t j = 0; j < n; j++) ax[j] = 1.0; Independent(ax); ay[0] = my_max(ax) + my_max(ax); CppAD::ADFun f(ax, ay); - - f.optimize(); - + + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + vector x(n), w(1), dx(n); for(size_t j = 0;j < n; j++) x[j] = double(j); @@ -1655,7 +1732,7 @@ using CppAD::AD; // f(x) = x[0] + x[0] if x[0] >= 3 - // = x[0] + x[1] otherwise + // = x[0] + x[1] otherwise vector< AD > ax(2), ay(3); ax[0] = 1.0; ax[1] = 2.0; @@ -1669,7 +1746,10 @@ // a unary expression ay[2] = CppAD::CondExpGe(ax[0], three, exp(ax[0]), exp(ax[0]) ); CppAD::ADFun f(ax, ay); - f.optimize(); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); // check case where x[0] >= 3 vector x(2), y(3); @@ -1694,58 +1774,73 @@ bool optimize(void) { bool ok = true; + conditional_skip_ = true; + atomic_sparsity_option_ = CppAD::atomic_base::bool_sparsity_enum; - atomic_sparsity_option = CppAD::atomic_base::bool_sparsity_enum; - for(size_t i = 0; i < 2; i++) - { // check conditional expression sparsity pattern - // (used to optimize calls to atomic functions). + // atomic sparsity loop + for(size_t i = 0; i < 3; i++) + { if( i == 0 ) atomic_sparsity_option_ = + CppAD::atomic_base::pack_sparsity_enum; + else if( i == 1 ) atomic_sparsity_option_ = + CppAD::atomic_base::bool_sparsity_enum; + else if( i == 2 ) atomic_sparsity_option_ = + CppAD::atomic_base::set_sparsity_enum; + else + ok &= false; + // + // check conditional expression sparsity pattern + // (used to optimize calls to atomic functions). ok &= atomic_cond_exp_sparsity(); // check optimizing out entire atomic function ok &= atomic_cond_exp(); // check optimizing out atomic arguments ok &= atomic_no_used(); ok &= atomic_arguments(); - atomic_sparsity_option = - CppAD::atomic_base::set_sparsity_enum; } - // check nested conditional expressions - ok &= nested_cond_exp(); - // check reverse dependency analysis optimization - ok &= depend_one(); - ok &= depend_two(); - ok &= depend_three(); - ok &= depend_four(); - // check removal of duplicate expressions - ok &= duplicate_one(); - ok &= duplicate_two(); - ok &= duplicate_three(); - ok &= duplicate_four(); - // convert sequence of additions to cummulative summation - ok &= cummulative_sum(); - ok &= forward_csum(); - ok &= reverse_csum(); - // sparsity patterns - ok &= forward_sparse_jacobian(); - ok &= reverse_sparse_jacobian(); - ok &= reverse_sparse_hessian(); - // check that CondExp properly detects dependencies - ok &= cond_exp_depend(); - // check that CondExp properly handles expressions that are removed - ok &= cond_exp_removed(); - // check old_atomic functions - ok &= old_atomic_test(); - // case where results are not identically equal - ok &= not_identically_equal(); - // case where a discrete function is used - ok &= discrete_function(); - // check conditional skip of an atomic function - ok &= cond_exp_skip_atomic(); - // check conditional dependence through atomic function - ok &= cond_exp_atomic_dependence(); - // check reverse mode conditional skipping - ok &= cond_exp_reverse(); - // check case where an expresion needed by both true and false case - ok &= cond_exp_both_true_and_false(); + + // conditional skip loop + for(size_t i = 0; i < 2; i++) + { conditional_skip_ = i == 0; + // + // check nested conditional expressions + ok &= nested_cond_exp(); + // check reverse dependency analysis optimization + ok &= depend_one(); + ok &= depend_two(); + ok &= depend_three(); + ok &= depend_four(); + // check removal of duplicate expressions + ok &= duplicate_one(); + ok &= duplicate_two(); + ok &= duplicate_three(); + ok &= duplicate_four(); + // convert sequence of additions to cummulative summation + ok &= cummulative_sum(); + ok &= forward_csum(); + ok &= reverse_csum(); + // sparsity patterns + ok &= forward_sparse_jacobian(); + ok &= reverse_sparse_jacobian(); + ok &= reverse_sparse_hessian(); + // check that CondExp properly detects dependencies + ok &= cond_exp_depend(); + // check that it properly handles expressions that have been removed + ok &= cond_exp_removed(); + // check old_atomic functions + ok &= old_atomic_test(); + // case where results are not identically equal + ok &= not_identically_equal(); + // case where a discrete function is used + ok &= discrete_function(); + // check conditional skip of an atomic function + ok &= cond_exp_skip_atomic(); + // check conditional dependence through atomic function + ok &= cond_exp_atomic_dependence(); + // check reverse mode conditional skipping + ok &= cond_exp_reverse(); + // check case where an expresion needed by both true and false case + ok &= cond_exp_both_true_and_false(); + } // CppAD::user_atomic::clear(); return ok; diff -Nru cppad-2015.00.00.9/test_more/parameter.cpp cppad-2016.00.00.1/test_more/parameter.cpp --- cppad-2015.00.00.9/test_more/parameter.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/parameter.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: parameter.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: parameter.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -31,21 +31,21 @@ size_t j, n = n_parameter * n_repeat; CPPAD_TESTVECTOR(AD) ax(n); for(j = 0; j < n; j++) - ax[j] = Float(j); + ax[j] = Float(j); Independent(ax); // dependent variable vector and indices size_t i, m = n; CPPAD_TESTVECTOR(AD) ay(m); for(i = 0; i < m; i++) - { // must avoid Float(k) = 0 because it would get optimized out - size_t k = (i % n_parameter); + { // must avoid Float(k) = 0 because it would get optimized out + size_t k = (i % n_parameter); k = k * k * 10 + 1; j = i; ay[i] = ax[j] + Float(k); } - // create f: ax -> ay + // create f: ax -> ay ADFun f(ax, ay); ok = f.size_par() == n_parameter; @@ -58,6 +58,6 @@ bool parameter(void) { bool ok = true; ok &= test(); - ok &= test(); + ok &= test(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/poly.cpp cppad-2016.00.00.1/test_more/poly.cpp --- cppad-2015.00.00.9/test_more/poly.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/poly.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: poly.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: poly.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -42,11 +42,11 @@ Z[0] = 3.; // value of independent variable Independent(Z); // declare independent variable - // dependent variables + // dependent variables CPPAD_TESTVECTOR(AD) P(1); // one dependent variable P[0] = Poly(0, A, Z[0]); // value of polynomial at Z[0] - // define f : Z -> P as a function mapping independent to dependent + // define f : Z -> P as a function mapping independent to dependent ADFun f(Z, P); // ADFun corresponding to polynomial // compute derivative of polynomial diff -Nru cppad-2015.00.00.9/test_more/pow.cpp cppad-2016.00.00.1/test_more/pow.cpp --- cppad-2015.00.00.9/test_more/pow.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/pow.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: pow.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: pow.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -34,7 +34,7 @@ // declare independent variables and start tape recording CppAD::Independent(XY); - // range space vector + // range space vector size_t m = 3; CPPAD_TESTVECTOR(AD) Z(m); Z[0] = CppAD::pow(XY[0], XY[1]); // pow(variable, variable) @@ -42,9 +42,9 @@ Z[2] = CppAD::pow(x, XY[1]); // pow(parameter, variable) // create f: XY -> Z and stop tape recording - CppAD::ADFun f(XY, Z); + CppAD::ADFun f(XY, Z); - // check value + // check value double check = std::pow(x, y); size_t i; for(i = 0; i < m; i++) @@ -152,19 +152,19 @@ w = f.Forward(1, v); ok &= ( w[y] == U[s] * u * Z[y] ); // dy/dt - // forward computation of second Taylor coefficient w.r.t. t + // forward computation of second Taylor coefficient w.r.t. t v[t] = 1.; w = f.Forward(1, v); v[t] = 0.; CPPAD_TESTVECTOR(double) f_tt = f.Forward(2, v); - // forward computation of second Taylor coefficient w.r.t. s + // forward computation of second Taylor coefficient w.r.t. s v[s] = 1.; w = f.Forward(1, v); v[s] = 0.; CPPAD_TESTVECTOR(double) f_ss = f.Forward(2, v); - // second Taylor coefficient w.r.t. direction r = (s,t) + // second Taylor coefficient w.r.t. direction r = (s,t) v[s] = 1.; v[t] = 1.; w = f.Forward(1, v); @@ -174,12 +174,12 @@ // check second order partial of y ok &= NearEqual( - f_rr[y] - f_ss[y] - f_tt[y], - (1. + U[s]) * u * Z[y] + + f_rr[y] - f_ss[y] - f_tt[y], + (1. + U[s]) * u * Z[y] + (1. + U[s]) * U[t] * u * U[s] * u * Z[y], 1e-10 , - 1e-10 - ); + 1e-10 + ); return ok; } @@ -198,7 +198,7 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 4; CPPAD_TESTVECTOR(AD) y(m); @@ -209,7 +209,7 @@ y[3] = pow(1., x[0]); // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); // check function values ok &= (Value(y[0]) == 1.); @@ -227,7 +227,7 @@ ok &= NearEqual(dy[2], 1., 1e-10, 1e-10); ok &= (dy[3] == 0.); - // reverse mode computation of derivative of y[0]+y[1]+y[2]+y[3] + // reverse mode computation of derivative of y[0]+y[1]+y[2]+y[3] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; @@ -237,7 +237,7 @@ dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., 1e-10, 1e-10); - return ok; + return ok; } bool PowTestFour(void) @@ -255,18 +255,18 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 5; CPPAD_TESTVECTOR(AD) y(m); // some special cases (skip zero raised to a negative power) y[0] = pow(1., x[0]); size_t i; - for(i = 1; i < m; i++) + for(i = 1; i < m; i++) y[i] = pow(x[0], i-1); // pow(AD, int) // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); ok &= (Value(y[0]) == 1.); double check; @@ -298,7 +298,7 @@ dw = f.Reverse(1, w); ok &= NearEqual(dw[0], sum, 1e-10, 1e-10); - return ok; + return ok; } bool PowTestFive(void) { bool ok = true; @@ -315,7 +315,7 @@ // declare independent variables and start tape recording CppAD::Independent(x); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); @@ -324,7 +324,7 @@ y[0] = pow(x[0], int(e)); // use pow(AD, int) // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); // check function value ok &= (Value(y[0]) == pow(x0, e) ); @@ -337,7 +337,7 @@ dy = f.Forward(1, dx); ok &= NearEqual(dy[0], d1, 1e-10, 1e-10); - // reverse mode computation of second partials + // reverse mode computation of second partials // x.r.t. x[1],x[0] and x[1], x[1] double d2 = e * (e-1) * pow(x0, (e-2)); CPPAD_TESTVECTOR(double) w(m); @@ -347,7 +347,7 @@ ok &= NearEqual(ddw[0], d1, 1e-10, 1e-10); ok &= NearEqual(ddw[1], d2, 1e-10, 1e-10); - return ok; + return ok; } bool PowTestSix(void) { bool ok = true; @@ -368,16 +368,16 @@ // declare independent variables and start tape recording CppAD::Independent(X); - // range space vector + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD< AD >) Y(m); // case of AD< AD > raised to a double power double e = 2.5; - Y[0] = pow(X[0], e); + Y[0] = pow(X[0], e); // create F: X -> Y and stop tape recording - CppAD::ADFun< AD > F(X, Y); + CppAD::ADFun< AD > F(X, Y); // check function value ok &= (Value( Value(Y[0]) ) == pow(x0, e) ); @@ -390,7 +390,7 @@ dy = F.Forward(1, dx); ok &= NearEqual(dy[0], d1, 1e-10, 1e-10); - // reverse mode computation of second partials + // reverse mode computation of second partials // x.r.t. x[1],x[0] and x[1], x[1] double d2 = e * (e-1) * pow(x0, (e-2)); CPPAD_TESTVECTOR(AD) w(m); @@ -400,11 +400,11 @@ ok &= NearEqual(ddw[0], d1, 1e-10, 1e-10); ok &= NearEqual(ddw[1], d2, 1e-10, 1e-10); - return ok; + return ok; } } // END empty namespace - + bool Pow(void) { bool ok = true; ok &= PowTestOne(); diff -Nru cppad-2015.00.00.9/test_more/pow_int.cpp cppad-2016.00.00.1/test_more/pow_int.cpp --- cppad-2015.00.00.9/test_more/pow_int.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/pow_int.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: pow_int.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: pow_int.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -52,7 +52,7 @@ ok &= NearEqual(Z[0] , exp( log(u) * 5.), 1e-10 , 1e-10); ok &= NearEqual(Z[1] , exp( - log(u) * 5.), 1e-10 , 1e-10); - // forward computation of partials + // forward computation of partials v[0] = 1.; w = f.Forward(1, v); ok &= NearEqual(w[0] , 5. * exp( log(u) * 4.), 1e-10 , 1e-10); diff -Nru cppad-2015.00.00.9/test_more/print_for.cpp cppad-2016.00.00.1/test_more/print_for.cpp --- cppad-2015.00.00.9/test_more/print_for.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/print_for.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: print_for.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: print_for.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -13,7 +13,7 @@ // modified version of test that used to be in ../print_for/print_for.cpp # include -namespace { +namespace { using std::endl; using CppAD::AD; @@ -26,7 +26,7 @@ PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); return log(y); - } + } } bool print_for(void) @@ -46,13 +46,13 @@ CppAD::VecAD av(1); AD Zero(0); av[Zero] = 0.; - PrintFor("v[0] = ", av[Zero]); + PrintFor("v[0] = ", av[Zero]); string_check += "v[0] = 0"; // v[0] == 0 during Forward(0, x) // Print a newline to separate this from previous output, // then print an AD object that is a variable. - PrintFor("\nv[0] + x[0] = ", av[0] + ax[0]); - string_check += "\nv[0] + x[0] = 2"; // x[0] == 2 during Forward(0, x) + PrintFor("\nv[0] + x[0] = ", av[0] + ax[0]); + string_check += "\nv[0] + x[0] = 2"; // x[0] == 2 during Forward(0, x) // A conditional print that will not generate output when x[0] = 2. PrintFor(ax[0], "\n 2. + x[0] = ", 2. + ax[0], "\n"); @@ -66,20 +66,20 @@ AD log_var = check_log(var); string_check += "check_log: y == 0 which is <= 0\n"; - // dependent variable vector + // dependent variable vector size_t m = 2; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = av[Zero] + ax[0]; // define f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); - // zero order forward with x[0] = 2 + // zero order forward with x[0] = 2 CPPAD_TESTVECTOR(double) x(n); x[0] = 2.; - f.Forward(0, x, stream_out); + f.Forward(0, x, stream_out); std::string string_out = stream_out.str(); - ok &= string_out == string_check; + ok &= string_out == string_check; return ok; } diff -Nru cppad-2015.00.00.9/test_more/reverse.cpp cppad-2016.00.00.1/test_more/reverse.cpp --- cppad-2015.00.00.9/test_more/reverse.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/reverse.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: reverse.cpp 2859 2013-05-28 06:03:21Z bradbell $ */ +// $Id: reverse.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -22,7 +22,7 @@ using namespace CppAD; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) U(3); U[0] = 0.; U[1] = 1.; U[2] = 2.; Independent(U); @@ -36,7 +36,7 @@ Prod *= U[i]; } - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) V(2); V[0] = Sum; V[1] = Prod; @@ -61,7 +61,7 @@ // compare values for(i = 0; i < 3; i++) - { ok &= NearEqual(r1[i] , + { ok &= NearEqual(r1[i] , v[0] * g0[i] + v[1] * g1[i], 1e-10, 1e-10); } @@ -85,16 +85,16 @@ // check derivative of the zero order term for(i = 0; i < 3; i++) - { ok &= NearEqual(r2[p * i + 0] , + { ok &= NearEqual(r2[p * i + 0] , v[0] * g0[i] + v[1] * g1[i], 1e-10, 1e-10); } /* - The j-th component of the first order term is + The j-th component of the first order term is d/dt z_j(0, u0, u1) = f_j^{(1)} (u0) * u1 We use ei to denote the vector with its i-th component one and all the other components zero. The partial derivative of the j-th - component of the first order term with respect u0[i] is + component of the first order term with respect u0[i] is ei * f_j^{(2)} ( u0 ) * u1 */ @@ -121,7 +121,7 @@ } // define the template function reverse_any_cases in empty namespace -template +template bool reverse_any_cases(void) { bool ok = true; using CppAD::AD; @@ -130,7 +130,7 @@ // domain space vector size_t n = 3; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; X[2] = 2.; @@ -218,22 +218,22 @@ $index composition, example$$ $index example, composition$$ -$index test, composition$$ +$index test, composition$$ $head Purpose$$ -Break a derivative computation into pieces and only store values at the +Break a derivative computation into pieces and only store values at the interface of the pieces. -In actual applications, there may be many functions, but +In actual applications, there may be many functions, but for this example there are only two. -The functions -$latex F : \B{R}^2 \rightarrow \B{R}^2$$ +The functions +$latex F : \B{R}^2 \rightarrow \B{R}^2$$ and -$latex G : \B{R}^2 \rightarrow \B{R}^2$$ +$latex G : \B{R}^2 \rightarrow \B{R}^2$$ defined by $latex \[ - F(x) = \left( \begin{array}{c} x_0 x_1 \\ x_1 - x_0 \end{array} \right) + F(x) = \left( \begin{array}{c} x_0 x_1 \\ x_1 - x_0 \end{array} \right) \; , \; - G(y) = \left( \begin{array}{c} y_0 - y_1 \\ y_1 y_0 \end{array} \right) + G(y) = \left( \begin{array}{c} y_0 - y_1 \\ y_1 y_0 \end{array} \right) \] $$ Another difference is that in actual applications, the memory corresponding to function objects not currently being used @@ -245,21 +245,21 @@ is defined by $latex \[ \begin{array}{rcl} - H(x) - & = & G_0 [ F(x) ] + G_1 [ F(x) ] + H(x) + & = & G_0 [ F(x) ] + G_1 [ F(x) ] \\ - & = & x_0 x_1 - ( x_1 - x_0 ) + x_0 x_1 ( x_1 - x_0 ) + & = & x_0 x_1 - ( x_1 - x_0 ) + x_0 x_1 ( x_1 - x_0 ) \\ & = & x_0 x_1 ( 1 - x_0 + x_1 ) - x_1 + x_0 \end{array} -\] $$ -Given the zero and first order Taylor coefficients +\] $$ +Given the zero and first order Taylor coefficients $latex x^{(0)} $$ and $latex x^{(1)}$$, we use $latex X(t)$$, $latex Y(t)$$ and $latex Z(t)$$ for the corresponding functions; i.e., $latex \[ \begin{array}{rcl} - X(t) & = & x^{(0)} + x^{(1)} t + X(t) & = & x^{(0)} + x^{(1)} t \\ Y(t) & = & F[X(t)] = y^{(0)} + y^{(1)} t + O(t^2) \\ @@ -272,13 +272,13 @@ \] $$ Here are the processing steps: $list number$$ -Use forward mode on $latex F(x)$$ to compute -$latex y^{(0)}$$ and $latex y^{(1)}$$ +Use forward mode on $latex F(x)$$ to compute +$latex y^{(0)}$$ and $latex y^{(1)}$$ $lnext -Use forward mode on $latex G(y)$$ to compute -$latex z^{(0)}$$ and $latex z^{(1)}$$ +Use forward mode on $latex G(y)$$ to compute +$latex z^{(0)}$$ and $latex z^{(1)}$$ $lnext -Use reverse mode on $latex G(y)$$ to compute the derivative of +Use reverse mode on $latex G(y)$$ to compute the derivative of $latex h^{(k)}$$ with respect to $latex y^{(0)}$$ and $latex y^{(1)}$$. $lnext @@ -388,13 +388,13 @@ w[0*p+0] = 1.; // coefficient for z^0_0 w[1*p+0] = 1.; // coefficient for z^0_1 w[0*p+1] = 0.; // coefficient for z^1_0 - w[1*p+1] = 0.; // coefficient for z^1_1 + w[1*p+1] = 0.; // coefficient for z^1_1 dw = g.Reverse(p, w); - // dv^0 = dw^0 * \partial_x^0 y^0 (x) + dw^1 * \partial_x^0 y^1 (x) - // dv^1 = dw^0 * \partial_x^1 y^0 (x) + dw^1 * \partial_x^1 y^1 (x) + // dv^0 = dw^0 * \partial_x^0 y^0 (x) + dw^1 * \partial_x^0 y^1 (x) + // dv^1 = dw^0 * \partial_x^1 y^0 (x) + dw^1 * \partial_x^1 y^1 (x) CPPAD_TESTVECTOR(double) dv(n*p); - dv = f.Reverse(p, dw); + dv = f.Reverse(p, dw); // check partial of h^0 w.r.t x^0_0 check = x0[1] * (1. - x0[0] + x0[1]) + 1.; @@ -417,12 +417,12 @@ w[0*p+0] = 0.; // coefficient for z^0_0 w[1*p+0] = 0.; // coefficient for z^0_1 w[0*p+1] = 1.; // coefficient for z^1_0 - w[1*p+1] = 1.; // coefficient for z^1_1 + w[1*p+1] = 1.; // coefficient for z^1_1 dw = g.Reverse(p, w); - // dv^0 = dw^0 * \partial_x^0 y^0 (x) + dw^1 * \partial_x^0 y^1 (x) - // dv^1 = dw^0 * \partial_x^1 y^0 (x) + dw^1 * \partial_x^1 y^1 (x) - dv = f.Reverse(p, dw); + // dv^0 = dw^0 * \partial_x^0 y^0 (x) + dw^1 * \partial_x^0 y^1 (x) + // dv^1 = dw^0 * \partial_x^1 y^0 (x) + dw^1 * \partial_x^1 y^1 (x) + dv = f.Reverse(p, dw); // check partial of h^1 w.r.t x^0_0 check = x0[1] * (- x1[0] + x1[1]); @@ -432,7 +432,7 @@ // check partial of h^1 w.r.t x^0_1 check = x0[0] * (- x1[0] + x1[1]); - check += x1[0] * (1. - x0[0] + x0[1]) + x1[0] * x0[1]; + check += x1[0] * (1. - x0[0] + x0[1]) + x1[0] * x0[1]; check += x0[0] * x1[1]; ok &= NearEqual(dv[1*p+0], check, eps, eps); @@ -451,7 +451,7 @@ return ok; } // ---------------------------------------------------------------------------- -} // End empty namespace +} // End empty namespace # include # include diff -Nru cppad-2015.00.00.9/test_more/rev_sparse_hes.cpp cppad-2016.00.00.1/test_more/rev_sparse_hes.cpp --- cppad-2015.00.00.9/test_more/rev_sparse_hes.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/rev_sparse_hes.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rev_sparse_hes.cpp 2935 2013-10-12 19:40:01Z bradbell $ */ +// $Id: rev_sparse_hes.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -12,7 +12,7 @@ # include - + namespace { // Begin empty namespace bool case_one() @@ -20,7 +20,7 @@ using namespace CppAD; // dimension of the domain space - size_t n = 10; + size_t n = 10; // dimension of the range space size_t m = 2; @@ -33,7 +33,7 @@ for(j = 0; j < n * n; j++) Check[j] = false; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); for(j = 0; j < n; j++) X[j] = AD(j); @@ -54,7 +54,7 @@ sum += CondExpLt(X[1], X[2], sin(X[6]), cos(X[7]) ); Check[6 * n + 6] = true; Check[7 * n + 7] = true; - + // pow(variable, variable) sum += pow(X[8], X[9]); Check[8 * n + 8] = Check[8 * n + 9] = true; @@ -82,7 +82,7 @@ // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Px); - // compute sparsity pattern for Hessian of F_0 ( U(x) ) + // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(bool) Py(m); Py[0] = true; Py[1] = false; @@ -109,7 +109,7 @@ // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Sx); - // compute sparsity pattern for Hessian of F_0 ( U(x) ) + // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(std::set) Sy(1); Sy[0].insert(0); CPPAD_TESTVECTOR(std::set) Sxx(n); @@ -142,7 +142,7 @@ using namespace CppAD; // dimension of the domain space - size_t n = 4; + size_t n = 4; // dimension of the range space size_t m = 1; @@ -155,14 +155,14 @@ for(j = 0; j < n * n; j++) Check[j] = false; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); for(j = 0; j < n; j++) X[j] = AD(j); Independent(X); // Test the case where dependent variable is a non-linear function - // of the result of a conditional expression. + // of the result of a conditional expression. CPPAD_TESTVECTOR(AD) Y(m); Y[0] = CondExpLt(X[0], X[1], X[2], X[3]); Y[0] = cos(Y[0]) + X[0] + X[1]; @@ -173,7 +173,7 @@ // inefficiency of the conditional expression operator). Check[2 * n + 2] = Check[ 2 * n + 3 ] = true; Check[3 * n + 2] = Check[ 3 * n + 3 ] = true; - + // create function object F : X -> Y ADFun F(X, Y); @@ -189,7 +189,7 @@ // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Px); - // compute sparsity pattern for Hessian of F_0 ( U(x) ) + // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(bool) Py(m); Py[0] = true; CPPAD_TESTVECTOR(bool) Pxx(n * n); @@ -208,7 +208,7 @@ // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Sx); - // compute sparsity pattern for Hessian of F_0 ( U(x) ) + // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(std::set) Sy(1); Sy[0].insert(0); CPPAD_TESTVECTOR(std::set) Sxx(n); @@ -230,9 +230,9 @@ using CppAD::AD; // domain space vector - size_t n = 1; + size_t n = 1; CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; // declare independent variables and start recording CppAD::Independent(X); @@ -281,7 +281,7 @@ // compute sparsity pattern for Jacobian of F(U(x)) f.ForSparseJac(n, Sx); - // compute sparsity pattern for Hessian of F_0 ( U(x) ) + // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(std::set) Sy(1); Sy[0].insert(0); CPPAD_TESTVECTOR(std::set) Sxx(n); @@ -299,7 +299,7 @@ using namespace CppAD; // dimension of the domain space - size_t n = 3; + size_t n = 3; // dimension of the range space size_t m = 1; @@ -310,9 +310,9 @@ for(k = 0; k < n-1; k++) Z[k] = 0.; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; X[2] = 2.; Independent(X); @@ -320,7 +320,7 @@ // VecAD vector z depends on both x[1] and x[2] // (component indices do not matter because they can change). Z[ X[0] ] = X[1] * X[2]; - Z[ X[1] ] = 0.; + Z[ X[1] ] = 0.; // dependent variable vector CPPAD_TESTVECTOR(AD) Y(m); @@ -366,7 +366,7 @@ for(i = 0; i < n; i++) { for(j = 0; j < n; j++) ok &= (h[i * n + j] == Check[i * n + j]); - } + } // ------------------------------------------------------------------ // sparsity pattern for the identity function U(x) = x @@ -377,7 +377,7 @@ // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Sx); - // compute sparsity pattern for Hessian of F_0 ( U(x) ) + // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(std::set) Sy(1); Sy[0].insert(0); CPPAD_TESTVECTOR(std::set) Sxx(n); @@ -400,7 +400,7 @@ size_t i, j, k; size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); + CPPAD_TESTVECTOR(AD) X(n); X[0] = 1.; X[1] = 2.; CppAD::Independent(X); @@ -422,7 +422,7 @@ // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Px); - // compute sparsity pattern for Hessian of F_k ( U(x) ) + // compute sparsity pattern for Hessian of F_k ( U(x) ) CPPAD_TESTVECTOR(bool) Py(m); CPPAD_TESTVECTOR(bool) Pxx(n * n); for(k = 0; k < m; k++) @@ -445,14 +445,14 @@ using namespace CppAD; // dimension of the domain space - size_t n = 3; + size_t n = 3; // dimension of the range space size_t m = 1; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; X[2] = 2.; Independent(X); @@ -512,7 +512,7 @@ for(i = 0; i < n; i++) { for(j = 0; j < n; j++) ok &= (h[i * n + j] == Check[i * n + j]); - } + } // compute the reverse Hessian sparsity pattern for R^T * F^2 transpose = false; @@ -522,7 +522,7 @@ for(i = 0; i < n; i++) { for(j = 0; j < n; j++) ok &= (h[j * n + i] == Check[i * n + j]); - } + } return ok; } diff -Nru cppad-2015.00.00.9/test_more/rev_sparse_jac.cpp cppad-2016.00.00.1/test_more/rev_sparse_jac.cpp --- cppad-2015.00.00.9/test_more/rev_sparse_jac.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/rev_sparse_jac.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rev_sparse_jac.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: rev_sparse_jac.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -48,7 +48,7 @@ Check[index * n + 1] = true; \ Check[index * n + 2] = false; \ index++; - + # define CheckBinaryFun(Fun) \ Y[index] = Fun( X[0] , 2.); \ @@ -74,14 +74,14 @@ using namespace CppAD; // dimension of the domain space - size_t n = 3; + size_t n = 3; // dimension of the range space size_t m = (4 + 11 + 1) * 3 + 4; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = .1; + X[0] = .1; X[1] = .2; X[2] = .3; Independent(X); @@ -166,7 +166,7 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Px[i * n + j] == Check[i * n + j]); - } + } // -------------------------------------------------------- // dependency matrix for the identity function U(y) = y CPPAD_TESTVECTOR(std::set) Sy(m); @@ -185,9 +185,9 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { found = Sx[i].find(j) != Sx[i].end(); - ok &= (found == Check[i * n + j]); + ok &= (found == Check[i * n + j]); } - } + } return ok; } @@ -197,7 +197,7 @@ using namespace CppAD; // dimension of the domain space - size_t n = 3; + size_t n = 3; // dimension of the range space size_t m = 3; @@ -208,16 +208,16 @@ for(k = 0; k < n-1; k++) Z[k] = 0.; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; + X[0] = 0.; X[1] = 1.; X[2] = 2.; Independent(X); // VecAD vector is going to depend on X[1] and X[2] Z[ X[0] ] = X[1]; - Z[ X[1] ] = X[2]; + Z[ X[1] ] = X[2]; // dependent variable vector CPPAD_TESTVECTOR(AD) Y(m); @@ -273,7 +273,7 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Px[i * n + j] == Check[i * n + j]); - } + } // -------------------------------------------------------- // dependency matrix for the identity function U(y) = y CPPAD_TESTVECTOR(std::set) Sy(m); @@ -292,9 +292,9 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { found = Sx[i].find(j) != Sx[i].end(); - ok &= (found == Check[i * n + j]); + ok &= (found == Check[i * n + j]); } - } + } return ok; } @@ -304,14 +304,14 @@ using namespace CppAD; // dimension of the domain space - size_t n = 2; + size_t n = 2; // dimension of the range space size_t m = 3; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; + X[0] = 2.; X[1] = 3.; Independent(X); @@ -365,10 +365,10 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Px[i * n + j] == Check[i * n + j]); - } + } // --------------------------------------------------------- - // dependency matrix for the identity function + // dependency matrix for the identity function CPPAD_TESTVECTOR(std::set) Sy(m); for(i = 0; i < m; i++) { assert( Sy[i].empty() ); @@ -386,7 +386,7 @@ { found = Sx[i].find(j) != Sx[i].end(); ok &= (found == Check[i * n + j]); } - } + } return ok; } @@ -394,19 +394,19 @@ // case where s is not identity matrix bool case_four() -{ +{ bool ok = true; using namespace CppAD; // dimension of the domain space - size_t n = 2; + size_t n = 2; // dimension of the range space size_t m = n; - // independent and variable vectors + // independent and variable vectors CPPAD_TESTVECTOR(AD) ax(n), ay(m); - ax[0] = 2.; + ax[0] = 2.; ax[1] = 3.; Independent(ax); ay[0] = ax[1]; @@ -434,14 +434,14 @@ using namespace CppAD; // dimension of the domain space - size_t n = 2; + size_t n = 2; // dimension of the range space size_t m = 3; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; + X[0] = 2.; X[1] = 3.; Independent(X); @@ -496,10 +496,10 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Px[j * m + i] == Check[i * n + j]); - } + } // --------------------------------------------------------- - // dependency matrix for the identity function + // dependency matrix for the identity function CPPAD_TESTVECTOR(std::set) Sy(m); for(i = 0; i < m; i++) { assert( Sy[i].empty() ); @@ -517,7 +517,7 @@ { found = Sx[j].find(i) != Sx[j].end(); ok &= (found == Check[i * n + j]); } - } + } return ok; } diff -Nru cppad-2015.00.00.9/test_more/rev_two.cpp cppad-2016.00.00.1/test_more/rev_two.cpp --- cppad-2015.00.00.9/test_more/rev_two.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/rev_two.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rev_two.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: rev_two.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -19,13 +19,13 @@ size_t n = 2; - vector< AD > X(n); + vector< AD > X(n); X[0] = 1.; X[1] = 1.; Independent(X); size_t m = 1; - vector< AD > Y(m); + vector< AD > Y(m); Y[0] = X[0] * X[0] + X[0] * X[1] + 2. * X[1] * X[1]; CppAD::ADFun F(X,Y); diff -Nru cppad-2015.00.00.9/test_more/romberg_one.cpp cppad-2016.00.00.1/test_more/romberg_one.cpp --- cppad-2015.00.00.9/test_more/romberg_one.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/romberg_one.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: romberg_one.cpp 3060 2013-12-27 20:38:57Z bradbell $ */ +/* $Id: romberg_one.cpp 3747 2015-11-09 14:25:41Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -11,7 +11,7 @@ -------------------------------------------------------------------------- */ /* -$begin romberg_one.cpp$$ +old romberg_one.cpp example / test $spell Romberg $$ @@ -23,7 +23,7 @@ $index test, Romberg$$ $code -$verbatim%example/romberg_one.cpp%0%// BEGIN C++%// END C++%1%$$ +old verbatim%example/romberg_one.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end @@ -38,7 +38,7 @@ const size_t degree; public: // constructor - Fun(size_t degree_) : degree(degree_) + Fun(size_t degree_) : degree(degree_) { } // function F(x) = x^degree @@ -68,14 +68,14 @@ Float e; size_t p; - // int_a^b F(x) dx = - // [ b^(degree+1) - a^(degree+1) ] / (degree+1) + // int_a^b F(x) dx = + // [ b^(degree+1) - a^(degree+1) ] / (degree+1) Float bpow(1); Float apow(1); for(i = 0; i <= degree; i++) { bpow *= b; apow *= a; - } + } Float check = (bpow - apow) / Float(degree+1); // step size corresponding to r @@ -91,7 +91,7 @@ r = CppAD::RombergOne(F, a, b, n, p, e); ok &= e < (degree+1) * spow; - ok &= CppAD::NearEqual(check, r, Float(0.), e); + ok &= CppAD::NearEqual(check, r, Float(0.), e); } return ok; diff -Nru cppad-2015.00.00.9/test_more/rosen_34.cpp cppad-2016.00.00.1/test_more/rosen_34.cpp --- cppad-2015.00.00.9/test_more/rosen_34.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/rosen_34.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: rosen_34.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: rosen_34.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,7 +23,7 @@ /* Case where x[0](0) = 1, x[0]'(t) = - w[0] * x[0](t) -x[1](0) = 1, x[1]'(t) = - w[1] * x[1](t) +x[1](0) = 1, x[1]'(t) = - w[1] * x[1](t) x[2](0) = 0, x[2]'(t) = w[2] * t x[0](t) = exp( - w[0] * t ) @@ -39,38 +39,38 @@ w = w_; } void Ode( - const CppAD::AD &t, - const CPPAD_TESTVECTOR(CppAD::AD) &x, - CPPAD_TESTVECTOR(CppAD::AD) &f) + const CppAD::AD &t, + const CPPAD_TESTVECTOR(CppAD::AD) &x, + CPPAD_TESTVECTOR(CppAD::AD) &f) { f[0] = - w[0] * x[0]; f[1] = - w[1] * x[1]; f[2] = w[2] * t; - + } - + void Ode_ind( - const CppAD::AD &t, - const CPPAD_TESTVECTOR(CppAD::AD) &x, - CPPAD_TESTVECTOR(CppAD::AD) &f_t) + const CppAD::AD &t, + const CPPAD_TESTVECTOR(CppAD::AD) &x, + CPPAD_TESTVECTOR(CppAD::AD) &f_t) { f_t[0] = 0.; f_t[1] = 0.; f_t[2] = w[2]; - + } - + void Ode_dep( - const CppAD::AD &t, - const CPPAD_TESTVECTOR(CppAD::AD) &x, - CPPAD_TESTVECTOR(CppAD::AD) &f_x) + const CppAD::AD &t, + const CPPAD_TESTVECTOR(CppAD::AD) &x, + CPPAD_TESTVECTOR(CppAD::AD) &f_x) { f_x[0] = - w[0]; f_x[1] = 0.; f_x[2] = 0.; f_x[3] = 0.; f_x[4] = - w[1]; f_x[5] = 0.; f_x[6] = 0.; f_x[7] = 0.; f_x[8] = 0.; - + } - + private: CPPAD_TESTVECTOR(CppAD::AD) w; }; @@ -96,13 +96,13 @@ // construct the function object using the independent variables TestFun fun(w); - + // initial value of x CPPAD_TESTVECTOR(AD) xini(3); xini[0] = 1.; xini[1] = 1.; xini[2] = 0.; - + // integrate the differential equation x = Rosen34(fun, nstep, t0, t1, xini); diff -Nru cppad-2015.00.00.9/test_more/runge_45.cpp cppad-2016.00.00.1/test_more/runge_45.cpp --- cppad-2015.00.00.9/test_more/runge_45.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/runge_45.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: runge_45.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: runge_45.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,19 +26,19 @@ w = w_; } void Ode( - const CppAD::AD &t, - const CPPAD_TESTVECTOR(CppAD::AD) &x, - CPPAD_TESTVECTOR(CppAD::AD) &f) + const CppAD::AD &t, + const CPPAD_TESTVECTOR(CppAD::AD) &x, + CPPAD_TESTVECTOR(CppAD::AD) &f) { using CppAD::exp; - + size_t n = x.size(); - + size_t i; f[0] = 0.; for(i = 1; i < n-1; i++) f[i] = w[i] * x[i-1]; - + f[n-1] = x[0] * x[1]; } private: @@ -117,7 +117,7 @@ { // check partial of x[i] w.r.t w[j] if (j == 0 ) ok &= NearEqual(q[j], x[i], 1e-14, 1e-14); - else if( j <= i ) + else if( j <= i ) ok &= NearEqual( q[j], x[i]/w[j], 1e-14, 1e-14); else ok &= NearEqual(q[j], 0., 1e-14, 1e-14); @@ -135,7 +135,7 @@ { // check partial of x[n-1] w.r.t w[j] if (j == 0 ) ok &= NearEqual(q[j], 2.*x[i], 1e-14, 1e-14); - else if( j == 1 ) + else if( j == 1 ) ok &= NearEqual( q[j], x[i]/w[1], 1e-14, 1e-14); else ok &= NearEqual(q[j], 0., 1e-14, 1e-14); diff -Nru cppad-2015.00.00.9/test_more/simple_vector.cpp cppad-2016.00.00.1/test_more/simple_vector.cpp --- cppad-2015.00.00.9/test_more/simple_vector.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/simple_vector.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: simple_vector.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: simple_vector.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -26,7 +26,7 @@ // # define MySimpleVector std::valarray // Assuming CppAD (http://www.seanet.com/~bradbell/cppad) is installed -# include +# include # define MySimpleVector CppAD::vector // Assuming Boost (http://www.boost.org) is installed @@ -44,7 +44,7 @@ // assignment operator MyInt& operator=(const MyInt &x) { value = x.value; - count++; + count++; return *this; } // equality operator @@ -57,7 +57,7 @@ { return count; } private: size_t count; // count number of assignments - int value; // value of this object + int value; // value of this object }; // Test of a Simple Vector template class @@ -66,7 +66,7 @@ typedef MySimpleVector vector; // class we are testing typedef vector::value_type myInt; // type of elements - vector x; // default constructor + vector x; // default constructor ok &= (x.size() == 0); x.resize(2); // resize and set element assignment @@ -81,7 +81,7 @@ ok &= (z.size() == 2); ok &= ( (z[0] == myInt(0)) && (z[1] == myInt(1)) ); - // check that vector assignment + // check that vector assignment x[0] = 2; // modify so that assignment changes x size_t x0count = x[0].Count(); // store initial counts size_t y1count = y[1].Count(); diff -Nru cppad-2015.00.00.9/test_more/sin_cos.cpp cppad-2016.00.00.1/test_more/sin_cos.cpp --- cppad-2015.00.00.9/test_more/sin_cos.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sin_cos.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sin_cos.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sin_cos.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -34,18 +34,18 @@ X[1] = y; Independent(X); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); AD U = X[0] * X[1]; - Z[0] = sin( U ); + Z[0] = sin( U ); // create f: X -> Z and vectors used for derivative calculations // f(x, y) = sin(x, y) - ADFun f(X, Z); + ADFun f(X, Z); CPPAD_TESTVECTOR(double) v( 2 ); CPPAD_TESTVECTOR(double) w( 1 ); - // check value + // check value double sin_u = sin( Value(U) ); double cos_u = cos( Value(U) ); @@ -59,7 +59,7 @@ v[1] = 0; // differential w.r.t. y double yj = 1; // y^j for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); // compute j-th power of y yj *= y ; @@ -77,13 +77,13 @@ jfac *= j; // check j-th derivative of z w.r.t x - ok &= NearEqual(jfac*w[0], sinj * yj, 1e-10 , 1e-10); + ok &= NearEqual(jfac*w[0], sinj * yj, 1e-10 , 1e-10); v[0] = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r( 2 * p); + CPPAD_TESTVECTOR(double) r( 2 * p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -131,18 +131,18 @@ X[1] = y; Independent(X); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); AD U = X[0] * X[1]; - Z[0] = cos( U ); + Z[0] = cos( U ); // create f: X -> Z and vectors used for derivative calculations // f(x, y) = cos(x, y) - ADFun f(X, Z); + ADFun f(X, Z); CPPAD_TESTVECTOR(double) v( 2 ); CPPAD_TESTVECTOR(double) w( 1 ); - // check value + // check value double sin_u = sin( Value(U) ); double cos_u = cos( Value(U) ); @@ -156,7 +156,7 @@ v[1] = 0; // differential w.r.t. y double yj = 1; // y^j for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); // compute j-th power of y yj *= y ; @@ -174,13 +174,13 @@ jfac *= j; // check j-th derivative of z w.r.t x - ok &= NearEqual(jfac*w[0], cosj * yj, 1e-10 , 1e-10); + ok &= NearEqual(jfac*w[0], cosj * yj, 1e-10 , 1e-10); v[0] = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r( 2 * p); + CPPAD_TESTVECTOR(double) r( 2 * p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -228,18 +228,18 @@ X[1] = y; Independent(X); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); AD U = X[0] * X[1]; - Z[0] = cosh( U ); + Z[0] = cosh( U ); // create f: X -> Z and vectors used for derivative calculations // f(x, y) = cosh(x, y) - ADFun f(X, Z); + ADFun f(X, Z); CPPAD_TESTVECTOR(double) v( 2 ); CPPAD_TESTVECTOR(double) w( 1 ); - // check value + // check value double sinh_u = sinh( Value(U) ); double cosh_u = cosh( Value(U) ); @@ -253,7 +253,7 @@ v[1] = 0; // differential w.r.t. y double yj = 1; // y^j for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); // compute j-th power of y yj *= y ; @@ -267,13 +267,13 @@ jfac *= j; // check j-th derivative of z w.r.t x - ok &= NearEqual(jfac*w[0], coshj * yj, 1e-10 , 1e-10); + ok &= NearEqual(jfac*w[0], coshj * yj, 1e-10 , 1e-10); v[0] = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r( 2 * p); + CPPAD_TESTVECTOR(double) r( 2 * p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -317,18 +317,18 @@ X[1] = y; Independent(X); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); AD U = X[0] * X[1]; - Z[0] = sinh( U ); + Z[0] = sinh( U ); // create f: X -> Z and vectors used for derivative calculations // f(x, y) = sinh(x, y) - ADFun f(X, Z); + ADFun f(X, Z); CPPAD_TESTVECTOR(double) v( 2 ); CPPAD_TESTVECTOR(double) w( 1 ); - // check value + // check value double sinh_u = sinh( Value(U) ); double cosh_u = cosh( Value(U) ); @@ -342,7 +342,7 @@ v[1] = 0; // differential w.r.t. y double yj = 1; // y^j for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); // compute j-th power of y yj *= y ; @@ -356,13 +356,13 @@ jfac *= j; // check j-th derivative of z w.r.t x - ok &= NearEqual(jfac*w[0], sinhj * yj, 1e-10 , 1e-10); + ok &= NearEqual(jfac*w[0], sinhj * yj, 1e-10 , 1e-10); v[0] = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r( 2 * p); + CPPAD_TESTVECTOR(double) r( 2 * p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -397,4 +397,4 @@ { bool ok = Sin() & Cos() & Cosh() & Sinh(); return ok; } - + diff -Nru cppad-2015.00.00.9/test_more/sin.cpp cppad-2016.00.00.1/test_more/sin.cpp --- cppad-2015.00.00.9/test_more/sin.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sin.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sin.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sin.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,16 +27,16 @@ U[0] = 1.; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = sin(U[0]); + Z[0] = sin(U[0]); // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value double sin_u = sin( Value(U[0]) ); double cos_u = cos( Value(U[0]) ); @@ -48,7 +48,7 @@ double jfac = 1.; v[0] = 1.; for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); double value; if( j % 4 == 1 ) @@ -65,7 +65,7 @@ } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; diff -Nru cppad-2015.00.00.9/test_more/sinh.cpp cppad-2016.00.00.1/test_more/sinh.cpp --- cppad-2015.00.00.9/test_more/sinh.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sinh.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sinh.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sinh.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -27,16 +27,16 @@ U[0] = 1.; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = sinh(U[0]); + Z[0] = sinh(U[0]); // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value double sin_u = sinh( Value(U[0]) ); double cos_u = cosh( Value(U[0]) ); @@ -48,7 +48,7 @@ double jfac = 1.; v[0] = 1.; for(j = 1; j < p; j++) - { w = f.Forward(j, v); + { w = f.Forward(j, v); double value; if( j % 2 == 1 ) @@ -61,7 +61,7 @@ } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; diff -Nru cppad-2015.00.00.9/test_more/sparse_hessian.cpp cppad-2016.00.00.1/test_more/sparse_hessian.cpp --- cppad-2015.00.00.9/test_more/sparse_hessian.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sparse_hessian.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_hessian.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sparse_hessian.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -38,8 +38,8 @@ check[ell] = 0.0; for(i = 0; i < m; i++) - { AD diff = a_x[i+1] - a_x[i]; - a_y[i] = 0.5 * diff * diff / double(i+2); + { AD diff = a_x[i+1] - a_x[i]; + a_y[i] = 0.5 * diff * diff / double(i+2); w[i] = double(i+1); ell = i * n + i; check[ell] += w[i] / double(i+2); @@ -53,7 +53,7 @@ // create f: x -> y CppAD::ADFun f(a_x, a_y); - + // determine the sparsity pattern p for Hessian of w^T f typedef CppAD::vector< std::set > VectorSet; VectorSet p_r(n); @@ -81,7 +81,7 @@ c[k] = i+1; k++; } - } + } ok &= k == K; // test computing sparse Hessian @@ -99,7 +99,7 @@ } -template +template bool bool_case() { bool ok = true; using CppAD::AD; @@ -127,7 +127,7 @@ for(i = 0; i < n; i++) x[i] = double(i); - // second derivative of y[1] + // second derivative of y[1] VectorBase w(m); w[0] = 1.; VectorBase h( n * n ); @@ -165,7 +165,7 @@ return ok; } -template +template bool set_case() { bool ok = true; using CppAD::AD; @@ -193,7 +193,7 @@ for(i = 0; i < n; i++) x[i] = double(i); - // second derivative of y[1] + // second derivative of y[1] VectorBase w(m); w[0] = 1.; VectorBase h( n * n ); @@ -229,7 +229,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool sparse_hessian(void) diff -Nru cppad-2015.00.00.9/test_more/sparse_jacobian.cpp cppad-2016.00.00.1/test_more/sparse_jacobian.cpp --- cppad-2015.00.00.9/test_more/sparse_jacobian.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sparse_jacobian.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_jacobian.cpp 3108 2014-02-20 13:51:45Z bradbell $ */ +// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -77,12 +77,12 @@ for(i = 0; i < n; i++) { r[k] = i; c[k] = i; - k++; + k++; if( i < n-1 ) { r[k] = i; c[k] = i+1; k++; - } + } } ok &= K == k; @@ -90,21 +90,21 @@ size_t n_sweep = f.SparseJacobianForward(x, p, r, c, jac, work); ok &= n_sweep == 3; for(k = 0; k < K; k++) - { ell = r[k] * n + c[k]; + { ell = r[k] * n + c[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } work.clear(); n_sweep = f.SparseJacobianReverse(x, p, r, c, jac, work); ok &= n_sweep == 3; for(k = 0; k < K; k++) - { ell = r[k] * n + c[k]; + { ell = r[k] * n + c[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } return ok; } -template +template bool rc_set(void) { bool ok = true; using CppAD::AD; @@ -135,7 +135,7 @@ for(j = 0; j < n; j++) x[j] = double(j); - // Jacobian of y + // Jacobian of y /* [ 1 2 0 0 ] jac = [ 0 0 3 4 ] @@ -152,7 +152,7 @@ s[i].insert(i); p = f.RevSparseJac(m, s); - // Use forward mode to compute columns 0 and 2 + // Use forward mode to compute columns 0 and 2 // (make sure order of rows and columns does not matter) CPPAD_TESTVECTOR(size_t) r(3), c(3); VectorBase jac(3); @@ -162,12 +162,12 @@ CppAD::sparse_jacobian_work work; size_t n_sweep = f.SparseJacobianForward(x, p, r, c, jac, work); for(k = 0; k < 3; k++) - { ell = r[k] * n + c[k]; + { ell = r[k] * n + c[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } ok &= (n_sweep == 1); - // Use reverse mode to compute rows 0 and 1 + // Use reverse mode to compute rows 0 and 1 // (make sure order of rows and columns does not matter) r.resize(4), c.resize(4); jac.resize(4); r[0] = 0; c[0] = 0; @@ -177,14 +177,14 @@ work.clear(); n_sweep = f.SparseJacobianReverse(x, p, r, c, jac, work); for(k = 0; k < 4; k++) - { ell = r[k] * n + c[k]; + { ell = r[k] * n + c[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } ok &= (n_sweep == 1); return ok; } -template +template bool rc_bool(void) { bool ok = true; using CppAD::AD; @@ -215,7 +215,7 @@ for(j = 0; j < n; j++) x[j] = double(j); - // Jacobian of y + // Jacobian of y /* [ 1 2 0 0 ] jac = [ 0 0 3 4 ] @@ -230,7 +230,7 @@ s[4] = false; s[5] = false; s[6] = true; s[7] = true; s[8] = true; s[9] = true; s[10] = false; s[11] = true; - // Use forward mode to compute columns 0 and 2 + // Use forward mode to compute columns 0 and 2 // (make sure order of rows and columns does not matter) CPPAD_TESTVECTOR(size_t) r(3), c(3); VectorBase jac(3); @@ -240,12 +240,12 @@ CppAD::sparse_jacobian_work work; size_t n_sweep = f.SparseJacobianForward(x, s, r, c, jac, work); for(k = 0; k < 3; k++) - { ell = r[k] * n + c[k]; + { ell = r[k] * n + c[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } ok &= (n_sweep == 1); - // Use reverse mode to compute rows 0 and 1 + // Use reverse mode to compute rows 0 and 1 // (make sure order of rows and columns does not matter) r.resize(4), c.resize(4); jac.resize(4); r[0] = 0; c[0] = 0; @@ -255,7 +255,7 @@ work.clear(); n_sweep = f.SparseJacobianReverse(x, s, r, c, jac, work); for(k = 0; k < 4; k++) - { ell = r[k] * n + c[k]; + { ell = r[k] * n + c[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } ok &= (n_sweep == 1); @@ -264,7 +264,7 @@ } -template +template bool reverse_bool(void) { bool ok = true; using CppAD::AD; @@ -325,7 +325,7 @@ return ok; } -template +template bool reverse_set(void) { bool ok = true; using CppAD::AD; @@ -382,7 +382,7 @@ return ok; } -template +template bool forward_bool(void) { bool ok = true; using CppAD::AD; @@ -423,9 +423,9 @@ [ 0 1 x_2 ] */ VectorBase check(m * n); - check[0] = 1.; check[1] = 0.; check[2] = 1.; + check[0] = 1.; check[1] = 0.; check[2] = 1.; check[3] = 1.; check[4] = 0.; check[5] = 1.; - check[6] = 0.; check[7] = 1.; check[8] = 1.; + check[6] = 0.; check[7] = 1.; check[8] = 1.; check[9] = 0.; check[10] = 1.; check[11] = x[2]; for(k = 0; k < 12; k++) ok &= NearEqual(check[k], jac[k], 1e-10, 1e-10 ); @@ -446,7 +446,7 @@ return ok; } -template +template bool forward_set(void) { bool ok = true; using CppAD::AD; @@ -487,9 +487,9 @@ [ 0 1 x_2 ] */ VectorBase check(m * n); - check[0] = 1.; check[1] = 0.; check[2] = 1.; + check[0] = 1.; check[1] = 0.; check[2] = 1.; check[3] = 1.; check[4] = 0.; check[5] = 1.; - check[6] = 0.; check[7] = 1.; check[8] = 1.; + check[6] = 0.; check[7] = 1.; check[8] = 1.; check[9] = 0.; check[10] = 1.; check[11] = x[2]; for(k = 0; k < 12; k++) ok &= NearEqual(check[k], jac[k], 1e-10, 1e-10 ); @@ -512,7 +512,7 @@ using CppAD::vector; size_t i, j; - // should be the same as the corresponding typedef in + // should be the same as the corresponding typedef in // cppad/local/sparse_pack.hpp typedef size_t Pack; @@ -549,7 +549,7 @@ return ok; } -} // End empty namespace +} // End empty namespace # include # include bool sparse_jacobian(void) diff -Nru cppad-2015.00.00.9/test_more/sparse_vec_ad.cpp cppad-2016.00.00.1/test_more/sparse_vec_ad.cpp --- cppad-2015.00.00.9/test_more/sparse_vec_ad.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sparse_vec_ad.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sparse_vec_ad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sparse_vec_ad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,14 +18,14 @@ using namespace CppAD; // dimension of the domain space - size_t n = 3; + size_t n = 3; size_t i, j; - // independent variable vector + // independent variable vector CPPAD_TESTVECTOR(AD) X(n); for(j = 0; j < n; j++) - X[j] = AD(j); + X[j] = AD(j); Independent(X); // dependent variable vector @@ -61,7 +61,7 @@ { for(i = 0; i < m; i++) Check[ i * m + j ] = (j <= i); } - + // create function object F : X -> Y ADFun F(X, Y); @@ -80,7 +80,7 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Px[i * m + j] == Check[i * m + j]); - } + } // evaluate the dependency matrix for F(Identity(x)) CPPAD_TESTVECTOR( bool ) Py(m * n); @@ -90,9 +90,9 @@ for(i = 0; i < m; i++) { for(j = 0; j < n; j++) ok &= (Py[i * m + j] == Check[i * m + j]); - } + } - // test sparsity pattern for Hessian of F_2 ( Identity(x) ) + // test sparsity pattern for Hessian of F_2 ( Identity(x) ) CPPAD_TESTVECTOR(bool) Hy(m); for(i = 0; i < m; i++) Hy[i] = false; @@ -104,7 +104,7 @@ ok &= (Pxx[i * n + j] == false ); } - // test sparsity pattern for Hessian of F_1 ( Identity(x) ) + // test sparsity pattern for Hessian of F_1 ( Identity(x) ) for(i = 0; i < m; i++) Hy[i] = false; Hy[1] = true; diff -Nru cppad-2015.00.00.9/test_more/sqrt.cpp cppad-2016.00.00.1/test_more/sqrt.cpp --- cppad-2015.00.00.9/test_more/sqrt.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sqrt.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sqrt.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sqrt.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -59,17 +59,17 @@ v = f.Reverse(1,w); ok &= NearEqual(v[s], .25 * pow(4., -.75), 1e-10 , 1e-10); // dy/ds - // forward computation of second partials w.r.t s + // forward computation of second partials w.r.t s v[s] = 1.; w = f.Forward(1, v); v[s] = 0.; w = f.Forward(2, v); ok &= NearEqual( // d^2 y / (ds ds) - 2. * w[y] , + 2. * w[y] , -.75 * .25 * pow(4., -1.75), 1e-10 , - 1e-10 - ); + 1e-10 + ); // reverse computation of second partials of y CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); @@ -77,11 +77,11 @@ w[y] = 1.; r = f.Reverse(2, w); ok &= NearEqual( // d^2 y / (ds ds) - r[2 * s + 1] , + r[2 * s + 1] , -.75 * .25 * pow(4., -1.75), 1e-10 , - 1e-10 - ); + 1e-10 + ); return ok; @@ -96,18 +96,18 @@ Independent(U); // a temporary values - AD x = U[0] * U[0]; + AD x = U[0] * U[0]; - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = sqrt( x ); // z = sqrt( u * u ) // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(U[0] , Z[0], 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -118,14 +118,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -163,31 +163,31 @@ CPPAD_TESTVECTOR(double) y1( f.Range() ); x1[0] = 1.; y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], exp(x/2.)/2., 1e-10 , 1e-10); + ok &= NearEqual(y1[0], exp(x/2.)/2., 1e-10 , 1e-10); // forward computation of second Taylor coefficient CPPAD_TESTVECTOR(double) x2( f.Domain() ); CPPAD_TESTVECTOR(double) y2( f.Range() ); x2[0] = 0.; y2 = f.Forward(2, x2); - ok &= NearEqual(2.*y2[0] , exp(x/2.)/4., 1e-10 , 1e-10 ); + ok &= NearEqual(2.*y2[0] , exp(x/2.)/4., 1e-10 , 1e-10 ); // forward computation of third Taylor coefficient CPPAD_TESTVECTOR(double) x3( f.Domain() ); CPPAD_TESTVECTOR(double) y3( f.Range() ); x3[0] = 0.; y3 = f.Forward(3, x3); - ok &= NearEqual(6.*y3[0] , exp(x/2.)/8., 1e-10 , 1e-10 ); + ok &= NearEqual(6.*y3[0] , exp(x/2.)/8., 1e-10 , 1e-10 ); // reverse computation of deritavitve of Taylor coefficients CPPAD_TESTVECTOR(double) r( f.Domain() * 4 ); CPPAD_TESTVECTOR(double) w(1); w[0] = 1.; r = f.Reverse(4, w); - ok &= NearEqual(r[0], exp(x/2.)/2., 1e-10 , 1e-10); - ok &= NearEqual(r[1], exp(x/2.)/4., 1e-10 , 1e-10 ); - ok &= NearEqual(2.*r[2], exp(x/2.)/8., 1e-10 , 1e-10 ); - ok &= NearEqual(6.*r[3], exp(x/2.)/16., 1e-10 , 1e-10 ); + ok &= NearEqual(r[0], exp(x/2.)/2., 1e-10 , 1e-10); + ok &= NearEqual(r[1], exp(x/2.)/4., 1e-10 , 1e-10 ); + ok &= NearEqual(2.*r[2], exp(x/2.)/8., 1e-10 , 1e-10 ); + ok &= NearEqual(6.*r[3], exp(x/2.)/16., 1e-10 , 1e-10 ); return ok; @@ -198,7 +198,7 @@ bool Sqrt(void) { bool ok = true; ok &= SqrtTestOne(); - ok &= SqrtTestTwo(); - ok &= SqrtTestThree(); + ok &= SqrtTestTwo(); + ok &= SqrtTestThree(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/std_math.cpp cppad-2016.00.00.1/test_more/std_math.cpp --- cppad-2015.00.00.9/test_more/std_math.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/std_math.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: std_math.cpp 3060 2013-12-27 20:38:57Z bradbell $ */ +// $Id: std_math.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ typedef CppAD::AD< ADdouble > ADDdouble; bool std_math(void) -{ using CppAD::NearEqual; +{ using CppAD::NearEqual; bool ok = true; ADDdouble half(.5); ADDdouble one(1.); diff -Nru cppad-2015.00.00.9/test_more/sub.cpp cppad-2016.00.00.1/test_more/sub.cpp --- cppad-2015.00.00.9/test_more/sub.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sub.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sub.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sub.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -41,7 +41,7 @@ // dependent variable values Z[x] = U[s] - U[t]; // AD - AD Z[y] = Z[x] - 1.; // AD - double - Z[z] = 1. - Z[y]; // double - AD + Z[z] = 1. - Z[y]; // double - AD // create f: U -> Z and vectors used for derivative calculations ADFun f(U, Z); @@ -87,19 +87,19 @@ AD a = 2. * U[0] - 1.; // AD - double AD b = a - 2; // AD - int - AD c = 3. - b; // double - AD - AD d = 4 - c; // int - AD + AD c = 3. - b; // double - AD + AD d = 4 - c; // int - AD - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = U[0] - d; // AD - AD // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(Value(Z[0]) , u0-4+3-2*u0+1+2, 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -110,14 +110,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -135,8 +135,8 @@ { bool ok = true; using namespace CppAD; - // special cases where tests above check OK and SubpvOp - // implementation is known to be worng. + // special cases where tests above check OK and SubpvOp + // implementation is known to be worng. // Probably two minuses make a plus. size_t n = 1; CPPAD_TESTVECTOR(AD) X(n); @@ -145,8 +145,8 @@ size_t m = 1; CPPAD_TESTVECTOR(AD) Y(m); Y[0] = 1. - X[0]; - ADFun f(X, Y); - + ADFun f(X, Y); + CPPAD_TESTVECTOR(double) w(m), dw(n); w[0] = 1.; dw = f.Reverse(1, w); @@ -170,13 +170,13 @@ if( 0. < X[0] && X[0] < 10. ) Y[0] = X[0] - 2.; else Y[0] = X[0] - 2.; - ADFun f(X, Y); - + ADFun f(X, Y); + CPPAD_TESTVECTOR(double) y(m), x(n); x[0] = 1.; y = f.Forward(0, x); ok &= (y[0] == -1.); - + CPPAD_TESTVECTOR(double) dy(m), dx(n); dx[0] = 1.; dy = f.Forward(1, dx); @@ -191,8 +191,8 @@ bool Sub(void) { bool ok = true; ok &= One(); - ok &= Two(); - ok &= Three(); + ok &= Two(); + ok &= Three(); ok &= Four(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/sub_eq.cpp cppad-2016.00.00.1/test_more/sub_eq.cpp --- cppad-2015.00.00.9/test_more/sub_eq.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sub_eq.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sub_eq.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sub_eq.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -36,10 +36,10 @@ size_t y = 1; // dependent variable values - Z[x] = U[s]; + Z[x] = U[s]; Z[y] = U[t]; - Z[x] -= U[t]; // AD -= AD - Z[y] -= 5.; // AD -= double + Z[x] -= U[t]; // AD -= AD + Z[y] -= 5.; // AD -= double // create f: U -> Z and vectors used for derivative calculations ADFun f(U, Z); @@ -76,22 +76,22 @@ // independent variable vector double u0 = .5; CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; + U[0] = u0; Independent(U); - // dependent variable vector + // dependent variable vector CPPAD_TESTVECTOR(AD) Z(1); Z[0] = U[0]; // initial value Z[0] -= 2; // AD -= int Z[0] -= 4.; // AD -= double - Z[0] -= 2 * U[0]; // AD -= AD + Z[0] -= 2 * U[0]; // AD -= AD // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); + ADFun f(U, Z); CPPAD_TESTVECTOR(double) v(1); CPPAD_TESTVECTOR(double) w(1); - // check value + // check value ok &= NearEqual(Z[0] , u0-2-4-2*u0, 1e-10 , 1e-10); // forward computation of partials w.r.t. u @@ -102,14 +102,14 @@ v[0] = 1.; for(j = 1; j < p; j++) { jfac *= j; - w = f.Forward(j, v); + w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); + CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; @@ -128,6 +128,6 @@ bool SubEq(void) { bool ok = true; ok &= SubEqTestOne(); - ok &= SubEqTestTwo(); + ok &= SubEqTestTwo(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/sub_zero.cpp cppad-2016.00.00.1/test_more/sub_zero.cpp --- cppad-2015.00.00.9/test_more/sub_zero.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/sub_zero.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: sub_zero.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: sub_zero.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ typedef CppAD::AD< ADdouble > ADDdouble; bool SubZero(void) -{ +{ using namespace CppAD; bool ok = true; diff -Nru cppad-2015.00.00.9/test_more/tan.cpp cppad-2016.00.00.1/test_more/tan.cpp --- cppad-2015.00.00.9/test_more/tan.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/tan.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: tan.cpp 3301 2014-05-24 05:20:21Z bradbell $ */ +/* $Id: tan.cpp 3683 2015-05-10 02:24:16Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -23,43 +23,43 @@ using CppAD::AD; using CppAD::NearEqual; double eps = 10. * std::numeric_limits::epsilon(); - + // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - + ax[0] = 0.5; + // declare independent variables and starting recording CppAD::Independent(ax); - + // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = tan( ax[0] ); - + // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); - + // first order Taylor coefficient CPPAD_TESTVECTOR(double) x1(n), y1; x1[0] = 2.0; y1 = f.Forward(1, x1); - ok &= y1.size() == m; - + ok &= size_t( y1.size() ) == m; + // secondorder Taylor coefficients CPPAD_TESTVECTOR(double) x2(n), y2; x2[0] = 0.0; y2 = f.Forward(2, x2); - ok &= y2.size() == m; - // - // Y (t) = F[X_0(t)] + ok &= size_t( y2.size() ) == m; + // + // Y (t) = F[X_0(t)] // = tan(0.5 + 2t ) // Y' (t) = 2 * cos(0.5 + 2t )^(-2) double sec_sq = 1.0 / ( cos(0.5) * cos(0.5) ); double check = 2.0 * sec_sq; ok &= NearEqual(y1[0] , check, eps, eps); // - // Y''(0) = 8*cos(0.5)^(-3)*sin(0.5) + // Y''(0) = 8*cos(0.5)^(-3)*sin(0.5) check = 8.0 * tan(0.5) * sec_sq / 2.0; ok &= NearEqual(y2[0] , check, eps, eps); // @@ -70,27 +70,27 @@ double eps = 100. * std::numeric_limits::epsilon(); using CppAD::AD; using CppAD::NearEqual; - + // independent variable vector, indices, values, and declaration size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = .7; Independent(ax); - + // dependent variable vector and indices size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); if( tan_first ) ay[0] = atan( tan( ax[0] ) ); else ay[0] = tan( atan( ax[0] ) ); - - // check value + + // check value ok &= NearEqual(ax[0] , ay[0], eps, eps); - + // create f: x -> y and vectors used for derivative calculations - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); CPPAD_TESTVECTOR(double) dx(n), dy(m); - + // forward computation of partials w.r.t. x dx[0] = 1.; dy = f.Forward(1, dx); @@ -101,7 +101,7 @@ { dy = f.Forward(p, dx); ok &= NearEqual(dy[0], 0e0, eps, eps); } - + // reverse computation of order partial CPPAD_TESTVECTOR(double) w(m), dw(n * order); w[0] = 1.; @@ -109,7 +109,7 @@ ok &= NearEqual(dw[0], 1e0, eps, eps); for(p = 1; p < order; p++) ok &= NearEqual(dw[p], 0e0, eps, eps); - + return ok; } bool tanh_case(bool tanh_first) @@ -117,13 +117,13 @@ double eps = 100. * std::numeric_limits::epsilon(); using CppAD::AD; using CppAD::NearEqual; - + // independent variable vector, indices, values, and declaration size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = .5; Independent(ax); - + // dependent variable vector and indices size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); @@ -136,13 +136,13 @@ { z = .5 * log( (1. + ax[0]) / (1. - ax[0]) ); ay[0] = tanh(z); } - // check value + // check value ok &= NearEqual(ax[0] , ay[0], eps, eps); - + // create f: x -> y and vectors used for derivative calculations - CppAD::ADFun f(ax, ay); + CppAD::ADFun f(ax, ay); CPPAD_TESTVECTOR(double) dx(n), dy(m); - + // forward computation of partials w.r.t. x dx[0] = 1.; dy = f.Forward(1, dx); @@ -153,7 +153,7 @@ { dy = f.Forward(p, dx); ok &= NearEqual(dy[0], 0e0, eps, eps); } - + // reverse computation of order partial CPPAD_TESTVECTOR(double) w(m), dw(n * order); w[0] = 1.; @@ -161,7 +161,7 @@ ok &= NearEqual(dw[0], 1e0, eps, eps); for(p = 1; p < order; p++) ok &= NearEqual(dw[p], 0e0, eps, eps); - + return ok; } } diff -Nru cppad-2015.00.00.9/test_more/test_more.cpp cppad-2016.00.00.1/test_more/test_more.cpp --- cppad-2015.00.00.9/test_more/test_more.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/test_more.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: test_more.cpp 3526 2014-12-29 21:56:45Z bradbell $ */ +// $Id: test_more.cpp 3768 2015-12-28 18:58:35Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,28 +14,33 @@ # include // memory leak checker -# include +# include // prototype external compiled tests (this line expected by bin/new_test.sh) extern bool abs(void); -extern bool Acos(void); +extern bool acos(void); +extern bool acosh(void); extern bool adfun_copy(void); extern bool Add(void); extern bool AddEq(void); extern bool AddZero(void); extern bool alloc_openmp(void); -extern bool Asin(void); +extern bool asin(void); +extern bool asinh(void); extern bool assign(void); -extern bool Atan(void); +extern bool atan(void); +extern bool atanh(void); extern bool atan2(void); +extern bool azmul(void); extern bool base_adolc(void); extern bool base_alloc_test(void); extern bool check_simple_vector(void); extern bool checkpoint(void); extern bool Compare(void); -extern bool CompareChange(void); +extern bool compare_change(void); extern bool CondExp(void); extern bool CondExpAD(void); +extern bool cond_exp_rev(void); extern bool copy(void); extern bool Cos(void); extern bool Cosh(void); @@ -44,8 +49,9 @@ extern bool Div(void); extern bool DivEq(void); extern bool DivZeroOne(void); -extern bool Erf(void); +extern bool erf(void); extern bool Exp(void); +extern bool expm1(void); extern bool ForHess(void); extern bool for_sparse_jac(void); extern bool Forward(void); @@ -55,16 +61,26 @@ extern bool FunCheck(void); extern bool ipopt_solve(void); extern bool jacobian(void); -extern bool limits(void); -extern bool Log(void); -extern bool Log10(void); +extern bool log(void); +extern bool log10(void); +extern bool log1p(void); extern bool Mul(void); extern bool mul_level(void); +extern bool mul_cond_rev(void); +extern bool mul_cskip(void); extern bool MulEq(void); +extern bool mul_zdouble(void); extern bool MulZeroOne(void); extern bool NearEqualExt(void); extern bool Neg(void); +extern bool num_limits(void); extern bool ode_err_control(void); +extern bool old_mat_mul(void); +extern bool old_reciprocal(void); +extern bool old_tan(void); +extern bool old_usead_1(void); +extern bool old_usead_2(void); +extern bool omp_alloc(void); extern bool optimize(void); extern bool parameter(void); extern bool Poly(void); @@ -91,12 +107,14 @@ extern bool SubEq(void); extern bool SubZero(void); extern bool tan(void); +extern bool to_string(void); extern bool test_vector(void); extern bool track_new_del(void); extern bool Value(void); extern bool VecAD(void); extern bool VecADPar(void); extern bool VecUnary(void); +extern bool zdouble(void); namespace { // function that runs one test @@ -104,7 +122,7 @@ static size_t Run_error_count = 0; bool Run(bool TestOk(void), std::string name) { bool ok = true; - std::streamsize width = 20; + std::streamsize width = 20; std::cout.width( width ); std::cout.setf( std::ios_base::left ); std::cout << name; @@ -128,25 +146,30 @@ { bool ok = true; using namespace std; - // This line is used by test_one.sh + // This line is used by test_one.sh // run external compiled tests (this line expected by bin/new_test.sh) ok &= Run( abs, "abs" ); - ok &= Run( Acos, "Acos" ); + ok &= Run( acos, "acos" ); + ok &= Run( acosh, "acosh" ); ok &= Run( adfun_copy, "adfun_copy" ); ok &= Run( Add, "Add" ); ok &= Run( AddEq, "AddEq" ); ok &= Run( AddZero, "AddZero" ); - ok &= Run( Asin, "Asin" ); + ok &= Run( asin, "asin" ); + ok &= Run( asinh, "asinh" ); ok &= Run( assign, "assign" ); - ok &= Run( Atan, "Atan" ); + ok &= Run( atan, "atan" ); + ok &= Run( atanh, "atanh" ); ok &= Run( atan2, "atan2" ); + ok &= Run( azmul, "azmul" ); ok &= Run( check_simple_vector, "check_simple_vector" ); ok &= Run( checkpoint, "checkpoint" ); ok &= Run( Compare, "Compare" ); - ok &= Run( CompareChange, "CompareChange" ); + ok &= Run( compare_change, "compare_change" ); ok &= Run( CondExp, "CondExp" ); ok &= Run( CondExpAD, "CondExpAD" ); + ok &= Run( cond_exp_rev, "cond_exp_rev" ); ok &= Run( copy, "copy" ); ok &= Run( Cos, "Cos" ); ok &= Run( Cosh, "Cosh" ); @@ -154,8 +177,9 @@ ok &= Run( Div, "Div" ); ok &= Run( DivEq, "DivEq" ); ok &= Run( DivZeroOne, "DivZeroOne" ); - ok &= Run( Erf, "Erf" ); + ok &= Run( erf, "erf" ); ok &= Run( Exp, "Exp" ); + ok &= Run( expm1, "expm1" ); ok &= Run( ForHess, "ForHess" ); ok &= Run( for_sparse_jac, "for_sparse_jac" ); ok &= Run( Forward, "Forward" ); @@ -164,16 +188,26 @@ ok &= Run( FromBase, "FromBase" ); ok &= Run( FunCheck, "FunCheck" ); ok &= Run( jacobian, "jacobian" ); - ok &= Run( limits, "limits" ); - ok &= Run( Log, "Log" ); - ok &= Run( Log10, "Log10" ); + ok &= Run( log, "log" ); + ok &= Run( log10, "log10" ); + ok &= Run( log1p, "log1p" ); ok &= Run( Mul, "Mul" ); ok &= Run( mul_level, "mul_level" ); + ok &= Run( mul_cond_rev, "mul_cond_rev" ); + ok &= Run( mul_cskip, "Mul_cskip" ); ok &= Run( MulEq, "MulEq" ); + ok &= Run( mul_zdouble, "mul_zdouble" ); ok &= Run( MulZeroOne, "MulZeroOne" ); ok &= Run( NearEqualExt, "NearEqualExt" ); ok &= Run( Neg, "Neg" ); + ok &= Run( num_limits, "num_limits" ); ok &= Run( ode_err_control, "ode_err_control"); + ok &= Run( old_mat_mul, "old_mat_mul" ); + ok &= Run( old_reciprocal, "old_reciprocal" ); + ok &= Run( old_tan, "old_tan" ); + ok &= Run( old_usead_1, "old_usead_1" ); + ok &= Run( old_usead_2, "old_usead_2" ); + ok &= Run( omp_alloc, "omp_alloc" ); ok &= Run( optimize, "optimize" ); ok &= Run( parameter, "parameter" ); ok &= Run( Poly, "Poly" ); @@ -200,11 +234,13 @@ ok &= Run( SubEq, "SubEq" ); ok &= Run( SubZero, "SubZero" ); ok &= Run( tan, "tan" ); + ok &= Run( to_string, "to_string" ); ok &= Run( track_new_del, "track_new_del" ); ok &= Run( Value, "Value" ); ok &= Run( VecAD, "VecAD" ); ok &= Run( VecADPar, "VecADPar" ); ok &= Run( VecUnary, "VecUnary" ); + ok &= Run( zdouble, "zdouble" ); # ifdef CPPAD_ADOLC_TEST ok &= Run( base_adolc, "base_adolc" ); # endif diff -Nru cppad-2015.00.00.9/test_more/test_one.sh.in cppad-2016.00.00.1/test_more/test_one.sh.in --- cppad-2015.00.00.9/test_more/test_one.sh.in 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/test_one.sh.in 2016-02-09 08:31:56.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/bash -e -# $Id: test_one.sh.in 3526 2014-12-29 21:56:45Z bradbell $ +# $Id: test_one.sh.in 3754 2015-11-26 22:23:05Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under -# the terms of the +# the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. @@ -24,7 +24,7 @@ echo "Cannot find the file $1" exit 1 fi -fun=`grep "^bool *[a-zA-Z0-9_]*( *void *)" $1 | tail -1 | \ +fun=`grep "^bool *[a-zA-Z0-9_]* *( *void *)" $1 | tail -1 | \ sed -e "s/^bool *\([a-zA-Z0-9_]*\) *( *void *)/\1/"` if [ -e test_one.exe ] then @@ -32,24 +32,25 @@ fi sed < test_more.cpp > test_one.cpp \ -e '/ok *\&= *Run( /d' \ --e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" +-e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" # # +cxxflags='@cppad_cxx_flags@' if echo "$fun" | grep 'eigen' > /dev/null then - cxxflags='-g -Wall -ansi -pedantic-errors' -else - cxxflags='-g -Wall -ansi -pedantic-errors -Wshadow' + cxxflags=`echo "$cxxflags" | sed -e 's|-Wshadow||'` fi -cmd="g++ test_one.cpp $* +cmd="g++ test_one.cpp $*" +cmd="$cmd -o test_one.exe $cxxflags - -std=c++11 + -L @cppad_BINARY_DIR@/cppad_lib + -lcppad_lib + -g + -fopenmp -DCPPAD_ADOLC_TEST -DCPPAD_OPENMP_TEST - -DCPPAD_MAX_NUM_THREADS=1 - @OPENMP_FLAGS@ - -I.. + -I.. " if [ -e @adolc_prefix@/include ] then @@ -78,12 +79,13 @@ if [ -e @ipopt_prefix@/$lib/pkgconfig ] then export PKG_CONFIG_PATH="@ipopt_prefix@/$lib/pkgconfig" - cflags=`pkg-config --cflags ipopt | + cflags=`pkg-config --cflags ipopt | sed -e 's|/coin$|/|' -e 's|/coin | |'` libs=`pkg-config --libs ipopt` cmd="$cmd $cflags $libs" fi done +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@cppad_BINARY_DIR@/cppad_lib" echo $cmd $cmd echo "./test_one.exe" diff -Nru cppad-2015.00.00.9/test_more/test_vector.cpp cppad-2016.00.00.1/test_more/test_vector.cpp --- cppad-2015.00.00.9/test_more/test_vector.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/test_vector.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: test_vector.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: test_vector.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -25,7 +25,7 @@ size_t n = 1; double x0 = 0.5; CPPAD_TEST_VECTOR< AD > x(n); - x[0] = x0; + x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); @@ -33,18 +33,18 @@ // some binary addition operations AD a = x[0] + 1.; // AD + double AD b = a + 2; // AD + int - AD c = 3. + b; // double + AD - AD d = 4 + c; // int + AD + AD c = 3. + b; // double + AD + AD d = 4 + c; // int + AD - // range space vector + // range space vector size_t m = 1; CPPAD_TEST_VECTOR< AD > y(m); - y[0] = d + x[0]; // AD + AD + y[0] = d + x[0]; // AD + AD // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + CppAD::ADFun f(x, y); - // check value + // check value ok &= NearEqual(y[0] , 2. * x0 + 10, 1e-10 , 1e-10); // forward computation of partials w.r.t. x[0] diff -Nru cppad-2015.00.00.9/test_more/to_string.cpp cppad-2016.00.00.1/test_more/to_string.cpp --- cppad-2015.00.00.9/test_more/to_string.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/to_string.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,56 @@ +// $Id$ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +// check complex case +# include + +namespace { + template + bool test(void) + { bool ok = true; + Float eps = std::numeric_limits::epsilon(); + Float pi = 4.0 * std::atan(1.0); + Float e = std::exp(1.0); + typedef std::complex Base; + Base c = Base(pi, e); + std::string s = CppAD::to_string( CppAD::AD(c) ); + // + // get strings corresponding to real and imaginary parts + std::string real = ""; + std::string imag = ""; + size_t index = 1; // skip ( at front + while( s[index] != ',' ) + real += s[index++]; + index++; + while( s[index] != ')' ) + imag += s[index++]; + // + Float check = std::atof( real.c_str() ); + ok &= std::fabs( check - pi ) <= 2.0 * eps; + // + check = std::atof( imag.c_str() ); + ok &= std::fabs( check - e ) <= 2.0 * eps; + // + return ok; + } +} + +bool to_string(void) +{ bool ok = true; + + ok &= test(); + ok &= test(); + + return ok; +} + +// END C++ diff -Nru cppad-2015.00.00.9/test_more/track_new_del.cpp cppad-2016.00.00.1/test_more/track_new_del.cpp --- cppad-2015.00.00.9/test_more/track_new_del.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/track_new_del.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: track_new_del.cpp 2794 2013-05-02 08:20:30Z bradbell $ */ +// $Id: track_new_del.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -14,14 +14,9 @@ $begin TrackNewDel.cpp$$ $section Tracking Use of New and Delete: Example and Test$$ +$mindex delete$$ + -$index new, example$$ -$index example, new$$ -$index test, new$$ - -$index delete, example$$ -$index example, delete$$ -$index test, delete$$ $code $verbatim%test_more/track_new_del.cpp%0%// BEGIN C++%// END C++%1%$$ @@ -31,7 +26,7 @@ */ // BEGIN C++ -# include +# include bool track_new_del(void) { bool ok = true; @@ -53,13 +48,13 @@ // extend the buffer to be lenght 10 newlen = 10; ptr = CPPAD_TRACK_EXTEND(newlen, ncopy, ptr); - + // copy data into the new part of the array for(i = ncopy; i < newlen; i++) ptr[i] = double(i); // check the values in the array - for(i = 0; i < newlen; i++) + for(i = 0; i < newlen; i++) ok &= (ptr[i] == double(i)); // free the memory allocated since previous call to TrackCount diff -Nru cppad-2015.00.00.9/test_more/value.cpp cppad-2016.00.00.1/test_more/value.cpp --- cppad-2015.00.00.9/test_more/value.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/value.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: value.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: value.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. diff -Nru cppad-2015.00.00.9/test_more/vec_ad.cpp cppad-2016.00.00.1/test_more/vec_ad.cpp --- cppad-2015.00.00.9/test_more/vec_ad.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/vec_ad.cpp 2016-02-09 08:31:57.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: vec_ad.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: vec_ad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -48,9 +48,9 @@ // check array values (while not taping) for(i = 0; i < n; i++) - ok &= ( V[i] == 2. * double(n - i) ); + ok &= ( V[i] == 2. * double(n - i) ); - // independent variable + // independent variable CPPAD_TESTVECTOR(AD) X(1); X[0] = double(n - 1); Independent(X); @@ -86,32 +86,32 @@ x[0] = double(i); z = f.Forward(0, x); vx = double(n - i); - ok &= NearEqual(z[0], sin(x[0]) * vx, 1e-10, 1e-10); + ok &= NearEqual(z[0], sin(x[0]) * vx, 1e-10, 1e-10); // note that derivative of v[x] w.r.t. x is zero dx[0] = 1.; dz = f.Forward(1, dx); - ok &= NearEqual(dz[0], cos(x[0]) * vx, 1e-10, 1e-10); + ok &= NearEqual(dz[0], cos(x[0]) * vx, 1e-10, 1e-10); // reverse mode calculation of same value dz[0] = 1.; dx = f.Reverse(1, dz); - ok &= NearEqual(dx[0], cos(x[0]) * vx, 1e-10, 1e-10); + ok &= NearEqual(dx[0], cos(x[0]) * vx, 1e-10, 1e-10); } return ok; } -// create the discrete function AD Floor(const AD &X) +// create the discrete function AD Floor(const AD &X) double Floor(const double &x) -{ return std::floor(x); } +{ return std::floor(x); } CPPAD_DISCRETE_FUNCTION(double, Floor) bool VecADTestTwo(void) { bool ok = true; using namespace CppAD; - + double pi = 4. * CppAD::atan(1.); size_t nx = 10; // number of x grid point double xLow = 0; // minimum value for x @@ -123,12 +123,12 @@ VecAD Data(nx); size_t i; for(i = 0; i < nx; i++) - { xCur = xLow + double(i) * xStep; + { xCur = xLow + double(i) * xStep; // use size_t indexing of Data while not taping - Data[i] = CppAD::sin(xCur); + Data[i] = CppAD::sin(xCur); } - // declare independent variable + // declare independent variable CPPAD_TESTVECTOR(AD) X(1); X[0] = 2.; Independent(X); @@ -174,7 +174,7 @@ # include bool SecondOrderReverse(void) -{ // Bradley M. Bell 2009-07-06 +{ // Bradley M. Bell 2009-07-06 // Reverse mode for LdpOp was only modifying the highest order partial // This test demonstrated the bug bool ok = true; @@ -198,7 +198,7 @@ // The LdvOp instruction corresponds to the index being a variable. AD one = X[0] - 1; // one in a variable here Z[one] = X[0] + 1.; - + // Compute a function where the second order partial for y // depends on the first order partials for z @@ -225,11 +225,11 @@ // check first derivative in dw double check = 2. * (Value( X[0] ) + 1.); - ok &= NearEqual(dw[0], check, eps, eps); + ok &= NearEqual(dw[0], check, eps, eps); // check second derivative in dw check = 2.; - ok &= NearEqual(dw[1], check, eps, eps); + ok &= NearEqual(dw[1], check, eps, eps); // Test LdvOp // second order reverse (test exp_if_true case) @@ -240,11 +240,11 @@ // check first derivative in dw check = 2. * (Value( X[0] ) + 1.); - ok &= NearEqual(dw[0], check, eps, eps); + ok &= NearEqual(dw[0], check, eps, eps); // check second derivative in dw check = 2.; - ok &= NearEqual(dw[1], check, eps, eps); + ok &= NearEqual(dw[1], check, eps, eps); return ok; } @@ -254,7 +254,7 @@ bool VecAD(void) { bool ok = true; ok &= VecADTestOne(); - ok &= VecADTestTwo(); + ok &= VecADTestTwo(); ok &= SecondOrderReverse(); return ok; } diff -Nru cppad-2015.00.00.9/test_more/vec_ad_par.cpp cppad-2016.00.00.1/test_more/vec_ad_par.cpp --- cppad-2015.00.00.9/test_more/vec_ad_par.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/vec_ad_par.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: vec_ad_par.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: vec_ad_par.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -20,7 +20,7 @@ typedef CppAD::AD< ADdouble > ADDdouble; bool VecADPar(void) -{ +{ using namespace CppAD; bool ok = true; @@ -37,7 +37,7 @@ VecAD< ADdouble > v(2); ADDdouble zero(0); ADDdouble one(1); - v[zero] = x[0]; // these two parameter values are equal, + v[zero] = x[0]; // these two parameter values are equal, v[one] = x[1]; // but they are not identically equal CPPAD_TESTVECTOR( ADDdouble ) z(1); diff -Nru cppad-2015.00.00.9/test_more/vec_unary.cpp cppad-2016.00.00.1/test_more/vec_unary.cpp --- cppad-2015.00.00.9/test_more/vec_unary.cpp 2015-02-24 08:31:42.000000000 +0000 +++ cppad-2016.00.00.1/test_more/vec_unary.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -1,9 +1,9 @@ -/* $Id: vec_unary.cpp 2506 2012-10-24 19:36:49Z bradbell $ */ +// $Id: vec_unary.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under -the terms of the +the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. @@ -18,7 +18,7 @@ bool VecUnary(void) -{ +{ using namespace CppAD; using CppAD::abs; using CppAD::sin; @@ -44,38 +44,38 @@ AD j; j = 0.; - Y[j] = X[0]; + Y[j] = X[0]; Z[0] = -Y[j]; j = 1.; - Y[j] = X[1]; + Y[j] = X[1]; Z[1] = sin( Y[j] ); j = 2.; - Y[j] = X[2]; + Y[j] = X[2]; Z[2] = abs( Y[j] ); j = 3.; - Y[j] = X[3]; + Y[j] = X[3]; Z[3] = atan( Y[j] ); j = 4.; - Y[j] = X[4]; + Y[j] = X[4]; Z[4] = cos( Y[j] ); j = 5.; - Y[j] = X[5]; + Y[j] = X[5]; Z[5] = exp( Y[j] ); j = 6.; - Y[j] = X[6]; + Y[j] = X[6]; Z[6] = log( Y[j] ); j = 7.; - Y[j] = X[7]; + Y[j] = X[7]; Z[7] = sqrt( Y[j] ); - + ADFun f(X, Z); CPPAD_TESTVECTOR(double) x(n); CPPAD_TESTVECTOR(double) z(n); diff -Nru cppad-2015.00.00.9/test_more/zdouble.cpp cppad-2016.00.00.1/test_more/zdouble.cpp --- cppad-2015.00.00.9/test_more/zdouble.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2016.00.00.1/test_more/zdouble.cpp 2016-02-09 08:31:56.000000000 +0000 @@ -0,0 +1,122 @@ +/* $Id$ */ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell + +CppAD is distributed under multiple licenses. This distribution is under +the terms of the + GNU General Public License Version 3. + +A copy of this license is included in the COPYING file of this distribution. +Please visit http://www.coin-or.org/CppAD/ for information on other licenses. +-------------------------------------------------------------------------- */ + +/* +$begin zdouble.cpp$$ +$spell + zdouble +$$ + +$section zdouble: Example and Test$$ + +$code +$verbatim%test_more/zdouble.cpp%0%// BEGIN C++%// END C++%1%$$ +$$ + +$end +*/ +// BEGIN C++ +# include + +namespace { + template bool test(bool is_double) + { bool ok = true; + Base eps = 10. * std::numeric_limits::epsilon(); + + typedef CppAD::AD a1type; + typedef CppAD::AD a2type; + + // value during taping + size_t n = 2; + CPPAD_TESTVECTOR(Base) x(n); + x[0] = 0.0; + x[1] = 0.0; + + // declare independent variable + CPPAD_TESTVECTOR(a2type) a2x(n); + for (size_t j = 0; j < n; j++) + a2x[j] = a2type( a1type(x[j]) ); + Independent(a2x); + + // zero and one as a2type values + a2type a2zero = a2type(0.0); + a2type a2one = a2type(1.0); + + // h(x) = x[0] / x[1] if x[1] > x[0] else 1.0 + a2type h_x = CondExpGt(a2x[1], a2x[0], a2x[0] / a2x[1], a2one); + + // f(x) = h(x) if x[0] > 0.0 else 0.0 + // = x[0] / x[1] if x[1] > x[0] and x[0] > 0.0 + // = 1.0 if x[0] >= x[1] and x[0] > 0.0 + // = 0.0 if x[0] <= 0.0 + a2type f_x = CondExpGt(a2x[0], a2zero, h_x, a2one); + + // define the function f(x) + size_t m = 1; + CPPAD_TESTVECTOR(a2type) a2y(m); + a2y[0] = f_x; + CppAD::ADFun af1; + af1.Dependent(a2x, a2y); + + // Define function g(x) = gradient of f(x) + CPPAD_TESTVECTOR(a1type) a1x(n), a1z(n), a1w(m); + for (size_t j = 0; j < n; j++) + a1x[j] = a1type(x[j]); + a1w[0] = a1type(1.0); + Independent(a1x); + af1.Forward(0, a1x); + a1z = af1.Reverse(1, a1w); + CppAD::ADFun g; + g.Dependent(a1x, a1z); + + // check result for a case where f(x) = 0.0; + CPPAD_TESTVECTOR(Base) z(2); + x[0] = 0.0; + x[1] = 0.0; + z = g.Forward(0, x); + ok &= z[0] == 0.0; + ok &= z[1] == 0.0; + + // check result for a case where f(x) = 1.0; + x[0] = 1.0; + x[1] = 0.5; + z = g.Forward(0, x); + ok &= z[0] == 0.0; + ok &= z[1] == 0.0; + + // check result for a case where f(x) = x[0] / x[1]; + x[0] = 1.0; + x[1] = 2.0; + z = g.Forward(0, x); + ok &= CppAD::NearEqual(z[0], 1.0/x[1], eps, eps); + ok &= CppAD::NearEqual(z[1], - x[0]/(x[1]*x[1]), eps, eps); + + return ok; + } +} + +bool zdouble(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::zdouble; + // + bool is_double = false; + ok &= test(is_double); + // + is_double = true; + ok &= test(is_double); + // + return ok; +} + +// END C++